Skip to content

Commit 8f6e552

Browse files
authored
Separate out multithreading tests in browser harness (#25459)
Annotate browser tests that require SAB by attribute, or renaming test to have word 'thread' in it.
1 parent 507d31f commit 8f6e552

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

test/test_browser.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ def webgpu_disabled():
192192
requires_offscreen_canvas = unittest.skipIf(os.getenv('EMTEST_LACKS_OFFSCREEN_CANVAS'), 'This test requires a browser with OffscreenCanvas')
193193
requires_es6_workers = unittest.skipIf(os.getenv('EMTEST_LACKS_ES6_WORKERS'), 'This test requires a browser with ES6 Module Workers support')
194194
requires_growable_arraybuffers = unittest.skipIf(os.getenv('EMTEST_LACKS_GROWABLE_ARRAYBUFFERS'), 'This test requires a browser that supports growable ArrayBuffers')
195+
# N.b. not all SharedArrayBuffer requiring tests are annotated with this decorator, since at this point there are so many of such tests.
196+
# As a middle ground, if a test has a name 'thread' or 'wasm_worker' in it, then it does not need decorating. To run all single-threaded tests in
197+
# the suite, one can run "EMTEST_LACKS_SHARED_ARRAY_BUFFER=1 test/runner browser skip:browser.test_*thread* skip:browser.test_*wasm_worker* skip:browser.test_*audio_worklet*"
198+
requires_shared_array_buffer = unittest.skipIf(os.getenv('EMTEST_LACKS_SHARED_ARRAY_BUFFER'), 'This test requires a browser with SharedArrayBuffer support')
195199

196200

197201
class browser(BrowserCore):
@@ -2036,7 +2040,7 @@ def test_cubegeom_regal(self):
20362040

20372041
@requires_graphics_hardware
20382042
@also_with_proxying
2039-
def test_cubegeom_regal_mt(self):
2043+
def test_cubegeom_regal_pthread(self):
20402044
self.reftest('third_party/cubegeom/cubegeom.c', 'third_party/cubegeom/cubegeom.png', cflags=['-O2', '-g', '-pthread', '-DUSE_REGAL', '-pthread', '-sUSE_REGAL', '-lGL', '-lSDL', '-lc++', '-lc++abi'])
20412045

20422046
@requires_graphics_hardware
@@ -2706,8 +2710,8 @@ def test_webgl2_objects(self):
27062710
@requires_offscreen_canvas
27072711
@parameterized({
27082712
'': ([],),
2709-
'offscreencanvas': (['-sOFFSCREENCANVAS_SUPPORT', '-pthread', '-sPROXY_TO_PTHREAD'],),
2710-
'offscreenframebuffer': (['-sOFFSCREEN_FRAMEBUFFER', '-pthread', '-sPROXY_TO_PTHREAD'],),
2713+
'offscreencanvas_pthread': (['-sOFFSCREENCANVAS_SUPPORT', '-pthread', '-sPROXY_TO_PTHREAD'],),
2714+
'offscreenframebuffer_pthread': (['-sOFFSCREEN_FRAMEBUFFER', '-pthread', '-sPROXY_TO_PTHREAD'],),
27112715
})
27122716
def test_html5_webgl_api(self, args):
27132717
if '-sOFFSCREENCANVAS_SUPPORT' in args and os.getenv('EMTEST_LACKS_OFFSCREEN_CANVAS'):
@@ -3538,6 +3542,7 @@ def test_dlopen_async(self):
35383542
self.emcc('side.c', ['-o', 'libside.so', '-sSIDE_MODULE'])
35393543
self.btest_exit('other/test_dlopen_async.c', cflags=['-sMAIN_MODULE=2'])
35403544

3545+
@requires_shared_array_buffer
35413546
def test_dlopen_blocking(self):
35423547
self.emcc(test_file('other/test_dlopen_blocking_side.c'), ['-o', 'libside.so', '-sSIDE_MODULE', '-pthread', '-Wno-experimental'])
35433548
# Attempt to use dlopen the side module (without preloading) should fail on the main thread
@@ -4587,6 +4592,7 @@ def test_fetch_to_memory_async(self):
45874592
create_file('myfile.dat', 'hello world\n' * 1000)
45884593
self.btest_exit('fetch/test_fetch_to_memory_async.c', cflags=['-sFETCH'])
45894594

4595+
@requires_shared_array_buffer
45904596
def test_fetch_to_memory_sync(self):
45914597
create_file('myfile.dat', 'hello world\n' * 1000)
45924598
self.btest_exit('fetch/test_fetch_to_memory_sync.c', cflags=['-sFETCH', '-pthread', '-sPROXY_TO_PTHREAD'])
@@ -4622,15 +4628,15 @@ def test_emscripten_set_canvas_element_size(self):
46224628
# thread to obtain the proper window.devicePixelRatio value).
46234629
@parameterized({
46244630
'': ([],),
4625-
'mt': (['-pthread', '-sPROXY_TO_PTHREAD'],),
4631+
'pthread': (['-pthread', '-sPROXY_TO_PTHREAD'],),
46264632
})
46274633
def test_emscripten_get_device_pixel_ratio(self, args):
46284634
self.btest_exit('emscripten_get_device_pixel_ratio.c', cflags=args)
46294635

46304636
# Tests that emscripten_run_script() variants of functions work in pthreads.
46314637
@parameterized({
46324638
'': ([],),
4633-
'mt': (['-pthread', '-sPROXY_TO_PTHREAD'],),
4639+
'pthread': (['-pthread', '-sPROXY_TO_PTHREAD'],),
46344640
})
46354641
def test_pthread_run_script(self, args):
46364642
shutil.copy(test_file('pthread/foo.js'), '.')
@@ -4934,9 +4940,11 @@ def test_emscripten_request_animation_frame_loop(self):
49344940
def test_request_animation_frame(self):
49354941
self.btest_exit('test_request_animation_frame.c')
49364942

4943+
@requires_shared_array_buffer
49374944
def test_emscripten_set_timeout(self):
49384945
self.btest_exit('emscripten_set_timeout.c', cflags=['-pthread', '-sPROXY_TO_PTHREAD'])
49394946

4947+
@requires_shared_array_buffer
49404948
def test_emscripten_set_timeout_loop(self):
49414949
self.btest_exit('emscripten_set_timeout_loop.c', cflags=['-pthread', '-sPROXY_TO_PTHREAD'])
49424950

@@ -4946,10 +4954,12 @@ def test_emscripten_set_immediate(self):
49464954
def test_emscripten_set_immediate_loop(self):
49474955
self.btest_exit('emscripten_set_immediate_loop.c')
49484956

4957+
@requires_shared_array_buffer
49494958
def test_emscripten_set_interval(self):
49504959
self.btest_exit('emscripten_set_interval.c', cflags=['-pthread', '-sPROXY_TO_PTHREAD'])
49514960

49524961
# Test emscripten_performance_now() and emscripten_date_now()
4962+
@requires_shared_array_buffer
49534963
def test_emscripten_performance_now(self):
49544964
self.btest('emscripten_performance_now.c', '0', cflags=['-pthread', '-sPROXY_TO_PTHREAD'])
49554965

@@ -5337,7 +5347,7 @@ def test_dlmalloc_3gb(self):
53375347
# could be tested on either thread; do the main thread for simplicity)
53385348
'bigint': (['-sPTHREAD_POOL_SIZE=5', '-sWASM_BIGINT'],),
53395349
})
5340-
def test_wasmfs_fetch_backend(self, args):
5350+
def test_wasmfs_fetch_backend_threaded(self, args):
53415351
create_file('data.dat', 'hello, fetch')
53425352
create_file('small.dat', 'hello')
53435353
create_file('test.txt', 'fetch 2')

0 commit comments

Comments
 (0)