MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / test_memorygrowth

Method test_memorygrowth

test/test_core.py:2105–2140  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2103
2104 @no_highmem('memory growth issues')
2105 def test_memorygrowth(self):
2106 if self.has_changed_setting('ALLOW_MEMORY_GROWTH'):
2107 self.skipTest('test needs to modify memory growth')
2108 if self.maybe_closure():
2109 # verify NO_DYNAMIC_EXECUTION is compatible with closure
2110 self.set_setting('DYNAMIC_EXECUTION', 0)
2111 # With typed arrays in particular, it is dangerous to use more memory than INITIAL_MEMORY,
2112 # since we then need to enlarge the heap(s).
2113 src = test_file('core/test_memorygrowth.c')
2114
2115 # Fail without memory growth
2116 self.do_runf(src, 'OOM', assert_returncode=NON_ZERO)
2117 fail = read_file(self.output_name('test_memorygrowth'))
2118
2119 # Win with it
2120 self.set_setting('ALLOW_MEMORY_GROWTH')
2121 output = self.do_runf(src)
2122 output = self.remove_growth_warning(output)
2123 self.assertContained('*pre: hello,4.955*\n*hello,4.955*\n*hello,4.955*', output)
2124 win = read_file(self.output_name('test_memorygrowth'))
2125
2126 if '-O2' in self.cflags and self.is_wasm2js():
2127 # Make sure ALLOW_MEMORY_GROWTH generates different code (should be less optimized)
2128 code_start = '// EMSCRIPTEN_START_FUNCS'
2129 self.assertContained(code_start, fail)
2130 fail = fail[fail.find(code_start):]
2131 win = win[win.find(code_start):]
2132 assert len(fail) < len(win), 'failing code - without memory growth on - is more optimized, and smaller' + str([len(fail), len(win)])
2133
2134 # Tracing of memory growths should work
2135 # (SAFE_HEAP would instrument the tracing code itself, leading to recursion)
2136 if not self.get_setting('SAFE_HEAP'):
2137 self.cflags += ['--tracing']
2138 output = self.do_runf(src)
2139 output = self.remove_growth_warning(output)
2140 self.assertContained('*pre: hello,4.955*\n*hello,4.955*\n*hello,4.955*', output)
2141
2142 @no_highmem('memory growth issues')
2143 def test_memorygrowth_2(self):

Callers

nothing calls this directly

Calls 12

maybe_closureMethod · 0.95
remove_growth_warningMethod · 0.95
test_fileFunction · 0.90
has_changed_settingMethod · 0.80
set_settingMethod · 0.80
do_runfMethod · 0.80
output_nameMethod · 0.80
assertContainedMethod · 0.80
is_wasm2jsMethod · 0.80
get_settingMethod · 0.80
read_fileFunction · 0.50
findMethod · 0.45

Tested by

no test coverage detected