Skip to content

Commit f302d4c

Browse files
authored
[test] Make use of is_wasm2js helper (#21413)
Also, don't check for `WASM2JS` settings. That is a private setting that cannot be set on the command line.
1 parent e37f83b commit f302d4c

File tree

4 files changed

+40
-43
lines changed

4 files changed

+40
-43
lines changed

test/common.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ def with_both_sjlj(f):
472472

473473
def metafunc(self, is_native):
474474
if is_native:
475-
if not self.is_wasm():
475+
if self.is_wasm2js():
476476
self.skipTest('wasm2js does not support wasm SjLj')
477477
self.require_wasm_eh()
478478
# FIXME Temporarily disabled. Enable this later when the bug is fixed.
@@ -691,9 +691,7 @@ def is_2gb(self):
691691
return self.get_setting('INITIAL_MEMORY') == '2200mb'
692692

693693
def check_dylink(self):
694-
if self.get_setting('ALLOW_MEMORY_GROWTH') == 1 and not self.is_wasm():
695-
self.skipTest('no dynamic linking with memory growth (without wasm)')
696-
if not self.is_wasm():
694+
if self.is_wasm2js():
697695
self.skipTest('no dynamic linking support in wasm2js yet')
698696
if '-fsanitize=undefined' in self.emcc_args:
699697
self.skipTest('no dynamic linking support in UBSan yet')
@@ -804,7 +802,7 @@ def require_jspi(self):
804802
# warnings-as-errors, so disable that warning
805803
self.emcc_args += ['-Wno-experimental']
806804
self.set_setting('ASYNCIFY', 2)
807-
if not self.is_wasm():
805+
if self.is_wasm2js():
808806
self.skipTest('JSPI is not currently supported for WASM2JS')
809807

810808
if self.is_browser_test():
@@ -850,14 +848,15 @@ def setup_node_pthreads(self):
850848
self.node_args += shared.node_pthread_flags(nodejs)
851849

852850
def uses_memory_init_file(self):
853-
if self.get_setting('SIDE_MODULE') or (self.is_wasm() and not self.get_setting('WASM2JS')):
851+
if self.get_setting('SIDE_MODULE') or self.is_wasm():
854852
return False
855-
elif '--memory-init-file' in self.emcc_args:
853+
854+
if '--memory-init-file' in self.emcc_args:
856855
return int(self.emcc_args[self.emcc_args.index('--memory-init-file') + 1])
857-
else:
858-
# side modules handle memory differently; binaryen puts the memory in the wasm module
859-
opt_supports = any(opt in self.emcc_args for opt in ('-O2', '-O3', '-Os', '-Oz'))
860-
return opt_supports
856+
857+
# side modules handle memory differently; binaryen puts the memory in the wasm module
858+
opt_supports = any(opt in self.emcc_args for opt in ('-O2', '-O3', '-Os', '-Oz'))
859+
return opt_supports
861860

862861
def set_temp_dir(self, temp_dir):
863862
self.temp_dir = temp_dir

test/test_browser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3989,7 +3989,7 @@ def test_pthread_gcc_atomic_fetch_and_op(self, args):
39893989
@no_4gb('https://github.com/emscripten-core/emscripten/issues/21318')
39903990
@requires_threads
39913991
def test_pthread_gcc_64bit_atomic_fetch_and_op(self):
3992-
if not self.is_wasm():
3992+
if self.is_wasm2js():
39933993
self.skipTest('https://github.com/WebAssembly/binaryen/issues/4358')
39943994
self.emcc_args += ['-Wno-sync-fetch-and-nand-semantics-changed']
39953995
self.btest_exit('pthread/test_pthread_gcc_64bit_atomic_fetch_and_op.cpp', args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8'])
@@ -4009,7 +4009,7 @@ def test_pthread_gcc_atomic_op_and_fetch(self):
40094009
@no_4gb('https://github.com/emscripten-core/emscripten/issues/21318')
40104010
@requires_threads
40114011
def test_pthread_gcc_64bit_atomic_op_and_fetch(self):
4012-
if not self.is_wasm():
4012+
if self.is_wasm2js():
40134013
self.skipTest('https://github.com/WebAssembly/binaryen/issues/4358')
40144014
self.emcc_args += ['-Wno-sync-fetch-and-nand-semantics-changed', '--profiling-funcs']
40154015
self.btest_exit('pthread/test_pthread_gcc_64bit_atomic_op_and_fetch.cpp', args=['-pthread', '-O2', '-sPTHREAD_POOL_SIZE=8'])

test/test_core.py

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def decorated(self, *args, **kwargs):
4646
self.require_simd()
4747
if self.get_setting('MEMORY64') == 2:
4848
self.skipTest('https://github.com/WebAssembly/binaryen/issues/4638')
49-
if not self.is_wasm():
49+
if self.is_wasm2js():
5050
self.skipTest('wasm2js only supports MVP for now')
5151
if '-O3' in self.emcc_args:
5252
self.skipTest('SIMD tests are too slow with -O3 in the new LLVM pass manager, https://github.com/emscripten-core/emscripten/issues/13427')
@@ -62,7 +62,7 @@ def decorated(self):
6262
if self.get_setting('MEMORY64') == 2:
6363
self.skipTest('https://github.com/WebAssembly/binaryen/issues/4638')
6464
# We don't actually run any tests yet, so don't require any engines.
65-
if not self.is_wasm():
65+
if self.is_wasm2js():
6666
self.skipTest('wasm2js only supports MVP for now')
6767
self.emcc_args.append('-mrelaxed-simd')
6868
f(self)
@@ -71,7 +71,7 @@ def decorated(self):
7171

7272
def needs_non_trapping_float_to_int(f):
7373
def decorated(self):
74-
if not self.is_wasm():
74+
if self.is_wasm2js():
7575
self.skipTest('wasm2js only supports MVP for now')
7676
f(self)
7777
return decorated
@@ -102,7 +102,7 @@ def with_both_eh_sjlj(f):
102102
def metafunc(self, is_native):
103103
if is_native:
104104
# Wasm EH is currently supported only in wasm backend and V8
105-
if not self.is_wasm():
105+
if self.is_wasm2js():
106106
self.skipTest('wasm2js does not support wasm EH/SjLj')
107107
self.require_wasm_eh()
108108
# FIXME Temporarily disabled. Enable this later when the bug is fixed.
@@ -902,7 +902,7 @@ def test_longjmp_with_and_without_exceptions(self):
902902
# Wasm SjLj with and without Wasm EH support
903903
self.clear_setting('DISABLE_EXCEPTION_CATCHING')
904904
self.set_setting('SUPPORT_LONGJMP', 'wasm')
905-
if not self.is_wasm():
905+
if self.is_wasm2js():
906906
self.skipTest('wasm2js does not support wasm EH/SjLj')
907907
self.require_wasm_eh()
908908
# FIXME Temporarily disabled. Enable this later when the bug is fixed.
@@ -1037,7 +1037,7 @@ def test_exceptions_with_and_without_longjmp(self):
10371037
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')
10381038
# Wasm EH with and without Wasm SjLj support
10391039
self.clear_setting('DISABLE_EXCEPTION_CATCHING')
1040-
if not self.is_wasm():
1040+
if self.is_wasm2js():
10411041
self.skipTest('wasm2js does not support wasm EH/SjLj')
10421042
self.require_wasm_eh()
10431043
# FIXME Temporarily disabled. Enable this later when the bug is fixed.
@@ -2028,7 +2028,7 @@ def test_memorygrowth(self):
20282028
self.do_runf(src, '*pre: hello,4.955*\n*hello,4.955*\n*hello,4.955*')
20292029
win = read_file('test_memorygrowth.js')
20302030

2031-
if '-O2' in self.emcc_args and not self.is_wasm():
2031+
if '-O2' in self.emcc_args and self.is_wasm2js():
20322032
# Make sure ALLOW_MEMORY_GROWTH generates different code (should be less optimized)
20332033
code_start = '// EMSCRIPTEN_START_FUNCS'
20342034
self.assertContained(code_start, fail)
@@ -2061,7 +2061,7 @@ def test_memorygrowth_2(self):
20612061
self.do_runf(src, '*pre: hello,4.955*\n*hello,4.955*\n*hello,4.955*')
20622062
win = read_file('test_memorygrowth_2.js')
20632063

2064-
if '-O2' in self.emcc_args and not self.is_wasm():
2064+
if '-O2' in self.emcc_args and self.is_wasm2js():
20652065
# Make sure ALLOW_MEMORY_GROWTH generates different code (should be less optimized)
20662066
assert len(fail) < len(win), 'failing code - without memory growth on - is more optimized, and smaller' + str([len(fail), len(win)])
20672067

@@ -2080,7 +2080,7 @@ def test_memorygrowth_3(self):
20802080
def test_memorygrowth_MAXIMUM_MEMORY(self):
20812081
if self.has_changed_setting('ALLOW_MEMORY_GROWTH'):
20822082
self.skipTest('test needs to modify memory growth')
2083-
if not self.is_wasm():
2083+
if self.is_wasm2js():
20842084
self.skipTest('wasm memory specific test')
20852085

20862086
# check that memory growth does not exceed the wasm mem max limit
@@ -2092,7 +2092,7 @@ def test_memorygrowth_MAXIMUM_MEMORY(self):
20922092
def test_memorygrowth_linear_step(self):
20932093
if self.has_changed_setting('ALLOW_MEMORY_GROWTH'):
20942094
self.skipTest('test needs to modify memory growth')
2095-
if not self.is_wasm():
2095+
if self.is_wasm2js():
20962096
self.skipTest('wasm memory specific test')
20972097

20982098
# check that memory growth does not exceed the wasm mem max limit and is exactly or one step below the wasm mem max
@@ -2105,7 +2105,7 @@ def test_memorygrowth_linear_step(self):
21052105
def test_memorygrowth_geometric_step(self):
21062106
if self.has_changed_setting('ALLOW_MEMORY_GROWTH'):
21072107
self.skipTest('test needs to modify memory growth')
2108-
if not self.is_wasm():
2108+
if self.is_wasm2js():
21092109
self.skipTest('wasm memory specific test')
21102110

21112111
self.emcc_args += ['-sALLOW_MEMORY_GROWTH', '-sMEMORY_GROWTH_GEOMETRIC_STEP=8.5', '-sMEMORY_GROWTH_GEOMETRIC_CAP=32MB']
@@ -4030,8 +4030,6 @@ def test_dylink_no_export(self):
40304030

40314031
@needs_dylink
40324032
def test_dylink_memory_growth(self):
4033-
if not self.is_wasm():
4034-
self.skipTest('wasm only')
40354033
self.set_setting('ALLOW_MEMORY_GROWTH')
40364034
self.do_basic_dylink_test()
40374035

@@ -4884,7 +4882,7 @@ def test_dylink_hyper_dupe(self):
48844882
''',
48854883
expected=['sidef: 10, sideg: 20.\nbsidef: 536.\nonly_in_second_0: 10, 20, 1337\nonly_in_third_1: 36, 49, 500, 1221\nonly_in_third_0: 36, 49, 500\nonly_in_second_1: 10, 20, 1337, 2112\n'],
48864884
# in wasm, we can't flip as the side would have an EM_ASM, which we don't support yet TODO
4887-
need_reverse=not self.is_wasm())
4885+
need_reverse=self.is_wasm2js())
48884886

48894887
print('check warnings')
48904888
full = self.run_js('src.js')
@@ -4927,7 +4925,7 @@ def test_dylink_load_compiled_side_module(self):
49274925
''',
49284926
expected=['sidef: 10'],
49294927
# in wasm, we can't flip as the side would have an EM_ASM, which we don't support yet TODO
4930-
need_reverse=not self.is_wasm())
4928+
need_reverse=self.is_wasm2js())
49314929

