diff --git a/test/pthread/test_pthread_run_on_main_thread.cpp b/test/pthread/test_pthread_run_on_main_thread.cpp index 1e12ddd1912a9..de019d58719f4 100644 --- a/test/pthread/test_pthread_run_on_main_thread.cpp +++ b/test/pthread/test_pthread_run_on_main_thread.cpp @@ -12,7 +12,7 @@ int v_called = 0; void v() { assert(emscripten_is_main_runtime_thread()); - printf("Hello!\n"); + emscripten_outf("Hello!"); v_called = 1; } @@ -20,7 +20,7 @@ int vi_called = 0; void vi(int param0) { assert(emscripten_is_main_runtime_thread()); - printf("Hello %d!\n", param0); + emscripten_outf("Hello %d!", param0); vi_called = 1; } @@ -28,7 +28,7 @@ int vii_called = 0; void vii(int param0, int param1) { assert(emscripten_is_main_runtime_thread()); - printf("Hello %d %d!\n", param0, param1); + emscripten_outf("Hello %d %d!", param0, param1); vii_called = 1; } @@ -36,7 +36,7 @@ int viii_called = 0; void viii(int param0, int param1, int param2) { assert(emscripten_is_main_runtime_thread()); - printf("Hello %d %d %d!\n", param0, param1, param2); + emscripten_outf("Hello %d %d %d!", param0, param1, param2); viii_called = 1; } @@ -44,7 +44,7 @@ int i_called = 0; int i() { assert(emscripten_is_main_runtime_thread()); - printf("Hello i!\n"); + emscripten_outf("Hello i!"); i_called = 1; return 84; } @@ -53,7 +53,7 @@ int ii_called = 0; int ii(int param0) { assert(emscripten_is_main_runtime_thread()); - printf("Hello ii %d!\n", param0); + emscripten_outf("Hello ii %d!", param0); ii_called = 1; return 85; } @@ -62,7 +62,7 @@ int iii_called = 0; int iii(int param0, int param1) { assert(emscripten_is_main_runtime_thread()); - printf("Hello iii %d %d!\n", param0, param1); + emscripten_outf("Hello iii %d %d!", param0, param1); iii_called = 1; return 86; } @@ -71,14 +71,14 @@ int iiii_called = 0; int iiii(int param0, int param1, int param2) { assert(emscripten_is_main_runtime_thread()); - printf("Hello iiii %d %d %d!\n", param0, param1, param2); + emscripten_outf("Hello iiii %d %d %d!", param0, param1, param2); iiii_called = 1; return 87; } void test_sync() { - printf("Testing sync proxied runs:\n"); + emscripten_outf("Testing sync proxied runs:"); int ret; v_called = 0; emscripten_sync_run_in_main_runtime_thread(EM_FUNC_SIG_V, v); assert(v_called == 1); vi_called = 0; emscripten_sync_run_in_main_runtime_thread(EM_FUNC_SIG_VI, vi, 42); assert(vi_called == 1); @@ -92,7 +92,7 @@ void test_sync() void test_async() { - printf("Testing async proxied runs:\n"); + emscripten_outf("Testing async proxied runs:"); emscripten_async_run_in_main_runtime_thread(EM_FUNC_SIG_V, v); emscripten_async_run_in_main_runtime_thread(EM_FUNC_SIG_VI, vi, 42); emscripten_async_run_in_main_runtime_thread(EM_FUNC_SIG_VII, vii, 42, 43); @@ -105,7 +105,7 @@ void test_async() void test_async_waitable() { - printf("Testing waitable async proxied runs:\n"); + emscripten_outf("Testing waitable async proxied runs:"); em_queued_call *c1 = emscripten_async_waitable_run_in_main_runtime_thread(EM_FUNC_SIG_V, v); em_queued_call *c2 = emscripten_async_waitable_run_in_main_runtime_thread(EM_FUNC_SIG_VI, vi, 42); em_queued_call *c3 = emscripten_async_waitable_run_in_main_runtime_thread(EM_FUNC_SIG_VII, vii, 42, 43); diff --git a/test/pthread/test_pthread_run_on_main_thread.out b/test/pthread/test_pthread_run_on_main_thread.out new file mode 100644 index 0000000000000..754013655134f --- /dev/null +++ b/test/pthread/test_pthread_run_on_main_thread.out @@ -0,0 +1,56 @@ +Testing sync proxied runs: +Hello! +Hello 42! +Hello 42 43! +Hello 42 43 44! +Hello i! +Hello ii 42! +Hello iii 42 43! +Hello iiii 42 43 44! +Testing waitable async proxied runs: +Hello! +Hello 42! +Hello 42 43! +Hello 42 43 44! +Hello i! +Hello ii 42! +Hello iii 42 43! +Hello iiii 42 43 44! +Testing sync proxied runs: +Hello! +Hello 42! +Hello 42 43! +Hello 42 43 44! +Hello i! +Hello ii 42! +Hello iii 42 43! +Hello iiii 42 43 44! +Testing async proxied runs: +Testing waitable async proxied runs: +Hello! +Hello 42! +Hello 42 43! +Hello 42 43 44! +Hello i! +Hello ii 42! +Hello iii 42 43! +Hello iiii 42 43 44! +Hello! +Hello 42! +Hello 42 43! +Hello 42 43 44! +Hello i! +Hello ii 42! +Hello iii 42 43! +Hello iiii 42 43 44! +Testing async proxied runs: +Hello! +Hello 42! +Hello 42 43! +Hello 42 43 44! +Hello i! +Hello ii 42! +Hello iii 42 43! +Hello iiii 42 43 44! +user callback triggered after runtime exited or application aborted. Ignoring. +received "loaded" command from terminated worker: 1 diff --git a/test/test_browser.py b/test/test_browser.py index cf766bda19854..4aea0fe183deb 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -4246,7 +4246,6 @@ def test_pthread_gauge_available_memory(self, args): # Test that the proxying operations of user code from pthreads to main thread # work - @disabled('https://github.com/emscripten-core/emscripten/issues/18210') @requires_threads def test_pthread_run_on_main_thread(self): self.btest_exit('pthread/test_pthread_run_on_main_thread.cpp', args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE']) diff --git a/test/test_core.py b/test/test_core.py index 52f9cc2f565c6..3b1d418a9f208 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -2639,6 +2639,11 @@ def test_pthread_wait_async(self): self.set_setting('PROXY_TO_PTHREAD') self.do_run_in_out_file_test('atomic/test_wait_async.c') + @node_pthreads + def test_pthread_run_on_main_thread(self): + self.set_setting('EXIT_RUNTIME') + self.do_run_in_out_file_test('pthread/test_pthread_run_on_main_thread.cpp') + def test_tcgetattr(self): self.do_runf('termios/test_tcgetattr.c', 'success')