Skip to content

Commit c2df6f8

Browse files
authored
[test] Add also_with_asan decorator. NFC (emscripten-core#23575)
1 parent b96f1e7 commit c2df6f8

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

test/common.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,24 @@ def metafunc(self, standalone):
628628
return decorated
629629

630630

631+
def also_with_asan(f):
632+
assert callable(f)
633+
634+
@wraps(f)
635+
def metafunc(self, asan, *args, **kwargs):
636+
if asan:
637+
if self.is_wasm64():
638+
self.skipTest('TODO: ASAN in memory64')
639+
if self.is_2gb() or self.is_4gb():
640+
self.skipTest('asan doesnt support GLOBAL_BASE')
641+
self.emcc_args.append('-fsanitize=address')
642+
f(self, *args, **kwargs)
643+
644+
parameterize(metafunc, {'': (False,),
645+
'asan': (True,)})
646+
return metafunc
647+
648+
631649
# Tests exception handling and setjmp/longjmp handling. This tests three
632650
# combinations:
633651
# - Emscripten EH + Emscripten SjLj

test/test_browser.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
import common
2424
from common import BrowserCore, RunnerCore, path_from_root, has_browser, EMTEST_BROWSER, Reporting
2525
from common import create_file, parameterized, ensure_dir, disabled, test_file, WEBIDL_BINDER
26-
from common import read_file, also_with_minimal_runtime, EMRUN, no_wasm64, no_2gb, no_4gb
27-
from common import requires_wasm2js, also_with_wasm2js, parameterize, find_browser_test_file
26+
from common import read_file, EMRUN, no_wasm64, no_2gb, no_4gb
27+
from common import requires_wasm2js, parameterize, find_browser_test_file
28+
from common import also_with_minimal_runtime, also_with_wasm2js, also_with_asan
2829
from tools import shared
2930
from tools import ports
3031
from tools.shared import EMCC, WINDOWS, FILE_PACKAGER, PIPE, DEBUG
@@ -4206,17 +4207,9 @@ def test_async_compile(self, opts, returncode):
42064207
self.btest_exit('test_async_compile.c', assert_returncode=1, args=common_args)
42074208

42084209
# Test that implementing Module.instantiateWasm() callback works.
4209-
@parameterized({
4210-
'': ([],),
4211-
'asan': (['-fsanitize=address'],)
4212-
})
4213-
def test_manual_wasm_instantiate(self, args):
4214-
if args:
4215-
if self.is_wasm64():
4216-
self.skipTest('TODO: ASAN in memory64')
4217-
if self.is_2gb() or self.is_4gb():
4218-
self.skipTest('asan doesnt support GLOBAL_BASE')
4219-
self.compile_btest('test_manual_wasm_instantiate.c', ['-o', 'manual_wasm_instantiate.js'] + args)
4210+
@also_with_asan
4211+
def test_manual_wasm_instantiate(self):
4212+
self.compile_btest('test_manual_wasm_instantiate.c', ['-o', 'manual_wasm_instantiate.js'])
42204213
shutil.copy(test_file('test_manual_wasm_instantiate.html'), '.')
42214214
self.run_browser('test_manual_wasm_instantiate.html', '/report_result?1')
42224215

test/test_other.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from common import compiler_for, EMBUILDER, requires_v8, requires_node, requires_wasm64, requires_node_canary
3838
from common import requires_wasm_eh, crossplatform, with_all_eh_sjlj, with_all_sjlj
3939
from common import also_with_standalone_wasm, also_with_wasm2js, also_with_noderawfs, also_with_wasmfs, with_all_fs
40-
from common import also_with_minimal_runtime, also_with_wasm_bigint, also_with_wasm64, flaky
40+
from common import also_with_minimal_runtime, also_with_wasm_bigint, also_with_wasm64, also_with_asan, flaky
4141
from common import EMTEST_BUILD_VERBOSE, PYTHON, WEBIDL_BINDER
4242
from common import requires_network, parameterize
4343
from tools import shared, building, utils, response_file, cache
@@ -11948,12 +11948,10 @@ def test_mmap_and_munmap(self):
1194811948
emcc_args.extend(['--embed-file', f])
1194911949
self.do_other_test('test_mmap_and_munmap.c', emcc_args)
1195011950

11951+
@also_with_asan
1195111952
def test_mmap_and_munmap_anonymous(self):
1195211953
self.do_other_test('test_mmap_and_munmap_anonymous.cpp', emcc_args=['-sNO_FILESYSTEM'])
1195311954

11954-
def test_mmap_and_munmap_anonymous_asan(self):
11955-
self.do_other_test('test_mmap_and_munmap_anonymous.cpp', emcc_args=['-sNO_FILESYSTEM', '-fsanitize=address'])
11956-
1195711955
def test_mmap_memorygrowth(self):
1195811956
self.do_other_test('test_mmap_memorygrowth.cpp', ['-sALLOW_MEMORY_GROWTH'])
1195911957

0 commit comments

Comments
 (0)