@@ -6371,7 +6371,13 @@ def test_RUNTIME_LINKED_LIBS(self):
63716371
63726372 self.assertBinaryEqual('main.wasm', 'main2.wasm')
63736373
6374- def test_ld_library_path(self):
6374+ @parameterized({
6375+ '': ([],),
6376+ 'pthread': (['-g', '-pthread', '-Wno-experimental', '-sPROXY_TO_PTHREAD', '-sEXIT_RUNTIME'],),
6377+ })
6378+ def test_ld_library_path(self, args):
6379+ if args:
6380+ self.setup_node_pthreads()
63756381 create_file('hello1.c', r'''
63766382#include <stdio.h>
63776383
@@ -6456,17 +6462,17 @@ def test_ld_library_path(self):
64566462 return 0;
64576463}
64586464''')
6459- self.run_process([EMCC, '-o', 'hello1.wasm', 'hello1.c', '-sSIDE_MODULE'])
6460- self.run_process([EMCC, '-o', 'hello2.wasm', 'hello2.c', '-sSIDE_MODULE'])
6461- self.run_process([EMCC, '-o', 'hello3.wasm', 'hello3.c', '-sSIDE_MODULE'])
6462- self.run_process([EMCC, '-o', 'hello4.wasm', 'hello4.c', '-sSIDE_MODULE'])
6465+ self.run_process([EMCC, '-o', 'hello1.wasm', 'hello1.c', '-sSIDE_MODULE'] + args )
6466+ self.run_process([EMCC, '-o', 'hello2.wasm', 'hello2.c', '-sSIDE_MODULE'] + args )
6467+ self.run_process([EMCC, '-o', 'hello3.wasm', 'hello3.c', '-sSIDE_MODULE'] + args )
6468+ self.run_process([EMCC, '-o', 'hello4.wasm', 'hello4.c', '-sSIDE_MODULE'] + args )
64636469 self.run_process([EMCC, '--profiling-funcs', '-o', 'main.js', 'main.c', '-sMAIN_MODULE=2', '-sINITIAL_MEMORY=32Mb',
64646470 '--embed-file', 'hello1.wasm@/lib/libhello1.wasm',
64656471 '--embed-file', 'hello2.wasm@/usr/lib/libhello2.wasm',
64666472 '--embed-file', 'hello3.wasm@/libhello3.wasm',
64676473 '--embed-file', 'hello4.wasm@/usr/local/lib/libhello4.wasm',
64686474 'hello1.wasm', 'hello2.wasm', 'hello3.wasm', 'hello4.wasm', '-sNO_AUTOLOAD_DYLIBS',
6469- '--pre-js', 'pre.js'])
6475+ '--pre-js', 'pre.js'] + args )
64706476 out = self.run_js('main.js')
64716477 self.assertContained('Hello1', out)
64726478 self.assertContained('Hello2', out)
@@ -13404,7 +13410,13 @@ def test_windows_batch_file_dp0_expansion_bug(self):
1340413410 create_file('build_with_quotes.bat', f'@"emcc" {test_file("hello_world.c")}')
1340513411 self.run_process(['build_with_quotes.bat'])
1340613412
13407- def test_preload_module(self):
13413+ @parameterized({
13414+ '': ([],),
13415+ 'pthread': (['-g', '-pthread', '-Wno-experimental', '-sPROXY_TO_PTHREAD', '-sEXIT_RUNTIME'],),
13416+ })
13417+ def test_preload_module(self, args):
13418+ if args:
13419+ self.setup_node_pthreads()
1340813420 # TODO(sbc): This test is copyied from test_browser.py. Perhaps find a better way to
1340913421 # share code between them.
1341013422 create_file('library.c', r'''
@@ -13413,17 +13425,20 @@ def test_preload_module(self):
1341313425 return 42;
1341413426 }
1341513427 ''')
13416- self.run_process([EMCC, 'library.c', '-sSIDE_MODULE', '-o', 'library.so'])
13428+ self.run_process([EMCC, 'library.c', '-sSIDE_MODULE', '-o', 'library.so'] + args )
1341713429 create_file('main.c', r'''
1341813430 #include <assert.h>
1341913431 #include <dlfcn.h>
1342013432 #include <stdio.h>
1342113433 #include <emscripten.h>
13434+ #include <emscripten/threading.h>
1342213435 int main() {
13423- int found = EM_ASM_INT(
13424- return preloadedWasm['/library.so'] !== undefined;
13425- );
13426- assert(found);
13436+ if (emscripten_is_main_runtime_thread()) {
13437+ int found = EM_ASM_INT(
13438+ return preloadedWasm['/library.so'] !== undefined;
13439+ );
13440+ assert(found);
13441+ }
1342713442 void *lib_handle = dlopen("/library.so", RTLD_NOW);
1342813443 assert(lib_handle);
1342913444 typedef int (*voidfunc)();
@@ -13434,4 +13449,4 @@ def test_preload_module(self):
1343413449 return 0;
1343513450 }
1343613451 ''')
13437- self.do_runf('main.c', 'done\n', emcc_args=['-sMAIN_MODULE=2', '--preload-file', '.@/', '--use-preload-plugins'])
13452+ self.do_runf('main.c', 'done\n', emcc_args=['-sMAIN_MODULE=2', '--preload-file', '.@/', '--use-preload-plugins'] + args )
0 commit comments