Skip to content

Commit f50de5b

Browse files
committed
[EH] Add more manual tests for new Wasm EH
The testing mode for the new Wasm EH (exnref) was added in `with_all_eh_sjlj` and `with_all_sjlj` in emscripten-core#21906. But this adds the new Wasm EH test mode for more tests that are not covered by those decorators.
1 parent 619f08d commit f50de5b

8 files changed

+67
-10
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
__indirect_function_table
2+
__trap
3+
__wasm_call_ctors
4+
_emscripten_stack_alloc
5+
dynCall_iiiiiijj
6+
dynCall_iiiiij
7+
dynCall_iiiiijj
8+
dynCall_jiji
9+
dynCall_viijii
10+
main
11+
memory
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9807
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
env._abort_js
2+
env._emscripten_memcpy_js
3+
env.emscripten_resize_heap
4+
env.strftime_l
5+
wasi_snapshot_preview1.environ_get
6+
wasi_snapshot_preview1.environ_sizes_get
7+
wasi_snapshot_preview1.fd_close
8+
wasi_snapshot_preview1.fd_read
9+
wasi_snapshot_preview1.fd_seek
10+
wasi_snapshot_preview1.fd_write
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24140
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
_abort_js
2+
_emscripten_memcpy_js
3+
emscripten_resize_heap
4+
environ_get
5+
environ_sizes_get
6+
fd_close
7+
fd_read
8+
fd_seek
9+
fd_write
10+
strftime_l
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
141975

test/test_core.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,10 @@ def test_longjmp_with_and_without_exceptions(self):
915915
self.emcc_args.append('-fwasm-exceptions')
916916
for arg in ['-fwasm-exceptions', '-fno-exceptions']:
917917
self.do_core_test('test_longjmp.c', emcc_args=[arg])
918+
# Wasm SjLj with and with new experimental EH support
919+
self.require_new_wasm_eh()
920+
self.set_setting('WASM_EXNREF')
921+
self.do_core_test('test_longjmp.c', emcc_args=['-fwasm-exceptions'])
918922

919923
@with_all_sjlj
920924
def test_longjmp2(self):
@@ -1051,6 +1055,12 @@ def test_exceptions_with_and_without_longjmp(self):
10511055
for support_longjmp in [0, 'wasm']:
10521056
self.set_setting('SUPPORT_LONGJMP', support_longjmp)
10531057
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
1058+
# Wasm new experimental EH with and without Wasm SjLj support
1059+
self.require_new_wasm_eh()
1060+
self.set_setting('WASM_EXNREF')
1061+
for support_longjmp in [0, 'wasm']:
1062+
self.set_setting('SUPPORT_LONGJMP', support_longjmp)
1063+
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
10541064

10551065
def test_exceptions_off(self):
10561066
self.set_setting('DISABLE_EXCEPTION_CATCHING')

test/test_other.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3298,13 +3298,16 @@ def test_embind_tsgen_memory64(self):
32983298
self.assertFileContents(test_file('other/embind_tsgen_memory64.d.ts'), read_file('embind_tsgen_memory64.d.ts'))
32993299

33003300
def test_embind_tsgen_exceptions(self):
3301-
# Check that when Wasm exceptions and assertions are enabled bindings still generate.
3302-
self.run_process([EMXX, test_file('other/embind_tsgen.cpp'),
3303-
'-lembind', '-fwasm-exceptions', '-sASSERTIONS',
3304-
# Use the deprecated `--embind-emit-tsd` to ensure it
3305-
# still works until removed.
3306-
'--embind-emit-tsd', 'embind_tsgen.d.ts', '-Wno-deprecated'])
3307-
self.assertFileContents(test_file('other/embind_tsgen.d.ts'), read_file('embind_tsgen.d.ts'))
3301+
for wasm_exnref in [0, 1]:
3302+
self.set_setting('WASM_EXNREF', wasm_exnref)
3303+
# Check that when Wasm exceptions and assertions are enabled bindings still generate.
3304+
self.run_process([EMXX, test_file('other/embind_tsgen.cpp'),
3305+
'-lembind', '-fwasm-exceptions', '-sASSERTIONS',
3306+
# Use the deprecated `--embind-emit-tsd` to ensure it
3307+
# still works until removed.
3308+
'--embind-emit-tsd', 'embind_tsgen.d.ts', '-Wno-deprecated']
3309+
+ self.get_emcc_args())
3310+
self.assertFileContents(test_file('other/embind_tsgen.d.ts'), read_file('embind_tsgen.d.ts'))
33083311

