Skip to content
Merged
Show file tree
Hide file tree
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
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion test/test_sbrk_brk.c → test/core/test_sbrk_brk.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,6 @@ int main() {
for(int j = 0; j < count; ++j)
assert(data[i][j] == (uint8_t)i);
}
printf("OK. brk at end: %p. \n", sbrk(0));
printf("brk at end: %p.\n", sbrk(0));
printf("success\n");
}
1 change: 1 addition & 0 deletions test/core/test_sbrk_brk.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
success
File renamed without changes.
File renamed without changes.
24 changes: 12 additions & 12 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,14 @@ def test_sdl1_in_emscripten_nonstrict_mode(self):
self.skipTest('This test requires being run in non-strict mode (EMCC_STRICT env. variable unset)')
# TODO: This test is verifying behavior that will be deprecated at some point in the future, remove this test once
# system JS libraries are no longer automatically linked to anymore.
self.reftest('hello_world_sdl.c', 'htmltest.png')
self.reftest('hello_world_sdl.c', 'browser/htmltest.png')

def test_sdl1(self):
self.reftest('hello_world_sdl.c', 'htmltest.png', cflags=['-lSDL', '-lGL'])
self.reftest('hello_world_sdl.c', 'htmltest.png', cflags=['-sUSE_SDL', '-lGL']) # is the default anyhow
self.reftest('hello_world_sdl.c', 'browser/htmltest.png', cflags=['-lSDL', '-lGL'])
self.reftest('hello_world_sdl.c', 'browser/htmltest.png', cflags=['-sUSE_SDL', '-lGL']) # is the default anyhow

def test_sdl1_es6(self):
self.reftest('hello_world_sdl.c', 'htmltest.png', cflags=['-sUSE_SDL', '-lGL', '-sEXPORT_ES6'])
self.reftest('hello_world_sdl.c', 'browser/htmltest.png', cflags=['-sUSE_SDL', '-lGL', '-sEXPORT_ES6'])

@no_safari('TODO: Fails in NEW Safari 26.0.1 (21622.1.22.11.15), but not in OLD Safari 17.6 (17618.3.11.11.7, 17618) or Safari 18.5 (20621.2.5.11.8)')
def test_emscripten_log(self):
Expand Down Expand Up @@ -850,7 +850,7 @@ def test_sdl_swsurface(self):

def test_sdl_surface_lock_opts(self):
# Test Emscripten-specific extensions to optimize SDL_LockSurface and SDL_UnlockSurface.
self.reftest('hello_world_sdl.c', 'htmltest.png', cflags=['-DTEST_SDL_LOCK_OPTS', '-lSDL', '-lGL'])
self.reftest('hello_world_sdl.c', 'browser/htmltest.png', cflags=['-DTEST_SDL_LOCK_OPTS', '-lSDL', '-lGL'])

@also_with_wasmfs
def test_sdl_image(self):
Expand Down Expand Up @@ -1265,7 +1265,7 @@ def test_webgl2_ubo_layout_binding(self):
# Test that -sGL_PREINITIALIZED_CONTEXT works and allows user to set Module['preinitializedWebGLContext'] to a preinitialized WebGL context.
@requires_graphics_hardware
def test_preinitialized_webgl_context(self):
self.btest_exit('test_preinitialized_webgl_context.c', cflags=['-sGL_PREINITIALIZED_CONTEXT', '--shell-file', test_file('test_preinitialized_webgl_context.html')])
self.btest_exit('test_preinitialized_webgl_context.c', cflags=['-sGL_PREINITIALIZED_CONTEXT', '--shell-file', test_file('browser/test_preinitialized_webgl_context.html')])

