@@ -200,7 +200,22 @@ def decorated(self, threads, *args, **kwargs):
200200 f (self , * args , ** kwargs )
201201
202202 parameterize (decorated , {'' : (False ,),
203- 'pthreads' : (True ,)})
203+ 'pthread' : (True ,)})
204+
205+ return decorated
206+
207+
208+ def also_with_proxy_to_pthread (f ):
209+ assert callable (f )
210+
211+ @wraps (f )
212+ def decorated (self , threads , * args , ** kwargs ):
213+ if threads :
214+ self .emcc_args += ['-pthread' , '-sPROXY_TO_PTHREAD' ]
215+ f (self , * args , ** kwargs )
216+
217+ parameterize (decorated , {'' : (False ,),
218+ 'pthread' : (True ,)})
204219
205220 return decorated
206221
@@ -496,14 +511,11 @@ def make_main_two_files(path1, path2, nonexistingpath):
496511 self .btest_exit ('main.c' , args = ['--pre-js' , 'pre.js' , '--use-preload-plugins' ])
497512
498513 # Tests that user .html shell files can manually download .data files created with --preload-file cmdline.
499- @parameterized ({
500- '' : ([],),
501- 'pthreads' : (['-pthread' , '-sPROXY_TO_PTHREAD' , '-sEXIT_RUNTIME' ],),
502- })
503- def test_preload_file_with_manual_data_download (self , args ):
514+ @also_with_proxy_to_pthread
515+ def test_preload_file_with_manual_data_download (self ):
504516 create_file ('file.txt' , 'Hello!' )
505517
506- self .compile_btest ('browser/test_manual_download_data.c' , ['-sEXIT_RUNTIME' , '-o' , 'out.js' , '--preload-file' , 'file.txt@/file.txt' ] + args )
518+ self .compile_btest ('browser/test_manual_download_data.c' , ['-sEXIT_RUNTIME' , '-o' , 'out.js' , '--preload-file' , 'file.txt@/file.txt' ])
507519 shutil .copy (test_file ('browser/test_manual_download_data.html' ), '.' )
508520
509521 # Move .data file out of server root to ensure that getPreloadedPackage is actually used
@@ -1603,12 +1615,9 @@ def test_glfw_time(self):
16031615 def test_egl (self , args ):
16041616 self .btest_exit ('test_egl.c' , args = ['-O2' , '-lEGL' , '-lGL' , '-sGL_ENABLE_GET_PROC_ADDRESS' ] + args )
16051617
1606- @parameterized ({
1607- '' : ([],),
1608- 'proxy_to_pthread' : (['-pthread' , '-sPROXY_TO_PTHREAD' ],),
1609- })
1610- def test_egl_width_height (self , args ):
1611- self .btest_exit ('test_egl_width_height.c' , args = ['-O2' , '-lEGL' , '-lGL' ] + args )
1618+ @also_with_proxy_to_pthread
1619+ def test_egl_width_height (self ):
1620+ self .btest_exit ('test_egl_width_height.c' , args = ['-O2' , '-lEGL' , '-lGL' ])
16121621
16131622 @requires_graphics_hardware
16141623 def test_egl_createcontext_error (self ):
@@ -1901,27 +1910,17 @@ def test_emscripten_fs_api2(self):
19011910 self .btest_exit ('emscripten_fs_api_browser2.c' , args = ['-sASSERTIONS=0' ])
19021911 self .btest_exit ('emscripten_fs_api_browser2.c' , args = ['-sASSERTIONS=1' ])
19031912
1904- @parameterized ({
1905- '' : ([],),
1906- 'pthreads' : (['-pthread' , '-sPROXY_TO_PTHREAD' , '-sEXIT_RUNTIME' ],),
1907- })
1908- def test_emscripten_main_loop (self , args ):
1909- self .btest_exit ('test_emscripten_main_loop.c' , args = args )
1913+ @also_with_proxy_to_pthread
1914+ def test_emscripten_main_loop (self ):
1915+ self .btest_exit ('test_emscripten_main_loop.c' )
19101916
1911- @parameterized ({
1912- '' : ([],),
1913- # test pthreads + AUTO_JS_LIBRARIES mode as well
1914- 'pthreads' : (['-pthread' , '-sPROXY_TO_PTHREAD' , '-sAUTO_JS_LIBRARIES=0' ],),
1915- })
1916- def test_emscripten_main_loop_settimeout (self , args ):
1917- self .btest_exit ('test_emscripten_main_loop_settimeout.c' , args = args )
1917+ @also_with_proxy_to_pthread
1918+ def test_emscripten_main_loop_settimeout (self ):
1919+ self .btest_exit ('test_emscripten_main_loop_settimeout.c' , args = ['-sAUTO_JS_LIBRARIES=0' ])
19181920
1919- @parameterized ({
1920- '' : ([],),
1921- 'pthreads' : (['-pthread' , '-sPROXY_TO_PTHREAD' ],),
1922- })
1923- def test_emscripten_main_loop_and_blocker (self , args ):
1924- self .btest_exit ('test_emscripten_main_loop_and_blocker.c' , args = args )
1921+ @also_with_proxy_to_pthread
1922+ def test_emscripten_main_loop_and_blocker (self ):
1923+ self .btest_exit ('test_emscripten_main_loop_and_blocker.c' )
19251924
19261925 def test_emscripten_main_loop_and_blocker_exit (self ):
19271926 # Same as above but tests that EXIT_RUNTIME works with emscripten_main_loop. The
@@ -1977,13 +1976,10 @@ def test_sdl_glshader2(self):
19771976 def test_gl_glteximage (self ):
19781977 self .btest ('gl_teximage.c' , '1' , args = ['-lGL' , '-lSDL' ])
19791978
1980- @parameterized ({
1981- '' : ([],),
1982- 'pthreads' : (['-pthread' , '-sPROXY_TO_PTHREAD' , '-sOFFSCREEN_FRAMEBUFFER' ],),
1983- })
19841979 @requires_graphics_hardware
1985- def test_gl_textures (self , args ):
1986- self .btest_exit ('gl_textures.c' , args = ['-lGL' , '-g' , '-sSTACK_SIZE=1MB' ] + args )
1980+ @also_with_proxy_to_pthread
1981+ def test_gl_textures (self ):
1982+ self .btest_exit ('gl_textures.c' , args = ['-lGL' , '-g' , '-sSTACK_SIZE=1MB' , '-sOFFSCREEN_FRAMEBUFFER' ])
19871983
19881984 @requires_graphics_hardware
19891985 def test_gl_ps (self ):
@@ -2618,10 +2614,10 @@ def test_html5_core(self, opts):
26182614 self .emcc_args .append ('--pre-js=pre.js' )
26192615 self .btest_exit ('test_html5_core.c' , args = opts )
26202616
2617+ @also_with_proxy_to_pthread
26212618 @parameterized ({
26222619 '' : ([],),
26232620 'closure' : (['-O2' , '-g1' , '--closure=1' ],),
2624- 'pthread' : (['-pthread' , '-sPROXY_TO_PTHREAD' ],),
26252621 })
26262622 def test_html5_gamepad (self , args ):
26272623 self .btest_exit ('test_gamepad.c' , args = args )
@@ -4932,24 +4928,28 @@ def test_emscripten_request_animation_frame_loop(self):
49324928 def test_request_animation_frame (self ):
49334929 self .btest_exit ('test_request_animation_frame.c' )
49344930
4931+ @also_with_proxy_to_pthread
49354932 def test_emscripten_set_timeout (self ):
4936- self .btest_exit ('emscripten_set_timeout.c' , args = [ '-pthread' , '-sPROXY_TO_PTHREAD' ] )
4933+ self .btest_exit ('emscripten_set_timeout.c' )
49374934
4935+ @also_with_proxy_to_pthread
49384936 def test_emscripten_set_timeout_loop (self ):
4939- self .btest_exit ('emscripten_set_timeout_loop.c' , args = [ '-pthread' , '-sPROXY_TO_PTHREAD' ] )
4937+ self .btest_exit ('emscripten_set_timeout_loop.c' )
49404938
49414939 def test_emscripten_set_immediate (self ):
49424940 self .btest_exit ('emscripten_set_immediate.c' )
49434941
49444942 def test_emscripten_set_immediate_loop (self ):
49454943 self .btest_exit ('emscripten_set_immediate_loop.c' )
49464944
4945+ @also_with_proxy_to_pthread
49474946 def test_emscripten_set_interval (self ):
4948- self .btest_exit ('emscripten_set_interval.c' , args = [ '-pthread' , '-sPROXY_TO_PTHREAD' ] )
4947+ self .btest_exit ('emscripten_set_interval.c' )
49494948
49504949 # Test emscripten_performance_now() and emscripten_date_now()
4950+ @also_with_proxy_to_pthread
49514951 def test_emscripten_performance_now (self ):
4952- self .btest ('emscripten_performance_now.c' , '0' , args = [ '-pthread' , '-sPROXY_TO_PTHREAD' ] )
4952+ self .btest_exit ('emscripten_performance_now.c' )
49534953
49544954 def test_embind_with_pthreads (self ):
49554955 self .btest_exit ('embind/test_pthreads.cpp' , args = ['-lembind' , '-pthread' , '-sPTHREAD_POOL_SIZE=2' ])
@@ -5021,12 +5021,9 @@ def test_minimal_runtime_loader_shell(self, args):
50215021 def test_minimal_runtime_hello_world (self , args ):
50225022 self .btest_exit ('small_hello_world.c' , args = args + ['-sMINIMAL_RUNTIME' ])
50235023
5024- @parameterized ({
5025- '' : ([],),
5026- 'pthread' : (['-sPROXY_TO_PTHREAD' , '-pthread' ],)
5027- })
5028- def test_offset_converter (self , args ):
5029- self .btest_exit ('test_offset_converter.c' , args = ['-sUSE_OFFSET_CONVERTER' , '-gsource-map' ] + args )
5024+ @also_with_proxy_to_pthread
5025+ def test_offset_converter (self ):
5026+ self .btest_exit ('test_offset_converter.c' , args = ['-sUSE_OFFSET_CONVERTER' , '-gsource-map' ])
50305027
50315028 # Tests emscripten_unwind_to_js_event_loop() behavior
50325029 def test_emscripten_unwind_to_js_event_loop (self ):
0 commit comments