@@ -2394,8 +2394,13 @@ def test_pre_run_deps(self):
2394
2394
2395
2395
self .btest ('test_pre_run_deps.c' , expected = '10' , emcc_args = ['--pre-js' , 'pre.js' ])
2396
2396
2397
+
2397
2398
@also_with_wasm2js
2398
- def test_runtime_misuse (self ):
2399
+ @parameterized ({
2400
+ '' : ([], '600' ),
2401
+ 'no_main' : (['-DNO_MAIN' , '--pre-js' , 'pre_runtime.js' ], '601' ), # 601, because no main means we *do* run another call after exit()
2402
+ })
2403
+ def test_runtime_misuse (self , extra_args , second_code ):
2399
2404
self .set_setting ('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE' , '$ccall,$cwrap' )
2400
2405
post_prep = '''
2401
2406
var expected_ok = false;
@@ -2453,36 +2458,31 @@ def test_runtime_misuse(self):
2453
2458
setTimeout(async () => {
2454
2459
out('done timeout noted = ' + Module.noted);
2455
2460
assert(Module.noted);
2456
- await fetch('http://localhost:%s /report_result?' + HEAP32[Module.noted/4]);
2461
+ await fetch('http://localhost:8888 /report_result?' + HEAP32[Module.noted/4]);
2457
2462
window.close();
2458
2463
}, 0);
2459
2464
// called from main, this is an ok time
2460
2465
doCcall(100);
2461
2466
doCwrapCall(200);
2462
2467
doDirectCall(300);
2463
2468
}
2464
- ''' % self . PORT
2469
+ '''
2465
2470
2466
2471
create_file ('pre_runtime.js' , r'''
2467
2472
Module.onRuntimeInitialized = myJSCallback;
2468
2473
''' )
2469
2474
2470
- for filename , extra_args , second_code in [
2471
- ('test_runtime_misuse.c' , [], 600 ),
2472
- ('test_runtime_misuse_2.c' , ['--pre-js' , 'pre_runtime.js' ], 601 ), # 601, because no main means we *do* run another call after exit()
2473
- ]:
2474
- print ('\n ' , filename , extra_args )
2475
-
2476
- print ('mem init, so async, call too early' )
2477
- create_file ('post.js' , post_prep + post_test + post_hook )
2478
- self .btest (filename , expected = '600' , emcc_args = ['--post-js' , 'post.js' , '-sEXIT_RUNTIME' ] + extra_args , reporting = Reporting .NONE )
2479
- print ('sync startup, call too late' )
2480
- create_file ('post.js' , post_prep + 'Module.postRun = () => { ' + post_test + ' };' + post_hook )
2481
- self .btest (filename , expected = str (second_code ), emcc_args = ['--post-js' , 'post.js' , '-sEXIT_RUNTIME' ] + extra_args , reporting = Reporting .NONE )
2482
-
2483
- print ('sync, runtime still alive, so all good' )
2484
- create_file ('post.js' , post_prep + 'expected_ok = true; Module.postRun = () => { ' + post_test + ' };' + post_hook )
2485
- self .btest (filename , expected = '606' , emcc_args = ['--post-js' , 'post.js' ] + extra_args , reporting = Reporting .NONE )
2475
+ print ('mem init, so async, call too early' )
2476
+ create_file ('post.js' , post_prep + post_test + post_hook )
2477
+ self .btest ('test_runtime_misuse.c' , expected = '600' , emcc_args = ['--post-js' , 'post.js' , '-sEXIT_RUNTIME' ] + extra_args , reporting = Reporting .NONE )
2478
+
2479
+ print ('sync startup, call too late' )
2480
+ create_file ('post.js' , post_prep + 'Module.postRun = () => { ' + post_test + ' };' + post_hook )
2481
+ self .btest ('test_runtime_misuse.c' , expected = second_code , emcc_args = ['--post-js' , 'post.js' , '-sEXIT_RUNTIME' ] + extra_args , reporting = Reporting .NONE )
2482
+
2483
+ print ('sync, runtime still alive, so all good' )
2484
+ create_file ('post.js' , post_prep + 'expected_ok = true; Module.postRun = () => { ' + post_test + ' };' + post_hook )
2485
+ self .btest ('test_runtime_misuse.c' , expected = '606' , emcc_args = ['--post-js' , 'post.js' ] + extra_args , reporting = Reporting .NONE )
2486
2486
2487
2487
def test_cwrap_early (self ):
2488
2488
self .btest ('browser/test_cwrap_early.c' , emcc_args = ['-O2' , '-sASSERTIONS' , '--pre-js' , test_file ('browser/test_cwrap_early.js' ), '-sEXPORTED_RUNTIME_METHODS=cwrap' ], expected = '0' )
0 commit comments