@@ -6371,7 +6371,13 @@ def test_RUNTIME_LINKED_LIBS(self):
6371
6371
6372
6372
self.assertBinaryEqual('main.wasm', 'main2.wasm')
6373
6373
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()
6375
6381
create_file('hello1.c', r'''
6376
6382
#include <stdio.h>
6377
6383
@@ -6456,17 +6462,17 @@ def test_ld_library_path(self):
6456
6462
return 0;
6457
6463
}
6458
6464
''')
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 )
6463
6469
self.run_process([EMCC, '--profiling-funcs', '-o', 'main.js', 'main.c', '-sMAIN_MODULE=2', '-sINITIAL_MEMORY=32Mb',
6464
6470
'--embed-file', 'hello1.wasm@/lib/libhello1.wasm',
6465
6471
'--embed-file', 'hello2.wasm@/usr/lib/libhello2.wasm',
6466
6472
'--embed-file', 'hello3.wasm@/libhello3.wasm',
6467
6473
'--embed-file', 'hello4.wasm@/usr/local/lib/libhello4.wasm',
6468
6474
'hello1.wasm', 'hello2.wasm', 'hello3.wasm', 'hello4.wasm', '-sNO_AUTOLOAD_DYLIBS',
6469
- '--pre-js', 'pre.js'])
6475
+ '--pre-js', 'pre.js'] + args )
6470
6476
out = self.run_js('main.js')
6471
6477
self.assertContained('Hello1', out)
6472
6478
self.assertContained('Hello2', out)
@@ -13404,7 +13410,13 @@ def test_windows_batch_file_dp0_expansion_bug(self):
13404
13410
create_file('build_with_quotes.bat', f'@"emcc" {test_file("hello_world.c")}')
13405
13411
self.run_process(['build_with_quotes.bat'])
13406
13412
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()
13408
13420
# TODO(sbc): This test is copyied from test_browser.py. Perhaps find a better way to
13409
13421
# share code between them.
13410
13422
create_file('library.c', r'''
@@ -13413,17 +13425,20 @@ def test_preload_module(self):
13413
13425
return 42;
13414
13426
}
13415
13427
''')
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 )
13417
13429
create_file('main.c', r'''
13418
13430
#include <assert.h>
13419
13431
#include <dlfcn.h>
13420
13432
#include <stdio.h>
13421
13433
#include <emscripten.h>
13434
+ #include <emscripten/threading.h>
13422
13435
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
+ }
13427
13442
void *lib_handle = dlopen("/library.so", RTLD_NOW);
13428
13443
assert(lib_handle);
13429
13444
typedef int (*voidfunc)();
@@ -13434,4 +13449,4 @@ def test_preload_module(self):
13434
13449
return 0;
13435
13450
}
13436
13451
''')
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