Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 33 additions & 36 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,21 @@ def decorated(self, threads, *args, **kwargs):
return decorated


def also_with_proxy_to_pthread(f):
assert callable(f)

@wraps(f)
def decorated(self, threads, *args, **kwargs):
if threads:
self.cflags += ['-pthread', '-sPROXY_TO_PTHREAD']
f(self, *args, **kwargs)

parameterize(decorated, {'': (False,),
'proxy_to_pthread': (True,)})

return decorated


def skipIfFeatureNotAvailable(skip_env_var, feature, message):
for env_var in skip_env_var if type(skip_env_var) == list else [skip_env_var]:
should_skip = browser_should_skip_feature(env_var, feature)
Expand Down Expand Up @@ -471,14 +486,11 @@ def make_main_two_files(path1, path2, nonexistingpath):
self.btest_exit('main.c', cflags=['--pre-js', 'pre.js', '--use-preload-plugins'])

# Tests that user .html shell files can manually download .data files created with --preload-file cmdline.
@parameterized({
'': ([],),
'pthreads': (['-pthread', '-sPROXY_TO_PTHREAD', '-sEXIT_RUNTIME'],),
})
def test_preload_file_with_manual_data_download(self, args):
@also_with_proxy_to_pthread
def test_preload_file_with_manual_data_download(self):
create_file('file.txt', 'Hello!')

self.compile_btest('browser/test_manual_download_data.c', ['-sEXIT_RUNTIME', '-o', 'out.js', '--preload-file', 'file.txt@/file.txt'] + args)
self.compile_btest('browser/test_manual_download_data.c', ['-sEXIT_RUNTIME', '-o', 'out.js', '--preload-file', 'file.txt@/file.txt'])
shutil.copy(test_file('browser/test_manual_download_data.html'), '.')

# Move .data file out of server root to ensure that getPreloadedPackage is actually used
Expand Down Expand Up @@ -1536,12 +1548,9 @@ def test_glfw_time(self):
def test_egl(self, args):
self.btest_exit('test_egl.c', cflags=['-O2', '-lEGL', '-lGL', '-sGL_ENABLE_GET_PROC_ADDRESS'] + args)

@parameterized({
'': ([],),
'proxy_to_pthread': (['-pthread', '-sPROXY_TO_PTHREAD'],),
})
def test_egl_width_height(self, args):
self.btest_exit('test_egl_width_height.c', cflags=['-O2', '-lEGL', '-lGL'] + args)
@also_with_proxy_to_pthread
def test_egl_width_height(self):
self.btest_exit('test_egl_width_height.c', cflags=['-O2', '-lEGL', '-lGL'])

@requires_graphics_hardware
def test_egl_createcontext_error(self):
Expand Down Expand Up @@ -1821,12 +1830,9 @@ def setup():
def test_emscripten_api_infloop(self):
self.btest_exit('emscripten_api_browser_infloop.cpp')

@parameterized({
'': ([],),
'pthreads': (['-pthread', '-sPROXY_TO_PTHREAD', '-sEXIT_RUNTIME'],),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also added coverage for EXIT_RUNTIME?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was added conservatively (since sometime we had issues with EXIT_RUNTIME being needed with PROXY_TO_PTHREAD. However, since removing it doesn't break the test I think its the right thing to do here.

})
def test_emscripten_main_loop(self, args):
self.btest_exit('test_emscripten_main_loop.c', cflags=args)
@also_with_proxy_to_pthread
def test_emscripten_main_loop(self):
self.btest_exit('test_emscripten_main_loop.c')

@parameterized({
'': ([],),
Expand All @@ -1836,12 +1842,9 @@ def test_emscripten_main_loop(self, args):
def test_emscripten_main_loop_settimeout(self, args):
self.btest_exit('test_emscripten_main_loop_settimeout.c', cflags=args)

@parameterized({
'': ([],),
'pthreads': (['-pthread', '-sPROXY_TO_PTHREAD'],),
})
def test_emscripten_main_loop_and_blocker(self, args):
self.btest_exit('test_emscripten_main_loop_and_blocker.c', cflags=args)
@also_with_proxy_to_pthread
def test_emscripten_main_loop_and_blocker(self):
self.btest_exit('test_emscripten_main_loop_and_blocker.c')

def test_emscripten_main_loop_and_blocker_exit(self):
# Same as above but tests that EXIT_RUNTIME works with emscripten_main_loop. The
Expand Down Expand Up @@ -4574,21 +4577,15 @@ def test_emscripten_set_canvas_element_size(self):

# Test that emscripten_get_device_pixel_ratio() is callable from pthreads (and proxies to main
# thread to obtain the proper window.devicePixelRatio value).
@parameterized({
'': ([],),
'pthread': (['-pthread', '-sPROXY_TO_PTHREAD'],),
})
def test_emscripten_get_device_pixel_ratio(self, args):
self.btest_exit('emscripten_get_device_pixel_ratio.c', cflags=args)
@also_with_proxy_to_pthread
def test_emscripten_get_device_pixel_ratio(self):
self.btest_exit('emscripten_get_device_pixel_ratio.c')

# Tests that emscripten_run_script() variants of functions work in pthreads.
@parameterized({
'': ([],),
'pthread': (['-pthread', '-sPROXY_TO_PTHREAD'],),
})
def test_pthread_run_script(self, args):
@also_with_proxy_to_pthread
def test_pthread_run_script(self):
shutil.copy(test_file('pthread/foo.js'), '.')
self.btest_exit('pthread/test_pthread_run_script.c', cflags=['-O3'] + args)
self.btest_exit('pthread/test_pthread_run_script.c', cflags=['-O3'])

# Tests emscripten_set_canvas_element_size() and OffscreenCanvas functionality in different build configurations.
@requires_graphics_hardware
Expand Down