def test_memorygrowth(self):
    if self.has_changed_setting('ALLOW_MEMORY_GROWTH'):
        self.skipTest('test needs to modify memory growth')
    if self.maybe_closure():
        self.set_setting('DYNAMIC_EXECUTION', 0)
    src = open(path_from_root('tests', 'core', 'test_memorygrowth.c')).read()
    self.do_run(src, 'OOM', assert_returncode=None)
    fail = open('src.cpp.o.js').read()
    self.emcc_args += ['-Wno-almost-asm', '-s', 'ALLOW_MEMORY_GROWTH']
    self.do_run(src, '*pre: hello,4.955*\n*hello,4.955*\n*hello,4.955*')
    win = open('src.cpp.o.js').read()
    if (('-O2' in self.emcc_args) and (not self.is_wasm())):
        possible_starts = ['// EMSCRIPTEN_START_FUNCS', 'var TOTAL_STACK']
        code_start = None
        for s in possible_starts:
            if (fail.find(s) >= 0):
                code_start = s
                break
        assert (code_start is not None), ('Generated code must contain one of ' + str(possible_starts))
        fail = fail[fail.find(code_start):]
        win = win[win.find(code_start):]
        assert (len(fail) < len(win)), ('failing code - without memory growth on - is more optimized, and smaller' + str([len(fail), len(win)]))
    self.set_setting('EMSCRIPTEN_TRACING', 1)
    self.emcc_args += ['--tracing']
    self.do_run(src, '*pre: hello,4.955*\n*hello,4.955*\n*hello,4.955*')
def test_memorygrowth(self):
    if self.has_changed_setting('ALLOW_MEMORY_GROWTH'):
        self.skipTest('test needs to modify memory growth')
    if self.maybe_closure():
        self.set_setting('DYNAMIC_EXECUTION', 0)
    src = open(path_from_root('tests', 'core', 'test_memorygrowth.c')).read()
    self.do_run(src, 'OOM', assert_returncode=None)
    fail = open('src.cpp.o.js').read()
    self.emcc_args += ['-Wno-almost-asm', '-s', 'ALLOW_MEMORY_GROWTH']
    self.do_run(src, '*pre: hello,4.955*\n*hello,4.955*\n*hello,4.955*')
    win = open('src.cpp.o.js').read()
    if (('-O2' in self.emcc_args) and (not self.is_wasm())):
        possible_starts = ['// EMSCRIPTEN_START_FUNCS', 'var TOTAL_STACK']
        code_start = None
        for s in possible_starts:
            if (fail.find(s) >= 0):
                code_start = s
                break
        assert (code_start is not None), ('Generated code must contain one of ' + str(possible_starts))
        fail = fail[fail.find(code_start):]
        win = win[win.find(code_start):]
        assert (len(fail) < len(win)), ('failing code - without memory growth on - is more optimized, and smaller' + str([len(fail), len(win)]))
    self.set_setting('EMSCRIPTEN_TRACING', 1)
    self.emcc_args += ['--tracing']
    self.do_run(src, '*pre: hello,4.955*\n*hello,4.955*\n*hello,4.955*')