generated from WebAssembly/wasi-proposal-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
``` (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% ``` * import shared memory in wat tests as suggested in WebAssembly/wasi-libc#369 the corresponding toywasm change: yamt/toywasm@4d81846 ``` 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% ```
- Loading branch information
Showing
17 changed files
with
407 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,6 @@ | ||
#!/bin/bash | ||
#! /bin/sh | ||
|
||
CC=${CC:=clang} | ||
set -e | ||
|
||
for input in testsuite/*.c; do | ||
output="testsuite/$(basename $input .c).wasm" | ||
|
||
if [ "$input" -nt "$output" ]; then | ||
echo "Compiling $input" | ||
$CC "$input" testsuite/wasi_thread_spawn.S -o "$output" | ||
fi | ||
done | ||
./scripts/build-wat.sh | ||
./scripts/build-c.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
CC=${CC:=clang} | ||
|
||
for input in testsuite/*.c; do | ||
output="testsuite/$(basename $input .c).wasm" | ||
|
||
if [ "$input" -nt "$output" ]; then | ||
echo "Compiling $input" | ||
$CC "$input" testsuite/wasi_thread_spawn.S -o "$output" | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#! /bin/sh | ||
|
||
WAT2WASM=${WAT2WASM:-wat2wasm} | ||
for wat in testsuite/*.wat; do | ||
${WAT2WASM} --enable-threads -o ${wat%%.wat}.wasm ${wat} | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"exit_code": 99 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
;; When the main thread calls proc_exit, it should terminate | ||
;; a thread blocking in `memory.atomic.wait32` opcode. | ||
;; | ||
;; linear memory usage: | ||
;; 0: notify/wait | ||
|
||
(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) | ||
;; 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 | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"exit_code": 99 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
;; 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) | ||
(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 | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"exit_code": 99 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
;; 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) | ||
(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 | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"exit_code": 99 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
;; When a non-main thread calls proc_exit, it should terminate | ||
;; the main thread blocking in `memory.atomic.wait32` opcode. | ||
;; | ||
;; linear memory usage: | ||
;; 0: wait | ||
|
||
(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) | ||
;; 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 | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"exit_code": 99 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
;; 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) | ||
(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 | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"exit_code": 99 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
;; 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) | ||
(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 | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"exit_code": 22 | ||
} |
Oops, something went wrong.