49324930
@needs_dylink
49334931
def test_dylink_dso_needed(self):
@@ -5363,7 +5361,7 @@ def test_langinfo(self):
53635361

53645362
def test_files(self):
53655363
# Use closure here, to test we don't break FS stuff
5366-
if '-O3' in self.emcc_args and not self.is_wasm():
5364+
if '-O3' in self.emcc_args and self.is_wasm2js():
53675365
print('closure 2')
53685366
self.emcc_args += ['--closure', '2'] # Use closure 2 here for some additional coverage
53695367
# Sadly --closure=2 is not yet free of closure warnings
@@ -6204,7 +6202,7 @@ def test_iostream_and_determinism(self):
62046202
shutil.copy2('src.js', 'src.js.previous')
62056203

62066204
# Same but for the wasm file.
6207-
if self.is_wasm() and not self.get_setting('WASM2JS'):
6205+
if self.is_wasm():
62086206
if os.path.exists('src.wasm.previous'):
62096207
self.assertBinaryEqual('src.wasm', 'src.wasm.previous')
62106208
shutil.copy2('src.wasm', 'src.wasm.previous')
@@ -7730,7 +7728,7 @@ def test_source_map(self, args):
77307728
self.emcc(os.path.abspath('src.cpp'),
77317729
self.get_emcc_args(),
77327730
out_filename)
7733-
map_referent = out_filename if not self.is_wasm() else wasm_filename
7731+
map_referent = out_filename if self.is_wasm2js() else wasm_filename
77347732
# after removing the @line and @sourceMappingURL comments, the build
77357733
# result should be identical to the non-source-mapped debug version.
77367734
# this is worth checking because the parser AST swaps strings for token
@@ -7908,7 +7906,7 @@ def test_modularize_closure_pre(self):
79087906
# test that the combination of modularize + closure + pre-js works. in that mode,
79097907
# closure should not minify the Module object in a way that the pre-js cannot use it.
79107908
create_file('post.js', 'var TheModule = Module();\n')
7911-
if not self.is_wasm():
7909+
if self.is_wasm2js():
79127910
# TODO(sbc): Fix closure warnings with MODULARIZE + WASM=0
79137911
self.ldflags.append('-Wno-error=closure')
79147912