@parameterized({
'': ([],),
Expand Down Expand Up @@ -2165,7 +2165,7 @@ def test_sdl_surface_refcount(self):
self.btest_exit('test_sdl_surface_refcount.c', cflags=['-lSDL'])

def test_sdl_free_screen(self):
self.reftest('test_sdl_free_screen.c', 'htmltest.png', cflags=['-lSDL', '-lGL'])
self.reftest('test_sdl_free_screen.c', 'browser/htmltest.png', cflags=['-lSDL', '-lGL'])

@requires_graphics_hardware
def test_glbegin_points(self):
Expand Down Expand Up @@ -2557,7 +2557,7 @@ def test_html5_remove_event_listener(self):
'pthread': (['-pthread', '-sPROXY_TO_PTHREAD'],),
})
def test_html5_gamepad(self, args):
self.btest_exit('test_gamepad.c', cflags=args)
self.btest_exit('test_html5_gamepad.c', cflags=args)

def test_html5_unknown_event_target(self):
self.btest_exit('test_html5_unknown_event_target.c')
Expand Down Expand Up @@ -4405,7 +4405,7 @@ def test_webgpu_required_limits(self):
# Preallocating the buffer in this was is asm.js only (wasm needs a Memory).
@requires_wasm2js
def test_preallocated_heap(self):
self.btest_exit('test_preallocated_heap.cpp', cflags=['-sWASM=0', '-sIMPORTED_MEMORY', '-sINITIAL_MEMORY=16MB', '-sABORTING_MALLOC=0', '--shell-file', test_file('test_preallocated_heap_shell.html')])
self.btest_exit('test_preallocated_heap.cpp', cflags=['-sWASM=0', '-sIMPORTED_MEMORY', '-sINITIAL_MEMORY=16MB', '-sABORTING_MALLOC=0', '--shell-file', test_file('browser/test_preallocated_heap_shell.html')])

# Tests emscripten_fetch() usage to XHR data directly to memory without persisting results to IndexedDB.
@also_with_wasm2js
Expand Down Expand Up @@ -4962,7 +4962,7 @@ def test_minimal_runtime_loader_shell(self, args):
'streaming_inst': (['-sMINIMAL_RUNTIME_STREAMING_WASM_INSTANTIATION', '-sENVIRONMENT=web', '--closure=1'],),
})
def test_minimal_runtime_hello_world(self, args):
self.btest_exit('small_hello_world.c', cflags=args + ['-sMINIMAL_RUNTIME'])
self.btest_exit('hello_world_small.c', cflags=args + ['-sMINIMAL_RUNTIME'])

# Tests emscripten_unwind_to_js_event_loop() behavior
def test_emscripten_unwind_to_js_event_loop(self):
Expand All @@ -4975,7 +4975,7 @@ def test_emscripten_unwind_to_js_event_loop(self):
})
def test_wasm2js_fallback(self, args):
self.set_setting('EXIT_RUNTIME')
self.compile_btest('small_hello_world.c', ['-sWASM=2', '-o', 'test.html'] + args)
self.compile_btest('hello_world_small.c', ['-sWASM=2', '-o', 'test.html'] + args)

# First run with WebAssembly support enabled
# Move the Wasm2js fallback away to test it is not accidentally getting loaded.
Expand All @@ -4997,7 +4997,7 @@ def test_wasm2js_fallback(self, args):
})
def test_wasm2js_fallback_on_wasm_compilation_failure(self, args):
self.set_setting('EXIT_RUNTIME')
self.compile_btest('small_hello_world.c', ['-sWASM=2', '-o', 'test.html'] + args)
self.compile_btest('hello_world_small.c', ['-sWASM=2', '-o', 'test.html'] + args)

# Run without the .wasm.js file present: with Wasm support, the page should still run
os.rename('test.wasm.js', 'test.wasm.js.unused')
Expand Down
2 changes: 1 addition & 1 deletion test/test_codesize.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_minimal_runtime_code_size(self, test_name, wasm2js, compare_js_output=F
'-ffast-math']

