refactor: move Wasm test files to tests/all/cli_tests

Previously the inputs to `tests/all/cli_tests.rs` were contained in
`tests/wasm`. This change moves them to the more obvious
`tests/all/cli_tests` directory and updates the paths that point to
them.
This commit is contained in:
Andrew Brown
2021-07-21 13:40:57 -07:00
parent 3309b1a684
commit 4deed8fe50
21 changed files with 25 additions and 25 deletions

View File

@@ -55,7 +55,7 @@ fn build_wasm(wat_path: impl AsRef<Path>) -> Result<NamedTempFile> {
// Very basic use case: compile binary wasm file and run specific function with arguments.
#[test]
fn run_wasmtime_simple() -> Result<()> {
let wasm = build_wasm("tests/wasm/simple.wat")?;
let wasm = build_wasm("tests/all/cli_tests/simple.wat")?;
run_wasmtime(&[
"run",
wasm.path().to_str().unwrap(),
@@ -70,7 +70,7 @@ fn run_wasmtime_simple() -> Result<()> {
// Wasmtime shakk when not enough arguments were provided.
#[test]
fn run_wasmtime_simple_fail_no_args() -> Result<()> {
let wasm = build_wasm("tests/wasm/simple.wat")?;
let wasm = build_wasm("tests/all/cli_tests/simple.wat")?;
assert!(
run_wasmtime(&[
"run",
@@ -88,7 +88,7 @@ fn run_wasmtime_simple_fail_no_args() -> Result<()> {
// Running simple wat
#[test]
fn run_wasmtime_simple_wat() -> Result<()> {
let wasm = build_wasm("tests/wasm/simple.wat")?;
let wasm = build_wasm("tests/all/cli_tests/simple.wat")?;
run_wasmtime(&[
"run",
wasm.path().to_str().unwrap(),
@@ -123,7 +123,7 @@ fn run_wasmtime_simple_wat() -> Result<()> {
// Running a wat that traps.
#[test]
fn run_wasmtime_unreachable_wat() -> Result<()> {
let wasm = build_wasm("tests/wasm/unreachable.wat")?;
let wasm = build_wasm("tests/all/cli_tests/unreachable.wat")?;
let output = run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"])?;
assert_ne!(output.stderr, b"");
@@ -146,7 +146,7 @@ fn run_wasmtime_unreachable_wat() -> Result<()> {
// Run a simple WASI hello world, snapshot0 edition.
#[test]
fn hello_wasi_snapshot0() -> Result<()> {
let wasm = build_wasm("tests/wasm/hello_wasi_snapshot0.wat")?;
let wasm = build_wasm("tests/all/cli_tests/hello_wasi_snapshot0.wat")?;
let stdout = run_wasmtime(&[wasm.path().to_str().unwrap(), "--disable-cache"])?;
assert_eq!(stdout, "Hello, world!\n");
Ok(())
@@ -155,7 +155,7 @@ fn hello_wasi_snapshot0() -> Result<()> {
// Run a simple WASI hello world, snapshot1 edition.
#[test]
fn hello_wasi_snapshot1() -> Result<()> {
let wasm = build_wasm("tests/wasm/hello_wasi_snapshot1.wat")?;
let wasm = build_wasm("tests/all/cli_tests/hello_wasi_snapshot1.wat")?;
let stdout = run_wasmtime(&[wasm.path().to_str().unwrap(), "--disable-cache"])?;
assert_eq!(stdout, "Hello, world!\n");
Ok(())
@@ -163,7 +163,7 @@ fn hello_wasi_snapshot1() -> Result<()> {
#[test]
fn timeout_in_start() -> Result<()> {
let wasm = build_wasm("tests/wasm/iloop-start.wat")?;
let wasm = build_wasm("tests/all/cli_tests/iloop-start.wat")?;
let output = run_wasmtime_for_output(&[
"run",
wasm.path().to_str().unwrap(),
@@ -184,7 +184,7 @@ fn timeout_in_start() -> Result<()> {
#[test]
fn timeout_in_invoke() -> Result<()> {
let wasm = build_wasm("tests/wasm/iloop-invoke.wat")?;
let wasm = build_wasm("tests/all/cli_tests/iloop-invoke.wat")?;
let output = run_wasmtime_for_output(&[
"run",
wasm.path().to_str().unwrap(),
@@ -206,7 +206,7 @@ fn timeout_in_invoke() -> Result<()> {
// Exit with a valid non-zero exit code, snapshot0 edition.
#[test]
fn exit2_wasi_snapshot0() -> Result<()> {
let wasm = build_wasm("tests/wasm/exit2_wasi_snapshot0.wat")?;
let wasm = build_wasm("tests/all/cli_tests/exit2_wasi_snapshot0.wat")?;
let output = run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"])?;
assert_eq!(output.status.code().unwrap(), 2);
Ok(())
@@ -215,7 +215,7 @@ fn exit2_wasi_snapshot0() -> Result<()> {
// Exit with a valid non-zero exit code, snapshot1 edition.
#[test]
fn exit2_wasi_snapshot1() -> Result<()> {
let wasm = build_wasm("tests/wasm/exit2_wasi_snapshot1.wat")?;
let wasm = build_wasm("tests/all/cli_tests/exit2_wasi_snapshot1.wat")?;
let output = run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"])?;
assert_eq!(output.status.code().unwrap(), 2);
Ok(())
@@ -224,7 +224,7 @@ fn exit2_wasi_snapshot1() -> Result<()> {
// Exit with a valid non-zero exit code, snapshot0 edition.
#[test]
fn exit125_wasi_snapshot0() -> Result<()> {
let wasm = build_wasm("tests/wasm/exit125_wasi_snapshot0.wat")?;
let wasm = build_wasm("tests/all/cli_tests/exit125_wasi_snapshot0.wat")?;
let output = run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"])?;
if cfg!(windows) {
assert_eq!(output.status.code().unwrap(), 1);
@@ -237,7 +237,7 @@ fn exit125_wasi_snapshot0() -> Result<()> {
// Exit with a valid non-zero exit code, snapshot1 edition.
#[test]
fn exit125_wasi_snapshot1() -> Result<()> {
let wasm = build_wasm("tests/wasm/exit125_wasi_snapshot1.wat")?;
let wasm = build_wasm("tests/all/cli_tests/exit125_wasi_snapshot1.wat")?;
let output = run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"])?;
if cfg!(windows) {
assert_eq!(output.status.code().unwrap(), 1);
@@ -250,7 +250,7 @@ fn exit125_wasi_snapshot1() -> Result<()> {
// Exit with an invalid non-zero exit code, snapshot0 edition.
#[test]
fn exit126_wasi_snapshot0() -> Result<()> {
let wasm = build_wasm("tests/wasm/exit126_wasi_snapshot0.wat")?;
let wasm = build_wasm("tests/all/cli_tests/exit126_wasi_snapshot0.wat")?;
let output = run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"])?;
if cfg!(windows) {
assert_eq!(output.status.code().unwrap(), 3);
@@ -265,7 +265,7 @@ fn exit126_wasi_snapshot0() -> Result<()> {
// Exit with an invalid non-zero exit code, snapshot1 edition.
#[test]
fn exit126_wasi_snapshot1() -> Result<()> {
let wasm = build_wasm("tests/wasm/exit126_wasi_snapshot1.wat")?;
let wasm = build_wasm("tests/all/cli_tests/exit126_wasi_snapshot1.wat")?;
let output = run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"])?;
if cfg!(windows) {
assert_eq!(output.status.code().unwrap(), 3);
@@ -280,7 +280,7 @@ fn exit126_wasi_snapshot1() -> Result<()> {
// Run a minimal command program.
#[test]
fn minimal_command() -> Result<()> {
let wasm = build_wasm("tests/wasm/minimal-command.wat")?;
let wasm = build_wasm("tests/all/cli_tests/minimal-command.wat")?;
let stdout = run_wasmtime(&[wasm.path().to_str().unwrap(), "--disable-cache"])?;
assert_eq!(stdout, "");
Ok(())
@@ -289,7 +289,7 @@ fn minimal_command() -> Result<()> {
// Run a minimal reactor program.
#[test]
fn minimal_reactor() -> Result<()> {
let wasm = build_wasm("tests/wasm/minimal-reactor.wat")?;
let wasm = build_wasm("tests/all/cli_tests/minimal-reactor.wat")?;
let stdout = run_wasmtime(&[wasm.path().to_str().unwrap(), "--disable-cache"])?;
assert_eq!(stdout, "");
Ok(())
@@ -298,7 +298,7 @@ fn minimal_reactor() -> Result<()> {
// Attempt to call invoke on a command.
#[test]
fn command_invoke() -> Result<()> {
let wasm = build_wasm("tests/wasm/minimal-command.wat")?;
let wasm = build_wasm("tests/all/cli_tests/minimal-command.wat")?;
run_wasmtime(&[
"run",
wasm.path().to_str().unwrap(),
@@ -312,7 +312,7 @@ fn command_invoke() -> Result<()> {
// Attempt to call invoke on a command.
#[test]
fn reactor_invoke() -> Result<()> {
let wasm = build_wasm("tests/wasm/minimal-reactor.wat")?;
let wasm = build_wasm("tests/all/cli_tests/minimal-reactor.wat")?;
run_wasmtime(&[
"run",
wasm.path().to_str().unwrap(),
@@ -326,13 +326,13 @@ fn reactor_invoke() -> Result<()> {
// Run the greeter test, which runs a preloaded reactor and a command.
#[test]
fn greeter() -> Result<()> {
let wasm = build_wasm("tests/wasm/greeter_command.wat")?;
let wasm = build_wasm("tests/all/cli_tests/greeter_command.wat")?;
let stdout = run_wasmtime(&[
"run",
wasm.path().to_str().unwrap(),
"--disable-cache",
"--preload",
"reactor=tests/wasm/greeter_reactor.wat",
"reactor=tests/all/cli_tests/greeter_reactor.wat",
])?;
assert_eq!(
stdout,
@@ -344,13 +344,13 @@ fn greeter() -> Result<()> {
// Run the greeter test, but this time preload a command.
#[test]
fn greeter_preload_command() -> Result<()> {
let wasm = build_wasm("tests/wasm/greeter_reactor.wat")?;
let wasm = build_wasm("tests/all/cli_tests/greeter_reactor.wat")?;
let stdout = run_wasmtime(&[
"run",
wasm.path().to_str().unwrap(),
"--disable-cache",
"--preload",
"reactor=tests/wasm/hello_wasi_snapshot1.wat",
"reactor=tests/all/cli_tests/hello_wasi_snapshot1.wat",
])?;
assert_eq!(stdout, "Hello _initialize\n");
Ok(())
@@ -359,13 +359,13 @@ fn greeter_preload_command() -> Result<()> {
// Run the greeter test, which runs a preloaded reactor and a command.
#[test]
fn greeter_preload_callable_command() -> Result<()> {
let wasm = build_wasm("tests/wasm/greeter_command.wat")?;
let wasm = build_wasm("tests/all/cli_tests/greeter_command.wat")?;
let stdout = run_wasmtime(&[
"run",
wasm.path().to_str().unwrap(),
"--disable-cache",
"--preload",
"reactor=tests/wasm/greeter_callable_command.wat",
"reactor=tests/all/cli_tests/greeter_callable_command.wat",
])?;
assert_eq!(stdout, "Hello _start\nHello callable greet\nHello done\n");
Ok(())
@@ -375,7 +375,7 @@ fn greeter_preload_callable_command() -> Result<()> {
// See https://github.com/bytecodealliance/wasmtime/issues/1967
#[test]
fn exit_with_saved_fprs() -> Result<()> {
let wasm = build_wasm("tests/wasm/exit_with_saved_fprs.wat")?;
let wasm = build_wasm("tests/all/cli_tests/exit_with_saved_fprs.wat")?;
let output = run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"])?;
assert_eq!(output.status.code().unwrap(), 0);
assert!(output.stdout.is_empty());

View File

@@ -0,0 +1,9 @@
(module
(import "wasi_unstable" "proc_exit"
(func $__wasi_proc_exit (param i32)))
(memory (export "memory") 0)
(func $_start
(call $__wasi_proc_exit (i32.const 125))
)
(export "_start" (func $_start))
)

View File

@@ -0,0 +1,9 @@
(module
(import "wasi_snapshot_preview1" "proc_exit"
(func $__wasi_proc_exit (param i32)))
(memory (export "memory") 0)
(func $_start
(call $__wasi_proc_exit (i32.const 125))
)
(export "_start" (func $_start))
)

View File

@@ -0,0 +1,9 @@
(module
(import "wasi_unstable" "proc_exit"
(func $__wasi_proc_exit (param i32)))
(memory (export "memory") 0)
(func $_start
(call $__wasi_proc_exit (i32.const 126))
)
(export "_start" (func $_start))
)

View File

@@ -0,0 +1,9 @@
(module
(import "wasi_snapshot_preview1" "proc_exit"
(func $__wasi_proc_exit (param i32)))
(memory (export "memory") 0)
(func $_start
(call $__wasi_proc_exit (i32.const 126))
)
(export "_start" (func $_start))
)

View File

@@ -0,0 +1,9 @@
(module
(import "wasi_unstable" "proc_exit"
(func $__wasi_proc_exit (param i32)))
(memory (export "memory") 0)
(func $_start
(call $__wasi_proc_exit (i32.const 2))
)
(export "_start" (func $_start))
)

View File

@@ -0,0 +1,9 @@
(module
(import "wasi_snapshot_preview1" "proc_exit"
(func $__wasi_proc_exit (param i32)))
(memory (export "memory") 0)
(func $_start
(call $__wasi_proc_exit (i32.const 2))
)
(export "_start" (func $_start))
)

View File

@@ -0,0 +1,41 @@
;;; This is a test case for https://github.com/bytecodealliance/wasmtime/issues/1967
(module
(type (func (param i32)))
(import "wasi_snapshot_preview1" "proc_exit" (func (type 0)))
(memory (export "memory") 0)
(func $exit (param i32)
local.get 0
call 0
unreachable
)
(func $do_something (param f64 f64 f64 f64 f64 f64 f64 f64)
i32.const 0
call $exit
unreachable
)
(func $has_saved_fprs (export "_start")
(local f64 f64 f64 f64 f64 f64 f64 f64)
(local.set 0 (f64.const 1))
(local.set 1 (f64.const 2))
(local.set 2 (f64.const 3))
(local.set 3 (f64.const 4))
(local.set 4 (f64.const 5))
(local.set 5 (f64.const 6))
(local.set 6 (f64.const 7))
(local.set 7 (f64.const 8))
local.get 0
local.get 1
local.get 2
local.get 3
local.get 4
local.get 5
local.get 6
local.get 7
call $do_something
unreachable
)
)

View File

@@ -0,0 +1,23 @@
;; Like greeter_reactor, but exports "_start" instead of "_initialize".
(module
(import "wasi_snapshot_preview1" "fd_write"
(func $__wasi_fd_write (param i32 i32 i32 i32) (result i32)))
(func (export "_start")
(call $print (i32.const 32) (i32.const 22))
)
(func (export "greet")
(call $print (i32.const 64) (i32.const 21))
)
(func $print (param $ptr i32) (param $len i32)
(i32.store (i32.const 8) (local.get $len))
(i32.store (i32.const 4) (local.get $ptr))
(drop (call $__wasi_fd_write
(i32.const 1)
(i32.const 4)
(i32.const 1)
(i32.const 0)))
)
(memory (export "memory") 1)
(data (i32.const 32) "Hello callable _start\0a")
(data (i32.const 64) "Hello callable greet\0a")
)

View File

@@ -0,0 +1,22 @@
(module
(import "wasi_snapshot_preview1" "fd_write"
(func $__wasi_fd_write (param i32 i32 i32 i32) (result i32)))
(import "reactor" "greet" (func $greet))
(func (export "_start")
(call $print (i32.const 32) (i32.const 13))
(call $greet)
(call $print (i32.const 64) (i32.const 11))
)
(func $print (param $ptr i32) (param $len i32)
(i32.store (i32.const 8) (local.get $len))
(i32.store (i32.const 4) (local.get $ptr))
(drop (call $__wasi_fd_write
(i32.const 1)
(i32.const 4)
(i32.const 1)
(i32.const 0)))
)
(memory (export "memory") 1)
(data (i32.const 32) "Hello _start\0a")
(data (i32.const 64) "Hello done\0a")
)

View File

@@ -0,0 +1,22 @@
(module
(import "wasi_snapshot_preview1" "fd_write"
(func $__wasi_fd_write (param i32 i32 i32 i32) (result i32)))
(func (export "_initialize")
(call $print (i32.const 32) (i32.const 18))
)
(func (export "greet")
(call $print (i32.const 64) (i32.const 12))
)
(func $print (param $ptr i32) (param $len i32)
(i32.store (i32.const 8) (local.get $len))
(i32.store (i32.const 4) (local.get $ptr))
(drop (call $__wasi_fd_write
(i32.const 1)
(i32.const 4)
(i32.const 1)
(i32.const 0)))
)
(memory (export "memory") 1)
(data (i32.const 32) "Hello _initialize\0a")
(data (i32.const 64) "Hello greet\0a")
)

View 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")
)

View 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")
)

View File

@@ -0,0 +1,2 @@
(module
(func (export "_start") (loop br 0)))

View File

@@ -0,0 +1,3 @@
(module
(start 0)
(func (loop br 0)))

View File

@@ -0,0 +1,13 @@
(module
(func (export "run") (result i32)
(local $i i32)
(i32.const 0) ;; sum
(i32.const 10) ;; i
(loop $loop (param i32 i32) (result i32)
(local.tee $i)
(i32.add) ;; sum = i + sum
(i32.sub (local.get $i) (i32.const 1))
(i32.eqz (local.tee $i))
(if (param i32) (result i32)
(then)
(else (local.get $i) (br $loop))))))

View File

@@ -0,0 +1,3 @@
(module
(func (export "_start"))
)

View File

@@ -0,0 +1,3 @@
(module
(func (export "_initialize"))
)

View 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"))

View File

@@ -0,0 +1,7 @@
(module
(func (export "simple") (param i32) (result i32)
local.get 0
)
(func (export "get_f32") (result f32) f32.const 100)
(func (export "get_f64") (result f64) f64.const 100)
)

View File

@@ -0,0 +1,5 @@
(module
(func (export "_start")
unreachable
)
)