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
8 changes: 4 additions & 4 deletions test/atomic/test_wait_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ void asyncWaitFinishedShouldBeOk(int32_t* ptr,
assert(numCalled == 2);
assert(waitResult == ATOMICS_WAIT_OK);
emscripten_out("test finished");
#ifdef REPORT_RESULT
REPORT_RESULT(0);
#endif
#if !defined(__EMSCRIPTEN_WASM_WORKERS__)
#ifdef __EMSCRIPTEN_WASM_WORKERS__
emscripten_terminate_all_wasm_workers();
#else
pthread_join(t, NULL);
#endif
emscripten_force_exit(0);
}

int main() {
Expand Down
4 changes: 2 additions & 2 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5018,7 +5018,7 @@ def test_wasm_worker_thread_stack(self, mode):
# Tests emscripten_malloc_wasm_worker() and emscripten_current_thread_is_wasm_worker() functions
@also_with_minimal_runtime
def test_wasm_worker_malloc(self):
self.btest('wasm_worker/malloc_wasm_worker.c', expected='0', args=['-sWASM_WORKERS'])
self.btest_exit('wasm_worker/malloc_wasm_worker.c', args=['-sWASM_WORKERS'])

# Tests Wasm Worker+pthreads simultaneously
@also_with_minimal_runtime
Expand Down Expand Up @@ -5098,7 +5098,7 @@ def test_wasm_worker_wait64_notify(self):
# Tests emscripten_atomic_wait_async() function.
@also_with_minimal_runtime
def test_wasm_worker_wait_async(self):
self.btest('atomic/test_wait_async.c', expected='0', args=['-sWASM_WORKERS'])
self.btest_exit('atomic/test_wait_async.c', args=['-sWASM_WORKERS'])

# Tests emscripten_atomic_cancel_wait_async() function.
@also_with_minimal_runtime
Expand Down
7 changes: 0 additions & 7 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9647,23 +9647,16 @@ def test_emscripten_async_load_script(self):
self.run_process([FILE_PACKAGER, 'test.data', '--preload', 'file1.txt', 'file2.txt', '--from-emcc', '--js-output=script2.js'])
self.do_runf('test_emscripten_async_load_script.c', emcc_args=['-sFORCE_FILESYSTEM'])

def prep_wasm_worker_in_node(self):
# Auto exit after 3 seconds in Nodejs environment to get WASM Worker stdout
self.add_pre_run("setTimeout(()=>process.exit(), 3000);")

@node_pthreads
def test_wasm_worker_hello(self):
self.prep_wasm_worker_in_node()
self.do_run_in_out_file_test('wasm_worker/hello_wasm_worker.c', emcc_args=['-sWASM_WORKERS'])

@node_pthreads
def test_wasm_worker_malloc(self):
self.prep_wasm_worker_in_node()
self.do_run_in_out_file_test('wasm_worker/malloc_wasm_worker.c', emcc_args=['-sWASM_WORKERS'])

@node_pthreads
def test_wasm_worker_wait_async(self):
self.prep_wasm_worker_in_node()
self.do_runf('atomic/test_wait_async.c', emcc_args=['-sWASM_WORKERS'])


Expand Down
11 changes: 8 additions & 3 deletions test/wasm_worker/malloc_wasm_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@

// Test emscripten_malloc_wasm_worker() and emscripten_current_thread_is_wasm_worker() functions

void do_exit() {
emscripten_out("do_exit");
emscripten_terminate_all_wasm_workers();
emscripten_force_exit(0);
}

void worker_main() {
emscripten_out("Hello from wasm worker!");
assert(emscripten_current_thread_is_wasm_worker());
#ifdef REPORT_RESULT
REPORT_RESULT(0);
#endif
emscripten_wasm_worker_post_function_v(EMSCRIPTEN_WASM_WORKER_ID_PARENT, do_exit);
}

int main() {
assert(!emscripten_current_thread_is_wasm_worker());
emscripten_wasm_worker_t worker = emscripten_malloc_wasm_worker(/*stack size: */1024);
assert(worker);
emscripten_wasm_worker_post_function_v(worker, worker_main);
emscripten_exit_with_live_runtime();
}
Loading