math_sources = [test_file('codesize/math.c')]
hello_world_sources = [test_file('small_hello_world.c'),
hello_world_sources = [test_file('hello_world_small.c'),
'-sMALLOC=none']
random_printf_sources = [test_file('hello_random_printf.c'),
'-sMALLOC=none',
Expand Down
12 changes: 6 additions & 6 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8472,7 +8472,7 @@ def test_wasm2js_fallback(self):
if self.is_wasm2js():
self.skipTest('redundant to test wasm2js in wasm2js* mode')

self.run_process([EMCC, test_file('small_hello_world.c'), '-sWASM=2'])
self.run_process([EMCC, test_file('hello_world_small.c'), '-sWASM=2'])

# First run with WebAssembly support enabled
# Move the Wasm2js fallback away to test it is not accidentally getting loaded.
Expand Down Expand Up @@ -8589,11 +8589,11 @@ def test_binaryen_2170_emscripten_atomic_cas_u8(self):

@also_with_standalone_wasm()
def test_sbrk(self):
self.do_runf('test_sbrk_brk.c', 'OK.')
self.do_runf('test_sbrk_brk.c', 'OK.', cflags=['-sALLOW_MEMORY_GROWTH'])
self.do_core_test('test_sbrk_brk.c')
self.do_core_test('test_sbrk_brk.c', cflags=['-sALLOW_MEMORY_GROWTH'])

def test_brk(self):
self.do_runf('test_sbrk_brk.c', 'OK.', cflags=['-DTEST_BRK=1'])
self.do_core_test('test_sbrk_brk.c', cflags=['-DTEST_BRK=1'])

# Tests that we can use the dlmalloc mallinfo() function to obtain information
# about malloc()ed blocks and compute how much memory is used/freed.
Expand Down Expand Up @@ -8700,7 +8700,7 @@ def test_no_declare_asm_module_exports(self):
def test_minimal_runtime_hello_world(self, args):
self.maybe_closure()
self.cflags += ['--pre-js', test_file('minimal_runtime_exit_handling.js')]
self.do_runf('small_hello_world.c', 'hello!', cflags=['-sMINIMAL_RUNTIME'] + args)
self.do_runf('hello_world_small.c', 'hello!', cflags=['-sMINIMAL_RUNTIME'] + args)

# Test that printf() works in MINIMAL_RUNTIME=1
@no_wasmfs('https://github.com/emscripten-core/emscripten/issues/16816')
Expand Down Expand Up @@ -8732,7 +8732,7 @@ def test_minimal_runtime_safe_heap(self):
# lsan pulls in $FS
if '-fsanitize=leak' not in self.cflags:
self.maybe_closure()
self.do_runf('small_hello_world.c', 'hello')
self.do_runf('hello_world_small.c', 'hello')

# Tests global initializer with -sMINIMAL_RUNTIME
@no_wasmfs('https://github.com/emscripten-core/emscripten/issues/16816')
Expand Down
2 changes: 1 addition & 1 deletion test/test_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_html5_core(self):
self.btest_exit('test_html5_core.c', cflags=['-DKEEP_ALIVE'])

def test_html5_fullscreen(self):
self.btest('test_html5_fullscreen.c', expected='0', cflags=['-sDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR', '-sEXPORTED_FUNCTIONS=_requestFullscreen,_enterSoftFullscreen,_main', '--shell-file', test_file('test_html5_fullscreen.html')])
self.btest('test_html5_fullscreen.c', expected='0', cflags=['-sDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR', '-sEXPORTED_FUNCTIONS=_requestFullscreen,_enterSoftFullscreen,_main', '--shell-file', test_file('browser/test_html5_fullscreen.html')])

def test_html5_emscripten_exit_with_escape(self):
self.btest('test_html5_emscripten_exit_fullscreen.c', expected='1', cflags=['-DEXIT_WITH_F'])
Expand Down
8 changes: 4 additions & 4 deletions test/test_jslib.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def test_jslib_warnings(self):

# Tests using the #error directive in JS library files
def test_jslib_errors(self):
shutil.copy(test_file('error_in_js_libraries.js'), '.')
shutil.copy(test_file('jslib/error_in_js_libraries.js'), '.')
err = self.expect_fail([EMCC, test_file('hello_world.c'), '--js-library', 'error_in_js_libraries.js'])
self.assertNotContained('This error should not be present!', err)
self.assertContained('error: error_in_js_libraries.js:5: #error This is an error string!', err)
Expand Down Expand Up @@ -706,11 +706,11 @@ def test_jslib_override_system_symbol(self):

# When WebGL is implicitly linked in, the implicit linking should happen before any user
# --js-libraries, so that they can adjust the behavior afterwards.
self.do_run_in_out_file_test('test_jslib_override_system_symbol.c', cflags=['--js-library', test_file('test_jslib_override_system_symbol.js'), '-sMAX_WEBGL_VERSION=2'])
self.do_run_in_out_file_test('jslib/test_jslib_override_system_symbol.c', cflags=['--js-library', test_file('jslib/test_jslib_override_system_symbol.js'), '-sMAX_WEBGL_VERSION=2'])

# When WebGL is explicitly linked to in strict mode, the linking order on command line should enable overriding.
self.cflags += ['-sAUTO_JS_LIBRARIES=0', '-sMAX_WEBGL_VERSION=2', '-lwebgl.js', '--js-library', test_file('test_jslib_override_system_symbol.js')]
self.do_run_in_out_file_test('test_jslib_override_system_symbol.c')
self.cflags += ['-sAUTO_JS_LIBRARIES=0', '-sMAX_WEBGL_VERSION=2', '-lwebgl.js', '--js-library', test_file('jslib/test_jslib_override_system_symbol.js')]
self.do_run_in_out_file_test('jslib/test_jslib_override_system_symbol.c')

def test_jslib_version_check(self):
create_file('libfoo.js', '''
Expand Down
14 changes: 6 additions & 8 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -5841,7 +5841,7 @@ def test_bad_locale(self):

@crossplatform
@requires_node
def test_browser_language_detection(self):
def test_language_detection(self):
# Test HTTP Accept-Language parsing by simulating navigator.languages #8751
expected_lang = os.environ.get('LANG')
if expected_lang is None:
Expand All @@ -5853,17 +5853,15 @@ def test_browser_language_detection(self):

# We support both "C" and system LANG here since older versions of node do
# not expose navigator.languages.
output = self.do_runf('test_browser_language_detection.c')
self.assertContained(f'LANG=({expected_lang}|en_US.UTF-8|C.UTF-8)', output, regex=True)
self.do_runf('other/test_language_detection.c', f'LANG=({expected_lang}|en_US.UTF-8|C.UTF-8)', regex=True)

# Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
create_file('pre.js', 'delete global.navigator; globalThis.navigator = { language: "fr" };')
output = self.do_runf('test_browser_language_detection.c', cflags=['--pre-js', 'pre.js'])
self.assertContained('LANG=fr.UTF-8', output)
self.do_runf('other/test_language_detection.c', 'LANG=fr.UTF-8', cflags=['--pre-js', 'pre.js'])

# Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.5,en;q=0.3
create_file('pre.js', r'delete global.navigator; globalThis.navigator = { language: "fr-FR" };')
self.do_runf('test_browser_language_detection.c', 'LANG=fr_FR.UTF-8', cflags=['--pre-js=pre.js'])
self.do_runf('other/test_language_detection.c', 'LANG=fr_FR.UTF-8', cflags=['--pre-js=pre.js'])

def test_js_main(self):
# try to add a main() from JS, at runtime. this is not supported (the
Expand Down Expand Up @@ -11836,9 +11834,9 @@ def test_output_to_nowhere(self):
# I.e. -sMIN_X_VERSION=-1 is equal to -sMIN_X_VERSION=Infinity
def test_drop_support_for_browser(self):
# Test that -1 means "not supported"
self.run_process([EMCC, test_file('test_html5_core.c')])
self.run_process([EMCC, test_file('browser/test_html5_core.c')])
self.assertContained('document.webkitFullscreenEnabled', read_file('a.out.js'))
self.run_process([EMCC, test_file('test_html5_core.c'), '-sMIN_SAFARI_VERSION=-1'])
self.run_process([EMCC, test_file('browser/test_html5_core.c'), '-sMIN_SAFARI_VERSION=-1'])
self.assertNotContained('document.webkitFullscreenEnabled', read_file('a.out.js'))

def test_errno_type(self):
Expand Down