@@ -8396,7 +8394,7 @@ def verify_broken(args):
83968394
@no_sanitize('no wasm2js support yet in sanitizers')
83978395
@requires_wasm2js
83988396
def test_wasm2js(self):
8399-
if not self.is_wasm():
8397+
if self.is_wasm2js():
84008398
self.skipTest('redundant to test wasm2js in wasm2js* mode')
84018399
self.set_setting('WASM', 0)
84028400
self.do_core_test('test_hello_world.c')
@@ -8412,7 +8410,7 @@ def test_wasm2js(self):
84128410
@no_sanitize('no wasm2js support yet in sanitizers')
84138411
@requires_wasm2js
84148412
def test_maybe_wasm2js(self):
8415-
if not self.is_wasm():
8413+
if self.is_wasm2js():
84168414
self.skipTest('redundant to test wasm2js in wasm2js* mode')
84178415
self.set_setting('MAYBE_WASM2JS')
84188416
# see that running as wasm works
@@ -8434,7 +8432,7 @@ def test_maybe_wasm2js(self):
84348432
'minimal_runtime': (['-sMINIMAL_RUNTIME'],),
84358433
})
84368434
def test_wasm2js_fallback(self, args):
8437-
if not self.is_wasm():
8435+
if self.is_wasm2js():
84388436
self.skipTest('redundant to test wasm2js in wasm2js* mode')
84398437