33093312
def test_embind_jsgen_method_pointer_stability(self):
33103313
self.emcc_args += ['-lembind', '-sEMBIND_AOT']
@@ -8531,6 +8534,7 @@ def test_metadce_minimal_pthreads(self):
85318534
'-sDEMANGLE_SUPPORT', '-Wno-deprecated'], [], ['waka']), # noqa
85328535
# Wasm EH's code size increase is smaller than that of Emscripten EH
85338536
'except_wasm': (['-O2', '-fwasm-exceptions'], [], ['waka']), # noqa
8537+
'except_wasm_exnref': (['-O2', '-fwasm-exceptions', '-sWASM_EXNREF'], [], ['waka']), # noqa
85348538
# eval_ctors 1 can partially optimize, but runs into getenv() for locale
85358539
# code. mode 2 ignores those and fully optimizes out the ctors
85368540
'ctors1': (['-O2', '-sEVAL_CTORS'], [], ['waka']), # noqa
@@ -8830,7 +8834,8 @@ def test_lto(self, args):
88308834
@parameterized({
88318835
'noexcept': [],
88328836
'except': ['-sDISABLE_EXCEPTION_CATCHING=0'],
8833-
'except_wasm': ['-fwasm-exceptions']
8837+
'except_wasm': ['-fwasm-exceptions'],
8838+
'except_wasm_exnref': ['-fwasm-exceptions', '-sWASM_EXNREF']
88348839
})
88358840
def test_lto_libcxx(self, *args):
88368841
self.run_process([EMXX, test_file('hello_libcxx.cpp'), '-flto'] + list(args))
@@ -8849,11 +8854,15 @@ def test_lto_flags(self):
88498854

88508855
# We have LTO tests covered in 'wasmltoN' targets in test_core.py, but they
88518856
# don't run as a part of Emscripten CI, so we add a separate LTO test here.
8852-
@requires_wasm_eh
88538857
def test_lto_wasm_exceptions(self):
88548858
self.set_setting('EXCEPTION_DEBUG')
8859+
self.require_wasm_eh()
88558860
self.emcc_args += ['-fwasm-exceptions', '-flto']
88568861
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
8862+
# New Wasm EH with exnref
8863+
self.require_wasm_exnref()
8864+
self.set_setting('WASM_EXNREF')
8865+
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
88578866

88588867
@parameterized({
88598868
'': ([],),
@@ -12269,12 +12278,16 @@ def test_standalone_export_main(self):
1226912278
# We should consider making this a warning since the `_main` export is redundant.
1227012279
self.run_process([EMCC, '-sEXPORTED_FUNCTIONS=_main', '-sSTANDALONE_WASM', test_file('core/test_hello_world.c')])
1227112280

12272-
@requires_wasm_eh
1227312281
def test_standalone_wasm_exceptions(self):
1227412282
self.set_setting('STANDALONE_WASM')
1227512283
self.set_setting('WASM_BIGINT')
1227612284
self.wasm_engines = []
1227712285
self.emcc_args += ['-fwasm-exceptions']
12286+
self.require_wasm_eh()
12287+
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
12288+
# New Wasm EH with exnref
12289+
self.require_wasm_exnref()
12290+
self.set_setting('WASM_EXNREF')
1227812291
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
1227912292

1228012293
def test_missing_malloc_export(self):

0 commit comments

Comments
 (0)