@@ -5445,88 +5445,6 @@ def test_webpack(self, es6):
54455445 shutil .copy ('webpack/src/hello.wasm' , 'webpack/dist/' )
54465446 self .run_browser ('webpack/dist/index.html' , '/report_result?exit:0' )
54475447
5448- def test_fetch_polyfill_preload (self ):
5449- create_file ('hello.txt' , 'hello, world!' )
5450- create_file ('main.c' , r'''
5451- #include <stdio.h>
5452- #include <string.h>
5453- #include <emscripten.h>
5454- int main() {
5455- FILE *f = fopen("hello.txt", "r");
5456- char buf[100];
5457- fread(buf, 1, 20, f);
5458- buf[20] = 0;
5459- fclose(f);
5460- printf("%s\n", buf);
5461- return 0;
5462- }''' )
5463-
5464- create_file ('on_window_error_shell.html' , r'''
5465- <html>
5466- <center><canvas id='canvas' width='256' height='256'></canvas></center>
5467- <hr><div id='output'></div><hr>
5468- <script type='text/javascript'>
5469- window.addEventListener('error', event => {
5470- const error = String(event.message);
5471- window.disableErrorReporting = true;
5472- window.onerror = null;
5473- var xhr = new XMLHttpRequest();
5474- xhr.open('GET', 'http://localhost:8888/report_result?exception:' + error.substr(-23), true);
5475- xhr.send();
5476- setTimeout(function() { window.close() }, 1000);
5477- });
5478- </script>
5479- {{{ SCRIPT }}}
5480- </body>
5481- </html>''' )
5482-
5483- def test (args , expect_fail ):
5484- self .compile_btest ('main.c' , ['-sEXIT_RUNTIME' , '--preload-file' , 'hello.txt' , '--shell-file' , 'on_window_error_shell.html' , '-o' , 'a.out.html' ] + args )
5485- if expect_fail :
5486- js = read_file ('a.out.js' )
5487- create_file ('a.out.js' , 'let origFetch = fetch; fetch = undefined;\n ' + js )
5488- return self .run_browser ('a.out.html' , '/report_result?exception:fetch is not a function' )
5489- else :
5490- return self .run_browser ('a.out.html' , '/report_result?exit:0' )
5491-
5492- test ([], expect_fail = False )
5493- test ([], expect_fail = True )
5494- test (['-sLEGACY_VM_SUPPORT' ], expect_fail = False )
5495- test (['-sLEGACY_VM_SUPPORT' , '-sNO_POLYFILL' ], expect_fail = True )
5496-
5497- @no_wasm64 ('https://github.com/llvm/llvm-project/issues/98778' )
5498- def test_fetch_polyfill_shared_lib (self ):
5499- create_file ('library.c' , r'''
5500- int library_func() {
5501- return 42;
5502- }
5503- ''' )
5504- create_file ('main.c' , r'''
5505- #include <dlfcn.h>
5506- #include <stdio.h>
5507- int main() {
5508- void *lib_handle = dlopen("/library.so", RTLD_NOW);
5509- typedef int (*voidfunc)();
5510- voidfunc x = (voidfunc)dlsym(lib_handle, "library_func");
5511- return x();
5512- }
5513- ''' )
5514-
5515- self .emcc ('library.c' , ['-sSIDE_MODULE' , '-O2' , '-o' , 'library.so' ])
5516-
5517- def test (args , expect_fail ):
5518- self .compile_btest ('main.c' , ['-fPIC' , 'library.so' , '-sMAIN_MODULE=2' , '-sEXIT_RUNTIME' , '-o' , 'a.out.html' ] + args )
5519- if expect_fail :
5520- js = read_file ('a.out.js' )
5521- create_file ('a.out.js' , 'let origFetch = fetch; fetch = undefined;\n ' + js )
5522- return self .run_browser ('a.out.html' , '/report_result?abort:both async and sync fetching of the wasm failed' )
5523- else :
5524- return self .run_browser ('a.out.html' , '/report_result?exit:42' )
5525-
5526- test ([], expect_fail = True )
5527- test (['-sLEGACY_VM_SUPPORT' ], expect_fail = False )
5528- test (['-sLEGACY_VM_SUPPORT' , '-sNO_POLYFILL' ], expect_fail = True )
5529-
55305448
55315449class emrun (RunnerCore ):
55325450 def test_emrun_info (self ):
0 commit comments