(self)
| 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): |
nothing calls this directly
no test coverage detected