From e2c22b82505ddf81c7098672c3780981288efe94 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 15 May 2026 10:07:21 -0700 Subject: [PATCH] [test] Add `no_highmem` decorator. NFC --- test/decorators.py | 2 ++ test/test_browser.py | 37 +++++++++++++----------------------- test/test_core.py | 45 ++++++++++++++++---------------------------- 3 files changed, 31 insertions(+), 53 deletions(-) diff --git a/test/decorators.py b/test/decorators.py index 9743c3e921339..02f17d0f3898f 100644 --- a/test/decorators.py +++ b/test/decorators.py @@ -115,6 +115,8 @@ def disabled(note=''): no_4gb = skip_if('no_4gb', lambda t: t.is_4gb()) +no_highmem = skip_if('no_highmem', lambda t: t.is_2gb() or t.is_4gb()) + only_windows = skip_if('only_windows', lambda _: not WINDOWS) requires_native_clang = skip_if_simple('native clang tests are disabled', lambda _: common.EMTEST_LACKS_NATIVE_CLANG) diff --git a/test/test_browser.py b/test/test_browser.py index 46fb9fae67c8e..5d9a871b9f618 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -57,6 +57,7 @@ flaky, no_2gb, no_4gb, + no_highmem, no_wasm64, parameterize, parameterized, @@ -1938,8 +1939,7 @@ def test_gl_renderers(self): self.reftest('gl_renderers.c', cflags=['-sGL_UNSAFE_OPTS=0', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL']) @requires_graphics_hardware - @no_2gb('render fails') - @no_4gb('render fails') + @no_highmem('render fails') def test_gl_stride(self): self.reftest('gl_stride.c', cflags=['-sGL_UNSAFE_OPTS=0', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL']) @@ -3636,8 +3636,7 @@ def test_dylink_pthread_many(self): self.btest_exit('main.cpp', cflags=['-Wno-experimental', '-pthread', '-sMAIN_MODULE=2', 'side1.wasm', 'side2.wasm']) - @no_2gb('uses INITIAL_MEMORY') - @no_4gb('uses INITIAL_MEMORY') + @no_highmem('uses INITIAL_MEMORY') def test_memory_growth_during_startup(self): create_file('data.dat', 'X' * (30 * 1024 * 1024)) self.btest_exit('browser_test_hello_world.c', cflags=['-sASSERTIONS', '-sALLOW_MEMORY_GROWTH', '-sINITIAL_MEMORY=16MB', '-sSTACK_SIZE=16384', '--preload-file', 'data.dat']) @@ -3788,8 +3787,7 @@ def test_pthread_preallocates_workers(self): self.btest_exit('pthread/test_pthread_preallocates_workers.c', cflags=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE=4', '-sPTHREAD_POOL_DELAY_LOAD']) # Test that allocating a lot of threads doesn't regress. This needs to be checked manually! - @no_2gb('uses INITIAL_MEMORY') - @no_4gb('uses INITIAL_MEMORY') + @no_highmem('uses INITIAL_MEMORY') def test_pthread_large_pthread_allocation(self): self.btest_exit('pthread/test_large_pthread_allocation.c', cflags=['-sINITIAL_MEMORY=128MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=50']) @@ -3926,8 +3924,7 @@ def test_pthread_proxying_in_futex_wait(self): self.btest_exit('pthread/test_pthread_proxying_in_futex_wait.c', cflags=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE']) # Test that sbrk() operates properly in multithreaded conditions - @no_2gb('uses INITIAL_MEMORY') - @no_4gb('uses INITIAL_MEMORY') + @no_highmem('uses INITIAL_MEMORY') @parameterized({ '': (['-DABORTING_MALLOC=0', '-sABORTING_MALLOC=0'],), 'aborting_malloc': (['-DABORTING_MALLOC=1'],), @@ -4032,8 +4029,7 @@ def test_pthread_lsan(self, name, args): self.btest(Path('pthread', name + '.cpp'), expected='1', cflags=['-fsanitize=leak', '-pthread', '-sPROXY_TO_PTHREAD', '--pre-js', test_file('pthread', name + '.js')] + args) @no_wasm64('TODO: ASAN in memory64') - @no_2gb('ASAN + GLOBAL_BASE') - @no_4gb('ASAN + GLOBAL_BASE') + @no_highmem('ASAN + GLOBAL_BASE') @parameterized({ # Reusing the LSan test files for ASan. 'leak': ['test_pthread_lsan_leak', ['-gsource-map']], @@ -4044,14 +4040,12 @@ def test_pthread_asan(self, name, args): self.btest(Path('pthread', name + '.cpp'), expected='1', cflags=['-fsanitize=address', '-pthread', '-sPROXY_TO_PTHREAD', '--pre-js', test_file('pthread', name + '.js')] + args) @no_wasm64('TODO: ASAN in memory64') - @no_2gb('ASAN + GLOBAL_BASE') - @no_4gb('ASAN + GLOBAL_BASE') + @no_highmem('ASAN + GLOBAL_BASE') def test_pthread_asan_use_after_free(self): self.btest('pthread/test_pthread_asan_use_after_free.cpp', expected='1', cflags=['-fsanitize=address', '-pthread', '-sPROXY_TO_PTHREAD', '--pre-js', test_file('pthread/test_pthread_asan_use_after_free.js')]) @no_wasm64('TODO: ASAN in memory64') - @no_2gb('ASAN + GLOBAL_BASE') - @no_4gb('ASAN + GLOBAL_BASE') + @no_highmem('ASAN + GLOBAL_BASE') @no_firefox('https://github.com/emscripten-core/emscripten/issues/20006') @no_safari('TODO: Hangs') # Fails in Safari 17.6 (17618.3.11.11.7, 17618), Safari 26.0.1 (21622.1.22.11.15) @also_with_wasmfs @@ -4640,8 +4634,7 @@ def test_minimal_runtime_hello_thread(self, opts): 'growable_arraybuffers': (['-sGROWABLE_ARRAYBUFFERS', '-Wno-experimental'], 1), 'proxy': (['-sPROXY_TO_PTHREAD', '-sEXIT_RUNTIME'], 2), }) - @no_2gb('uses INITIAL_MEMORY') - @no_4gb('uses INITIAL_MEMORY') + @no_highmem('uses INITIAL_MEMORY') @requires_growable_arraybuffers def test_pthread_growth_mainthread(self, cflags, pthread_pool_size): self.set_setting('PTHREAD_POOL_SIZE', pthread_pool_size) @@ -4657,8 +4650,7 @@ def test_pthread_growth_mainthread(self, cflags, pthread_pool_size): 'proxy': (['-sPROXY_TO_PTHREAD'], 2), 'minimal': (['-sMINIMAL_RUNTIME', '-sMODULARIZE', '-sEXPORT_NAME=MyModule'],), }) - @no_2gb('uses INITIAL_MEMORY') - @no_4gb('uses INITIAL_MEMORY') + @no_highmem('uses INITIAL_MEMORY') @requires_growable_arraybuffers def test_pthread_growth(self, cflags, pthread_pool_size=1): self.set_setting('PTHREAD_POOL_SIZE', pthread_pool_size) @@ -5232,8 +5224,7 @@ def test_wasm_worker_proxied_function(self): self.btest('wasm_worker/proxied_function.c', expected='0', cflags=['--js-library', test_file('wasm_worker/proxied_function.js'), '-sWASM_WORKERS', '-sASSERTIONS=0']) @no_firefox('no 4GB support yet') - @no_2gb('uses MAXIMUM_MEMORY') - @no_4gb('uses MAXIMUM_MEMORY') + @no_highmem('uses MAXIMUM_MEMORY') def test_4gb(self): # TODO Convert to an actual browser test when it reaches stable. # For now, keep this in browser as this suite runs serially, which @@ -5371,8 +5362,7 @@ def test_emmalloc_memgrowth(self): self.btest_exit('emmalloc_memgrowth.cpp', cflags=['-sMALLOC=emmalloc', '-sALLOW_MEMORY_GROWTH=1', '-sABORTING_MALLOC=0', '-sASSERTIONS=2', '-sMINIMAL_RUNTIME=1']) @no_firefox('no 4GB support yet') - @no_2gb('uses MAXIMUM_MEMORY') - @no_4gb('uses MAXIMUM_MEMORY') + @no_highmem('uses MAXIMUM_MEMORY') def test_2gb_fail(self): # TODO Convert to an actual browser test when it reaches stable. # For now, keep this in browser as this suite runs serially, which @@ -5386,8 +5376,7 @@ def test_2gb_fail(self): self.do_run_in_out_file_test('browser/test_2gb_fail.c') @no_firefox('no 4GB support yet') - @no_2gb('uses MAXIMUM_MEMORY') - @no_4gb('uses MAXIMUM_MEMORY') + @no_highmem('uses MAXIMUM_MEMORY') def test_4gb_fail(self): # TODO Convert to an actual browser test when it reaches stable. # For now, keep this in browser as this suite runs serially, which diff --git a/test/test_core.py b/test/test_core.py index 402b376ac265e..25218f23ab570 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -59,6 +59,7 @@ no_4gb, no_bun, no_deno, + no_highmem, no_wasm64, no_windows, parameterize, @@ -155,7 +156,7 @@ def asan(func): @no_safe_heap('asan does not work with SAFE_HEAP') @no_wasm2js('TODO: ASAN in wasm2js') @no_wasm64('TODO: ASAN in memory64') - @no_2gb("asan doesn't support GLOBAL_BASE") + @no_highmem("asan doesn't support GLOBAL_BASE") def decorated(self, *args, **kwargs): return func(self, *args, **kwargs) @@ -961,8 +962,7 @@ def test_emmalloc_usable_size(self): @no_asan('ASan does not support custom memory allocators') @no_lsan('LSan does not support custom memory allocators') - @no_4gb('uses INITIAL_MEMORY') - @no_2gb('uses INITIAL_MEMORY') + @no_highmem('uses INITIAL_MEMORY') def test_emmalloc_memory_statistics(self): self.set_setting('MALLOC', 'emmalloc') self.set_setting('INITIAL_MEMORY', '128MB') @@ -976,8 +976,7 @@ def test_emmalloc_memory_statistics(self): self.assertContained(r'emmalloc_unclaimed_heap_memory\s*: [1-9]\d+', output, regex=True) @no_optimize('output is sensitive to optimization flags, so only test unoptimized builds') - @no_2gb('output is sensitive to absolute data layout') - @no_4gb('output is sensitive to absolute data layout') + @no_highmem('output is sensitive to absolute data layout') @no_asan('ASan does not support custom memory allocators') @no_lsan('LSan does not support custom memory allocators') def test_emmalloc_trim(self): @@ -1731,8 +1730,7 @@ def test_ctors_no_main(self): self.do_core_test('test_ctors_no_main.cpp', cflags=['--no-entry']) @no_wasm2js('eval_ctors not supported yet') - @no_2gb('https://github.com/WebAssembly/binaryen/issues/5893') - @no_4gb('https://github.com/WebAssembly/binaryen/issues/5893') + @no_highmem('https://github.com/WebAssembly/binaryen/issues/5893') @also_with_standalone_wasm(impure=True) def test_eval_ctors_no_main(self): self.set_setting('EVAL_CTORS') @@ -2090,8 +2088,7 @@ def remove_growth_warning(self, text): return re.sub(r"\nWarning: Enlarging memory arrays, this is not fast! \d+,\d+\n", "\n", text) # Tests that -sMINIMAL_RUNTIME builds can utilize -sALLOW_MEMORY_GROWTH option. - @no_4gb('memory growth issues') - @no_2gb('memory growth issues') + @no_highmem('memory growth issues') @no_modularize_instance('MODULARIZE=instance is not compatible with MINIMAL_RUNTIME') def test_minimal_runtime_memorygrowth(self): if self.has_changed_setting('ALLOW_MEMORY_GROWTH'): @@ -2106,8 +2103,7 @@ def test_minimal_runtime_memorygrowth(self): output = self.remove_growth_warning(output) self.assertContained('*pre: hello,4.955*\n*hello,4.955*\n*hello,4.955*', output) - @no_2gb('memory growth issues') - @no_4gb('memory growth issues') + @no_highmem('memory growth issues') def test_memorygrowth(self): if self.has_changed_setting('ALLOW_MEMORY_GROWTH'): self.skipTest('test needs to modify memory growth') @@ -2145,8 +2141,7 @@ def test_memorygrowth(self): output = self.remove_growth_warning(output) self.assertContained('*pre: hello,4.955*\n*hello,4.955*\n*hello,4.955*', output) - @no_4gb('memory growth issues') - @no_2gb('memory growth issues') + @no_highmem('memory growth issues') def test_memorygrowth_2(self): if self.has_changed_setting('ALLOW_MEMORY_GROWTH'): self.skipTest('test needs to modify memory growth') @@ -2180,8 +2175,7 @@ def test_memorygrowth_3(self): self.do_core_test('test_memorygrowth_3.c') @also_with_standalone_wasm() - @no_4gb('depends on INITIAL_MEMORY') - @no_2gb('depends on INITIAL_MEMORY') + @no_highmem('depends on INITIAL_MEMORY') def test_memorygrowth_MAXIMUM_MEMORY(self): if self.has_changed_setting('ALLOW_MEMORY_GROWTH'): self.skipTest('test needs to modify memory growth') @@ -2192,8 +2186,7 @@ def test_memorygrowth_MAXIMUM_MEMORY(self): self.cflags += ['-sALLOW_MEMORY_GROWTH', '-sINITIAL_MEMORY=64Mb', '-sMAXIMUM_MEMORY=100Mb'] self.do_core_test('test_memorygrowth_wasm_mem_max.c') - @no_4gb('depends on INITIAL_MEMORY') - @no_2gb('depends on INITIAL_MEMORY') + @no_highmem('depends on INITIAL_MEMORY') def test_memorygrowth_linear_step(self): if self.has_changed_setting('ALLOW_MEMORY_GROWTH'): self.skipTest('test needs to modify memory growth') @@ -2205,8 +2198,7 @@ def test_memorygrowth_linear_step(self): self.do_core_test('test_memorygrowth_linear_step.c') @no_ubsan('UBSan seems to affect the precise memory usage') - @no_4gb('depends on specific memory layout') - @no_2gb('depends on specific memory layout') + @no_highmem('depends on specific memory layout') def test_memorygrowth_geometric_step(self): if self.has_changed_setting('ALLOW_MEMORY_GROWTH'): self.skipTest('test needs to modify memory growth') @@ -2231,8 +2223,7 @@ def test_memorygrowth_3_force_fail_reallocBuffer(self): }) @no_asan('requires more memory when growing') @no_lsan('requires more memory when growing') - @no_4gb('depends on MAXIMUM_MEMORY') - @no_2gb('depends on MAXIMUM_MEMORY') + @no_highmem('depends on MAXIMUM_MEMORY') def test_aborting_new(self, args): # test that C++ new properly errors if we fail to malloc when growth is # enabled, with or without growth @@ -2244,16 +2235,14 @@ def test_aborting_new(self, args): }) @no_asan('requires more memory when growing') @no_lsan('requires more memory when growing') - @no_4gb('depends on MAXIMUM_MEMORY') - @no_2gb('depends on MAXIMUM_MEMORY') + @no_highmem('depends on MAXIMUM_MEMORY') def test_nothrow_new(self, args): self.do_core_test('test_nothrow_new.cpp', cflags=args) @no_wasm2js('no WebAssembly.Memory()') @no_asan('ASan alters the memory size') @no_lsan('LSan alters the memory size') - @no_4gb('depends on memory size') - @no_2gb('depends on memory size') + @no_highmem('depends on memory size') @no_esm_integration('external wasmMemory') def test_module_wasm_memory(self): self.set_setting('IMPORTED_MEMORY') @@ -3278,8 +3267,7 @@ def test_dlfcn_varargs(self): @needs_dylink @no_sanitize('contains ODR violation') - @no_2gb('output is sensitive to absolute data layout') - @no_4gb('output is sensitive to absolute data layout') + @no_highmem('output is sensitive to absolute data layout') def test_dlfcn_alignment_and_zeroing(self): self.set_setting('INITIAL_MEMORY', '16mb') create_file('libside.c', r''' @@ -6513,8 +6501,7 @@ def test_dlmalloc(self): # Tests that a large allocation should gracefully fail @no_asan('the memory size limit here is too small for asan') @no_lsan('the memory size limit here is too small for lsan') - @no_4gb('output is sensitive to absolute data layout') - @no_2gb('output is sensitive to absolute data layout') + @no_highmem('output is sensitive to absolute data layout') def test_dlmalloc_large(self): self.cflags += ['-sABORTING_MALLOC=0', '-sALLOW_MEMORY_GROWTH=1', '-sMAXIMUM_MEMORY=128MB'] self.do_runf('dlmalloc_test_large.c', '0 0 0 1')