diff --git a/Cargo.lock b/Cargo.lock index df08919502a..f16024dd151 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -891,6 +891,26 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +[[package]] +name = "gumdrop" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46571f5d540478cf70d2a42dd0d6d8e9f4b9cc7531544b93311e657b86568a0b" +dependencies = [ + "gumdrop_derive", +] + +[[package]] +name = "gumdrop_derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915ef07c710d84733522461de2a734d4d62a3fd39a4d4f404c2f385ef8618d05" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "half" version = "1.7.1" @@ -2364,6 +2384,18 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +[[package]] +name = "wasi-test-generator" +version = "2.0.0" +dependencies = [ + "glob", + "gumdrop", + "serde", + "serde_json", + "tempfile", + "wast 24.0.0", +] + [[package]] name = "wasm-bindgen" version = "0.2.75" @@ -2926,7 +2958,7 @@ dependencies = [ "wasmer", "wasmer-vfs", "wasmer-wasi", - "wast", + "wast 37.0.0", ] [[package]] @@ -2948,6 +2980,7 @@ dependencies = [ "test-generator", "tracing", "tracing-subscriber", + "wasi-test-generator", "wasmer", "wasmer-cache", "wasmer-compiler", @@ -3003,6 +3036,15 @@ dependencies = [ "wasmparser 0.80.0", ] +[[package]] +name = "wast" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ff1e3bd3ad0b2ee7784add89c30dc96b89a54b43e5d6d95d774eda1863b3500" +dependencies = [ + "leb128", +] + [[package]] name = "wast" version = "37.0.0" @@ -3018,7 +3060,7 @@ version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ab2cc8d9a69d1ab28a41d9149bb06bb927aba8fc9d56625f8b597a564c83f50" dependencies = [ - "wast", + "wast 37.0.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index a19e0789477..44449c8945e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ wasmer-engine-dylib = { version = "2.0.0", path = "lib/engine-dylib", optional = wasmer-engine-staticlib = { version = "2.0.0", path = "lib/engine-staticlib", optional = true } wasmer-wasi = { version = "2.0.0", path = "lib/wasi", optional = true } wasmer-wast = { version = "2.0.0", path = "tests/lib/wast", optional = true } +wasi-test-generator = { version = "2.0.0", path = "tests/wasi-wast", optional = true } wasmer-cache = { version = "2.0.0", path = "lib/cache", optional = true } wasmer-types = { version = "2.0.0", path = "lib/types" } wasmer-middlewares = { version = "2.0.0", path = "lib/middlewares", optional = true } @@ -50,6 +51,7 @@ members = [ "lib/wasi-types", "lib/wasi-experimental-io-devices", "lib/types", + "tests/wasi-wast", "tests/lib/wast", "tests/lib/compiler-test-derive", "tests/integration/cli", diff --git a/Makefile b/Makefile index 9c0d92e5c28..b9c8e9b90f3 100644 --- a/Makefile +++ b/Makefile @@ -564,6 +564,9 @@ test-capi-integration-%: test-wasi-unit: cargo test --manifest-path lib/wasi/Cargo.toml --release +test-wasi: + cargo test --release --tests $(compiler_features) -- wasi::wasitests::snapshot1 + test-examples: cargo test --release $(compiler_features) --features wasi --examples @@ -573,6 +576,10 @@ test-integration: test-integration-ios: cargo test -p wasmer-integration-tests-ios +generate-wasi-tests: +# Uncomment the following for installing the toolchain +# cargo run -p wasi-test-generator -- -s + cargo run -p wasi-test-generator -- -g ##### # # Packaging. diff --git a/tests/wasi-wast/Cargo.toml b/tests/wasi-wast/Cargo.toml index 76ae5b76f53..bc8022faa02 100644 --- a/tests/wasi-wast/Cargo.toml +++ b/tests/wasi-wast/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasi-test-generator" -version = "0.17.0" +version = "2.0.0" description = "Tests for our WASI implementation" license = "MIT" authors = ["Wasmer Engineering Team "] diff --git a/tests/wasi-wast/src/wasi_version.rs b/tests/wasi-wast/src/wasi_version.rs index 10abf6785e8..88dd4c61b20 100644 --- a/tests/wasi-wast/src/wasi_version.rs +++ b/tests/wasi-wast/src/wasi_version.rs @@ -16,7 +16,7 @@ impl WasiVersion { pub fn get_compiler_toolchain(&self) -> &'static str { match self { WasiVersion::Unstable => "nightly-2019-09-13", - WasiVersion::Snapshot1 => "nightly-2019-12-18", + WasiVersion::Snapshot1 => "1.53.0", } } diff --git a/tests/wasi-wast/src/wasitests.rs b/tests/wasi-wast/src/wasitests.rs index 72fa7ab0b81..39e8a426a74 100644 --- a/tests/wasi-wast/src/wasitests.rs +++ b/tests/wasi-wast/src/wasitests.rs @@ -147,7 +147,7 @@ fn compile_wasm_for_version( .create(true) .open(&temp_wasi_rs_file_name) .unwrap(); - actual_file.write_all(b"#![feature(wasi_ext)]\n").unwrap(); + // actual_file.write_all(b"#![feature(wasi_ext)]\n").unwrap(); actual_file.write_all(file_contents.as_bytes()).unwrap(); } diff --git a/tests/wasi-wast/wasi/snapshot1/fd_rename_path.wasm b/tests/wasi-wast/wasi/snapshot1/fd_rename_path.wasm new file mode 100755 index 00000000000..e3396e3ec61 Binary files /dev/null and b/tests/wasi-wast/wasi/snapshot1/fd_rename_path.wasm differ diff --git a/tests/wasi-wast/wasi/snapshot1/fd_rename_path.wast b/tests/wasi-wast/wasi/snapshot1/fd_rename_path.wast new file mode 100644 index 00000000000..97046bb5783 --- /dev/null +++ b/tests/wasi-wast/wasi/snapshot1/fd_rename_path.wast @@ -0,0 +1,7 @@ +;; This file was generated by https://github.com/wasmerio/wasi-tests + +(wasi_test "fd_rename_path.wasm" + (preopens "test_fs") + (assert_return (i64.const 101)) + (assert_stderr "thread 'main' panicked at 'assertion failed: fs::rename(old_path, new_path).is_ok()', /Users/syrus/Development/wasmer/tests/wasi-wast/wasi/tests/fd_rename_path.rs:10:3\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n") +) diff --git a/tests/wasi-wast/wasi/tests/fd_rename_path.rs b/tests/wasi-wast/wasi/tests/fd_rename_path.rs new file mode 100644 index 00000000000..66e9c7b537f --- /dev/null +++ b/tests/wasi-wast/wasi/tests/fd_rename_path.rs @@ -0,0 +1,11 @@ +// WASI: +// dir: test_fs + +use std::fs; + +fn main() { + let old_path = "test_fs/oldname"; + let new_path = "test_fs/newname"; + + assert!(fs::rename(old_path, new_path).is_ok()); +}