Add a few CLI tests for WASI. (#1281)
While here, move rs2wasm-add-func.wat into the same directory as the other .wat tests to keep things tidy.
This commit is contained in:
25
tests/wasm/hello_wasi_snapshot0.wat
Normal file
25
tests/wasm/hello_wasi_snapshot0.wat
Normal file
@@ -0,0 +1,25 @@
|
||||
(module
|
||||
(import "wasi_unstable" "proc_exit"
|
||||
(func $__wasi_proc_exit (param i32)))
|
||||
(import "wasi_unstable" "fd_write"
|
||||
(func $__wasi_fd_write (param i32 i32 i32 i32) (result i32)))
|
||||
(func $_start
|
||||
(i32.store (i32.const 24) (i32.const 14))
|
||||
(i32.store (i32.const 20) (i32.const 0))
|
||||
(block
|
||||
(br_if 0
|
||||
(call $__wasi_fd_write
|
||||
(i32.const 1)
|
||||
(i32.const 20)
|
||||
(i32.const 1)
|
||||
(i32.const 16)))
|
||||
(br_if 0 (i32.ne (i32.load (i32.const 16)) (i32.const 14)))
|
||||
(br 1)
|
||||
)
|
||||
(call $__wasi_proc_exit (i32.const 1))
|
||||
)
|
||||
(memory 1)
|
||||
(export "memory" (memory 0))
|
||||
(export "_start" (func $_start))
|
||||
(data (i32.const 0) "Hello, world!\0a")
|
||||
)
|
||||
25
tests/wasm/hello_wasi_snapshot1.wat
Normal file
25
tests/wasm/hello_wasi_snapshot1.wat
Normal file
@@ -0,0 +1,25 @@
|
||||
(module
|
||||
(import "wasi_snapshot_preview1" "proc_exit"
|
||||
(func $__wasi_proc_exit (param i32)))
|
||||
(import "wasi_snapshot_preview1" "fd_write"
|
||||
(func $__wasi_fd_write (param i32 i32 i32 i32) (result i32)))
|
||||
(func $_start
|
||||
(i32.store (i32.const 24) (i32.const 14))
|
||||
(i32.store (i32.const 20) (i32.const 0))
|
||||
(block
|
||||
(br_if 0
|
||||
(call $__wasi_fd_write
|
||||
(i32.const 1)
|
||||
(i32.const 20)
|
||||
(i32.const 1)
|
||||
(i32.const 16)))
|
||||
(br_if 0 (i32.ne (i32.load (i32.const 16)) (i32.const 14)))
|
||||
(br 1)
|
||||
)
|
||||
(call $__wasi_proc_exit (i32.const 1))
|
||||
)
|
||||
(memory 1)
|
||||
(export "memory" (memory 0))
|
||||
(export "_start" (func $_start))
|
||||
(data (i32.const 0) "Hello, world!\0a")
|
||||
)
|
||||
20
tests/wasm/rs2wasm-add-func.wat
Normal file
20
tests/wasm/rs2wasm-add-func.wat
Normal file
@@ -0,0 +1,20 @@
|
||||
(module
|
||||
(type (;0;) (func))
|
||||
(type (;1;) (func (param i32 i32) (result i32)))
|
||||
(func $add (type 1) (param i32 i32) (result i32)
|
||||
get_local 1
|
||||
get_local 0
|
||||
i32.add)
|
||||
(func $start (type 0))
|
||||
(table (;0;) 1 1 anyfunc)
|
||||
(memory (;0;) 17)
|
||||
(global (;0;) i32 (i32.const 1049114))
|
||||
(global (;1;) i32 (i32.const 1049114))
|
||||
(export "memory" (memory 0))
|
||||
(export "__indirect_function_table" (table 0))
|
||||
(export "__heap_base" (global 0))
|
||||
(export "__data_end" (global 1))
|
||||
(export "add" (func $add))
|
||||
(export "start" (func $start))
|
||||
(data (i32.const 1048576) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00")
|
||||
(data (i32.const 1049092) "invalid malloc request"))
|
||||
Reference in New Issue
Block a user