Skip to content

Commit 1aa6dfa

Browse files
authored
[test] Add @asan decorator. NFC (#24582)
Also remove `no_wasm64` from test_dylink_basics_no_modify (it's not longer needed there).
1 parent 47ca47c commit 1aa6dfa

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

test/test_core.py

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,21 @@ def decorated(self, *args, **kwargs):
103103
return decorated
104104

105105

106+
def asan(f):
107+
assert callable(f)
108+
109+
@wraps(f)
110+
@no_safe_heap('asan does not work with SAFE_HEAP')
111+
@no_wasm2js('TODO: ASAN in wasm2js')
112+
@no_wasm64('TODO: ASAN in memory64')
113+
@no_2gb('asan doesnt support GLOBAL_BASE')
114+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
115+
def decorated(self, *args, **kwargs):
116+
f(self, *args, **kwargs)
117+
118+
return decorated
119+
120+
106121
def wasm_relaxed_simd(f):
107122
assert callable(f)
108123

@@ -4122,7 +4137,6 @@ def test_dylink_basics(self):
41224137
self.verify_in_strict_mode(self.output_name('main'))
41234138

41244139
@with_dylink_reversed
4125-
@no_wasm64('Requires table64 lowering in all cases')
41264140
def test_dylink_basics_no_modify(self):
41274141
if self.is_optimizing():
41284142
self.skipTest('no modify mode only works with non-optimizing builds')
@@ -8971,11 +8985,7 @@ def test_template_class_deduction(self):
89718985
self.emcc_args += ['-std=c++17']
89728986
self.do_core_test('test_template_class_deduction.cpp')
89738987

8974-
@no_wasm2js('TODO: ASAN in wasm2js')
8975-
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
8976-
@no_safe_heap('asan does not work with SAFE_HEAP')
8977-
@no_wasm64('TODO: ASAN in memory64')
8978-
@no_2gb('asan doesnt support GLOBAL_BASE')
8988+
@asan
89798989
@parameterized({
89808990
'c': ['test_asan_no_error.c'],
89818991
'cpp': ['test_asan_no_error.cpp'],
@@ -8990,10 +9000,7 @@ def test_asan_no_error(self, name):
89909000
# clang optimizing things away. for example, a memset might be optimized into
89919001
# stores, and then the stores identified as dead, which leaves nothing for
89929002
# asan to test. here we want to test asan itself, so we work around that.
8993-
@no_safe_heap('asan does not work with SAFE_HEAP')
8994-
@no_wasm64('TODO: ASAN in memory64')
8995-
@no_2gb('asan doesnt support GLOBAL_BASE')
8996-
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
9003+
@asan
89979004
@parameterized({
89989005
'use_after_free_c': ('test_asan_use_after_free.c', [
89999006
'AddressSanitizer: heap-use-after-free on address',
@@ -9051,9 +9058,6 @@ def test_asan(self, name, expected_output, cflags=None):
90519058
if '-Oz' in self.emcc_args:
90529059
self.skipTest('-Oz breaks source maps')
90539060

9054-
if self.is_wasm2js():
9055-
self.skipTest('wasm2js has no ASan support')
9056-
90579061
self.emcc_args.append('-fsanitize=address')
90589062
self.set_setting('ALLOW_MEMORY_GROWTH')
90599063
self.set_setting('INITIAL_MEMORY', '300mb')
@@ -9063,33 +9067,20 @@ def test_asan(self, name, expected_output, cflags=None):
90639067
expected_output=expected_output, assert_all=True,
90649068
check_for_error=False, assert_returncode=NON_ZERO)
90659069

9066-
@no_safe_heap('asan does not work with SAFE_HEAP')
9067-
@no_wasm2js('TODO: ASAN in wasm2js')
9068-
@no_wasm64('TODO: ASAN in memory64')
9069-
@no_2gb('asan doesnt support GLOBAL_BASE')
9070-
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
9070+
@asan
90719071
def test_asan_js_stack_op(self):
90729072
self.emcc_args.append('-fsanitize=address')
90739073
self.set_setting('ALLOW_MEMORY_GROWTH')
90749074
self.set_setting('INITIAL_MEMORY', '300mb')
9075-
self.do_runf('core/test_asan_js_stack_op.c',
9076-
expected_output='Hello, World!')
9075+
self.do_runf('core/test_asan_js_stack_op.c', 'Hello, World!')
90779076

9078-
@no_safe_heap('asan does not work with SAFE_HEAP')
9079-
@no_wasm2js('TODO: ASAN in wasm2js')
9080-
@no_wasm64('TODO: ASAN in memory64')
9081-
@no_2gb('asan doesnt support GLOBAL_BASE')
9082-
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
9077+
@asan
90839078
def test_asan_api(self):
90849079
self.emcc_args.append('-fsanitize=address')
90859080
self.set_setting('INITIAL_MEMORY', '300mb')
90869081
self.do_core_test('test_asan_api.c')
90879082

9088-
@no_safe_heap('asan does not work with SAFE_HEAP')
9089-
@no_wasm2js('TODO: ASAN in wasm2js')
9090-
@no_wasm64('TODO: ASAN in memory64')
9091-
@no_2gb('asan doesnt support GLOBAL_BASE')
9092-
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
9083+
@asan
90939084
def test_asan_modularized_with_closure(self):
90949085
# the bug is that createModule() returns undefined, instead of the
90959086
# proper Promise object.

0 commit comments

Comments
 (0)