Skip to content

Commit 1ba1441

Browse files
authored
Add omitexports0 test suite (#25124)
Add omitexports0 test suite to test -sDECLARE_ASM_MODULE_EXPORTS=0 option, and fix the test suite to pass in that mode.
1 parent aeff42d commit 1ba1441

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

src/lib/libcore.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,11 @@ addToLibrary({
16151615
#if !DECLARE_ASM_MODULE_EXPORTS
16161616
// When DECLARE_ASM_MODULE_EXPORTS is not set we export native symbols
16171617
// at runtime rather than statically in JS code.
1618-
$exportWasmSymbols__deps: ['$asmjsMangle'],
1618+
$exportWasmSymbols__deps: ['$asmjsMangle'
1619+
#if DYNCALLS || !WASM_BIGINT
1620+
, '$dynCalls'
1621+
#endif
1622+
],
16191623
$exportWasmSymbols: (wasmExports) => {
16201624
#if ENVIRONMENT_MAY_BE_NODE && ENVIRONMENT_MAY_BE_WEB
16211625
var global_object = (typeof process != "undefined" ? global : this);
@@ -1627,6 +1631,11 @@ addToLibrary({
16271631

16281632
for (var __exportedFunc in wasmExports) {
16291633
var jsname = asmjsMangle(__exportedFunc);
1634+
#if DYNCALLS || !WASM_BIGINT
1635+
if (jsname.startsWith('dynCall_')) {
1636+
dynCalls[jsname.substr(8)] = wasmExports[__exportedFunc];
1637+
}
1638+
#endif
16301639
#if MINIMAL_RUNTIME
16311640
global_object[jsname] = wasmExports[__exportedFunc];
16321641
#else

test/common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,8 @@ def also_with_modularize(f):
765765
@wraps(f)
766766
def metafunc(self, modularize, *args, **kwargs):
767767
if modularize:
768+
if self.get_setting('DECLARE_ASM_MODULE_EXPORTS') == 0:
769+
self.skipTest('DECLARE_ASM_MODULE_EXPORTS=0 is not compatible with MODULARIZE')
768770
if self.get_setting('STRICT_JS'):
769771
self.skipTest('MODULARIZE is not compatible with STRICT_JS')
770772
if self.get_setting('WASM_ESM_INTEGRATION'):

test/test_core.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,14 @@ def decorator(f):
356356

357357
@wraps(f)
358358
def decorated(self, *args, **kwargs):
359-
if (name + '=1') in self.cflags or self.get_setting(name):
359+
if '=' in name:
360+
key, val = name.split('=', 1)
361+
else:
362+
key = name
363+
val = 1
364+
if int(val) == 1 and f'-s{key}' in self.cflags:
365+
self.skipTest(note)
366+
if f'-s{key}={val}' in self.cflags or self.get_setting(key) == int(val):
360367
self.skipTest(note)
361368
f(self, *args, **kwargs)
362369
return decorated
@@ -382,6 +389,7 @@ def decorated(self, textdecoder, *args, **kwargs):
382389
no_strict = make_no_decorator_for_setting('STRICT')
383390
no_strict_js = make_no_decorator_for_setting('STRICT_JS')
384391
no_big_endian = make_no_decorator_for_setting('SUPPORT_BIG_ENDIAN')
392+
no_omit_asm_module_exports = make_no_decorator_for_setting('DECLARE_ASM_MODULE_EXPORTS=0')
385393

386394

387395
def is_sanitizing(args):
@@ -6355,6 +6363,7 @@ def test_jslib(self):
63556363
@crossplatform
63566364
@no_modularize_instance('uses MODULARIZE')
63576365
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
6366+
@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
63586367
def test_unicode_js_library(self):
63596368
# First verify that we have correct overridden the default python file encoding.
63606369
# The follow program should fail, assuming the above LC_CTYPE + PYTHONUTF8
@@ -7315,7 +7324,6 @@ def test_large_exported_response(self):
73157324

73167325
self.set_setting('EXPORTED_FUNCTIONS', '@large_exported_response.json')
73177326
self.do_run(src, 'waka 4999!')
7318-
self.assertContained('_exported_func_from_response_file_1', read_file('src.js'))
73197327

73207328
def test_emulate_function_pointer_casts(self):
73217329
# Forcibly disable EXIT_RUNTIME due to:
@@ -8064,6 +8072,7 @@ def get_wat_addr(call_index):
80648072
self.assertLessEqual(start_wat_addr, dwarf_addr)
80658073
self.assertLessEqual(dwarf_addr, end_wat_addr)
80668074

8075+
@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
80678076
@no_modularize_instance('uses -sMODULARIZE')
80688077
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
80698078
def test_modularize_closure_pre(self):
@@ -8631,7 +8640,7 @@ def test_memprof_requirements(self):
86318640
if (typeof _emscripten_stack_get_base === 'function' &&
86328641
typeof _emscripten_stack_get_end === 'function' &&
86338642
typeof _emscripten_stack_get_current === 'function' &&
8634-
typeof Module['___heap_base'] === 'number') {
8643+
Module['___heap_base'] > 0) {
86358644
out('able to run memprof');
86368645
return 0;
86378646
} else {
@@ -9121,6 +9130,7 @@ def test_asan_api(self):
91219130

91229131
@asan
91239132
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
9133+
@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
91249134
def test_asan_modularized_with_closure(self):
91259135
# the bug is that createModule() returns undefined, instead of the
91269136
# proper Promise object.
@@ -9780,6 +9790,7 @@ def test_esm_integration(self):
97809790
self.assertContained('hello, world! (3)', self.run_js('runner.mjs'))
97819791
self.assertFileContents(test_file('core/test_esm_integration.expected.mjs'), read_file('hello_world.mjs'))
97829792

9793+
@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
97839794
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
97849795
def test_modularize_instance_hello(self):
97859796
self.do_core_test('test_hello_world.c', cflags=['-sMODULARIZE=instance', '-Wno-experimental'])
@@ -9788,6 +9799,7 @@ def test_modularize_instance_hello(self):
97889799
'': ([],),
97899800
'pthreads': (['-pthread'],),
97909801
})
9802+
@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
97919803
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
97929804
def test_modularize_instance(self, args):
97939805
if args:
@@ -9822,6 +9834,7 @@ def test_modularize_instance(self, args):
98229834

98239835
self.assertContained('main1\nmain2\nfoo\nbar\nbaz\n', self.run_js('runner.mjs'))
98249836

9837+
@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
98259838
@no_4gb('EMBIND_AOT can\'t lower 4gb')
98269839
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
98279840
def test_modularize_instance_embind(self):
@@ -10037,5 +10050,7 @@ def setUp(self):
1003710050
# runs all unit tests via qemu on the s390x big endian version of Node.js.
1003810051
bigendian0 = make_run('bigendian0', cflags=['-O0', '-Wno-experimental'], settings={'SUPPORT_BIG_ENDIAN': 1})
1003910052

10053+
omitexports0 = make_run('omitexports0', cflags=['-O0'], settings={'DECLARE_ASM_MODULE_EXPORTS': 0})
10054+
1004010055
# TestCoreBase is just a shape for the specific subclasses, we don't test it itself
1004110056
del TestCoreBase # noqa

0 commit comments

Comments
 (0)