diff options
Diffstat (limited to 'test/ctor-eval/ignore-external-input.wast')
-rw-r--r-- | test/ctor-eval/ignore-external-input.wast | 63 |
1 files changed, 63 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) + ) + ) +) |