Skip to content

Commit 7e7c057

Browse files
authored
[EH] Add more manual tests for new Wasm EH (#21913)
The testing mode for the new Wasm EH (exnref) was added in `with_all_eh_sjlj` and `with_all_sjlj` in #21906. But this adds the new Wasm EH test mode for more tests that are not covered by those decorators.
1 parent 2a08958 commit 7e7c057

8 files changed

+65
-9
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: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from common import env_modify, with_env_modify, disabled, flaky, node_pthreads, also_with_wasm_bigint
2929
from common import read_file, read_binary, requires_v8, requires_node, requires_wasm2js, requires_node_canary
3030
from common import compiler_for, crossplatform, no_4gb, no_2gb, also_with_minimal_runtime
31-
from common import with_all_eh_sjlj, with_all_sjlj, also_with_standalone_wasm, can_do_standalone, no_wasm64
31+
from common import with_all_eh_sjlj, with_all_sjlj, also_with_standalone_wasm, can_do_standalone, no_wasm64, requires_wasm_exnref
3232
from common import NON_ZERO, WEBIDL_BINDER, EMBUILDER, PYTHON
3333
import clang_native
3434

@@ -896,6 +896,7 @@ def test_longjmp_zero(self):
896896
self.skipTest('https://github.com/emscripten-core/emscripten/issues/21533')
897897
self.do_core_test('test_longjmp_zero.c')
898898

899+
@requires_wasm_exnref
899900
def test_longjmp_with_and_without_exceptions(self):
900901
# Emscripten SjLj with and without Emscripten EH support
901902
self.set_setting('SUPPORT_LONGJMP', 'emscripten')
@@ -908,13 +909,15 @@ def test_longjmp_with_and_without_exceptions(self):
908909
self.set_setting('SUPPORT_LONGJMP', 'wasm')
909910
if self.is_wasm2js():
910911
self.skipTest('wasm2js does not support wasm EH/SjLj')
911-
self.require_wasm_eh()
912912
# FIXME Temporarily disabled. Enable this later when the bug is fixed.
913913
if '-fsanitize=address' in self.emcc_args:
914914
self.skipTest('Wasm EH does not work with asan yet')
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 EH (exnref) support
919+
self.set_setting('WASM_EXNREF')
920+
self.do_core_test('test_longjmp.c', emcc_args=['-fwasm-exceptions'])
918921

919922
@with_all_sjlj
920923
def test_longjmp2(self):
@@ -1031,6 +1034,7 @@ def test_exceptions(self):
10311034
self.maybe_closure()
10321035
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
10331036

1037+
@requires_wasm_exnref
10341038
def test_exceptions_with_and_without_longjmp(self):
10351039
self.set_setting('EXCEPTION_DEBUG')
10361040
self.maybe_closure()
@@ -1043,14 +1047,18 @@ def test_exceptions_with_and_without_longjmp(self):
10431047
self.clear_setting('DISABLE_EXCEPTION_CATCHING')
10441048
if self.is_wasm2js():
10451049
self.skipTest('wasm2js does not support wasm EH/SjLj')
1046-
self.require_wasm_eh()
10471050
# FIXME Temporarily disabled. Enable this later when the bug is fixed.
10481051
if '-fsanitize=address' in self.emcc_args:
10491052
self.skipTest('Wasm EH does not work with asan yet')
10501053
self.emcc_args.append('-fwasm-exceptions')
10511054
for support_longjmp in [0, 'wasm']:
10521055
self.set_setting('SUPPORT_LONGJMP', support_longjmp)
10531056
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
1057+
# Wasm new EH (exnref) with and without Wasm SjLj support
1058+
self.set_setting('WASM_EXNREF')
1059+
for support_longjmp in [0, 'wasm']:
1060+
self.set_setting('SUPPORT_LONGJMP', support_longjmp)
1061+
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
10541062

10551063
def test_exceptions_off(self):
10561064
self.set_setting('DISABLE_EXCEPTION_CATCHING')

test/test_other.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from common import env_modify, no_mac, no_windows, only_windows, requires_native_clang, with_env_modify
3535
from common import create_file, parameterized, NON_ZERO, node_pthreads, TEST_ROOT, test_file
3636
from common import compiler_for, EMBUILDER, requires_v8, requires_node, requires_wasm64, requires_node_canary
37-
from common import requires_wasm_eh, crossplatform, with_all_eh_sjlj, with_all_sjlj
37+
from common import requires_wasm_exnref, crossplatform, with_all_eh_sjlj, with_all_sjlj
3838
from common import also_with_standalone_wasm, also_with_env_modify, also_with_wasm2js
3939
from common import also_with_minimal_runtime, also_with_wasm_bigint, also_with_wasm64, flaky
4040
from common import EMTEST_BUILD_VERBOSE, PYTHON, WEBIDL_BINDER
@@ -3295,13 +3295,19 @@ def test_embind_tsgen_memory64(self):
32953295
self.get_emcc_args())
32963296
self.assertFileContents(test_file('other/embind_tsgen_memory64.d.ts'), read_file('embind_tsgen_memory64.d.ts'))
32973297

