diff --git a/test/cocos2d_hello.cpp b/test/browser/cocos2d_hello.cpp similarity index 100% rename from test/cocos2d_hello.cpp rename to test/browser/cocos2d_hello.cpp diff --git a/test/cocos2d_hello.png b/test/browser/cocos2d_hello.png similarity index 100% rename from test/cocos2d_hello.png rename to test/browser/cocos2d_hello.png diff --git a/test/html5_callbacks_on_calling_thread.c b/test/browser/html5_callbacks_on_calling_thread.c similarity index 100% rename from test/html5_callbacks_on_calling_thread.c rename to test/browser/html5_callbacks_on_calling_thread.c diff --git a/test/html5_event_callback_in_two_threads.c b/test/browser/html5_event_callback_in_two_threads.c similarity index 100% rename from test/html5_event_callback_in_two_threads.c rename to test/browser/html5_event_callback_in_two_threads.c diff --git a/test/html5_webgl.c b/test/browser/html5_webgl.c similarity index 100% rename from test/html5_webgl.c rename to test/browser/html5_webgl.c diff --git a/test/htmltest.png b/test/browser/htmltest.png similarity index 100% rename from test/htmltest.png rename to test/browser/htmltest.png diff --git a/test/test_html5_core.c b/test/browser/test_html5_core.c similarity index 100% rename from test/test_html5_core.c rename to test/browser/test_html5_core.c diff --git a/test/test_html5_emscripten_exit_fullscreen.c b/test/browser/test_html5_emscripten_exit_fullscreen.c similarity index 100% rename from test/test_html5_emscripten_exit_fullscreen.c rename to test/browser/test_html5_emscripten_exit_fullscreen.c diff --git a/test/test_html5_fullscreen.c b/test/browser/test_html5_fullscreen.c similarity index 100% rename from test/test_html5_fullscreen.c rename to test/browser/test_html5_fullscreen.c diff --git a/test/test_html5_fullscreen.html b/test/browser/test_html5_fullscreen.html similarity index 100% rename from test/test_html5_fullscreen.html rename to test/browser/test_html5_fullscreen.html diff --git a/test/test_gamepad.c b/test/browser/test_html5_gamepad.c similarity index 100% rename from test/test_gamepad.c rename to test/browser/test_html5_gamepad.c diff --git a/test/test_html5_mouse.c b/test/browser/test_html5_mouse.c similarity index 100% rename from test/test_html5_mouse.c rename to test/browser/test_html5_mouse.c diff --git a/test/test_html5_pointerlockerror.c b/test/browser/test_html5_pointerlockerror.c similarity index 100% rename from test/test_html5_pointerlockerror.c rename to test/browser/test_html5_pointerlockerror.c diff --git a/test/test_html5_remove_event_listener.c b/test/browser/test_html5_remove_event_listener.c similarity index 100% rename from test/test_html5_remove_event_listener.c rename to test/browser/test_html5_remove_event_listener.c diff --git a/test/test_html5_unknown_event_target.c b/test/browser/test_html5_unknown_event_target.c similarity index 100% rename from test/test_html5_unknown_event_target.c rename to test/browser/test_html5_unknown_event_target.c diff --git a/test/test_preallocated_heap.cpp b/test/browser/test_preallocated_heap.cpp similarity index 100% rename from test/test_preallocated_heap.cpp rename to test/browser/test_preallocated_heap.cpp diff --git a/test/test_preallocated_heap_shell.html b/test/browser/test_preallocated_heap_shell.html similarity index 100% rename from test/test_preallocated_heap_shell.html rename to test/browser/test_preallocated_heap_shell.html diff --git a/test/test_preinitialized_webgl_context.c b/test/browser/test_preinitialized_webgl_context.c similarity index 100% rename from test/test_preinitialized_webgl_context.c rename to test/browser/test_preinitialized_webgl_context.c diff --git a/test/test_preinitialized_webgl_context.html b/test/browser/test_preinitialized_webgl_context.html similarity index 100% rename from test/test_preinitialized_webgl_context.html rename to test/browser/test_preinitialized_webgl_context.html diff --git a/test/test_sbrk_brk.c b/test/core/test_sbrk_brk.c similarity index 97% rename from test/test_sbrk_brk.c rename to test/core/test_sbrk_brk.c index 8a6bb85449f3e..2251b302d86c6 100644 --- a/test/test_sbrk_brk.c +++ b/test/core/test_sbrk_brk.c @@ -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"); } diff --git a/test/core/test_sbrk_brk.out b/test/core/test_sbrk_brk.out new file mode 100644 index 0000000000000..2e9ba477f89e8 --- /dev/null +++ b/test/core/test_sbrk_brk.out @@ -0,0 +1 @@ +success diff --git a/test/small_hello_world.c b/test/hello_world_small.c similarity index 100% rename from test/small_hello_world.c rename to test/hello_world_small.c diff --git a/test/error_in_js_libraries.js b/test/jslib/error_in_js_libraries.js similarity index 100% rename from test/error_in_js_libraries.js rename to test/jslib/error_in_js_libraries.js diff --git a/test/test_jslib_override_system_symbol.c b/test/jslib/test_jslib_override_system_symbol.c similarity index 100% rename from test/test_jslib_override_system_symbol.c rename to test/jslib/test_jslib_override_system_symbol.c diff --git a/test/test_jslib_override_system_symbol.js b/test/jslib/test_jslib_override_system_symbol.js similarity index 100% rename from test/test_jslib_override_system_symbol.js rename to test/jslib/test_jslib_override_system_symbol.js diff --git a/test/test_jslib_override_system_symbol.out b/test/jslib/test_jslib_override_system_symbol.out similarity index 100% rename from test/test_jslib_override_system_symbol.out rename to test/jslib/test_jslib_override_system_symbol.out diff --git a/test/test_browser_language_detection.c b/test/other/test_language_detection.c similarity index 100% rename from test/test_browser_language_detection.c rename to test/other/test_language_detection.c diff --git a/test/test_browser.py b/test/test_browser.py index 118e53d1c3475..76aab85db37ea 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -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): @@ -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): @@ -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({ '': ([],), @@ -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): @@ -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') @@ -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 @@ -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): @@ -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. @@ -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') diff --git a/test/test_codesize.py b/test/test_codesize.py index 2552b973fad33..20ddc9bff00c4 100644 --- a/test/test_codesize.py +++ b/test/test_codesize.py @@ -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', diff --git a/test/test_core.py b/test/test_core.py index 9599dd13b86ce..dfd1ba19f3f71 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -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. @@ -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. @@ -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') @@ -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') diff --git a/test/test_interactive.py b/test/test_interactive.py index 5581394e60058..a5101b9481728 100644 --- a/test/test_interactive.py +++ b/test/test_interactive.py @@ -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']) diff --git a/test/test_jslib.py b/test/test_jslib.py index 1624e6e530a30..68ece9837b9cf 100644 --- a/test/test_jslib.py +++ b/test/test_jslib.py @@ -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) @@ -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', ''' diff --git a/test/test_other.py b/test/test_other.py index a3103565befe4..9c0f3e77cbdc5 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -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: @@ -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 @@ -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):