Skip to content

Commit ccab97d

Browse files
authored
Add test of EM_JS + USE_PRTHREADS (#16574)
I realized we didn't have any testing of this configuration (at least not under node). See #16573
1 parent b8f9f45 commit ccab97d

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

.circleci/config.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,9 @@ jobs:
349349
EMCC_READ_METADATA: "compare"
350350
steps:
351351
- run-tests-linux:
352-
test_targets: "core0"
352+
# test_em_js_pthreads current triggers a bug in python metadata
353+
# extraction: https://github.com/emscripten-core/emscripten/issues/16573
354+
test_targets: "core0 skip:core0.test_em_js_pthreads"
353355
test-core2:
354356
executor: bionic
355357
environment:

tests/common.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,7 @@ def decorated(self, *args, **kwargs):
190190

191191
def node_pthreads(f):
192192
def decorated(self, *args, **kwargs):
193-
self.set_setting('USE_PTHREADS')
194-
self.emcc_args += ['-Wno-pthreads-mem-growth']
195-
if self.get_setting('MINIMAL_RUNTIME'):
196-
self.skipTest('node pthreads not yet supported with MINIMAL_RUNTIME')
197-
self.js_engines = [config.NODE_JS]
198-
self.node_args += ['--experimental-wasm-threads', '--experimental-wasm-bulk-memory']
193+
self.setup_node_pthreads()
199194
f(self, *args, **kwargs)
200195
return decorated
201196

@@ -397,6 +392,15 @@ def require_node(self):
397392
self.fail('node required to run this test. Use EMTEST_SKIP_NODE to skip')
398393
self.js_engines = [config.NODE_JS]
399394

395+
def setup_node_pthreads(self):
396+
self.require_node()
397+
self.set_setting('USE_PTHREADS')
398+
self.emcc_args += ['-Wno-pthreads-mem-growth']
399+
if self.get_setting('MINIMAL_RUNTIME'):
400+
self.skipTest('node pthreads not yet supported with MINIMAL_RUNTIME')
401+
self.js_engines = [config.NODE_JS]
402+
self.node_args += ['--experimental-wasm-threads', '--experimental-wasm-bulk-memory']
403+
400404
def uses_memory_init_file(self):
401405
if self.get_setting('SIDE_MODULE') or (self.is_wasm() and not self.get_setting('WASM2JS')):
402406
return False

tests/test_core.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -2114,16 +2114,19 @@ def test_em_asm_direct(self):
21142114

21152115
@parameterized({
21162116
'': ([], False),
2117+
'pthreads': (['-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '-sEXIT_RUNTIME'], False),
21172118
'c': ([], True),
21182119
'linked': (['-sMAIN_MODULE'], False),
21192120
'linked_c': (['-sMAIN_MODULE'], True),
21202121
})
21212122
def test_em_js(self, args, force_c):
21222123
if '-sMAIN_MODULE' in args:
21232124
self.check_dylink()
2124-
self.emcc_args += args
2125-
if '-sMAIN_MODULE' not in args:
2125+
else:
21262126
self.emcc_args += ['-sEXPORTED_FUNCTIONS=_main,_malloc']
2127+
self.emcc_args += args
2128+
if '-sUSE_PTHREADS' in args:
2129+
self.setup_node_pthreads()
21272130

21282131
self.do_core_test('test_em_js.cpp', force_c=force_c)
21292132
self.assertContained("no args returning int", read_file('test_em_js.js'))

0 commit comments

Comments
 (0)