84408438
cmd = [EMCC, test_file('small_hello_world.c'), '-sWASM=2'] + args
@@ -8736,7 +8734,7 @@ def test_return_address(self):
87368734
@no_lsan('-fsanitize-minimal-runtime cannot be used with LSan')
87378735
def test_ubsan_minimal_too_many_errors(self):
87388736
self.emcc_args += ['-fsanitize=undefined', '-fsanitize-minimal-runtime']
8739-
if not self.is_wasm():
8737+
if self.is_wasm2js():
87408738
if self.is_optimizing():
87418739
self.skipTest('test can only be run without optimizations on asm.js')
87428740
# Need to use `-g` to get proper line numbers in asm.js
@@ -8750,10 +8748,10 @@ def test_ubsan_minimal_too_many_errors(self):
87508748
@no_lsan('-fsanitize-minimal-runtime cannot be used with LSan')
87518749
def test_ubsan_minimal_errors_same_place(self):
87528750
self.emcc_args += ['-fsanitize=undefined', '-fsanitize-minimal-runtime']
8753-
if not self.is_wasm():
8751+
if self.is_wasm2js():
87548752
if self.is_optimizing():
8755-
self.skipTest('test can only be run without optimizations on asm.js')
8756-
# Need to use `-g` to get proper line numbers in asm.js
8753+
self.skipTest('test can only be run without optimizations under wasm2js')
8754+
# Need to use `-g` to get proper line numbers in wasm2js
87578755
self.emcc_args += ['-g']
87588756
self.do_runf('core/test_ubsan_minimal_errors_same_place.c',
87598757
expected_output='ubsan: add-overflow by 0x[0-9a-z]*\n' * 5,
@@ -8851,7 +8849,7 @@ def test_ubsan_full_static_cast(self, args):
88518849
@no_wasm2js('TODO: sanitizers in wasm2js')
88528850
def test_ubsan_full_stack_trace(self, g_flag, expected_output):
88538851
if g_flag == '-gsource-map':
8854-
if not self.is_wasm():
8852+
if self.is_wasm2js():
88558853
self.skipTest('wasm2js has no source map support')
88568854
elif self.get_setting('EVAL_CTORS'):
88578855
self.skipTest('EVAL_CTORS does not support source maps')
@@ -8963,7 +8961,7 @@ def test_asan(self, name, expected_output, cflags=None):
89638961
if '-Oz' in self.emcc_args:
89648962
self.skipTest('-Oz breaks source maps')
89658963

8966-
if not self.is_wasm():
8964+
if self.is_wasm2js():
89678965
self.skipTest('wasm2js has no ASan support')
89688966

89698967
self.emcc_args.append('-fsanitize=address')

test/test_other.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9655,7 +9655,7 @@ def test_EM_ASM_ES6(self, args):
96559655
self.do_runf('src.c', 'hello!', emcc_args=args)
96569656

96579657
def test_check_sourcemapurl(self):
9658-
if not self.is_wasm():
9658+
if self.is_wasm2js():
96599659
self.skipTest('only supported with wasm')
96609660
self.run_process([EMCC, test_file('hello_123.c'), '-gsource-map', '-o', 'a.js', '--source-map-base', 'dir/'])
96619661
output = read_binary('a.wasm')
@@ -9681,7 +9681,7 @@ def test_check_source_map_args(self):
96819681
'profiling': ['--profiling'] # -gsource-map --profiling should still emit a source map; see #8584
96829682
})
96839683
def test_check_sourcemapurl_default(self, *args):
9684-
if not self.is_wasm():
9684+
if self.is_wasm2js():
96859685
self.skipTest('only supported with wasm')
96869686

96879687
self.run_process([EMCC, test_file('hello_123.c'), '-gsource-map', '-o', 'a.js'] + list(args))

0 commit comments

Comments
 (0)