3298-
def test_embind_tsgen_exceptions(self):
3298+
@parameterized({
3299+
'': [0],
3300+
'wasm_exnref': [1]
3301+
})
3302+
def test_embind_tsgen_exceptions(self, wasm_exnref):
3303+
self.set_setting('WASM_EXNREF', wasm_exnref)
32993304
# Check that when Wasm exceptions and assertions are enabled bindings still generate.
33003305
self.run_process([EMXX, test_file('other/embind_tsgen.cpp'),
33013306
'-lembind', '-fwasm-exceptions', '-sASSERTIONS',
33023307
# Use the deprecated `--embind-emit-tsd` to ensure it
33033308
# still works until removed.
3304-
'--embind-emit-tsd', 'embind_tsgen.d.ts', '-Wno-deprecated'])
3309+
'--embind-emit-tsd', 'embind_tsgen.d.ts', '-Wno-deprecated'] +
3310+
self.get_emcc_args())
33053311
self.assertFileContents(test_file('other/embind_tsgen.d.ts'), read_file('embind_tsgen.d.ts'))
33063312

33073313
def test_embind_jsgen_method_pointer_stability(self):
@@ -8529,6 +8535,7 @@ def test_metadce_minimal_pthreads(self):
85298535
'-sDEMANGLE_SUPPORT', '-Wno-deprecated'], [], ['waka']), # noqa
85308536
# Wasm EH's code size increase is smaller than that of Emscripten EH
85318537
'except_wasm': (['-O2', '-fwasm-exceptions'], [], ['waka']), # noqa
8538+
'except_wasm_exnref': (['-O2', '-fwasm-exceptions', '-sWASM_EXNREF'], [], ['waka']), # noqa
85328539
# eval_ctors 1 can partially optimize, but runs into getenv() for locale
85338540
# code. mode 2 ignores those and fully optimizes out the ctors
85348541
'ctors1': (['-O2', '-sEVAL_CTORS'], [], ['waka']), # noqa
@@ -8828,7 +8835,8 @@ def test_lto(self, args):
88288835
@parameterized({
88298836
'noexcept': [],
88308837
'except': ['-sDISABLE_EXCEPTION_CATCHING=0'],
8831-
'except_wasm': ['-fwasm-exceptions']
8838+
'except_wasm': ['-fwasm-exceptions'],
8839+
'except_wasm_exnref': ['-fwasm-exceptions', '-sWASM_EXNREF']
88328840
})
88338841
def test_lto_libcxx(self, *args):
88348842
self.run_process([EMXX, test_file('hello_libcxx.cpp'), '-flto'] + list(args))
@@ -8847,11 +8855,14 @@ def test_lto_flags(self):
88478855

88488856
# We have LTO tests covered in 'wasmltoN' targets in test_core.py, but they
88498857
# don't run as a part of Emscripten CI, so we add a separate LTO test here.
8850-
@requires_wasm_eh
8858+
@requires_wasm_exnref
88518859
def test_lto_wasm_exceptions(self):
88528860
self.set_setting('EXCEPTION_DEBUG')
88538861
self.emcc_args += ['-fwasm-exceptions', '-flto']
88548862
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
8863+
# New Wasm EH with exnref
8864+
self.set_setting('WASM_EXNREF')
8865+
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
88558866

88568867
@parameterized({
88578868
'': ([],),
@@ -12267,13 +12278,16 @@ def test_standalone_export_main(self):
1226712278
# We should consider making this a warning since the `_main` export is redundant.
1226812279
self.run_process([EMCC, '-sEXPORTED_FUNCTIONS=_main', '-sSTANDALONE_WASM', test_file('core/test_hello_world.c')])
1226912280

12270-
@requires_wasm_eh
12281+
@requires_wasm_exnref
1227112282
def test_standalone_wasm_exceptions(self):
1227212283
self.set_setting('STANDALONE_WASM')
1227312284
self.set_setting('WASM_BIGINT')
1227412285
self.wasm_engines = []
1227512286
self.emcc_args += ['-fwasm-exceptions']
1227612287
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
12288+
# New Wasm EH with exnref
12289+
self.set_setting('WASM_EXNREF')
12290+
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
1227712291

1227812292
def test_missing_malloc_export(self):
1227912293
# we used to include malloc by default. show a clear error in builds with

0 commit comments

Comments
 (0)