From 4ad2f9522dd4db0bfb389cc3fd482ed6a490311d Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 22 Dec 2022 09:11:27 +0900 Subject: [PATCH 01/11] Add some low level tests ``` (venv) spacetanuki% TOYWASM=~/git/toywasm/b/toywasm python3 test-runner/wasi_test_runner.py -t ~/git/wasm/wasi-threads/test/testsuite -r ~/git/toywasm/test/wasi-testsuite-adapter.py Test wasi_threads_exit_nonmain_wasi passed Test wasi_threads_exit_main_busy passed Test wasi_threads_exit_main_wasi passed Test wasi_threads_exit_nonmain_busy passed Test wasi_threads_spawn passed Test wasi_threads_exit_main_block passed Test wasi_threads_exit_nonmain_block passed ===== Test results ===== Runtime: toywasm v0.0 Suite: WASI threads proposal Total: 7 Passed: 7 Failed: 0 Test suites: 1 passed, 0 total Tests: 7 passed, 0 total (venv) spacetanuki% ``` --- test/build-wat.sh | 6 ++ .../wasi_threads_exit_main_block.json | 3 + .../wasi_threads_exit_main_block.wat | 39 +++++++++++ .../wasi_threads_exit_main_busy.json | 3 + .../testsuite/wasi_threads_exit_main_busy.wat | 38 +++++++++++ .../wasi_threads_exit_main_wasi.json | 3 + .../testsuite/wasi_threads_exit_main_wasi.wat | 45 +++++++++++++ .../wasi_threads_exit_nonmain_block.json | 3 + .../wasi_threads_exit_nonmain_block.wat | 39 +++++++++++ .../wasi_threads_exit_nonmain_busy.json | 3 + .../wasi_threads_exit_nonmain_busy.wat | 38 +++++++++++ .../wasi_threads_exit_nonmain_wasi.json | 3 + .../wasi_threads_exit_nonmain_wasi.wat | 45 +++++++++++++ test/testsuite/wasi_threads_spawn.json | 3 + test/testsuite/wasi_threads_spawn.wat | 67 +++++++++++++++++++ 15 files changed, 338 insertions(+) create mode 100755 test/build-wat.sh create mode 100644 test/testsuite/wasi_threads_exit_main_block.json create mode 100644 test/testsuite/wasi_threads_exit_main_block.wat create mode 100644 test/testsuite/wasi_threads_exit_main_busy.json create mode 100644 test/testsuite/wasi_threads_exit_main_busy.wat create mode 100644 test/testsuite/wasi_threads_exit_main_wasi.json create mode 100644 test/testsuite/wasi_threads_exit_main_wasi.wat create mode 100644 test/testsuite/wasi_threads_exit_nonmain_block.json create mode 100644 test/testsuite/wasi_threads_exit_nonmain_block.wat create mode 100644 test/testsuite/wasi_threads_exit_nonmain_busy.json create mode 100644 test/testsuite/wasi_threads_exit_nonmain_busy.wat create mode 100644 test/testsuite/wasi_threads_exit_nonmain_wasi.json create mode 100644 test/testsuite/wasi_threads_exit_nonmain_wasi.wat create mode 100644 test/testsuite/wasi_threads_spawn.json create mode 100644 test/testsuite/wasi_threads_spawn.wat diff --git a/test/build-wat.sh b/test/build-wat.sh new file mode 100755 index 0000000..3df8bef --- /dev/null +++ b/test/build-wat.sh @@ -0,0 +1,6 @@ +#! /bin/sh + +WAT2WASM=${WAT2WASM:-wat2wasm} +for wat in testsuite/*.wat; do + ${WAT2WASM} --enable-threads -o ${wat%%.wat}.wasm ${wat} +done diff --git a/test/testsuite/wasi_threads_exit_main_block.json b/test/testsuite/wasi_threads_exit_main_block.json new file mode 100644 index 0000000..e8a2acf --- /dev/null +++ b/test/testsuite/wasi_threads_exit_main_block.json @@ -0,0 +1,3 @@ +{ + "exit_code": 99 +} diff --git a/test/testsuite/wasi_threads_exit_main_block.wat b/test/testsuite/wasi_threads_exit_main_block.wat new file mode 100644 index 0000000..315858d --- /dev/null +++ b/test/testsuite/wasi_threads_exit_main_block.wat @@ -0,0 +1,39 @@ +(module + (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) + (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) + (func (export "wasi_thread_start") (param i32 i32) + ;; infinite wait + i32.const 0 + i32.const 0 + i64.const -1 + memory.atomic.wait32 + unreachable + ) + (func (export "_start") + ;; spawn a thread + i32.const 0 + call $thread_spawn + ;; check error + i32.const 0 + i32.le_s + if + unreachable + end + ;; wait 500ms to ensure the other thread block + i32.const 0 + i32.const 0 + i64.const 500_000_000 + memory.atomic.wait32 + ;; assert a timeout + i32.const 2 + i32.ne + if + unreachable + end + ;; exit + i32.const 99 + call $proc_exit + unreachable + ) + (memory 1 1 shared) +) diff --git a/test/testsuite/wasi_threads_exit_main_busy.json b/test/testsuite/wasi_threads_exit_main_busy.json new file mode 100644 index 0000000..e8a2acf --- /dev/null +++ b/test/testsuite/wasi_threads_exit_main_busy.json @@ -0,0 +1,3 @@ +{ + "exit_code": 99 +} diff --git a/test/testsuite/wasi_threads_exit_main_busy.wat b/test/testsuite/wasi_threads_exit_main_busy.wat new file mode 100644 index 0000000..c699f6f --- /dev/null +++ b/test/testsuite/wasi_threads_exit_main_busy.wat @@ -0,0 +1,38 @@ +(module + (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) + (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) + (func (export "wasi_thread_start") (param i32 i32) + ;; infinite loop + loop + br 0 + end + unreachable + ) + (func (export "_start") + ;; spawn a thread + i32.const 0 + call $thread_spawn + ;; check error + i32.const 0 + i32.le_s + if + unreachable + end + ;; wait 500ms to ensure the other thread to enter the busy loop + i32.const 0 + i32.const 0 + i64.const 500_000_000 + memory.atomic.wait32 + ;; assert a timeout + i32.const 2 + i32.ne + if + unreachable + end + ;; exit + i32.const 99 + call $proc_exit + unreachable + ) + (memory 1 1 shared) +) diff --git a/test/testsuite/wasi_threads_exit_main_wasi.json b/test/testsuite/wasi_threads_exit_main_wasi.json new file mode 100644 index 0000000..e8a2acf --- /dev/null +++ b/test/testsuite/wasi_threads_exit_main_wasi.json @@ -0,0 +1,3 @@ +{ + "exit_code": 99 +} diff --git a/test/testsuite/wasi_threads_exit_main_wasi.wat b/test/testsuite/wasi_threads_exit_main_wasi.wat new file mode 100644 index 0000000..68ea016 --- /dev/null +++ b/test/testsuite/wasi_threads_exit_main_wasi.wat @@ -0,0 +1,45 @@ +(module + (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) + (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) + (func $poll_oneoff (import "wasi_snapshot_preview1" "poll_oneoff") (param i32 i32 i32 i32) (result i32)) + (func (export "wasi_thread_start") (param i32 i32) + ;; long enough block + ;; clock_realtime, !abstime (zeros) + i32.const 124 ;; 100 + offsetof(subscription, timeout) + i64.const 1_000_000_000 ;; 1s + i64.store + i32.const 100 ;; subscription + i32.const 200 ;; event (out) + i32.const 1 ;; nsubscriptions + i32.const 300 ;; retp (out) + call $poll_oneoff + unreachable + ) + (func (export "_start") + ;; spawn a thread + i32.const 0 + call $thread_spawn + ;; check error + i32.const 0 + i32.le_s + if + unreachable + end + ;; wait 500ms to ensure the other thread block + i32.const 0 + i32.const 0 + i64.const 500_000_000 + memory.atomic.wait32 + ;; assert a timeout + i32.const 2 + i32.ne + if + unreachable + end + ;; exit + i32.const 99 + call $proc_exit + unreachable + ) + (memory 1 1 shared) +) diff --git a/test/testsuite/wasi_threads_exit_nonmain_block.json b/test/testsuite/wasi_threads_exit_nonmain_block.json new file mode 100644 index 0000000..e8a2acf --- /dev/null +++ b/test/testsuite/wasi_threads_exit_nonmain_block.json @@ -0,0 +1,3 @@ +{ + "exit_code": 99 +} diff --git a/test/testsuite/wasi_threads_exit_nonmain_block.wat b/test/testsuite/wasi_threads_exit_nonmain_block.wat new file mode 100644 index 0000000..6fb6384 --- /dev/null +++ b/test/testsuite/wasi_threads_exit_nonmain_block.wat @@ -0,0 +1,39 @@ +(module + (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) + (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) + (func (export "wasi_thread_start") (param i32 i32) + ;; wait 500ms to ensure the other thread block + i32.const 0 + i32.const 0 + i64.const 500_000_000 + memory.atomic.wait32 + ;; assert a timeout + i32.const 2 + i32.ne + if + unreachable + end + ;; exit + i32.const 99 + call $proc_exit + unreachable + ) + (func (export "_start") + ;; spawn a thread + i32.const 0 + call $thread_spawn + ;; check error + i32.const 0 + i32.le_s + if + unreachable + end + ;; infinite wait + i32.const 0 + i32.const 0 + i64.const -1 + memory.atomic.wait32 + unreachable + ) + (memory 1 1 shared) +) diff --git a/test/testsuite/wasi_threads_exit_nonmain_busy.json b/test/testsuite/wasi_threads_exit_nonmain_busy.json new file mode 100644 index 0000000..e8a2acf --- /dev/null +++ b/test/testsuite/wasi_threads_exit_nonmain_busy.json @@ -0,0 +1,3 @@ +{ + "exit_code": 99 +} diff --git a/test/testsuite/wasi_threads_exit_nonmain_busy.wat b/test/testsuite/wasi_threads_exit_nonmain_busy.wat new file mode 100644 index 0000000..39fe16f --- /dev/null +++ b/test/testsuite/wasi_threads_exit_nonmain_busy.wat @@ -0,0 +1,38 @@ +(module + (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) + (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) + (func (export "wasi_thread_start") (param i32 i32) + ;; wait 500ms to ensure the other thread to enter the busy loop + i32.const 0 + i32.const 0 + i64.const 500_000_000 + memory.atomic.wait32 + ;; assert a timeout + i32.const 2 + i32.ne + if + unreachable + end + ;; exit + i32.const 99 + call $proc_exit + unreachable + ) + (func (export "_start") + ;; spawn a thread + i32.const 0 + call $thread_spawn + ;; check error + i32.const 0 + i32.le_s + if + unreachable + end + ;; infinite loop + loop + br 0 + end + unreachable + ) + (memory 1 1 shared) +) diff --git a/test/testsuite/wasi_threads_exit_nonmain_wasi.json b/test/testsuite/wasi_threads_exit_nonmain_wasi.json new file mode 100644 index 0000000..e8a2acf --- /dev/null +++ b/test/testsuite/wasi_threads_exit_nonmain_wasi.json @@ -0,0 +1,3 @@ +{ + "exit_code": 99 +} diff --git a/test/testsuite/wasi_threads_exit_nonmain_wasi.wat b/test/testsuite/wasi_threads_exit_nonmain_wasi.wat new file mode 100644 index 0000000..9f1772f --- /dev/null +++ b/test/testsuite/wasi_threads_exit_nonmain_wasi.wat @@ -0,0 +1,45 @@ +(module + (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) + (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) + (func $poll_oneoff (import "wasi_snapshot_preview1" "poll_oneoff") (param i32 i32 i32 i32) (result i32)) + (func (export "wasi_thread_start") (param i32 i32) + ;; wait 500ms to ensure the other thread block + i32.const 0 + i32.const 0 + i64.const 500_000_000 + memory.atomic.wait32 + ;; assert a timeout + i32.const 2 + i32.ne + if + unreachable + end + ;; exit + i32.const 99 + call $proc_exit + unreachable + ) + (func (export "_start") + ;; spawn a thread + i32.const 0 + call $thread_spawn + ;; check error + i32.const 0 + i32.le_s + if + unreachable + end + ;; long enough block + ;; clock_realtime, !abstime (zeros) + i32.const 124 ;; 100 + offsetof(subscription, timeout) + i64.const 1_000_000_000 ;; 1s + i64.store + i32.const 100 ;; subscription + i32.const 200 ;; event (out) + i32.const 1 ;; nsubscriptions + i32.const 300 ;; retp (out) + call $poll_oneoff + unreachable + ) + (memory 1 1 shared) +) diff --git a/test/testsuite/wasi_threads_spawn.json b/test/testsuite/wasi_threads_spawn.json new file mode 100644 index 0000000..3e5ce1c --- /dev/null +++ b/test/testsuite/wasi_threads_spawn.json @@ -0,0 +1,3 @@ +{ + "exit_code": 22 +} diff --git a/test/testsuite/wasi_threads_spawn.wat b/test/testsuite/wasi_threads_spawn.wat new file mode 100644 index 0000000..c3dca69 --- /dev/null +++ b/test/testsuite/wasi_threads_spawn.wat @@ -0,0 +1,67 @@ +(module + (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) + (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) + (func (export "wasi_thread_start") (param i32 i32) + ;; store tid + i32.const 4 + local.get 0 + i32.store + ;; store user pointer + i32.const 8 + local.get 1 + i32.store + ;; notify the main + i32.const 0 + i32.const 1 + i32.atomic.store + i32.const 0 + i32.const 1 + memory.atomic.notify + drop + ;; returning from wasi_thread_start terminates only this thread + ) + (func (export "_start") (local i32) + ;; spawn a thread + i32.const 12345 ;; user pointer + call $thread_spawn + ;; check error + local.tee 0 ;; save the tid to check later + i32.const 0 + i32.le_s + if + unreachable + end + ;; wait for the spawned thread to run + i32.const 0 + i32.const 0 + i64.const -1 + memory.atomic.wait32 + ;; assert it was not a timeout + i32.const 2 + i32.eq + if + unreachable + end + ;; check the tid + local.get 0 + i32.const 4 + i32.load + i32.ne + if + unreachable + end + ;; check the user pointer + i32.const 8 + i32.load + i32.const 12345 + i32.ne + if + unreachable + end + ;; exit + i32.const 22 + call $proc_exit + unreachable + ) + (memory 1 1 shared) +) From 3d9d00d4d82616ec0c0a3ca2cdb3a407877eea07 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Sat, 24 Dec 2022 11:45:15 +0900 Subject: [PATCH 02/11] import shared memory in wat tests as suggested in https://github.com/WebAssembly/wasi-libc/pull/369 the corresponding toywasm change: https://github.com/yamt/toywasm/commit/4d81846e3aa6f01f97e6aef0a51238fd18f6ecf1 ``` spacetanuki% TOYWASM=~/git/toywasm/b/toywasm python3 ~/git/wasm/wasi-testsuite/test-runner/wasi_test_runner.py -t ./test/testsuite -r ~/git/toywasm/test/wasi-testsuite-adapter.py Test wasi_threads_exit_nonmain_wasi passed Test wasi_threads_exit_main_busy passed Test wasi_threads_exit_main_wasi passed Test wasi_threads_exit_nonmain_busy passed Test wasi_threads_spawn passed Test wasi_threads_exit_main_block passed Test wasi_threads_exit_nonmain_block passed ===== Test results ===== Runtime: toywasm v0.0 Suite: WASI threads proposal Total: 7 Passed: 7 Failed: 0 Test suites: 1 passed, 0 total Tests: 7 passed, 0 total spacetanuki% ``` --- test/testsuite/wasi_threads_exit_main_block.wat | 2 +- test/testsuite/wasi_threads_exit_main_busy.wat | 2 +- test/testsuite/wasi_threads_exit_main_wasi.wat | 2 +- test/testsuite/wasi_threads_exit_nonmain_block.wat | 2 +- test/testsuite/wasi_threads_exit_nonmain_busy.wat | 2 +- test/testsuite/wasi_threads_exit_nonmain_wasi.wat | 2 +- test/testsuite/wasi_threads_spawn.wat | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/testsuite/wasi_threads_exit_main_block.wat b/test/testsuite/wasi_threads_exit_main_block.wat index 315858d..e0a0539 100644 --- a/test/testsuite/wasi_threads_exit_main_block.wat +++ b/test/testsuite/wasi_threads_exit_main_block.wat @@ -1,4 +1,5 @@ (module + (memory (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func (export "wasi_thread_start") (param i32 i32) @@ -35,5 +36,4 @@ call $proc_exit unreachable ) - (memory 1 1 shared) ) diff --git a/test/testsuite/wasi_threads_exit_main_busy.wat b/test/testsuite/wasi_threads_exit_main_busy.wat index c699f6f..9d96f38 100644 --- a/test/testsuite/wasi_threads_exit_main_busy.wat +++ b/test/testsuite/wasi_threads_exit_main_busy.wat @@ -1,4 +1,5 @@ (module + (memory (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func (export "wasi_thread_start") (param i32 i32) @@ -34,5 +35,4 @@ call $proc_exit unreachable ) - (memory 1 1 shared) ) diff --git a/test/testsuite/wasi_threads_exit_main_wasi.wat b/test/testsuite/wasi_threads_exit_main_wasi.wat index 68ea016..bf09d5e 100644 --- a/test/testsuite/wasi_threads_exit_main_wasi.wat +++ b/test/testsuite/wasi_threads_exit_main_wasi.wat @@ -1,4 +1,5 @@ (module + (memory (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func $poll_oneoff (import "wasi_snapshot_preview1" "poll_oneoff") (param i32 i32 i32 i32) (result i32)) @@ -41,5 +42,4 @@ call $proc_exit unreachable ) - (memory 1 1 shared) ) diff --git a/test/testsuite/wasi_threads_exit_nonmain_block.wat b/test/testsuite/wasi_threads_exit_nonmain_block.wat index 6fb6384..02e3800 100644 --- a/test/testsuite/wasi_threads_exit_nonmain_block.wat +++ b/test/testsuite/wasi_threads_exit_nonmain_block.wat @@ -1,4 +1,5 @@ (module + (memory (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func (export "wasi_thread_start") (param i32 i32) @@ -35,5 +36,4 @@ memory.atomic.wait32 unreachable ) - (memory 1 1 shared) ) diff --git a/test/testsuite/wasi_threads_exit_nonmain_busy.wat b/test/testsuite/wasi_threads_exit_nonmain_busy.wat index 39fe16f..78d979d 100644 --- a/test/testsuite/wasi_threads_exit_nonmain_busy.wat +++ b/test/testsuite/wasi_threads_exit_nonmain_busy.wat @@ -1,4 +1,5 @@ (module + (memory (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func (export "wasi_thread_start") (param i32 i32) @@ -34,5 +35,4 @@ end unreachable ) - (memory 1 1 shared) ) diff --git a/test/testsuite/wasi_threads_exit_nonmain_wasi.wat b/test/testsuite/wasi_threads_exit_nonmain_wasi.wat index 9f1772f..56142f9 100644 --- a/test/testsuite/wasi_threads_exit_nonmain_wasi.wat +++ b/test/testsuite/wasi_threads_exit_nonmain_wasi.wat @@ -1,4 +1,5 @@ (module + (memory (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func $poll_oneoff (import "wasi_snapshot_preview1" "poll_oneoff") (param i32 i32 i32 i32) (result i32)) @@ -41,5 +42,4 @@ call $poll_oneoff unreachable ) - (memory 1 1 shared) ) diff --git a/test/testsuite/wasi_threads_spawn.wat b/test/testsuite/wasi_threads_spawn.wat index c3dca69..69a987e 100644 --- a/test/testsuite/wasi_threads_spawn.wat +++ b/test/testsuite/wasi_threads_spawn.wat @@ -1,4 +1,5 @@ (module + (memory (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func (export "wasi_thread_start") (param i32 i32) @@ -63,5 +64,4 @@ call $proc_exit unreachable ) - (memory 1 1 shared) ) From cd61a730d8493604aa9bf22dc3f12a4470124333 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 11 Jan 2023 16:06:58 +0900 Subject: [PATCH 03/11] Make wat test export memory as well While it's a bit redundant to both import and export a memory, it's what WASI implementations expect. Emscripten, toywasm: Import alone is fine. But export wouldn't hurt. wasm-micro-runtime: Export is checked. Nothing actually seems to rely on it though. wasmtime: Export is necessary? References: https://github.com/WebAssembly/WASI/blob/main/legacy/application-abi.md#current-unstable-abi https://github.com/WebAssembly/wasi-threads/issues/22 --- test/testsuite/wasi_threads_exit_main_block.wat | 2 +- test/testsuite/wasi_threads_exit_main_busy.wat | 2 +- test/testsuite/wasi_threads_exit_main_wasi.wat | 2 +- test/testsuite/wasi_threads_exit_nonmain_block.wat | 2 +- test/testsuite/wasi_threads_exit_nonmain_busy.wat | 2 +- test/testsuite/wasi_threads_exit_nonmain_wasi.wat | 2 +- test/testsuite/wasi_threads_spawn.wat | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/testsuite/wasi_threads_exit_main_block.wat b/test/testsuite/wasi_threads_exit_main_block.wat index e0a0539..1d2dbd2 100644 --- a/test/testsuite/wasi_threads_exit_main_block.wat +++ b/test/testsuite/wasi_threads_exit_main_block.wat @@ -1,5 +1,5 @@ (module - (memory (import "foo" "bar") 1 1 shared) + (memory (export "memory") (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func (export "wasi_thread_start") (param i32 i32) diff --git a/test/testsuite/wasi_threads_exit_main_busy.wat b/test/testsuite/wasi_threads_exit_main_busy.wat index 9d96f38..f8263b6 100644 --- a/test/testsuite/wasi_threads_exit_main_busy.wat +++ b/test/testsuite/wasi_threads_exit_main_busy.wat @@ -1,5 +1,5 @@ (module - (memory (import "foo" "bar") 1 1 shared) + (memory (export "memory") (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func (export "wasi_thread_start") (param i32 i32) diff --git a/test/testsuite/wasi_threads_exit_main_wasi.wat b/test/testsuite/wasi_threads_exit_main_wasi.wat index bf09d5e..44d0db9 100644 --- a/test/testsuite/wasi_threads_exit_main_wasi.wat +++ b/test/testsuite/wasi_threads_exit_main_wasi.wat @@ -1,5 +1,5 @@ (module - (memory (import "foo" "bar") 1 1 shared) + (memory (export "memory") (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func $poll_oneoff (import "wasi_snapshot_preview1" "poll_oneoff") (param i32 i32 i32 i32) (result i32)) diff --git a/test/testsuite/wasi_threads_exit_nonmain_block.wat b/test/testsuite/wasi_threads_exit_nonmain_block.wat index 02e3800..b990715 100644 --- a/test/testsuite/wasi_threads_exit_nonmain_block.wat +++ b/test/testsuite/wasi_threads_exit_nonmain_block.wat @@ -1,5 +1,5 @@ (module - (memory (import "foo" "bar") 1 1 shared) + (memory (export "memory") (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func (export "wasi_thread_start") (param i32 i32) diff --git a/test/testsuite/wasi_threads_exit_nonmain_busy.wat b/test/testsuite/wasi_threads_exit_nonmain_busy.wat index 78d979d..aaa1c42 100644 --- a/test/testsuite/wasi_threads_exit_nonmain_busy.wat +++ b/test/testsuite/wasi_threads_exit_nonmain_busy.wat @@ -1,5 +1,5 @@ (module - (memory (import "foo" "bar") 1 1 shared) + (memory (export "memory") (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func (export "wasi_thread_start") (param i32 i32) diff --git a/test/testsuite/wasi_threads_exit_nonmain_wasi.wat b/test/testsuite/wasi_threads_exit_nonmain_wasi.wat index 56142f9..8d03f0e 100644 --- a/test/testsuite/wasi_threads_exit_nonmain_wasi.wat +++ b/test/testsuite/wasi_threads_exit_nonmain_wasi.wat @@ -1,5 +1,5 @@ (module - (memory (import "foo" "bar") 1 1 shared) + (memory (export "memory") (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func $poll_oneoff (import "wasi_snapshot_preview1" "poll_oneoff") (param i32 i32 i32 i32) (result i32)) diff --git a/test/testsuite/wasi_threads_spawn.wat b/test/testsuite/wasi_threads_spawn.wat index 69a987e..c92edf7 100644 --- a/test/testsuite/wasi_threads_spawn.wat +++ b/test/testsuite/wasi_threads_spawn.wat @@ -1,5 +1,5 @@ (module - (memory (import "foo" "bar") 1 1 shared) + (memory (export "memory") (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func (export "wasi_thread_start") (param i32 i32) From d6206ddc3dd276948f58ab7b7ba3ce07eab1c2f4 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 23 Jan 2023 13:12:54 +0900 Subject: [PATCH 04/11] Add a short summary on each wat files --- test/testsuite/wasi_threads_exit_main_block.wat | 3 +++ test/testsuite/wasi_threads_exit_main_busy.wat | 3 +++ test/testsuite/wasi_threads_exit_main_wasi.wat | 3 +++ test/testsuite/wasi_threads_exit_nonmain_block.wat | 3 +++ test/testsuite/wasi_threads_exit_nonmain_busy.wat | 3 +++ test/testsuite/wasi_threads_exit_nonmain_wasi.wat | 3 +++ test/testsuite/wasi_threads_spawn.wat | 2 ++ 7 files changed, 20 insertions(+) diff --git a/test/testsuite/wasi_threads_exit_main_block.wat b/test/testsuite/wasi_threads_exit_main_block.wat index 1d2dbd2..b75773c 100644 --- a/test/testsuite/wasi_threads_exit_main_block.wat +++ b/test/testsuite/wasi_threads_exit_main_block.wat @@ -1,3 +1,6 @@ +;; When the main thread calls proc_exit, it should terminate +;; a thread blocking in `memory.atomic.wait32` opecode. + (module (memory (export "memory") (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) diff --git a/test/testsuite/wasi_threads_exit_main_busy.wat b/test/testsuite/wasi_threads_exit_main_busy.wat index f8263b6..650e8a0 100644 --- a/test/testsuite/wasi_threads_exit_main_busy.wat +++ b/test/testsuite/wasi_threads_exit_main_busy.wat @@ -1,3 +1,6 @@ +;; When the main thread calls proc_exit, it should terminate +;; a busy-looping thread. + (module (memory (export "memory") (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) diff --git a/test/testsuite/wasi_threads_exit_main_wasi.wat b/test/testsuite/wasi_threads_exit_main_wasi.wat index 44d0db9..e9df52d 100644 --- a/test/testsuite/wasi_threads_exit_main_wasi.wat +++ b/test/testsuite/wasi_threads_exit_main_wasi.wat @@ -1,3 +1,6 @@ +;; When the main thread calls proc_exit, it should terminate +;; a thread blocking in a WASI call. (poll_oneoff) + (module (memory (export "memory") (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) diff --git a/test/testsuite/wasi_threads_exit_nonmain_block.wat b/test/testsuite/wasi_threads_exit_nonmain_block.wat index b990715..fda71fa 100644 --- a/test/testsuite/wasi_threads_exit_nonmain_block.wat +++ b/test/testsuite/wasi_threads_exit_nonmain_block.wat @@ -1,3 +1,6 @@ +;; When a non-main thread calls proc_exit, it should terminate +;; the main thread blocking in `memory.atomic.wait32` opecode. + (module (memory (export "memory") (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) diff --git a/test/testsuite/wasi_threads_exit_nonmain_busy.wat b/test/testsuite/wasi_threads_exit_nonmain_busy.wat index aaa1c42..972cec7 100644 --- a/test/testsuite/wasi_threads_exit_nonmain_busy.wat +++ b/test/testsuite/wasi_threads_exit_nonmain_busy.wat @@ -1,3 +1,6 @@ +;; When a non-main thread calls proc_exit, it should terminate +;; the main thread which is busy-looping. + (module (memory (export "memory") (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) diff --git a/test/testsuite/wasi_threads_exit_nonmain_wasi.wat b/test/testsuite/wasi_threads_exit_nonmain_wasi.wat index 8d03f0e..c14b121 100644 --- a/test/testsuite/wasi_threads_exit_nonmain_wasi.wat +++ b/test/testsuite/wasi_threads_exit_nonmain_wasi.wat @@ -1,3 +1,6 @@ +;; When a non-main thread calls proc_exit, it should terminate +;; the main thread which is blocking in a WASI call. (poll_oneoff) + (module (memory (export "memory") (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) diff --git a/test/testsuite/wasi_threads_spawn.wat b/test/testsuite/wasi_threads_spawn.wat index c92edf7..f99a10b 100644 --- a/test/testsuite/wasi_threads_spawn.wat +++ b/test/testsuite/wasi_threads_spawn.wat @@ -1,3 +1,5 @@ +;; Create a thread with thread-spawn and perform a few sanity checks. + (module (memory (export "memory") (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) From 0f6a4fd6858c66ee369d1b8c10d5b9bf9c6ebce8 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 23 Jan 2023 13:28:11 +0900 Subject: [PATCH 05/11] Rename build.sh to build-c.sh --- test/{build.sh => build-c.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{build.sh => build-c.sh} (100%) diff --git a/test/build.sh b/test/build-c.sh similarity index 100% rename from test/build.sh rename to test/build-c.sh From 3b4f5b75e344dafb8954475234ce206f22f7b233 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 23 Jan 2023 13:29:59 +0900 Subject: [PATCH 06/11] Add build.sh which invokes build-*.sh --- test/build.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 test/build.sh diff --git a/test/build.sh b/test/build.sh new file mode 100755 index 0000000..87ea830 --- /dev/null +++ b/test/build.sh @@ -0,0 +1,6 @@ +#! /bin/sh + +set -e + +./build-wat.sh +./build-c.sh From d12f78480146243e8aa4612def6dcdb63c3a5ed6 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 23 Jan 2023 13:31:38 +0900 Subject: [PATCH 07/11] Move build-*.sh into a separate directory --- test/build.sh | 4 ++-- test/{ => scripts}/build-c.sh | 0 test/{ => scripts}/build-wat.sh | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename test/{ => scripts}/build-c.sh (100%) rename test/{ => scripts}/build-wat.sh (100%) diff --git a/test/build.sh b/test/build.sh index 87ea830..86c4f5a 100755 --- a/test/build.sh +++ b/test/build.sh @@ -2,5 +2,5 @@ set -e -./build-wat.sh -./build-c.sh +./scripts/build-wat.sh +./scripts/build-c.sh diff --git a/test/build-c.sh b/test/scripts/build-c.sh similarity index 100% rename from test/build-c.sh rename to test/scripts/build-c.sh diff --git a/test/build-wat.sh b/test/scripts/build-wat.sh similarity index 100% rename from test/build-wat.sh rename to test/scripts/build-wat.sh From 43aaad221de8e441f067188ebee8e0e099f7a25c Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 23 Jan 2023 13:52:33 +0900 Subject: [PATCH 08/11] Give names to some locals and params in wat Also add some comments --- test/testsuite/wasi_threads_exit_main_block.wat | 3 +++ test/testsuite/wasi_threads_exit_main_busy.wat | 3 +++ test/testsuite/wasi_threads_exit_main_wasi.wat | 6 ++++++ .../wasi_threads_exit_nonmain_block.wat | 3 +++ .../wasi_threads_exit_nonmain_busy.wat | 3 +++ .../wasi_threads_exit_nonmain_wasi.wat | 6 ++++++ test/testsuite/wasi_threads_spawn.wat | 17 +++++++++++------ 7 files changed, 35 insertions(+), 6 deletions(-) diff --git a/test/testsuite/wasi_threads_exit_main_block.wat b/test/testsuite/wasi_threads_exit_main_block.wat index b75773c..12ac34f 100644 --- a/test/testsuite/wasi_threads_exit_main_block.wat +++ b/test/testsuite/wasi_threads_exit_main_block.wat @@ -1,5 +1,8 @@ ;; When the main thread calls proc_exit, it should terminate ;; a thread blocking in `memory.atomic.wait32` opecode. +;; +;; linear memory usage: +;; 0: notify/wait (module (memory (export "memory") (import "foo" "bar") 1 1 shared) diff --git a/test/testsuite/wasi_threads_exit_main_busy.wat b/test/testsuite/wasi_threads_exit_main_busy.wat index 650e8a0..7eb41cf 100644 --- a/test/testsuite/wasi_threads_exit_main_busy.wat +++ b/test/testsuite/wasi_threads_exit_main_busy.wat @@ -1,5 +1,8 @@ ;; When the main thread calls proc_exit, it should terminate ;; a busy-looping thread. +;; +;; linear memory usage: +;; 0: wait (module (memory (export "memory") (import "foo" "bar") 1 1 shared) diff --git a/test/testsuite/wasi_threads_exit_main_wasi.wat b/test/testsuite/wasi_threads_exit_main_wasi.wat index e9df52d..8a6f52b 100644 --- a/test/testsuite/wasi_threads_exit_main_wasi.wat +++ b/test/testsuite/wasi_threads_exit_main_wasi.wat @@ -1,5 +1,11 @@ ;; When the main thread calls proc_exit, it should terminate ;; a thread blocking in a WASI call. (poll_oneoff) +;; +;; linear memory usage: +;; 0: wait +;; 100: poll_oneoff subscription +;; 200: poll_oneoff event +;; 300: poll_oneoff return value (module (memory (export "memory") (import "foo" "bar") 1 1 shared) diff --git a/test/testsuite/wasi_threads_exit_nonmain_block.wat b/test/testsuite/wasi_threads_exit_nonmain_block.wat index fda71fa..41b7945 100644 --- a/test/testsuite/wasi_threads_exit_nonmain_block.wat +++ b/test/testsuite/wasi_threads_exit_nonmain_block.wat @@ -1,5 +1,8 @@ ;; When a non-main thread calls proc_exit, it should terminate ;; the main thread blocking in `memory.atomic.wait32` opecode. +;; +;; linear memory usage: +;; 0: wait (module (memory (export "memory") (import "foo" "bar") 1 1 shared) diff --git a/test/testsuite/wasi_threads_exit_nonmain_busy.wat b/test/testsuite/wasi_threads_exit_nonmain_busy.wat index 972cec7..e4e681c 100644 --- a/test/testsuite/wasi_threads_exit_nonmain_busy.wat +++ b/test/testsuite/wasi_threads_exit_nonmain_busy.wat @@ -1,5 +1,8 @@ ;; When a non-main thread calls proc_exit, it should terminate ;; the main thread which is busy-looping. +;; +;; linear memory usage: +;; 0: wait (module (memory (export "memory") (import "foo" "bar") 1 1 shared) diff --git a/test/testsuite/wasi_threads_exit_nonmain_wasi.wat b/test/testsuite/wasi_threads_exit_nonmain_wasi.wat index c14b121..fd729e3 100644 --- a/test/testsuite/wasi_threads_exit_nonmain_wasi.wat +++ b/test/testsuite/wasi_threads_exit_nonmain_wasi.wat @@ -1,5 +1,11 @@ ;; When a non-main thread calls proc_exit, it should terminate ;; the main thread which is blocking in a WASI call. (poll_oneoff) +;; +;; linear memory usage: +;; 0: wait +;; 100: poll_oneoff subscription +;; 200: poll_oneoff event +;; 300: poll_oneoff return value (module (memory (export "memory") (import "foo" "bar") 1 1 shared) diff --git a/test/testsuite/wasi_threads_spawn.wat b/test/testsuite/wasi_threads_spawn.wat index f99a10b..078969b 100644 --- a/test/testsuite/wasi_threads_spawn.wat +++ b/test/testsuite/wasi_threads_spawn.wat @@ -1,17 +1,22 @@ ;; Create a thread with thread-spawn and perform a few sanity checks. +;; linear memory usage: +;; 0: notify/wait +;; 4: tid +;; 8: user_arg + (module (memory (export "memory") (import "foo" "bar") 1 1 shared) (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) - (func (export "wasi_thread_start") (param i32 i32) + (func (export "wasi_thread_start") (param $tid i32) (param $user_arg i32) ;; store tid i32.const 4 - local.get 0 + local.get $tid i32.store ;; store user pointer i32.const 8 - local.get 1 + local.get $user_arg i32.store ;; notify the main i32.const 0 @@ -23,12 +28,12 @@ drop ;; returning from wasi_thread_start terminates only this thread ) - (func (export "_start") (local i32) + (func (export "_start") (local $tid i32) ;; spawn a thread i32.const 12345 ;; user pointer call $thread_spawn ;; check error - local.tee 0 ;; save the tid to check later + local.tee $tid ;; save the tid to check later i32.const 0 i32.le_s if @@ -46,7 +51,7 @@ unreachable end ;; check the tid - local.get 0 + local.get $tid i32.const 4 i32.load i32.ne From 276bd4799e508d7ec3fb0544ac9ed158e029f816 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 23 Jan 2023 17:27:04 +0900 Subject: [PATCH 09/11] wasi_threads_spawn.wat: sprinkle a few memory fences While I suspect wait and notify are memory barriers for most implementations, it's safer to issue explicit fences. --- test/testsuite/wasi_threads_spawn.wat | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/testsuite/wasi_threads_spawn.wat b/test/testsuite/wasi_threads_spawn.wat index 078969b..b855229 100644 --- a/test/testsuite/wasi_threads_spawn.wat +++ b/test/testsuite/wasi_threads_spawn.wat @@ -18,6 +18,8 @@ i32.const 8 local.get $user_arg i32.store + ;; store fence + atomic.fence ;; notify the main i32.const 0 i32.const 1 @@ -50,6 +52,8 @@ if unreachable end + ;; load fence + atomic.fence ;; check the tid local.get $tid i32.const 4 From 7164d4be5e6a0f147e09ed09694ceccf882104ad Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 24 Jan 2023 07:53:00 +0900 Subject: [PATCH 10/11] opecode -> opcode in comments --- test/testsuite/wasi_threads_exit_main_block.wat | 2 +- test/testsuite/wasi_threads_exit_nonmain_block.wat | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/testsuite/wasi_threads_exit_main_block.wat b/test/testsuite/wasi_threads_exit_main_block.wat index 12ac34f..62f9c0b 100644 --- a/test/testsuite/wasi_threads_exit_main_block.wat +++ b/test/testsuite/wasi_threads_exit_main_block.wat @@ -1,5 +1,5 @@ ;; When the main thread calls proc_exit, it should terminate -;; a thread blocking in `memory.atomic.wait32` opecode. +;; a thread blocking in `memory.atomic.wait32` opcode. ;; ;; linear memory usage: ;; 0: notify/wait diff --git a/test/testsuite/wasi_threads_exit_nonmain_block.wat b/test/testsuite/wasi_threads_exit_nonmain_block.wat index 41b7945..615fee3 100644 --- a/test/testsuite/wasi_threads_exit_nonmain_block.wat +++ b/test/testsuite/wasi_threads_exit_nonmain_block.wat @@ -1,5 +1,5 @@ ;; When a non-main thread calls proc_exit, it should terminate -;; the main thread blocking in `memory.atomic.wait32` opecode. +;; the main thread blocking in `memory.atomic.wait32` opcode. ;; ;; linear memory usage: ;; 0: wait From 9082bcaba44bc6ec4f954c05e235e6eab8cce638 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 1 Feb 2023 14:11:01 +0900 Subject: [PATCH 11/11] Rename thread_spawn to thread-spawn in wat tests cf. https://github.com/WebAssembly/wasi-threads/pull/26 https://github.com/WebAssembly/wasi-libc/pull/387 --- test/testsuite/wasi_threads_exit_main_block.wat | 2 +- test/testsuite/wasi_threads_exit_main_busy.wat | 2 +- test/testsuite/wasi_threads_exit_main_wasi.wat | 2 +- test/testsuite/wasi_threads_exit_nonmain_block.wat | 2 +- test/testsuite/wasi_threads_exit_nonmain_busy.wat | 2 +- test/testsuite/wasi_threads_exit_nonmain_wasi.wat | 2 +- test/testsuite/wasi_threads_spawn.wat | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/testsuite/wasi_threads_exit_main_block.wat b/test/testsuite/wasi_threads_exit_main_block.wat index 62f9c0b..d6e5900 100644 --- a/test/testsuite/wasi_threads_exit_main_block.wat +++ b/test/testsuite/wasi_threads_exit_main_block.wat @@ -6,7 +6,7 @@ (module (memory (export "memory") (import "foo" "bar") 1 1 shared) - (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) + (func $thread_spawn (import "wasi" "thread-spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func (export "wasi_thread_start") (param i32 i32) ;; infinite wait diff --git a/test/testsuite/wasi_threads_exit_main_busy.wat b/test/testsuite/wasi_threads_exit_main_busy.wat index 7eb41cf..3ea7709 100644 --- a/test/testsuite/wasi_threads_exit_main_busy.wat +++ b/test/testsuite/wasi_threads_exit_main_busy.wat @@ -6,7 +6,7 @@ (module (memory (export "memory") (import "foo" "bar") 1 1 shared) - (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) + (func $thread_spawn (import "wasi" "thread-spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func (export "wasi_thread_start") (param i32 i32) ;; infinite loop diff --git a/test/testsuite/wasi_threads_exit_main_wasi.wat b/test/testsuite/wasi_threads_exit_main_wasi.wat index 8a6f52b..34e65d6 100644 --- a/test/testsuite/wasi_threads_exit_main_wasi.wat +++ b/test/testsuite/wasi_threads_exit_main_wasi.wat @@ -9,7 +9,7 @@ (module (memory (export "memory") (import "foo" "bar") 1 1 shared) - (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) + (func $thread_spawn (import "wasi" "thread-spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func $poll_oneoff (import "wasi_snapshot_preview1" "poll_oneoff") (param i32 i32 i32 i32) (result i32)) (func (export "wasi_thread_start") (param i32 i32) diff --git a/test/testsuite/wasi_threads_exit_nonmain_block.wat b/test/testsuite/wasi_threads_exit_nonmain_block.wat index 615fee3..36428bd 100644 --- a/test/testsuite/wasi_threads_exit_nonmain_block.wat +++ b/test/testsuite/wasi_threads_exit_nonmain_block.wat @@ -6,7 +6,7 @@ (module (memory (export "memory") (import "foo" "bar") 1 1 shared) - (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) + (func $thread_spawn (import "wasi" "thread-spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func (export "wasi_thread_start") (param i32 i32) ;; wait 500ms to ensure the other thread block diff --git a/test/testsuite/wasi_threads_exit_nonmain_busy.wat b/test/testsuite/wasi_threads_exit_nonmain_busy.wat index e4e681c..b256b0d 100644 --- a/test/testsuite/wasi_threads_exit_nonmain_busy.wat +++ b/test/testsuite/wasi_threads_exit_nonmain_busy.wat @@ -6,7 +6,7 @@ (module (memory (export "memory") (import "foo" "bar") 1 1 shared) - (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) + (func $thread_spawn (import "wasi" "thread-spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func (export "wasi_thread_start") (param i32 i32) ;; wait 500ms to ensure the other thread to enter the busy loop diff --git a/test/testsuite/wasi_threads_exit_nonmain_wasi.wat b/test/testsuite/wasi_threads_exit_nonmain_wasi.wat index fd729e3..3e1ed4a 100644 --- a/test/testsuite/wasi_threads_exit_nonmain_wasi.wat +++ b/test/testsuite/wasi_threads_exit_nonmain_wasi.wat @@ -9,7 +9,7 @@ (module (memory (export "memory") (import "foo" "bar") 1 1 shared) - (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) + (func $thread_spawn (import "wasi" "thread-spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func $poll_oneoff (import "wasi_snapshot_preview1" "poll_oneoff") (param i32 i32 i32 i32) (result i32)) (func (export "wasi_thread_start") (param i32 i32) diff --git a/test/testsuite/wasi_threads_spawn.wat b/test/testsuite/wasi_threads_spawn.wat index b855229..74086c9 100644 --- a/test/testsuite/wasi_threads_spawn.wat +++ b/test/testsuite/wasi_threads_spawn.wat @@ -7,7 +7,7 @@ (module (memory (export "memory") (import "foo" "bar") 1 1 shared) - (func $thread_spawn (import "wasi" "thread_spawn") (param i32) (result i32)) + (func $thread_spawn (import "wasi" "thread-spawn") (param i32) (result i32)) (func $proc_exit (import "wasi_snapshot_preview1" "proc_exit") (param i32)) (func (export "wasi_thread_start") (param $tid i32) (param $user_arg i32) ;; store tid