diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ctor-eval/ignore-external-input.wast | 63 | ||||
-rw-r--r-- | test/ctor-eval/ignore-external-input.wast.ctors | 1 | ||||
-rw-r--r-- | test/ctor-eval/ignore-external-input.wast.out | 17 | ||||
-rw-r--r-- | test/lit/help/wasm-ctor-eval.test | 3 |
4 files changed, 84 insertions, 0 deletions
diff --git a/test/ctor-eval/ignore-external-input.wast b/test/ctor-eval/ignore-external-input.wast new file mode 100644 index 000000000..0849c67ab --- /dev/null +++ b/test/ctor-eval/ignore-external-input.wast @@ -0,0 +1,63 @@ +(module + (import "wasi_snapshot_preview1" "environ_sizes_get" (func $wasi_environ_sizes_get (param i32 i32) (result i32))) + (import "wasi_snapshot_preview1" "environ_get" (func $wasi_environ_get (param i32 i32) (result i32))) + + (import "wasi_snapshot_preview1" "args_sizes_get" (func $wasi_args_sizes_get (param i32 i32) (result i32))) + (import "wasi_snapshot_preview1" "args_get" (func $wasi_args_get (param i32 i32) (result i32))) + + (import "wasi_snapshot_preview1" "something_else" (func $wasi_something_else (result i32))) + + (memory 256 256) + (data (i32.const 0) "aaaaaaaaaaaaaaaaaaaaaaaaaaaa") ;; the final 4 'a's will remain + + (func "test1" + ;; This is ok to call: when ignoring external input we assume there is no + ;; environment to read. + (i32.store + (i32.const 0) ;; the result (0) will be written to address 0 + (call $wasi_environ_sizes_get + (i32.const 4) ;; count (0) will be written to address 4 + (i32.const 0) + ) + ) + (i32.store + (i32.const 8) ;; the result (0) will be written to address 8 + (call $wasi_environ_get + (i32.const 0) + (i32.const 0) + ) + ) + ) + + (func "test2" + ;; This is also ok to call: when ignoring external input we assume there are + ;; not args passed to main. + (i32.store + (i32.const 12) ;; the result (0) will be written to address 12 + (call $wasi_args_sizes_get + (i32.const 16) ;; argc (0) will be written to address 16 + (i32.const 0) + ) + ) + (i32.store + (i32.const 20) ;; the result (0) will be written to address 20 + (call $wasi_args_get + (i32.const 0) + (i32.const 0) + ) + ) + ) + + (func "test3" + ;; This is *not* ok to call, and we will *not* reach the final store after + ;; this call. This function will not be evalled and will remain in the + ;; output. + (drop + (call $wasi_something_else) + ) + (i32.store + (i32.const 24) + (i32.const 100) + ) + ) +) diff --git a/test/ctor-eval/ignore-external-input.wast.ctors b/test/ctor-eval/ignore-external-input.wast.ctors new file mode 100644 index 000000000..c7060ede5 --- /dev/null +++ b/test/ctor-eval/ignore-external-input.wast.ctors @@ -0,0 +1 @@ +test1,test2,test3 diff --git a/test/ctor-eval/ignore-external-input.wast.out b/test/ctor-eval/ignore-external-input.wast.out new file mode 100644 index 000000000..f728afd0e --- /dev/null +++ b/test/ctor-eval/ignore-external-input.wast.out @@ -0,0 +1,17 @@ +(module + (type $none_=>_i32 (func (result i32))) + (type $none_=>_none (func)) + (import "wasi_snapshot_preview1" "something_else" (func $wasi_something_else (result i32))) + (memory $0 256 256) + (data (i32.const 24) "aaaa") + (export "test3" (func $2)) + (func $2 + (drop + (call $wasi_something_else) + ) + (i32.store + (i32.const 24) + (i32.const 100) + ) + ) +) diff --git a/test/lit/help/wasm-ctor-eval.test b/test/lit/help/wasm-ctor-eval.test index cf0671c81..364ac5d4c 100644 --- a/test/lit/help/wasm-ctor-eval.test +++ b/test/lit/help/wasm-ctor-eval.test @@ -19,6 +19,9 @@ ;; CHECK-NEXT: --ctors,-c Comma-separated list of global ;; CHECK-NEXT: constructor functions to evaluate ;; CHECK-NEXT: +;; CHECK-NEXT: --ignore-external-input,-ipi Assumes no env vars are to be read, stdin +;; CHECK-NEXT: is empty, etc. +;; CHECK-NEXT: ;; CHECK-NEXT: ;; CHECK-NEXT: Tool options: ;; CHECK-NEXT: ------------- |