@@ -200,6 +200,21 @@ def decorated(self, threads, *args, **kwargs):
200200 return decorated
201201
202202
203+ def also_with_proxy_to_pthread (f ):
204+ assert callable (f )
205+
206+ @wraps (f )
207+ def decorated (self , threads , * args , ** kwargs ):
208+ if threads :
209+ self .cflags += ['-pthread' , '-sPROXY_TO_PTHREAD' ]
210+ f (self , * args , ** kwargs )
211+
212+ parameterize (decorated , {'' : (False ,),
213+ 'proxy_to_pthread' : (True ,)})
214+
215+ return decorated
216+
217+
203218def skipIfFeatureNotAvailable (skip_env_var , feature , message ):
204219 for env_var in skip_env_var if type (skip_env_var ) == list else [skip_env_var ]:
205220 should_skip = browser_should_skip_feature (env_var , feature )
@@ -471,14 +486,11 @@ def make_main_two_files(path1, path2, nonexistingpath):
471486 self .btest_exit ('main.c' , cflags = ['--pre-js' , 'pre.js' , '--use-preload-plugins' ])
472487
473488 # Tests that user .html shell files can manually download .data files created with --preload-file cmdline.
474- @parameterized ({
475- '' : ([],),
476- 'pthreads' : (['-pthread' , '-sPROXY_TO_PTHREAD' , '-sEXIT_RUNTIME' ],),
477- })
478- def test_preload_file_with_manual_data_download (self , args ):
489+ @also_with_proxy_to_pthread
490+ def test_preload_file_with_manual_data_download (self ):
479491 create_file ('file.txt' , 'Hello!' )
480492
481- self .compile_btest ('browser/test_manual_download_data.c' , ['-sEXIT_RUNTIME' , '-o' , 'out.js' , '--preload-file' , 'file.txt@/file.txt' ] + args )
493+ self .compile_btest ('browser/test_manual_download_data.c' , ['-sEXIT_RUNTIME' , '-o' , 'out.js' , '--preload-file' , 'file.txt@/file.txt' ])
482494 shutil .copy (test_file ('browser/test_manual_download_data.html' ), '.' )
483495
484496 # Move .data file out of server root to ensure that getPreloadedPackage is actually used
@@ -1536,12 +1548,9 @@ def test_glfw_time(self):
15361548 def test_egl (self , args ):
15371549 self .btest_exit ('test_egl.c' , cflags = ['-O2' , '-lEGL' , '-lGL' , '-sGL_ENABLE_GET_PROC_ADDRESS' ] + args )
15381550
1539- @parameterized ({
1540- '' : ([],),
1541- 'proxy_to_pthread' : (['-pthread' , '-sPROXY_TO_PTHREAD' ],),
1542- })
1543- def test_egl_width_height (self , args ):
1544- self .btest_exit ('test_egl_width_height.c' , cflags = ['-O2' , '-lEGL' , '-lGL' ] + args )
1551+ @also_with_proxy_to_pthread
1552+ def test_egl_width_height (self ):
1553+ self .btest_exit ('test_egl_width_height.c' , cflags = ['-O2' , '-lEGL' , '-lGL' ])
15451554
15461555 @requires_graphics_hardware
15471556 def test_egl_createcontext_error (self ):
@@ -1821,12 +1830,9 @@ def setup():
18211830 def test_emscripten_api_infloop (self ):
18221831 self .btest_exit ('emscripten_api_browser_infloop.cpp' )
18231832
1824- @parameterized ({
1825- '' : ([],),
1826- 'pthreads' : (['-pthread' , '-sPROXY_TO_PTHREAD' , '-sEXIT_RUNTIME' ],),
1827- })
1828- def test_emscripten_main_loop (self , args ):
1829- self .btest_exit ('test_emscripten_main_loop.c' , cflags = args )
1833+ @also_with_proxy_to_pthread
1834+ def test_emscripten_main_loop (self ):
1835+ self .btest_exit ('test_emscripten_main_loop.c' )
18301836
18311837 @parameterized ({
18321838 '' : ([],),
@@ -1836,12 +1842,9 @@ def test_emscripten_main_loop(self, args):
18361842 def test_emscripten_main_loop_settimeout (self , args ):
18371843 self .btest_exit ('test_emscripten_main_loop_settimeout.c' , cflags = args )
18381844
1839- @parameterized ({
1840- '' : ([],),
1841- 'pthreads' : (['-pthread' , '-sPROXY_TO_PTHREAD' ],),
1842- })
1843- def test_emscripten_main_loop_and_blocker (self , args ):
1844- self .btest_exit ('test_emscripten_main_loop_and_blocker.c' , cflags = args )
1845+ @also_with_proxy_to_pthread
1846+ def test_emscripten_main_loop_and_blocker (self ):
1847+ self .btest_exit ('test_emscripten_main_loop_and_blocker.c' )
18451848
18461849 def test_emscripten_main_loop_and_blocker_exit (self ):
18471850 # Same as above but tests that EXIT_RUNTIME works with emscripten_main_loop. The
@@ -4574,21 +4577,15 @@ def test_emscripten_set_canvas_element_size(self):
45744577
45754578 # Test that emscripten_get_device_pixel_ratio() is callable from pthreads (and proxies to main
45764579 # thread to obtain the proper window.devicePixelRatio value).
4577- @parameterized ({
4578- '' : ([],),
4579- 'pthread' : (['-pthread' , '-sPROXY_TO_PTHREAD' ],),
4580- })
4581- def test_emscripten_get_device_pixel_ratio (self , args ):
4582- self .btest_exit ('emscripten_get_device_pixel_ratio.c' , cflags = args )
4580+ @also_with_proxy_to_pthread
4581+ def test_emscripten_get_device_pixel_ratio (self ):
4582+ self .btest_exit ('emscripten_get_device_pixel_ratio.c' )
45834583
45844584 # Tests that emscripten_run_script() variants of functions work in pthreads.
4585- @parameterized ({
4586- '' : ([],),
4587- 'pthread' : (['-pthread' , '-sPROXY_TO_PTHREAD' ],),
4588- })
4589- def test_pthread_run_script (self , args ):
4585+ @also_with_proxy_to_pthread
4586+ def test_pthread_run_script (self ):
45904587 shutil .copy (test_file ('pthread/foo.js' ), '.' )
4591- self .btest_exit ('pthread/test_pthread_run_script.c' , cflags = ['-O3' ] + args )
4588+ self .btest_exit ('pthread/test_pthread_run_script.c' , cflags = ['-O3' ])
45924589
45934590 # Tests emscripten_set_canvas_element_size() and OffscreenCanvas functionality in different build configurations.
45944591 @requires_graphics_hardware
0 commit comments