@@ -3361,52 +3361,32 @@ def test_webidl(self, args):
3361
3361
self .btest ('webidl/test.cpp' , '1' , args = ['--post-js' , 'glue.js' , '-I.' , '-DBROWSER' ] + args )
3362
3362
3363
3363
@no_wasm64 ('https://github.com/llvm/llvm-project/issues/98778' )
3364
- def test_dynamic_link (self ):
3364
+ @parameterized ({
3365
+ '' : ([],),
3366
+ 'proxy_to_worker' : (['--proxy-to-worker' ],),
3367
+ })
3368
+ def test_dylink (self , args ):
3365
3369
create_file ('main.c' , r'''
3370
+ #include <assert.h>
3366
3371
#include <stdio.h>
3367
3372
#include <stdlib.h>
3368
3373
#include <string.h>
3369
- #include <emscripten.h>
3370
3374
char *side(const char *data);
3371
3375
int main() {
3372
- char *temp = side("hello through side\n");
3373
- char *ret = (char*)malloc(strlen(temp)+1);
3374
- strcpy(ret, temp);
3375
- temp[1] = 'x';
3376
- EM_ASM({
3377
- Module.realPrint = out;
3378
- out = (x) => {
3379
- if (!Module.printed) Module.printed = x;
3380
- Module.realPrint(x);
3381
- };
3382
- });
3376
+ char *ret = side("hello through side\n");
3383
3377
puts(ret);
3384
- EM_ASM({ assert(Module.printed === ' hello through side', ['expected', Module.printed]); } );
3378
+ assert(strcmp(ret, " hello through side\n") == 0 );
3385
3379
return 0;
3386
3380
}
3387
3381
''' )
3388
3382
create_file ('side.c' , r'''
3389
- #include <stdlib.h>
3390
3383
#include <string.h>
3391
- char *side(const char *data);
3392
3384
char *side(const char *data) {
3393
- char *ret = (char*)malloc(strlen(data)+1);
3394
- strcpy(ret, data);
3395
- return ret;
3385
+ return strdup(data);
3396
3386
}
3397
3387
''' )
3398
3388
self .emcc ('side.c' , ['-sSIDE_MODULE' , '-O2' , '-o' , 'side.wasm' ])
3399
- self .btest_exit (self .in_dir ('main.c' ), args = ['-sMAIN_MODULE=2' , '-O2' , 'side.wasm' ])
3400
-
3401
- print ('wasm in worker (we can read binary data synchronously there)' )
3402
-
3403
- self .emcc ('side.c' , ['-sSIDE_MODULE' , '-O2' , '-o' , 'side.wasm' ])
3404
- self .btest_exit (self .in_dir ('main.c' ), args = ['-sMAIN_MODULE=2' , '-O2' , '--proxy-to-worker' , 'side.wasm' ])
3405
-
3406
- print ('wasm (will auto-preload since no sync binary reading)' )
3407
-
3408
- # same wasm side module works
3409
- self .btest_exit (self .in_dir ('main.c' ), args = ['-sMAIN_MODULE=2' , '-O2' , '-sEXPORT_ALL' , 'side.wasm' ])
3389
+ self .btest_exit (self .in_dir ('main.c' ), args = ['-sMAIN_MODULE=2' , '-O2' , 'side.wasm' ] + args )
3410
3390
3411
3391
def test_dlopen_async (self ):
3412
3392
create_file ('side.c' , 'int foo = 42;\n ' )
@@ -3467,7 +3447,7 @@ def do_run(src, expected_output, emcc_args):
3467
3447
3468
3448
@requires_graphics_hardware
3469
3449
@no_wasm64 ('https://github.com/llvm/llvm-project/issues/98778' )
3470
- def test_dynamic_link_glemu (self ):
3450
+ def test_dylink_glemu (self ):
3471
3451
create_file ('main.c' , r'''
3472
3452
#include <stdio.h>
3473
3453
#include <string.h>
@@ -3493,7 +3473,7 @@ def test_dynamic_link_glemu(self):
3493
3473
3494
3474
self .btest_exit (self .in_dir ('main.c' ), args = ['-sMAIN_MODULE=2' , '-O2' , '-sLEGACY_GL_EMULATION' , '-lSDL' , '-lGL' , 'side.wasm' ])
3495
3475
3496
- def test_dynamic_link_many (self ):
3476
+ def test_dylink_many (self ):
3497
3477
# test asynchronously loading two side modules during startup
3498
3478
create_file ('main.c' , r'''
3499
3479
#include <assert.h>
@@ -3515,7 +3495,7 @@ def test_dynamic_link_many(self):
3515
3495
self .emcc ('side2.c' , ['-sSIDE_MODULE' , '-o' , 'side2.wasm' ])
3516
3496
self .btest_exit (self .in_dir ('main.c' ), args = ['-sMAIN_MODULE=2' , 'side1.wasm' , 'side2.wasm' ])
3517
3497
3518
- def test_dynamic_link_pthread_many (self ):
3498
+ def test_dylink_pthread_many (self ):
3519
3499
# Test asynchronously loading two side modules during startup
3520
3500
# They should always load in the same order
3521
3501
# Verify that function pointers in the browser's main thread
0 commit comments