diff --git a/Cargo.lock b/Cargo.lock index 21128ecc0..604b35181 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -766,6 +766,8 @@ name = "generate-wasi-tests" version = "0.16.2" dependencies = [ "glob 0.3.0", + "serde", + "serde_json", "tempfile", ] @@ -2046,9 +2048,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.105" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e707fbbf255b8fc8c3b99abb91e7257a622caeb20a9818cbadbeeede4e0932ff" +checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" dependencies = [ "serde_derive", ] @@ -2074,9 +2076,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.105" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac5d00fc561ba2724df6758a17de23df5914f20e41cb00f94d5b7ae42fffaff8" +checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" dependencies = [ "proc-macro2 1.0.9", "quote 1.0.2", @@ -2258,6 +2260,18 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "test-case" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "199464148b42bcf3da8b2a56f6ee87ca68f47402496d1268849291ec9fb463c8" +dependencies = [ + "proc-macro2 1.0.9", + "quote 1.0.2", + "syn 1.0.16", + "version_check", +] + [[package]] name = "test-generator" version = "0.1.0" @@ -2763,11 +2777,14 @@ dependencies = [ "generate-emscripten-tests", "generate-wasi-tests", "glob 0.3.0", + "lazy_static", "libc", "log", "rustc_version", "serde", + "serde_json", "structopt", + "test-case", "test-generator", "typetag", "wabt", @@ -2979,6 +2996,7 @@ dependencies = [ "libc", "log", "serde", + "thiserror", "time", "typetag", "wasmer-runtime-core", diff --git a/Cargo.toml b/Cargo.toml index 075edb4d9..3a0c77216 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,16 +27,20 @@ fern = { version = "0.5", features = ["colored"], optional = true } log = "0.4" structopt = "0.3" wabt = { version = "0.9.1", optional = true } -wasmer = { path = "lib/api" } -wasmer-clif-backend = { path = "lib/clif-backend", optional = true } -wasmer-singlepass-backend = { path = "lib/singlepass-backend", optional = true } +wasmer = { path = "lib/api", default-features = false } wasmer-middleware-common = { path = "lib/middleware-common" } -wasmer-runtime = { path = "lib/runtime" } +wasmer-runtime = { path = "lib/runtime", default-features = false } wasmer-runtime-core = { path = "lib/runtime-core" } -wasmer-emscripten = { path = "lib/emscripten" } -wasmer-llvm-backend = { path = "lib/llvm-backend", optional = true } -wasmer-wasi = { path = "lib/wasi", optional = true } wasmer-kernel-loader = { path = "lib/kernel-loader", optional = true } + +# Backends +wasmer-singlepass-backend = { path = "lib/singlepass-backend", optional = true } +wasmer-clif-backend = { path = "lib/clif-backend", optional = true } +wasmer-llvm-backend = { path = "lib/llvm-backend", optional = true } + +# Frontends +wasmer-emscripten = { path = "lib/emscripten" } +wasmer-wasi = { path = "lib/wasi", optional = true } wasmer-wasi-experimental-io-devices = { path = "lib/wasi-experimental-io-devices", optional = true } [workspace] @@ -76,21 +80,25 @@ rustc_version = "0.2" [dev-dependencies] anyhow = "1.0.19" wasmer-wast = { path = "tests/wast" } +lazy_static = "1.4.0" +# To allow parametrized tests +test-case = "1.0.0" criterion = "0.3" glob = "0.3" libc = "0.2.60" # for `tests/dev-utils`'s Stdout capturing serde = { version = "1", features = ["derive"] } # used by the plugin example +serde_json = "1" typetag = "0.1" # used by the plugin example wabt = "0.9.1" [features] -default = ["fast-tests", "wasi", "backend-cranelift", "wabt"] +# Don't add the backend features in default, please add them on the Makefile +# since we might want to autoconfigure them depending on the availability on the host. +default = ["wasi", "wabt"] "loader-kernel" = ["wasmer-kernel-loader"] debug = ["fern", "log/max_level_debug", "log/release_max_level_debug"] trace = ["fern", "log/max_level_trace", "log/release_max_level_trace"] docs = ["wasmer-runtime/docs"] -# This feature will allow cargo test to run much faster -fast-tests = [] backend-cranelift = [ "wasmer-clif-backend", "wasmer-clif-backend/generate-debug-information", diff --git a/Makefile b/Makefile index b12fc95d5..f3331c8aa 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,42 @@ .PHONY: spectests emtests clean build install lint precommit docs examples +ARCH := $(shell uname -m) + +backends := + +ifeq ($(ARCH), x86_64) + # In X64, Cranelift is enabled + backends += cranelift + # LLVM is enabled if not in Windows + ifneq ($(OS), Windows_NT) + LLVM_VERSION := $(shell llvm-config --version) + # If findstring is not empty, then it have found the value + ifneq (, $(findstring 9,$(LLVM_VERSION))) + backends += llvm + endif + endif +endif + +backends := $(filter-out ,$(backends)) + +# Singlepass is enabled +RUST_VERSION := $(shell rustc -V) + +ifneq (, $(findstring nightly,$(RUST_VERSION))) + backends += singlepass +endif + +bold:=$(shell tput bold) +green:=$(shell tput setaf 2) +reset:=$(shell tput sgr0) + +$(info Available backends for this host: $(bold)$(green)${backends}$(reset)) + +backend_features_spaced := $(foreach backend,$(backends),backend-$(backend)) +backend_features := --features "$(backend_features_spaced)" + +# $(info Cargo features ${backend_features}) + # Generate files generate-emtests: WASM_EMSCRIPTEN_GENERATE_EMTESTS=1 cargo build --release \ @@ -25,57 +62,53 @@ emtests-generate: generate-emtests wasitests-generate: generate-wasitests wasitests-setup-toolchain: wasitests-setup - WASITESTS_SET_UP_TOOLCHAIN=1 cargo build --release -vv + WASM_WASI_SET_UP_TOOLCHAIN=1 cargo build --release -vv wasitests-setup-toolchain-all: wasitests-setup - WASI_TEST_GENERATE_ALL=1 WASITESTS_SET_UP_TOOLCHAIN=1 cargo build --release -vv + WASI_TEST_GENERATE_ALL=1 WASM_WASI_SET_UP_TOOLCHAIN=1 cargo build --release -vv generate: generate-emtests generate-wasitests # Spectests spectests-singlepass: - WASMER_TEST_SINGLEPASS=1 cargo test singlepass::spec --release --no-default-features --features "wasi backend-singlepass" -- --nocapture + cargo test singlepass::spec --release $(backend_features) spectests-cranelift: - WASMER_TEST_CRANELFIT=1 cargo test cranelift::spec --release --no-default-features --features "wasi backend-cranelift" -- --nocapture + cargo test cranelift::spec --release $(backend_features) spectests-llvm: - WASMER_TEST_LLVM=1 cargo test llvm::spec --release --no-default-features --features "wasi backend-llvm wasmer-llvm-backend/test" -- --nocapture --test-threads=1 + cargo test llvm::spec --release $(backend_features) -- --test-threads=1 -spectests-all: - WASMER_TEST_CRANELIFT=1 WASMER_TEST_LLVM=1 WASMER_TEST_SINGLEPASS=1 \ - cargo test spec --release --no-default-features --features "wasi backend-cranelift backend-singlepass backend-llvm wasmer-llvm-backend/test" - - -spectests: spectests-singlepass spectests-cranelift spectests-llvm +spectests: + cargo test spec --release $(backend_features) -- --test-threads=1 # Emscripten tests emtests-singlepass: - WASMER_TEST_SINGLEPASS=1 cargo test emtest --release --no-default-features --features "wasi backend-singlepass" -- --test-threads=1 + cargo test singlepass::emscripten --release $(backend_features) emtests-cranelift: - WASMER_TEST_CRANELIFT=1 cargo test emtest --release --no-default-features --features "wasi backend-cranelift" -- --test-threads=1 + cargo test cranelift::emscripten --release $(backend_features) emtests-llvm: - WASMER_TEST_LLVM=1 cargo test emtest --release --no-default-features --features "wasi backend-llvm" -- --test-threads=1 + cargo test llvm::emscripten --release $(backend_features) -- --test-threads=1 -emtests-unit: - cargo test emscripten --release +emtests-all: + cargo test emscripten --release $(backend_features) -- --test-threads=1 -emtests: emtests-unit emtests-singlepass emtests-cranelift emtests-llvm +emtests: emtests-singlepass emtests-cranelift emtests-llvm # Middleware tests middleware-singlepass: - cargo test middleware --release --no-default-features --features "wasi backend-singlepass" + cargo test middleware::singlepass --release $(backend_features) middleware-cranelift: - cargo test middleware --release --no-default-features --features "wasi backend-cranelift" + cargo test middleware::cranelift --release $(backend_features) middleware-llvm: - cargo test middleware --release --no-default-features --features "wasi backend-llvm" + cargo test middleware::llvm --release $(backend_features) middleware: middleware-singlepass middleware-cranelift middleware-llvm @@ -86,13 +119,16 @@ wasitests-setup: mkdir -p tests/wasi_test_resources/test_fs/temp wasitests-singlepass: wasitests-setup - WASMER_TEST_SINGLEPASS=1 cargo test wasitest --release --no-default-features --features "wasi backend-singlepass" -- --test-threads=1 + cargo test wasi::singlepass --release $(backend_features) -- --test-threads=1 wasitests-cranelift: wasitests-setup - WASMER_TEST_CRANELIFT=1 cargo test wasitest --release --no-default-features --features "wasi backend-cranelift" -- --test-threads=1 --nocapture + cargo test wasi::cranelift --release $(backend_features) -- --test-threads=1 --nocapture wasitests-llvm: wasitests-setup - WASMER_TEST_LLVM=1 cargo test wasitest --release --no-default-features --features "wasi backend-llvm" -- --test-threads=1 + cargo test wasi::llvm --release $(backend_features) -- --test-threads=1 + +wasitests-all: wasitests-setup + cargo test wasi --release $(backend_features) -- --test-threads=1 wasitests-unit: wasitests-setup cargo test --manifest-path lib/wasi/Cargo.toml --release @@ -103,15 +139,15 @@ wasitests: wasitests-unit wasitests-singlepass wasitests-cranelift wasitests-llv # Backends singlepass: wasitests-setup cargo test -p wasmer-singlepass-backend --release - WASMER_TEST_SINGLEPASS=1 cargo test --release --no-default-features --features "wasi backend-singlepass" -- --test-threads=1 + cargo test singlepass --release $(backend_features) cranelift: wasitests-setup cargo test -p wasmer-clif-backend --release - WASMER_TEST_CRANELIFT=1 cargo test --release --no-default-features --features "wasi backend-cranelift" -- --test-threads=1 + cargo test cranelift --release $(backend_features) llvm: wasitests-setup cargo test -p wasmer-llvm-backend --release - WASMER_TEST_LLVM=1 cargo test --release --no-default-features --features "wasi backend-llvm" -- --test-threads=1 + cargo test llvm --release $(backend_features) -- --test-threads=1 # All tests @@ -163,7 +199,7 @@ test-rest: cargo test --release -p wasmer-wasi-experimental-io-devices cargo test --release -p wasmer-win-exception-handler -test: spectests emtests middleware wasitests test-rest examples +test: singlepass cranelift llvm test-rest examples test-android: ci/run-docker.sh x86_64-linux-android --manifest-path=lib/singlepass-backend/Cargo.toml @@ -188,20 +224,20 @@ lint: precommit: lint test debug: - cargo build --release --features backend-cranelift,backend-singlepass,debug,trace + cargo build --release --features "debug trace" install: cargo install --path . # Checks check-bench-singlepass: - cargo check --benches --all --no-default-features --features "backend-singlepass" \ + cargo check --benches --all singlepass \ --exclude wasmer-clif-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader check-bench-clif: - cargo check --benches --all --no-default-features --features "backend-cranelift" \ + cargo check --benches --all cranelift \ --exclude wasmer-singlepass-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader check-bench-llvm: - cargo check --benches --all --no-default-features --features "backend-llvm" \ + cargo check --benches --all llvm \ --exclude wasmer-singlepass-backend --exclude wasmer-clif-backend --exclude wasmer-kernel-loader check-bench: check-bench-singlepass check-bench-llvm @@ -270,7 +306,7 @@ check: check-bench # Release release: - cargo build --release --features backend-singlepass,backend-cranelift,backend-llvm,loader-kernel,experimental-io-devices,log/release_max_level_off + cargo build --release $(backend_features) --features loader-kernel,experimental-io-devices,log/release_max_level_off # Release with musl target release-musl: @@ -278,28 +314,28 @@ release-musl: # experimental-io-devices is not included due to missing x11-fb. cargo build --release --target x86_64-unknown-linux-musl --features backend-singlepass,backend-cranelift,loader-kernel,log/release_max_level_off,wasi --no-default-features -# Only one backend (cranelift) -release-clif: - # If you are on macOS, you will need mingw-w64 for cross compiling to Windows - # brew install mingw-w64 - cargo build --release --features backend-cranelift +# This way of releasing is deprecated, since backends are now detected +# automatically +release-clif: release -release-singlepass: - cargo build --release --features backend-singlepass +# This way of releasing is deprecated, since backends are now detected +# automatically +release-singlepass: release -release-llvm: - cargo build --release --features backend-llvm,experimental-io-devices +# This way of releasing is deprecated, since backends are now detected +# automatically +release-llvm: release bench-singlepass: # NOTE this will run some benchmarks using clif; TODO: fix this - cargo bench --all --no-default-features --features "backend-singlepass" \ + cargo bench --all singlepass \ --exclude wasmer-clif-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader bench-clif: - cargo bench --all --no-default-features --features "backend-cranelift" \ + cargo bench --all cranelift \ --exclude wasmer-singlepass-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader bench-llvm: # NOTE this will run some benchmarks using clif; TODO: fix this - cargo bench --all --no-default-features --features "backend-llvm" \ + cargo bench --all llvm \ --exclude wasmer-singlepass-backend --exclude wasmer-clif-backend --exclude wasmer-kernel-loader build-install-package: diff --git a/build.rs b/build.rs index 47cdcf25d..2f13a0109 100644 --- a/build.rs +++ b/build.rs @@ -5,15 +5,19 @@ use generate_emscripten_tests; use generate_wasi_tests; use std::env; -use std::fmt::Write; use std::fs; use std::path::PathBuf; use std::process::Command; use test_generator::{ build_ignores_from_textfile, extract_name, test_directory, test_directory_module, - with_test_module, Test, Testsuite, + with_backends, with_test_module, Test, Testsuite, }; +static EMTESTS_ENV_VAR: &str = "WASM_EMSCRIPTEN_GENERATE_EMTESTS"; +static WASITESTS_ENV_VAR: &str = "WASM_WASI_GENERATE_WASITESTS"; +static WASITESTS_SET_UP_TOOLCHAIN: &str = "WASM_WASI_SET_UP_TOOLCHAIN"; +static WASITESTS_GENERATE_ALL: &str = "WASI_TEST_GENERATE_ALL"; + /// Given a Testsuite and a path, process the path in case is a wast /// file. fn wast_processor(out: &mut Testsuite, p: PathBuf) -> Option { @@ -41,71 +45,199 @@ fn wast_processor(out: &mut Testsuite, p: PathBuf) -> Option { }) } +/// Given a Testsuite and a path, process the path in case is a Emscripten +/// wasm file. +fn emscripten_processor(out: &mut Testsuite, p: PathBuf) -> Option { + let ext = p.extension()?; + // Only look at wast files. + if ext != "wasm" { + return None; + } + + let outfile = { + let mut out_ext = p.clone(); + out_ext.set_extension("out"); + // let mut txt_ext = p.clone(); + // txt_ext.set_extension("txt"); + if out_ext.exists() { + out_ext + } + // else if txt_ext.exists() { + // txt_ext + // } + else { + return None; + } + }; + + let testname = extract_name(&p); + let compiler = out.path.get(0).unwrap(); + let body = format!( + "crate::run_emscripten(r#\"{}\"#, r#\"{}\"#, \"{}\")", + p.display(), + outfile.display(), + compiler + ); + + Some(Test { + name: testname.to_string(), + body: body.to_string(), + }) +} + +/// Given a Testsuite and a path, process the path in case is a WASI +/// wasm file. +fn wasi_processor(out: &mut Testsuite, p: PathBuf) -> Option { + let ext = p.extension()?; + // Only look at wast files. + if ext != "wasm" { + return None; + } + + let outfile = { + let mut out_ext = p.clone(); + out_ext.set_extension("out"); + // let mut txt_ext = p.clone(); + // txt_ext.set_extension("txt"); + if out_ext.exists() { + out_ext + } + // else if txt_ext.exists() { + // txt_ext + // } + else { + return None; + } + }; + + let testname = extract_name(&p); + let compiler = out.path.get(0).unwrap(); + let body = format!( + "crate::run_wasi(r#\"{}\"#, r#\"{}\"#, \"{}\")", + p.display(), + outfile.display(), + compiler + ); + + Some(Test { + name: testname.to_string(), + body: body.to_string(), + }) +} + +fn is_truthy_env(name: &str) -> bool { + env::var(name).unwrap_or("0".to_string()) == "1" +} + fn main() -> anyhow::Result<()> { + // println!("cargo:rustc-cfg=feature=\"backend-cranelift\""); println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=test/ignores.txt"); + println!("cargo:rerun-if-env-changed={}", EMTESTS_ENV_VAR); + println!("cargo:rerun-if-env-changed={}", WASITESTS_ENV_VAR); + println!("cargo:rerun-if-env-changed={}", WASITESTS_SET_UP_TOOLCHAIN); + println!("cargo:rerun-if-env-changed={}", WASITESTS_GENERATE_ALL); - generate_wasi_tests::build(); - generate_emscripten_tests::build(); + let wasi_versions = if is_truthy_env(WASITESTS_GENERATE_ALL) { + generate_wasi_tests::ALL_WASI_VERSIONS + } else { + generate_wasi_tests::LATEST_WASI_VERSION + }; + + // Install the Rust WASI toolchains for each of the versions + if is_truthy_env(WASITESTS_SET_UP_TOOLCHAIN) { + generate_wasi_tests::install_toolchains(wasi_versions); + } + + // Generate the WASI Wasm files + if is_truthy_env(WASITESTS_ENV_VAR) { + generate_wasi_tests::build(wasi_versions); + } + + // Generate Emscripten Wasm files + if is_truthy_env(EMTESTS_ENV_VAR) { + generate_emscripten_tests::build(); + } let out_dir = PathBuf::from( env::var_os("OUT_DIR").expect("The OUT_DIR environment variable must be set"), ); let ignores = build_ignores_from_textfile("tests/ignores.txt".into())?; - let mut out = Testsuite { + + // Spectests test generation + let mut spectests = Testsuite { buffer: String::new(), path: vec![], - ignores: ignores, + ignores: ignores.clone(), }; - - for compiler in &["singlepass", "cranelift", "llvm"] { - writeln!(out.buffer, "#[cfg(feature=\"backend-{}\")]", compiler); - writeln!(out.buffer, "#[cfg(test)]")?; - writeln!(out.buffer, "#[allow(non_snake_case)]")?; - with_test_module(&mut out, compiler, |mut out| { - with_test_module(&mut out, "spec", |out| { - let spec_tests = test_directory(out, "tests/spectests", wast_processor)?; - // Skip running spec_testsuite tests if the submodule isn't checked - // out. - // if spec_tests > 0 { - // test_directory_module( - // out, - // "tests/spec_testsuite/proposals/simd", - // wast_processor, - // )?; - // test_directory_module( - // out, - // "tests/spec_testsuite/proposals/multi-value", - // wast_processor, - // )?; - // test_directory_module( - // out, - // "tests/spec_testsuite/proposals/reference-types", - // wast_processor, - // )?; - // test_directory_module( - // out, - // "tests/spec_testsuite/proposals/bulk-memory-operations", - // wast_processor, - // )?; - // } else { - // println!( - // "cargo:warning=The spec testsuite is disabled. To enable, run `git submodule \ - // update --remote`." - // ); - // } - Ok(()) - })?; + let backends = vec!["singlepass", "cranelift", "llvm"]; + with_backends(&mut spectests, &backends, |mut spectests| { + with_test_module(&mut spectests, "spec", |spectests| { + let _spec_tests = test_directory(spectests, "tests/spectests", wast_processor)?; Ok(()) })?; - } + Ok(()) + })?; + + // Emscripten tests generation + let mut emtests = Testsuite { + buffer: String::new(), + path: vec![], + ignores: ignores.clone(), + }; + with_backends(&mut emtests, &backends, |mut emtests| { + with_test_module(&mut emtests, "emscripten", |emtests| { + let _emscripten_tests = test_directory( + emtests, + "tests/emscripten_resources/emtests", + emscripten_processor, + )?; + Ok(()) + })?; + Ok(()) + })?; + + // WASI tests generation + let mut wasitests = Testsuite { + buffer: String::new(), + path: vec![], + ignores: ignores.clone(), + }; + with_backends(&mut wasitests, &backends, |mut wasitests| { + with_test_module(&mut wasitests, "wasi", |wasitests| { + test_directory_module( + wasitests, + "tests/wasi_test_resources/unstable", + wasi_processor, + )?; + test_directory_module( + wasitests, + "tests/wasi_test_resources/snapshot1", + wasi_processor, + )?; + Ok(()) + })?; + Ok(()) + })?; + + let spectests_output = out_dir.join("generated_spectests.rs"); + fs::write(&spectests_output, spectests.buffer)?; + + let emtests_output = out_dir.join("generated_emtests.rs"); + fs::write(&emtests_output, emtests.buffer)?; + + // println!("WASI: {}", wasitests.buffer); + + let wasitests_output = out_dir.join("generated_wasitests.rs"); + fs::write(&wasitests_output, wasitests.buffer)?; - // println!("{}", out.buffer); - // std::process::exit(1); // Write out our auto-generated tests and opportunistically format them with // `rustfmt` if it's installed. - let output = out_dir.join("generated_tests.rs"); - fs::write(&output, out.buffer)?; - Command::new("rustfmt").arg(&output).status(); + // Note: We need drop because we don't want to run `unwrap` or `expect` as + // the command might fail, but we don't care about it's result. + drop(Command::new("rustfmt").arg(&spectests_output).status()); + drop(Command::new("rustfmt").arg(&emtests_output).status()); + drop(Command::new("rustfmt").arg(&wasitests_output).status()); + Ok(()) } diff --git a/lib/runtime/src/lib.rs b/lib/runtime/src/lib.rs index 91d86dada..7f7c8a459 100644 --- a/lib/runtime/src/lib.rs +++ b/lib/runtime/src/lib.rs @@ -208,6 +208,13 @@ impl Default for Backend { #[cfg(all(feature = "default-backend-llvm", not(feature = "docs")))] return Backend::LLVM; + + #[cfg(not(any( + feature = "default-backend-singlepass", + feature = "default-backend-cranelift", + feature = "default-backend-llvm", + )))] + panic!("There is no default-backend set."); } } @@ -241,7 +248,7 @@ impl std::str::FromStr for Backend { /// # Errors: /// If the operation fails, the function returns `Err(error::CompileError::...)`. pub fn compile(wasm: &[u8]) -> error::CompileResult { - wasmer_runtime_core::compile_with(&wasm[..], &default_compiler()) + wasmer_runtime_core::compile_with(&wasm[..], &*default_compiler()) } /// The same as `compile` but takes a `CompilerConfig` for the purpose of @@ -250,7 +257,7 @@ pub fn compile_with_config( wasm: &[u8], compiler_config: CompilerConfig, ) -> error::CompileResult { - wasmer_runtime_core::compile_with_config(&wasm[..], &default_compiler(), compiler_config) + wasmer_runtime_core::compile_with_config(&wasm[..], &*default_compiler(), compiler_config) } /// The same as `compile_with_config` but takes a `Compiler` for the purpose of @@ -291,7 +298,7 @@ pub fn instantiate(wasm: &[u8], import_object: &ImportObject) -> error::Result impl Compiler { +pub fn default_compiler() -> Box { #[cfg(any( all( feature = "default-backend-llvm", @@ -320,7 +327,19 @@ pub fn default_compiler() -> impl Compiler { #[cfg(any(feature = "default-backend-cranelift", feature = "docs"))] use wasmer_clif_backend::CraneliftCompiler as DefaultCompiler; - DefaultCompiler::new() + #[cfg(any( + feature = "default-backend-singlepass", + feature = "default-backend-cranelift", + feature = "default-backend-llvm", + ))] + return Box::new(DefaultCompiler::new()); + + #[cfg(not(any( + feature = "default-backend-singlepass", + feature = "default-backend-cranelift", + feature = "default-backend-llvm", + )))] + panic!("There is no default-compiler set."); } /// Get the `Compiler` as a trait object for the given `Backend`. @@ -350,6 +369,13 @@ pub fn compiler_for_backend(backend: Backend) -> Option> { return Some(Box::new(wasmer_clif_backend::CraneliftCompiler::new())); #[cfg(feature = "default-backend-llvm")] return Some(Box::new(wasmer_llvm_backend::LLVMCompiler::new())); + + #[cfg(not(any( + feature = "default-backend-singlepass", + feature = "default-backend-cranelift", + feature = "default-backend-llvm", + )))] + panic!("There is no default-compiler set."); } } } diff --git a/lib/wasi/Cargo.toml b/lib/wasi/Cargo.toml index e26bf73e3..5d955c8f5 100644 --- a/lib/wasi/Cargo.toml +++ b/lib/wasi/Cargo.toml @@ -12,6 +12,7 @@ edition = "2018" [dependencies] bincode = "1" byteorder = "1.3" +thiserror = "1.0.15" generational-arena = { version = "0.2", features = ["serde"] } libc = "0.2.60" log = "0.4" diff --git a/lib/wasi/src/state/builder.rs b/lib/wasi/src/state/builder.rs index 94b7e05ee..a0d69c7b5 100644 --- a/lib/wasi/src/state/builder.rs +++ b/lib/wasi/src/state/builder.rs @@ -3,6 +3,7 @@ use crate::state::{WasiFile, WasiFs, WasiFsError, WasiState}; use crate::syscalls::types::{__WASI_STDERR_FILENO, __WASI_STDIN_FILENO, __WASI_STDOUT_FILENO}; use std::path::{Path, PathBuf}; +use thiserror::Error; /// Creates an empty [`WasiStateBuilder`]. /// @@ -56,15 +57,23 @@ impl std::fmt::Debug for WasiStateBuilder { } /// Error type returned when bad data is given to [`WasiStateBuilder`]. -#[derive(Debug, PartialEq, Eq)] +#[derive(Error, Debug, PartialEq, Eq)] pub enum WasiStateCreationError { + #[error("bad environment variable format: `{0}`")] EnvironmentVariableFormatError(String), + #[error("argument contains null byte: `{0}`")] ArgumentContainsNulByte(String), + #[error("preopened directory not found: `{0}`")] PreopenedDirectoryNotFound(PathBuf), + #[error("preopened directory error: `{0}`")] PreopenedDirectoryError(String), + #[error("mapped dir alias has wrong format: `{0}`")] MappedDirAliasFormattingError(String), + #[error("wasi filesystem creation error: `{0}`")] WasiFsCreationError(String), + #[error("wasi filesystem setup error: `{0}`")] WasiFsSetupError(String), + #[error(transparent)] WasiFsError(WasiFsError), } diff --git a/lib/wasi/src/state/types.rs b/lib/wasi/src/state/types.rs index 3308887de..22d0b239c 100644 --- a/lib/wasi/src/state/types.rs +++ b/lib/wasi/src/state/types.rs @@ -9,60 +9,84 @@ use std::{ path::PathBuf, time::SystemTime, }; +use thiserror::Error; /// Error type for external users -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Error, Copy, Clone, Debug, PartialEq, Eq)] #[allow(dead_code)] // dead code beacuse this is for external use pub enum WasiFsError { /// The fd given as a base was not a directory so the operation was not possible + #[error("fd not a directory")] BaseNotDirectory, /// Expected a file but found not a file + #[error("fd not a file")] NotAFile, /// The fd given was not usable + #[error("invalid fd")] InvalidFd, /// File exists + #[error("file exists")] AlreadyExists, /// Something failed when doing IO. These errors can generally not be handled. /// It may work if tried again. + #[error("io error")] IOError, /// The address was in use + #[error("address is in use")] AddressInUse, /// The address could not be found + #[error("address could not be found")] AddressNotAvailable, /// A pipe was closed + #[error("broken pipe (was closed)")] BrokenPipe, /// The connection was aborted + #[error("connection aborted")] ConnectionAborted, /// The connection request was refused + #[error("connection refused")] ConnectionRefused, /// The connection was reset + #[error("connection reset")] ConnectionReset, /// The operation was interrupted before it could finish + #[error("operation interrupted")] Interrupted, /// Invalid internal data, if the argument data is invalid, use `InvalidInput` + #[error("invalid internal data")] InvalidData, /// The provided data is invalid + #[error("invalid input")] InvalidInput, /// Could not perform the operation because there was not an open connection + #[error("connection is not open")] NotConnected, /// The requested file or directory could not be found + #[error("entity not found")] EntityNotFound, /// The requested device couldn't be accessed + #[error("can't access device")] NoDevice, /// Caller was not allowed to perform this operation + #[error("permission denied")] PermissionDenied, /// The operation did not complete within the given amount of time + #[error("time out")] TimedOut, /// Found EOF when EOF was not expected + #[error("unexpected eof")] UnexpectedEof, /// Operation would block, this error lets the caller know that they can try again + #[error("blocking operation. try again")] WouldBlock, /// A call to write returned 0 + #[error("write returned 0")] WriteZero, /// A WASI error without an external name. If you encounter this it means /// that there's probably a bug on our side (maybe as simple as forgetting to wrap /// this error, but perhaps something broke) + #[error("unknown error: {0}")] UnknownError(__wasi_errno_t), } diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 607a7c1e0..6ac905362 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -7,18 +7,28 @@ unused_unsafe, unreachable_patterns )] -use std::env; #[cfg(all(target_os = "linux", feature = "loader-kernel"))] use wasmer_bin::commands::Kernel; -use wasmer_bin::commands::{Cache, Run, SelfUpdate, Validate}; +#[cfg(any( + feature = "backend-cranelift", + feature = "backend-llvm", + feature = "backend-singlepass" +))] +use wasmer_bin::commands::Run; +use wasmer_bin::commands::{Cache, SelfUpdate, Validate}; -use structopt::{clap, StructOpt}; +use structopt::StructOpt; #[derive(Debug, StructOpt)] #[structopt(name = "wasmer", about = "WebAssembly standalone runtime.", author)] /// The options for the wasmer Command Line Interface enum CLIOptions { /// Run a WebAssembly file. Formats accepted: wasm, wat + #[cfg(any( + feature = "backend-cranelift", + feature = "backend-llvm", + feature = "backend-singlepass" + ))] #[structopt(name = "run")] Run(Run), @@ -45,18 +55,36 @@ fn main() { // Eg. `wasmer ` // In case that fails, we fallback trying the Run subcommand directly. // Eg. `wasmer myfile.wasm --dir=.` - let args = env::args(); - let options = CLIOptions::from_iter_safe(args).unwrap_or_else(|e| { + #[cfg(any( + feature = "backend-cranelift", + feature = "backend-llvm", + feature = "backend-singlepass" + ))] + let options = CLIOptions::from_iter_safe(std::env::args()).unwrap_or_else(|e| { match e.kind { // This fixes a issue that: // 1. Shows the version twice when doing `wasmer -V` // 2. Shows the run help (instead of normal help) when doing `wasmer --help` - clap::ErrorKind::VersionDisplayed | clap::ErrorKind::HelpDisplayed => e.exit(), + structopt::clap::ErrorKind::VersionDisplayed + | structopt::clap::ErrorKind::HelpDisplayed => e.exit(), _ => CLIOptions::Run(Run::from_args()), } }); + // Do not try to wrap in Run, if the Run subcommand is not available + #[cfg(not(any( + feature = "backend-cranelift", + feature = "backend-llvm", + feature = "backend-singlepass" + )))] + let options = CLIOptions::from_args(); + match options { + #[cfg(any( + feature = "backend-cranelift", + feature = "backend-llvm", + feature = "backend-singlepass" + ))] CLIOptions::Run(mut options) => options.execute(), CLIOptions::SelfUpdate => SelfUpdate::execute(), CLIOptions::Cache(cache) => cache.execute(), diff --git a/src/commands.rs b/src/commands.rs index 03de432b3..15c846501 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1,10 +1,21 @@ mod cache; #[cfg(all(target_os = "linux", feature = "loader-kernel"))] mod kernel; +#[cfg(any( + feature = "backend-cranelift", + feature = "backend-llvm", + feature = "backend-singlepass" +))] mod run; mod selfupdate; mod validate; #[cfg(all(target_os = "linux", feature = "loader-kernel"))] pub use kernel::*; -pub use {cache::*, run::*, selfupdate::*, validate::*}; +#[cfg(any( + feature = "backend-cranelift", + feature = "backend-llvm", + feature = "backend-singlepass" +))] +pub use run::*; +pub use {cache::*, selfupdate::*, validate::*}; diff --git a/src/commands/run.rs b/src/commands/run.rs index cc851e743..b58075fd7 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -474,7 +474,12 @@ impl LLVMCallbacks for LLVMCLIOptions { /// Execute a wasm/wat file fn execute_wasm(options: &Run) -> Result<(), String> { - if options.generate_debug_info && options.backend != Backend::Cranelift { + #[cfg(feature = "backend-cranelift")] + let in_cranelift = options.backend == Backend::Cranelift; + #[cfg(not(feature = "backend-cranelift"))] + let in_cranelift = false; + + if options.generate_debug_info && !in_cranelift { return Err("Generating debug information is currently only available with the `cranelift` backend.".to_owned()); } diff --git a/tests/custom/call-indirect-spilled-stack.wast b/tests/custom/call-indirect-spilled-stack.wast new file mode 100644 index 000000000..95df771f8 --- /dev/null +++ b/tests/custom/call-indirect-spilled-stack.wast @@ -0,0 +1,35 @@ +;; Spilled stack tests +;; https://github.com/wasmerio/wasmer/pull/1191 + +(module + ;; Auxiliary definitions + (type $out-i32 (func (result i32))) + + (func $const-i32 (type $out-i32) (i32.const 0x132)) + + (table funcref + (elem + $const-i32 + ) + ) + + (memory 1) + + (func (export "call-indirect-from-spilled-stack") (result i32) + (i64.add (i64.const 0) (i64.const 0)) + (i64.add (i64.const 0) (i64.const 0)) + (i64.add (i64.const 0) (i64.const 0)) + (i64.add (i64.const 0) (i64.const 0)) + (i64.add (i64.const 0) (i64.const 0)) + (i64.add (i64.const 0) (i64.const 0)) + (i64.add (i64.const 0) (i64.const 0)) + (i64.add (i64.const 0) (i64.const 0)) + (i64.add (i64.const 0) (i64.const 0)) + (i64.add (i64.const 0x100000000) (i64.const 0)) + (i32.wrap_i64) + (call_indirect (type $out-i32)) + (return) + ) +) + +(assert_return (invoke "call-indirect-from-spilled-stack") (i32.const 0x132)) diff --git a/tests/spectests/fac.wast b/tests/custom/fac.wast similarity index 100% rename from tests/spectests/fac.wast rename to tests/custom/fac.wast diff --git a/tests/custom/multiple-traps.wast b/tests/custom/multiple-traps.wast new file mode 100644 index 000000000..e59a3a3fb --- /dev/null +++ b/tests/custom/multiple-traps.wast @@ -0,0 +1,10 @@ +;; We assert that we can call a function that traps repitedly + +(module + (func (export "throw_trap") + unreachable + )) + +(assert_trap (invoke "as-call_indirect-last") "unreachable") +(assert_trap (invoke "as-call_indirect-last") "unreachable") +(assert_trap (invoke "as-call_indirect-last") "unreachable") diff --git a/tests/spectests/wasmer.wast b/tests/custom/nan-canonicalization.wast similarity index 92% rename from tests/spectests/wasmer.wast rename to tests/custom/nan-canonicalization.wast index 1a7647ee1..2e80ab39a 100644 --- a/tests/spectests/wasmer.wast +++ b/tests/custom/nan-canonicalization.wast @@ -1,16 +1,16 @@ -;; Wasmer-specific tests. +;; NaN canonicalization tests. +;; +;; Things that are covered by spectests canonicalization +;; (`fabs`, `fneg`, `fcopysign`, `reinterpret`, `const`) +;; won't be duplicated here. (module ;; Auxiliary definitions - (type $out-i32 (func (result i32))) (type $f32-id (func (param f32) (result f32))) (type $f64-id (func (param f64) (result f64))) - (func $const-i32 (type $out-i32) (i32.const 0x132)) - (table funcref (elem - $const-i32 $nan-canonicalization-f32-func-call-target $nan-canonicalization-f64-func-call-target ) @@ -18,26 +18,6 @@ (memory 1) - ;; https://github.com/wasmerio/wasmer/pull/1191 - (func (export "call-indirect-from-spilled-stack") (result i32) - (i64.add (i64.const 0) (i64.const 0)) - (i64.add (i64.const 0) (i64.const 0)) - (i64.add (i64.const 0) (i64.const 0)) - (i64.add (i64.const 0) (i64.const 0)) - (i64.add (i64.const 0) (i64.const 0)) - (i64.add (i64.const 0) (i64.const 0)) - (i64.add (i64.const 0) (i64.const 0)) - (i64.add (i64.const 0) (i64.const 0)) - (i64.add (i64.const 0) (i64.const 0)) - (i64.add (i64.const 0x100000000) (i64.const 0)) - (i32.wrap_i64) - (call_indirect (type $out-i32)) - (return) - ) - - ;; NaN canonicalization tests. - ;; Things that are covered by spectests canonicalization (`fabs`, `fneg`, `fcopysign`, `reinterpret`, `const`) won't be duplicated here. - (func (export "nan-canonicalization-f32-add") (param i32) (result i32) (i32.reinterpret_f32 (f32.add (f32.reinterpret_i32 (get_local 0)) (f32.const 0))) ) @@ -173,7 +153,6 @@ ) ) -(assert_return (invoke "call-indirect-from-spilled-stack") (i32.const 0x132)) (assert_return (invoke "nan-canonicalization-f32-add" (i32.const 0x7fc00001)) (i32.const 0x7fc00000)) (assert_return (invoke "nan-canonicalization-f32-sub" (i32.const 0x7fc00001)) (i32.const 0x7fc00000)) (assert_return (invoke "nan-canonicalization-f32-mul" (i32.const 0x7fc00001)) (i32.const 0x7fc00000)) diff --git a/tests/emscripten_resources/emtests/clock_gettime.out b/tests/emscripten_resources/emtests/clock_gettime.out deleted file mode 100644 index 9dab40160..000000000 --- a/tests/emscripten_resources/emtests/clock_gettime.out +++ /dev/null @@ -1 +0,0 @@ -clock_gettime diff --git a/tests/emscripten_resources/emtests/env.out b/tests/emscripten_resources/emtests/env.out deleted file mode 100644 index a6cb32095..000000000 --- a/tests/emscripten_resources/emtests/env.out +++ /dev/null @@ -1,11 +0,0 @@ -INIT -UNEXISTENT_ENVVAR = [NULL] -Setting UNEXISTENT_ENVVAR=PUTENV (via putenv) -UNEXISTENT_ENVVAR = PUTENV -Setting UNEXISTENT_ENVVAR=SETENV (via setenv, overwrite) -UNEXISTENT_ENVVAR = SETENV -Setting UNEXISTENT_ENVVAR=SETENV_NEW (via setenv, NO overwrite) -UNEXISTENT_ENVVAR = SETENV -Unsetting UNEXISTENT_ENVVAR -UNEXISTENT_ENVVAR = [NULL] -END diff --git a/tests/emscripten_resources/emtests/hello.out b/tests/emscripten_resources/emtests/hello.out index 9a71f81a4..3b18e512d 100644 --- a/tests/emscripten_resources/emtests/hello.out +++ b/tests/emscripten_resources/emtests/hello.out @@ -1,2 +1 @@ hello world - diff --git a/tests/emscripten_resources/emtests/ignores.txt b/tests/emscripten_resources/emtests/ignores.txt deleted file mode 100644 index af8f21b00..000000000 --- a/tests/emscripten_resources/emtests/ignores.txt +++ /dev/null @@ -1,109 +0,0 @@ -test_ccall -test_demangle_stacks -emscripten_get_compiler_setting -fs_exports -getvalue_setvalue -legacy_exported_runtime_numbers -modularize_closure_pre -stackalloc -test_demangle_stacks_noassert -test_dlmalloc_partial_2 -test_em_asm -test_em_asm_2 -test_em_asm_parameter_pack -test_em_asm_signatures -test_em_asm_unicode -test_em_asm_unused_arguments -test_em_js -test_emscripten_api -test_exceptions_2 -test_exceptions_multi -test_exceptions_std -test_exceptions_white_list -test_fast_math -test_float_builtins -test_getopt -test_getopt_long -test_getloadavg -test_i16_emcc_intrinsic -test_i64 -test_i64_7z -test_i64_varargs -test_indirectbr_many -test_llvm_intrinsics -test_longjmp_exc -test_lower_intrinsics -test_main_thread_async_em_asm -test_mainenv -test_mathfuncptr -test_memcpy_memcmp -test_mmap -test_perrar -test_poll -test_posixtime -test_siglongjmp -test_sscanf_hex -test_sscanf_whitespace -test_sscanf_other_whitespace -test_sscanf_skip -test_stack_varargs -test_stack_void -test_statvfs -test_strings -test_strptime_days -test_strtold -test_tracing -test_uname -test_utf -test_varargs_multi -test_varargs -test_zero_multiplication -test_strftime -test_wprintf -test_std_cout_new -test_strptime_reentrant -test_gmtime -test_time_c -test_execvp -test_nl_types -test_phiundef -test_pipe -test_printf_2 -test_printf_more -test_regex -test_relocatable_void_function -test_rounding -test_set_align -test_sintvars -test_sizeof -test_sscanf -test_sscanf_3 -test_sscanf_4 -test_sscanf_5 -test_sscanf_6 -test_sscanf_caps -test_sscanf_float -test_sscanf_n -test_strcasecmp -test_strcmp_uni -test_strndup -test_strstr -test_strtod -test_strtok -test_strtol_bin -test_strtol_dec -test_strtol_hex -test_strtol_oct -test_strtoll_bin -test_strtoll_dec -test_strtoll_hex -test_strtoll_oct -test_struct_varargs -test_transtrcase -test_trickystring -test_unary_literal -test_vfs -test_vprintf -test_vsnprintf -test_write_stdout_fileno -test_zerodiv diff --git a/tests/emscripten_resources/emtests/localtime.out b/tests/emscripten_resources/emtests/localtime.out deleted file mode 100644 index 826f3db8a..000000000 --- a/tests/emscripten_resources/emtests/localtime.out +++ /dev/null @@ -1 +0,0 @@ -localtime diff --git a/tests/emscripten_resources/emtests/printf.out b/tests/emscripten_resources/emtests/printf.out deleted file mode 100644 index ac02f590a..000000000 --- a/tests/emscripten_resources/emtests/printf.out +++ /dev/null @@ -1,29 +0,0 @@ -ab1.23cd -n=7 - -Characters: a A -Decimals: 1977 650000 12 4 -Preceding with blanks: 1977 -1977 -Preceding with zeros: 0000001977 -000001977 -Force sign: +1977 -1977 +1977 -1977 -Force sign or space: 1977 -1977 1977 -1977 -Sign overrides space: +1977 -1977 +1977 -1977 -Some different radixes: 100 64 144 0x64 0144 -floats: 3.14 +3e+00 3.141600E+00 00003.14 -negative floats: -3.14 -3e+00 -3.141600E+00 -0003.14 -Force sign or space: 3.14 -3.14 3.14 -3.14 -Width trick: 10 -A string % -Null string: (null) -inf -INF --inf --INF -nan -NAN - nan -nan - nan -nan - inf --inf diff --git a/tests/emscripten_resources/emtests/puts.out b/tests/emscripten_resources/emtests/puts.out deleted file mode 100644 index b10a5b066..000000000 --- a/tests/emscripten_resources/emtests/puts.out +++ /dev/null @@ -1,4 +0,0 @@ -Hello, World! - -Hello, World! - diff --git a/tests/emscripten_resources/emtests/test_addr_of_stacked.out b/tests/emscripten_resources/emtests/test_addr_of_stacked.out deleted file mode 100644 index 2b8cf4a17..000000000 --- a/tests/emscripten_resources/emtests/test_addr_of_stacked.out +++ /dev/null @@ -1 +0,0 @@ -*7* \ No newline at end of file diff --git a/tests/emscripten_resources/emtests/test_alloca.out b/tests/emscripten_resources/emtests/test_alloca.out deleted file mode 100644 index 37de3d6bc..000000000 --- a/tests/emscripten_resources/emtests/test_alloca.out +++ /dev/null @@ -1 +0,0 @@ -z:1* \ No newline at end of file diff --git a/tests/emscripten_resources/emtests/test_alloca_stack.out b/tests/emscripten_resources/emtests/test_alloca_stack.out deleted file mode 100644 index d6a90d4e8..000000000 --- a/tests/emscripten_resources/emtests/test_alloca_stack.out +++ /dev/null @@ -1 +0,0 @@ -ok:-32768* \ No newline at end of file diff --git a/tests/emscripten_resources/emtests/test_array2.out b/tests/emscripten_resources/emtests/test_array2.out deleted file mode 100644 index a6ee88bbc..000000000 --- a/tests/emscripten_resources/emtests/test_array2.out +++ /dev/null @@ -1 +0,0 @@ -0:-1.00,-0.33 1:0.33,-1.00 2:-0.33,1.00 3:1.00,0.33 \ No newline at end of file diff --git a/tests/emscripten_resources/emtests/test_array2b.out b/tests/emscripten_resources/emtests/test_array2b.out deleted file mode 100644 index 422896dcc..000000000 --- a/tests/emscripten_resources/emtests/test_array2b.out +++ /dev/null @@ -1,2 +0,0 @@ -*6,6 -7,95* \ No newline at end of file diff --git a/tests/emscripten_resources/emtests/test_atoX.out b/tests/emscripten_resources/emtests/test_atoX.out deleted file mode 100644 index 4b76d26d3..000000000 --- a/tests/emscripten_resources/emtests/test_atoX.out +++ /dev/null @@ -1,3 +0,0 @@ -0*0*0*0*6*5*4*3*3*9*8 -0*0*0*0*6*5*4*3*3*9*8 -6294967296*0*0*0*0*6*5*4*3*3*9*8 diff --git a/tests/emscripten_resources/emtests/test_atomic.out b/tests/emscripten_resources/emtests/test_atomic.out deleted file mode 100644 index ed11bce08..000000000 --- a/tests/emscripten_resources/emtests/test_atomic.out +++ /dev/null @@ -1,5 +0,0 @@ -*15,15* -*15,10* -*6,10* -*10,0* -*7,1* \ No newline at end of file diff --git a/tests/emscripten_resources/emtests/test_bsearch.out b/tests/emscripten_resources/emtests/test_bsearch.out deleted file mode 100644 index cc6a32050..000000000 --- a/tests/emscripten_resources/emtests/test_bsearch.out +++ /dev/null @@ -1,10 +0,0 @@ --2 --1 -0 -6 -7 -9 -null -null -null -null \ No newline at end of file diff --git a/tests/emscripten_resources/emtests/test_complex.out b/tests/emscripten_resources/emtests/test_complex.out deleted file mode 100644 index 6f08f2010..000000000 --- a/tests/emscripten_resources/emtests/test_complex.out +++ /dev/null @@ -1,8 +0,0 @@ -value = real 1.00 imag 3.00 -abs = 3.16 -value = real 1.00 imag -3.00 -value = real -2.69 imag 0.38 -value = real 1.00 imag -3.00 -value = real 1.25 imag 0.00 -value = real 0.50 imag 0.00 -value = real 0.00 imag 1.00 diff --git a/tests/emscripten_resources/emtests/test_double_varargs.out b/tests/emscripten_resources/emtests/test_double_varargs.out deleted file mode 100644 index c907decea..000000000 --- a/tests/emscripten_resources/emtests/test_double_varargs.out +++ /dev/null @@ -1,2 +0,0 @@ -15.000000 -15.000000 diff --git a/tests/emscripten_resources/emtests/test_erf.out b/tests/emscripten_resources/emtests/test_erf.out deleted file mode 100644 index 3b48202f9..000000000 --- a/tests/emscripten_resources/emtests/test_erf.out +++ /dev/null @@ -1 +0,0 @@ -0.842701, 0.999978, -0.842701, 0.157299, 0.000022, 1.966105 \ No newline at end of file diff --git a/tests/emscripten_resources/emtests/test_errar.out b/tests/emscripten_resources/emtests/test_errar.out deleted file mode 100644 index 7df247dd0..000000000 --- a/tests/emscripten_resources/emtests/test_errar.out +++ /dev/null @@ -1,4 +0,0 @@ - - -<34> -<123> diff --git a/tests/emscripten_resources/emtests/test_execvp.out b/tests/emscripten_resources/emtests/test_execvp.out deleted file mode 100644 index 5048f1e2c..000000000 --- a/tests/emscripten_resources/emtests/test_execvp.out +++ /dev/null @@ -1 +0,0 @@ -_execvp diff --git a/tests/emscripten_resources/emtests/test_fast_math.out b/tests/emscripten_resources/emtests/test_fast_math.out deleted file mode 100644 index d1bb57009..000000000 --- a/tests/emscripten_resources/emtests/test_fast_math.out +++ /dev/null @@ -1 +0,0 @@ -total: 19 \ No newline at end of file diff --git a/tests/emscripten_resources/emtests/test_fcvt.out b/tests/emscripten_resources/emtests/test_fcvt.out deleted file mode 100644 index 835f34e73..000000000 --- a/tests/emscripten_resources/emtests/test_fcvt.out +++ /dev/null @@ -1 +0,0 @@ -source: 3.1415926535 buffer: '31415927' decimal: 1 sign: 0 \ No newline at end of file diff --git a/tests/emtest.rs b/tests/emtest.rs index bf9de1a27..0527081e6 100644 --- a/tests/emtest.rs +++ b/tests/emtest.rs @@ -1,2 +1,73 @@ -mod emtests; -pub mod utils; +mod utils; + +use crate::utils::stdio::StdioCapturer; +use anyhow::{anyhow, bail}; +use wasmer::compiler::{compile_with, compiler_for_backend, Backend}; +use wasmer_emscripten::{generate_emscripten_env, run_emscripten_instance, EmscriptenGlobals}; + +use lazy_static::lazy_static; +use std::sync::Mutex; +lazy_static! { + // We want to run emscripten tests one by one + // Based from: https://stackoverflow.com/questions/51694017/how-can-i-avoid-running-some-tests-in-parallel + static ref EMSCRIPTEN_LOCK: Mutex<()> = Mutex::new(()); +} + +// The generated tests (from build.rs) look like: +// #[cfg(test)] +// mod singlepass { +// mod wasi { +// #[test] +// fn test_hello_world() -> anyhow::Result<()> { +// crate::run_wasi( +// "tests/emscripten_resources/emtests/test_hello_world.wasm", +// "tests/emscripten_resources/emtests/test_hello_world.out", +// "singlepass" +// ) +// } +// } +// } +include!(concat!(env!("OUT_DIR"), "/generated_emtests.rs")); + +fn run_emscripten(wasm_program_path: &str, output_path: &str, backend: &str) -> anyhow::Result<()> { + let _shared = EMSCRIPTEN_LOCK.lock().unwrap_or_else(|e| e.into_inner()); + + let backend = utils::get_backend_from_str(backend)?; + let program_name = "name"; + + let wasm_binary = std::fs::read(wasm_program_path)?; + let compiler = compiler_for_backend(backend).expect("Backend not recognized"); + let module = compile_with(&wasm_binary, &*compiler).unwrap(); + + let mut emscripten_globals = EmscriptenGlobals::new(&module).expect("globals are valid"); + let import_object = generate_emscripten_env(&mut emscripten_globals); + + let mut instance = module + .instantiate(&import_object) + .map_err(|err| anyhow!("Can't instantiate the WebAssembly module: {:?}", err))?; + + let capturer = StdioCapturer::new(); + + run_emscripten_instance( + &module, + &mut instance, + &mut emscripten_globals, + program_name, + vec![], + None, + vec![], + ) + .expect("run_emscripten_instance finishes"); + + let output = capturer.end().unwrap().0; + + let expected_output = String::from_utf8(std::fs::read(output_path)?)?; + + assert!( + output.contains(&expected_output), + "Output: `{}` does not contain expected output: `{}`", + output, + expected_output + ); + Ok(()) +} diff --git a/tests/emtests/_common.rs b/tests/emtests/_common.rs deleted file mode 100644 index 9eae188d9..000000000 --- a/tests/emtests/_common.rs +++ /dev/null @@ -1,110 +0,0 @@ -use std::env; -use wasmer::compiler::Backend; - -pub fn get_backend() -> Option { - #[cfg(feature = "backend-cranelift")] - { - if let Ok(v) = env::var("WASMER_TEST_CRANELIFT") { - if v == "1" { - return Some(Backend::Cranelift); - } - } - } - #[cfg(feature = "backend-llvm")] - { - if let Ok(v) = env::var("WASMER_TEST_LLVM") { - if v == "1" { - return Some(Backend::LLVM); - } - } - } - #[cfg(feature = "backend-singlepass")] - { - if let Ok(v) = env::var("WASMER_TEST_SINGLEPASS") { - if v == "1" { - return Some(Backend::Singlepass); - } - } - } - - None -} - -macro_rules! assert_emscripten_output { - ($file:expr, $name:expr, $args:expr, $expected:expr) => {{ - - use wasmer_emscripten::{ - EmscriptenGlobals, - generate_emscripten_env, - }; - use crate::utils::stdio::StdioCapturer; - - let wasm_bytes = include_bytes!($file); - let backend = $crate::emtests::_common::get_backend().expect("Please set one of `WASMER_TEST_CRANELIFT`, `WASMER_TEST_LLVM`, or `WASMER_TEST_SINGELPASS` to `1`."); - let compiler = wasmer::compiler::compiler_for_backend(backend).expect("The desired compiler was not found!"); - - let module = wasmer::compiler::compile_with_config_with(&wasm_bytes[..], Default::default(), &*compiler).expect("WASM can't be compiled"); - - let mut emscripten_globals = EmscriptenGlobals::new(&module).expect("globals are valid"); - let import_object = generate_emscripten_env(&mut emscripten_globals); - - let mut instance = module.instantiate(&import_object) - .map_err(|err| format!("Can't instantiate the WebAssembly module: {:?}", err)).unwrap(); // NOTE: Need to figure what the unwrap is for ?? - - let capturer = StdioCapturer::new(); - - wasmer_emscripten::run_emscripten_instance( - &module, - &mut instance, - &mut emscripten_globals, - $name, - $args, - None, - vec![], - ).expect("run_emscripten_instance finishes"); - - let output = capturer.end().unwrap().0; - let expected_output = include_str!($expected); - - assert!( - output.contains(expected_output), - "Output: `{}` does not contain expected output: `{}`", - output, - expected_output - ); - }}; -} - -// pub fn assert_emscripten_output(wasm_bytes: &[u8], raw_expected_str: &str) { -// use wasmer_clif_backend::CraneliftCompiler; -// use wasmer_emscripten::{generate_emscripten_env, stdio::StdioCapturer, EmscriptenGlobals}; - -// let module = wasmer::compiler::compile_with(&wasm_bytes[..], &CraneliftCompiler::new()) -// .expect("WASM can't be compiled"); - -// let mut emscripten_globals = EmscriptenGlobals::new(&module); -// let import_object = generate_emscripten_env(&mut emscripten_globals); -// let mut instance = module -// .instantiate(&import_object) -// .map_err(|err| format!("Can't instantiate the WebAssembly module: {:?}", err)) -// .unwrap(); - -// let capturer = StdioCapturer::new(); - -// wasmer_emscripten::run_emscripten_instance(&module, &mut instance, "test", vec![]) -// .expect("run_emscripten_instance finishes"); - -// let raw_output_string = capturer.end().unwrap().0; - -// // trim the strings to avoid cross-platform line ending and white space issues -// let output = raw_output_string.trim(); -// let expected_output = raw_expected_str.trim(); - -// let contains_output = output.contains(expected_output); - -// assert!( -// contains_output, -// "Output: `{}` does not contain expected output: `{}`", -// output, expected_output -// ); -// } diff --git a/tests/emtests/clock_gettime.rs b/tests/emtests/clock_gettime.rs deleted file mode 100644 index 63f34fc4c..000000000 --- a/tests/emtests/clock_gettime.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_clock_gettime() { - assert_emscripten_output!( - "../emscripten_resources/emtests/clock_gettime.wasm", - "clock_gettime", - vec![], - "../emscripten_resources/emtests/clock_gettime.out" - ); -} diff --git a/tests/emtests/emscripten_get_compiler_setting.rs b/tests/emtests/emscripten_get_compiler_setting.rs deleted file mode 100644 index a9bb2c9d7..000000000 --- a/tests/emtests/emscripten_get_compiler_setting.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_emscripten_get_compiler_setting() { - assert_emscripten_output!( - "../emscripten_resources/emtests/emscripten_get_compiler_setting.wasm", - "emscripten_get_compiler_setting", - vec![], - "../emscripten_resources/emtests/emscripten_get_compiler_setting.out" - ); -} diff --git a/tests/emtests/env.rs b/tests/emtests/env.rs deleted file mode 100644 index c00e28e87..000000000 --- a/tests/emtests/env.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_env() { - assert_emscripten_output!( - "../emscripten_resources/emtests/env.wasm", - "env", - vec![], - "../emscripten_resources/emtests/env.out" - ); -} diff --git a/tests/emtests/fs_exports.rs b/tests/emtests/fs_exports.rs deleted file mode 100644 index 520da5e58..000000000 --- a/tests/emtests/fs_exports.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_fs_exports() { - assert_emscripten_output!( - "../emscripten_resources/emtests/FS_exports.wasm", - "fs_exports", - vec![], - "../emscripten_resources/emtests/FS_exports.txt" - ); -} diff --git a/tests/emtests/getvalue_setvalue.rs b/tests/emtests/getvalue_setvalue.rs deleted file mode 100644 index bd1836237..000000000 --- a/tests/emtests/getvalue_setvalue.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_getvalue_setvalue() { - assert_emscripten_output!( - "../emscripten_resources/emtests/getValue_setValue.wasm", - "getvalue_setvalue", - vec![], - "../emscripten_resources/emtests/getValue_setValue.txt" - ); -} diff --git a/tests/emtests/legacy_exported_runtime_numbers.rs b/tests/emtests/legacy_exported_runtime_numbers.rs deleted file mode 100644 index 53fe06fb0..000000000 --- a/tests/emtests/legacy_exported_runtime_numbers.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_legacy_exported_runtime_numbers() { - assert_emscripten_output!( - "../emscripten_resources/emtests/legacy_exported_runtime_numbers.wasm", - "legacy_exported_runtime_numbers", - vec![], - "../emscripten_resources/emtests/legacy_exported_runtime_numbers.txt" - ); -} diff --git a/tests/emtests/localtime.rs b/tests/emtests/localtime.rs deleted file mode 100644 index 3ede05177..000000000 --- a/tests/emtests/localtime.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_localtime() { - assert_emscripten_output!( - "../emscripten_resources/emtests/localtime.wasm", - "localtime", - vec![], - "../emscripten_resources/emtests/localtime.out" - ); -} diff --git a/tests/emtests/mod.rs b/tests/emtests/mod.rs deleted file mode 100644 index c63afcfd0..000000000 --- a/tests/emtests/mod.rs +++ /dev/null @@ -1,185 +0,0 @@ -// Rust test file autogenerated with cargo build (generate-emscripten-tests). -// Please do NOT modify it by hand, as it will be reseted on next build. - -// The _common module is not autogenerated, as it provides common macros for the emtests -#[macro_use] -mod _common; -mod clock_gettime; -mod emscripten_get_compiler_setting; -mod env; -mod fs_exports; -mod getvalue_setvalue; -mod legacy_exported_runtime_numbers; -mod localtime; -mod modularize_closure_pre; -mod printf; -mod puts; -mod stackalloc; -mod test_addr_of_stacked; -mod test_alloca; -mod test_alloca_stack; -mod test_array2; -mod test_array2b; -mod test_atomic; -mod test_atox; -mod test_bsearch; -mod test_ccall; -mod test_complex; -mod test_demangle_stacks; -mod test_demangle_stacks_noassert; -mod test_dlmalloc_partial_2; -mod test_double_varargs; -mod test_em_asm; -mod test_em_asm_2; -mod test_em_asm_parameter_pack; -mod test_em_asm_signatures; -mod test_em_asm_unicode; -mod test_em_asm_unused_arguments; -mod test_em_js; -mod test_emscripten_api; -mod test_erf; -mod test_errar; -mod test_exceptions_2; -mod test_exceptions_multi; -mod test_exceptions_std; -mod test_exceptions_white_list; -mod test_execvp; -mod test_fast_math; -mod test_flexarray_struct; -mod test_float32_precise; -mod test_float_builtins; -mod test_frexp; -mod test_funcptr; -mod test_funcptr_namecollide; -mod test_funcptrfunc; -mod test_funcs; -mod test_functionpointer_libfunc_varargs; -mod test_fwrite_0; -mod test_getcwd; -mod test_getgep; -mod test_getloadavg; -mod test_getopt; -mod test_getopt_long; -mod test_globaldoubles; -mod test_globals; -mod test_gmtime; -mod test_hello_world; -mod test_i16_emcc_intrinsic; -mod test_i32_mul_precise; -mod test_i64; -mod test_i64_4; -mod test_i64_7z; -mod test_i64_cmp2; -mod test_i64_i16; -mod test_i64_llabs; -mod test_i64_precise; -mod test_i64_precise_needed; -mod test_i64_precise_unneeded; -mod test_i64_qdouble; -mod test_i64_umul; -mod test_i64_varargs; -mod test_i64_zextneg; -mod test_if; -mod test_if_else; -mod test_indirectbr; -mod test_indirectbr_many; -mod test_isnan; -mod test_libcextra; -mod test_libgen; -mod test_literal_negative_zero; -mod test_llrint; -mod test_llvm_fabs; -mod test_llvm_intrinsics; -mod test_llvmswitch; -mod test_longjmp; -mod test_longjmp2; -mod test_longjmp3; -mod test_longjmp4; -mod test_longjmp_exc; -mod test_longjmp_funcptr; -mod test_longjmp_repeat; -mod test_longjmp_stacked; -mod test_longjmp_throw; -mod test_longjmp_unwind; -mod test_loop; -mod test_lower_intrinsics; -mod test_main_thread_async_em_asm; -mod test_mainenv; -mod test_mathfuncptr; -mod test_memcpy2; -mod test_memcpy3; -mod test_memcpy_memcmp; -mod test_memmove; -mod test_memmove2; -mod test_memmove3; -mod test_memset; -mod test_mmap; -mod test_negative_zero; -mod test_nested_struct_varargs; -mod test_nl_types; -mod test_perrar; -mod test_phiundef; -mod test_pipe; -mod test_poll; -mod test_posixtime; -mod test_printf_2; -mod test_printf_more; -mod test_regex; -mod test_relocatable_void_function; -mod test_rounding; -mod test_set_align; -mod test_siglongjmp; -mod test_sintvars; -mod test_sizeof; -mod test_sscanf; -mod test_sscanf_3; -mod test_sscanf_4; -mod test_sscanf_5; -mod test_sscanf_6; -mod test_sscanf_caps; -mod test_sscanf_float; -mod test_sscanf_hex; -mod test_sscanf_n; -mod test_sscanf_other_whitespace; -mod test_sscanf_skip; -mod test_sscanf_whitespace; -mod test_stack_varargs; -mod test_stack_void; -mod test_statvfs; -mod test_std_cout_new; -mod test_strcasecmp; -mod test_strcmp_uni; -mod test_strftime; -mod test_strings; -mod test_strndup; -mod test_strptime_days; -mod test_strptime_reentrant; -mod test_strstr; -mod test_strtod; -mod test_strtok; -mod test_strtol_bin; -mod test_strtol_dec; -mod test_strtol_hex; -mod test_strtol_oct; -mod test_strtold; -mod test_strtoll_bin; -mod test_strtoll_dec; -mod test_strtoll_hex; -mod test_strtoll_oct; -mod test_struct_varargs; -mod test_time_c; -mod test_tracing; -mod test_transtrcase; -mod test_trickystring; -mod test_uname; -mod test_unary_literal; -mod test_utf; -mod test_varargs; -mod test_varargs_multi; -mod test_vfs; -mod test_vprintf; -mod test_vsnprintf; -mod test_wprintf; -mod test_write_stdout_fileno; -mod test_zero_multiplication; -mod test_zerodiv; diff --git a/tests/emtests/modularize_closure_pre.rs b/tests/emtests/modularize_closure_pre.rs deleted file mode 100644 index 21cebbdbf..000000000 --- a/tests/emtests/modularize_closure_pre.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_modularize_closure_pre() { - assert_emscripten_output!( - "../emscripten_resources/emtests/modularize_closure_pre.wasm", - "modularize_closure_pre", - vec![], - "../emscripten_resources/emtests/modularize_closure_pre.out" - ); -} diff --git a/tests/emtests/printf.rs b/tests/emtests/printf.rs deleted file mode 100644 index a093a1a32..000000000 --- a/tests/emtests/printf.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_printf() { - assert_emscripten_output!( - "../emscripten_resources/emtests/printf.wasm", - "printf", - vec![], - "../emscripten_resources/emtests/printf.out" - ); -} diff --git a/tests/emtests/puts.rs b/tests/emtests/puts.rs deleted file mode 100644 index 900cadc93..000000000 --- a/tests/emtests/puts.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_puts() { - assert_emscripten_output!( - "../emscripten_resources/emtests/puts.wasm", - "puts", - vec![], - "../emscripten_resources/emtests/puts.out" - ); -} diff --git a/tests/emtests/stackalloc.rs b/tests/emtests/stackalloc.rs deleted file mode 100644 index 2c00b5547..000000000 --- a/tests/emtests/stackalloc.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_stackalloc() { - assert_emscripten_output!( - "../emscripten_resources/emtests/stackAlloc.wasm", - "stackalloc", - vec![], - "../emscripten_resources/emtests/stackAlloc.txt" - ); -} diff --git a/tests/emtests/syscalls.rs b/tests/emtests/syscalls.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/emtests/test_addr_of_stacked.rs b/tests/emtests/test_addr_of_stacked.rs deleted file mode 100644 index 1883a4fba..000000000 --- a/tests/emtests/test_addr_of_stacked.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_addr_of_stacked() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_addr_of_stacked.wasm", - "test_addr_of_stacked", - vec![], - "../emscripten_resources/emtests/test_addr_of_stacked.out" - ); -} diff --git a/tests/emtests/test_alloca.rs b/tests/emtests/test_alloca.rs deleted file mode 100644 index ee0683d9f..000000000 --- a/tests/emtests/test_alloca.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_alloca() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_alloca.wasm", - "test_alloca", - vec![], - "../emscripten_resources/emtests/test_alloca.out" - ); -} diff --git a/tests/emtests/test_alloca_stack.rs b/tests/emtests/test_alloca_stack.rs deleted file mode 100644 index 6fe6797a2..000000000 --- a/tests/emtests/test_alloca_stack.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_alloca_stack() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_alloca_stack.wasm", - "test_alloca_stack", - vec![], - "../emscripten_resources/emtests/test_alloca_stack.out" - ); -} diff --git a/tests/emtests/test_array2.rs b/tests/emtests/test_array2.rs deleted file mode 100644 index 53e916893..000000000 --- a/tests/emtests/test_array2.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_array2() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_array2.wasm", - "test_array2", - vec![], - "../emscripten_resources/emtests/test_array2.out" - ); -} diff --git a/tests/emtests/test_array2b.rs b/tests/emtests/test_array2b.rs deleted file mode 100644 index b60426f2d..000000000 --- a/tests/emtests/test_array2b.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_array2b() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_array2b.wasm", - "test_array2b", - vec![], - "../emscripten_resources/emtests/test_array2b.out" - ); -} diff --git a/tests/emtests/test_atomic.rs b/tests/emtests/test_atomic.rs deleted file mode 100644 index 5c9f44dfe..000000000 --- a/tests/emtests/test_atomic.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_atomic() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_atomic.wasm", - "test_atomic", - vec![], - "../emscripten_resources/emtests/test_atomic.out" - ); -} diff --git a/tests/emtests/test_atox.rs b/tests/emtests/test_atox.rs deleted file mode 100644 index 0e7bd0efd..000000000 --- a/tests/emtests/test_atox.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_atox() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_atoX.wasm", - "test_atox", - vec![], - "../emscripten_resources/emtests/test_atoX.out" - ); -} diff --git a/tests/emtests/test_bsearch.rs b/tests/emtests/test_bsearch.rs deleted file mode 100644 index f5c6ba428..000000000 --- a/tests/emtests/test_bsearch.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_bsearch() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_bsearch.wasm", - "test_bsearch", - vec![], - "../emscripten_resources/emtests/test_bsearch.out" - ); -} diff --git a/tests/emtests/test_ccall.rs b/tests/emtests/test_ccall.rs deleted file mode 100644 index 459e69c09..000000000 --- a/tests/emtests/test_ccall.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_ccall() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_ccall.wasm", - "test_ccall", - vec![], - "../emscripten_resources/emtests/test_ccall.out" - ); -} diff --git a/tests/emtests/test_complex.rs b/tests/emtests/test_complex.rs deleted file mode 100644 index d026c2c27..000000000 --- a/tests/emtests/test_complex.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_complex() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_complex.wasm", - "test_complex", - vec![], - "../emscripten_resources/emtests/test_complex.out" - ); -} diff --git a/tests/emtests/test_demangle_stacks.rs b/tests/emtests/test_demangle_stacks.rs deleted file mode 100644 index 0bd31dbcb..000000000 --- a/tests/emtests/test_demangle_stacks.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_demangle_stacks() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_demangle_stacks.wasm", - "test_demangle_stacks", - vec![], - "../emscripten_resources/emtests/test_demangle_stacks.out" - ); -} diff --git a/tests/emtests/test_demangle_stacks_noassert.rs b/tests/emtests/test_demangle_stacks_noassert.rs deleted file mode 100644 index b4a1dbf51..000000000 --- a/tests/emtests/test_demangle_stacks_noassert.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_demangle_stacks_noassert() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_demangle_stacks_noassert.wasm", - "test_demangle_stacks_noassert", - vec![], - "../emscripten_resources/emtests/test_demangle_stacks_noassert.out" - ); -} diff --git a/tests/emtests/test_dlmalloc_partial_2.rs b/tests/emtests/test_dlmalloc_partial_2.rs deleted file mode 100644 index 6b97f917b..000000000 --- a/tests/emtests/test_dlmalloc_partial_2.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_dlmalloc_partial_2() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_dlmalloc_partial_2.wasm", - "test_dlmalloc_partial_2", - vec![], - "../emscripten_resources/emtests/test_dlmalloc_partial_2.out" - ); -} diff --git a/tests/emtests/test_double_varargs.rs b/tests/emtests/test_double_varargs.rs deleted file mode 100644 index 556e65cae..000000000 --- a/tests/emtests/test_double_varargs.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_double_varargs() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_double_varargs.wasm", - "test_double_varargs", - vec![], - "../emscripten_resources/emtests/test_double_varargs.out" - ); -} diff --git a/tests/emtests/test_em_asm.rs b/tests/emtests/test_em_asm.rs deleted file mode 100644 index 182e23f0c..000000000 --- a/tests/emtests/test_em_asm.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_em_asm() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_em_asm.wasm", - "test_em_asm", - vec![], - "../emscripten_resources/emtests/test_em_asm.out" - ); -} diff --git a/tests/emtests/test_em_asm_2.rs b/tests/emtests/test_em_asm_2.rs deleted file mode 100644 index 4ee103579..000000000 --- a/tests/emtests/test_em_asm_2.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_em_asm_2() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_em_asm_2.wasm", - "test_em_asm_2", - vec![], - "../emscripten_resources/emtests/test_em_asm_2.out" - ); -} diff --git a/tests/emtests/test_em_asm_parameter_pack.rs b/tests/emtests/test_em_asm_parameter_pack.rs deleted file mode 100644 index 420efc5ea..000000000 --- a/tests/emtests/test_em_asm_parameter_pack.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_em_asm_parameter_pack() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_em_asm_parameter_pack.wasm", - "test_em_asm_parameter_pack", - vec![], - "../emscripten_resources/emtests/test_em_asm_parameter_pack.out" - ); -} diff --git a/tests/emtests/test_em_asm_signatures.rs b/tests/emtests/test_em_asm_signatures.rs deleted file mode 100644 index d0470166d..000000000 --- a/tests/emtests/test_em_asm_signatures.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_em_asm_signatures() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_em_asm_signatures.wasm", - "test_em_asm_signatures", - vec![], - "../emscripten_resources/emtests/test_em_asm_signatures.out" - ); -} diff --git a/tests/emtests/test_em_asm_unicode.rs b/tests/emtests/test_em_asm_unicode.rs deleted file mode 100644 index a00ae3b42..000000000 --- a/tests/emtests/test_em_asm_unicode.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_em_asm_unicode() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_em_asm_unicode.wasm", - "test_em_asm_unicode", - vec![], - "../emscripten_resources/emtests/test_em_asm_unicode.out" - ); -} diff --git a/tests/emtests/test_em_asm_unused_arguments.rs b/tests/emtests/test_em_asm_unused_arguments.rs deleted file mode 100644 index 3b7a07206..000000000 --- a/tests/emtests/test_em_asm_unused_arguments.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_em_asm_unused_arguments() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_em_asm_unused_arguments.wasm", - "test_em_asm_unused_arguments", - vec![], - "../emscripten_resources/emtests/test_em_asm_unused_arguments.out" - ); -} diff --git a/tests/emtests/test_em_js.rs b/tests/emtests/test_em_js.rs deleted file mode 100644 index ff4502c2e..000000000 --- a/tests/emtests/test_em_js.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_em_js() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_em_js.wasm", - "test_em_js", - vec![], - "../emscripten_resources/emtests/test_em_js.out" - ); -} diff --git a/tests/emtests/test_emscripten_api.rs b/tests/emtests/test_emscripten_api.rs deleted file mode 100644 index 95d79e708..000000000 --- a/tests/emtests/test_emscripten_api.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_emscripten_api() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_emscripten_api.wasm", - "test_emscripten_api", - vec![], - "../emscripten_resources/emtests/test_emscripten_api.out" - ); -} diff --git a/tests/emtests/test_erf.rs b/tests/emtests/test_erf.rs deleted file mode 100644 index efc16ccb3..000000000 --- a/tests/emtests/test_erf.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_erf() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_erf.wasm", - "test_erf", - vec![], - "../emscripten_resources/emtests/test_erf.out" - ); -} diff --git a/tests/emtests/test_errar.rs b/tests/emtests/test_errar.rs deleted file mode 100644 index 94238860c..000000000 --- a/tests/emtests/test_errar.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_errar() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_errar.wasm", - "test_errar", - vec![], - "../emscripten_resources/emtests/test_errar.out" - ); -} diff --git a/tests/emtests/test_exceptions_2.rs b/tests/emtests/test_exceptions_2.rs deleted file mode 100644 index 6360db35e..000000000 --- a/tests/emtests/test_exceptions_2.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_exceptions_2() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_exceptions_2.wasm", - "test_exceptions_2", - vec![], - "../emscripten_resources/emtests/test_exceptions_2.out" - ); -} diff --git a/tests/emtests/test_exceptions_multi.rs b/tests/emtests/test_exceptions_multi.rs deleted file mode 100644 index 1a6c28801..000000000 --- a/tests/emtests/test_exceptions_multi.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_exceptions_multi() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_exceptions_multi.wasm", - "test_exceptions_multi", - vec![], - "../emscripten_resources/emtests/test_exceptions_multi.out" - ); -} diff --git a/tests/emtests/test_exceptions_std.rs b/tests/emtests/test_exceptions_std.rs deleted file mode 100644 index 1003b60c3..000000000 --- a/tests/emtests/test_exceptions_std.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_exceptions_std() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_exceptions_std.wasm", - "test_exceptions_std", - vec![], - "../emscripten_resources/emtests/test_exceptions_std.out" - ); -} diff --git a/tests/emtests/test_exceptions_white_list.rs b/tests/emtests/test_exceptions_white_list.rs deleted file mode 100644 index ce5db9ff5..000000000 --- a/tests/emtests/test_exceptions_white_list.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_exceptions_white_list() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_exceptions_white_list.wasm", - "test_exceptions_white_list", - vec![], - "../emscripten_resources/emtests/test_exceptions_white_list.out" - ); -} diff --git a/tests/emtests/test_execvp.rs b/tests/emtests/test_execvp.rs deleted file mode 100644 index 2d60751a5..000000000 --- a/tests/emtests/test_execvp.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_execvp() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_execvp.wasm", - "test_execvp", - vec![], - "../emscripten_resources/emtests/test_execvp.out" - ); -} diff --git a/tests/emtests/test_fast_math.rs b/tests/emtests/test_fast_math.rs deleted file mode 100644 index 9a025d48c..000000000 --- a/tests/emtests/test_fast_math.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_fast_math() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_fast_math.wasm", - "test_fast_math", - vec![], - "../emscripten_resources/emtests/test_fast_math.out" - ); -} diff --git a/tests/emtests/test_flexarray_struct.rs b/tests/emtests/test_flexarray_struct.rs deleted file mode 100644 index 922209a2c..000000000 --- a/tests/emtests/test_flexarray_struct.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_flexarray_struct() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_flexarray_struct.wasm", - "test_flexarray_struct", - vec![], - "../emscripten_resources/emtests/test_flexarray_struct.out" - ); -} diff --git a/tests/emtests/test_float32_precise.rs b/tests/emtests/test_float32_precise.rs deleted file mode 100644 index 3fa808eb2..000000000 --- a/tests/emtests/test_float32_precise.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_float32_precise() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_float32_precise.wasm", - "test_float32_precise", - vec![], - "../emscripten_resources/emtests/test_float32_precise.out" - ); -} diff --git a/tests/emtests/test_float_builtins.rs b/tests/emtests/test_float_builtins.rs deleted file mode 100644 index 120455267..000000000 --- a/tests/emtests/test_float_builtins.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_float_builtins() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_float_builtins.wasm", - "test_float_builtins", - vec![], - "../emscripten_resources/emtests/test_float_builtins.out" - ); -} diff --git a/tests/emtests/test_frexp.rs b/tests/emtests/test_frexp.rs deleted file mode 100644 index 43552c702..000000000 --- a/tests/emtests/test_frexp.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_frexp() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_frexp.wasm", - "test_frexp", - vec![], - "../emscripten_resources/emtests/test_frexp.out" - ); -} diff --git a/tests/emtests/test_funcptr.rs b/tests/emtests/test_funcptr.rs deleted file mode 100644 index 48f08bf9d..000000000 --- a/tests/emtests/test_funcptr.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_funcptr() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_funcptr.wasm", - "test_funcptr", - vec![], - "../emscripten_resources/emtests/test_funcptr.out" - ); -} diff --git a/tests/emtests/test_funcptr_namecollide.rs b/tests/emtests/test_funcptr_namecollide.rs deleted file mode 100644 index 794ece293..000000000 --- a/tests/emtests/test_funcptr_namecollide.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_funcptr_namecollide() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_funcptr_namecollide.wasm", - "test_funcptr_namecollide", - vec![], - "../emscripten_resources/emtests/test_funcptr_namecollide.out" - ); -} diff --git a/tests/emtests/test_funcptrfunc.rs b/tests/emtests/test_funcptrfunc.rs deleted file mode 100644 index a9bbccd35..000000000 --- a/tests/emtests/test_funcptrfunc.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_funcptrfunc() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_funcptrfunc.wasm", - "test_funcptrfunc", - vec![], - "../emscripten_resources/emtests/test_funcptrfunc.out" - ); -} diff --git a/tests/emtests/test_funcs.rs b/tests/emtests/test_funcs.rs deleted file mode 100644 index bdd85b675..000000000 --- a/tests/emtests/test_funcs.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_funcs() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_funcs.wasm", - "test_funcs", - vec![], - "../emscripten_resources/emtests/test_funcs.out" - ); -} diff --git a/tests/emtests/test_functionpointer_libfunc_varargs.rs b/tests/emtests/test_functionpointer_libfunc_varargs.rs deleted file mode 100644 index 9e0e24025..000000000 --- a/tests/emtests/test_functionpointer_libfunc_varargs.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_functionpointer_libfunc_varargs() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_functionpointer_libfunc_varargs.wasm", - "test_functionpointer_libfunc_varargs", - vec![], - "../emscripten_resources/emtests/test_functionpointer_libfunc_varargs.out" - ); -} diff --git a/tests/emtests/test_fwrite_0.rs b/tests/emtests/test_fwrite_0.rs deleted file mode 100644 index 1ac0aa0e5..000000000 --- a/tests/emtests/test_fwrite_0.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_fwrite_0() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_fwrite_0.wasm", - "test_fwrite_0", - vec![], - "../emscripten_resources/emtests/test_fwrite_0.out" - ); -} diff --git a/tests/emtests/test_getcwd.rs b/tests/emtests/test_getcwd.rs deleted file mode 100644 index fd8012b24..000000000 --- a/tests/emtests/test_getcwd.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_getcwd() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_getcwd.wasm", - "test_getcwd", - vec![], - "../emscripten_resources/emtests/test_getcwd.out" - ); -} diff --git a/tests/emtests/test_getgep.rs b/tests/emtests/test_getgep.rs deleted file mode 100644 index 5a9cc8e3d..000000000 --- a/tests/emtests/test_getgep.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_getgep() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_getgep.wasm", - "test_getgep", - vec![], - "../emscripten_resources/emtests/test_getgep.out" - ); -} diff --git a/tests/emtests/test_getloadavg.rs b/tests/emtests/test_getloadavg.rs deleted file mode 100644 index a94db0dd0..000000000 --- a/tests/emtests/test_getloadavg.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_getloadavg() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_getloadavg.wasm", - "test_getloadavg", - vec![], - "../emscripten_resources/emtests/test_getloadavg.out" - ); -} diff --git a/tests/emtests/test_getopt.rs b/tests/emtests/test_getopt.rs deleted file mode 100644 index 6f2bf6bf7..000000000 --- a/tests/emtests/test_getopt.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_getopt() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_getopt.wasm", - "test_getopt", - vec![], - "../emscripten_resources/emtests/test_getopt.out" - ); -} diff --git a/tests/emtests/test_getopt_long.rs b/tests/emtests/test_getopt_long.rs deleted file mode 100644 index 06590b053..000000000 --- a/tests/emtests/test_getopt_long.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_getopt_long() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_getopt_long.wasm", - "test_getopt_long", - vec![], - "../emscripten_resources/emtests/test_getopt_long.out" - ); -} diff --git a/tests/emtests/test_globaldoubles.rs b/tests/emtests/test_globaldoubles.rs deleted file mode 100644 index e85702634..000000000 --- a/tests/emtests/test_globaldoubles.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_globaldoubles() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_globaldoubles.wasm", - "test_globaldoubles", - vec![], - "../emscripten_resources/emtests/test_globaldoubles.out" - ); -} diff --git a/tests/emtests/test_globals.rs b/tests/emtests/test_globals.rs deleted file mode 100644 index 3edd9dee8..000000000 --- a/tests/emtests/test_globals.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_globals() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_globals.wasm", - "test_globals", - vec![], - "../emscripten_resources/emtests/test_globals.out" - ); -} diff --git a/tests/emtests/test_gmtime.rs b/tests/emtests/test_gmtime.rs deleted file mode 100644 index 96f4c8c7d..000000000 --- a/tests/emtests/test_gmtime.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_gmtime() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_gmtime.wasm", - "test_gmtime", - vec![], - "../emscripten_resources/emtests/test_gmtime.out" - ); -} diff --git a/tests/emtests/test_hello_world.rs b/tests/emtests/test_hello_world.rs deleted file mode 100644 index 32b28f25c..000000000 --- a/tests/emtests/test_hello_world.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_hello_world() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_hello_world.wasm", - "test_hello_world", - vec![], - "../emscripten_resources/emtests/test_hello_world.out" - ); -} diff --git a/tests/emtests/test_i16_emcc_intrinsic.rs b/tests/emtests/test_i16_emcc_intrinsic.rs deleted file mode 100644 index cc4b5d6c0..000000000 --- a/tests/emtests/test_i16_emcc_intrinsic.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_i16_emcc_intrinsic() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_i16_emcc_intrinsic.wasm", - "test_i16_emcc_intrinsic", - vec![], - "../emscripten_resources/emtests/test_i16_emcc_intrinsic.out" - ); -} diff --git a/tests/emtests/test_i32_mul_precise.rs b/tests/emtests/test_i32_mul_precise.rs deleted file mode 100644 index 92c2b6bf6..000000000 --- a/tests/emtests/test_i32_mul_precise.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_i32_mul_precise() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_i32_mul_precise.wasm", - "test_i32_mul_precise", - vec![], - "../emscripten_resources/emtests/test_i32_mul_precise.out" - ); -} diff --git a/tests/emtests/test_i64.rs b/tests/emtests/test_i64.rs deleted file mode 100644 index 7b6c1cdc8..000000000 --- a/tests/emtests/test_i64.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_i64() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_i64.wasm", - "test_i64", - vec![], - "../emscripten_resources/emtests/test_i64.out" - ); -} diff --git a/tests/emtests/test_i64_4.rs b/tests/emtests/test_i64_4.rs deleted file mode 100644 index 394f0edd3..000000000 --- a/tests/emtests/test_i64_4.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_i64_4() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_i64_4.wasm", - "test_i64_4", - vec![], - "../emscripten_resources/emtests/test_i64_4.out" - ); -} diff --git a/tests/emtests/test_i64_7z.rs b/tests/emtests/test_i64_7z.rs deleted file mode 100644 index 4e76c919f..000000000 --- a/tests/emtests/test_i64_7z.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_i64_7z() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_i64_7z.wasm", - "test_i64_7z", - vec![], - "../emscripten_resources/emtests/test_i64_7z.out" - ); -} diff --git a/tests/emtests/test_i64_cmp2.rs b/tests/emtests/test_i64_cmp2.rs deleted file mode 100644 index 4ba994da4..000000000 --- a/tests/emtests/test_i64_cmp2.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_i64_cmp2() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_i64_cmp2.wasm", - "test_i64_cmp2", - vec![], - "../emscripten_resources/emtests/test_i64_cmp2.out" - ); -} diff --git a/tests/emtests/test_i64_i16.rs b/tests/emtests/test_i64_i16.rs deleted file mode 100644 index 32a98a633..000000000 --- a/tests/emtests/test_i64_i16.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_i64_i16() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_i64_i16.wasm", - "test_i64_i16", - vec![], - "../emscripten_resources/emtests/test_i64_i16.out" - ); -} diff --git a/tests/emtests/test_i64_llabs.rs b/tests/emtests/test_i64_llabs.rs deleted file mode 100644 index babf82e37..000000000 --- a/tests/emtests/test_i64_llabs.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_i64_llabs() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_i64_llabs.wasm", - "test_i64_llabs", - vec![], - "../emscripten_resources/emtests/test_i64_llabs.out" - ); -} diff --git a/tests/emtests/test_i64_precise.rs b/tests/emtests/test_i64_precise.rs deleted file mode 100644 index 4ed397f21..000000000 --- a/tests/emtests/test_i64_precise.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_i64_precise() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_i64_precise.wasm", - "test_i64_precise", - vec![], - "../emscripten_resources/emtests/test_i64_precise.out" - ); -} diff --git a/tests/emtests/test_i64_precise_needed.rs b/tests/emtests/test_i64_precise_needed.rs deleted file mode 100644 index 01eefaeb3..000000000 --- a/tests/emtests/test_i64_precise_needed.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_i64_precise_needed() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_i64_precise_needed.wasm", - "test_i64_precise_needed", - vec![], - "../emscripten_resources/emtests/test_i64_precise_needed.out" - ); -} diff --git a/tests/emtests/test_i64_precise_unneeded.rs b/tests/emtests/test_i64_precise_unneeded.rs deleted file mode 100644 index 4f8815bc5..000000000 --- a/tests/emtests/test_i64_precise_unneeded.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_i64_precise_unneeded() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_i64_precise_unneeded.wasm", - "test_i64_precise_unneeded", - vec![], - "../emscripten_resources/emtests/test_i64_precise_unneeded.out" - ); -} diff --git a/tests/emtests/test_i64_qdouble.rs b/tests/emtests/test_i64_qdouble.rs deleted file mode 100644 index dae1f36bf..000000000 --- a/tests/emtests/test_i64_qdouble.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_i64_qdouble() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_i64_qdouble.wasm", - "test_i64_qdouble", - vec![], - "../emscripten_resources/emtests/test_i64_qdouble.out" - ); -} diff --git a/tests/emtests/test_i64_umul.rs b/tests/emtests/test_i64_umul.rs deleted file mode 100644 index 8eb16c696..000000000 --- a/tests/emtests/test_i64_umul.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_i64_umul() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_i64_umul.wasm", - "test_i64_umul", - vec![], - "../emscripten_resources/emtests/test_i64_umul.out" - ); -} diff --git a/tests/emtests/test_i64_varargs.rs b/tests/emtests/test_i64_varargs.rs deleted file mode 100644 index 6a8c25492..000000000 --- a/tests/emtests/test_i64_varargs.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_i64_varargs() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_i64_varargs.wasm", - "test_i64_varargs", - vec![], - "../emscripten_resources/emtests/test_i64_varargs.out" - ); -} diff --git a/tests/emtests/test_i64_zextneg.rs b/tests/emtests/test_i64_zextneg.rs deleted file mode 100644 index 0f090ef9a..000000000 --- a/tests/emtests/test_i64_zextneg.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_i64_zextneg() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_i64_zextneg.wasm", - "test_i64_zextneg", - vec![], - "../emscripten_resources/emtests/test_i64_zextneg.out" - ); -} diff --git a/tests/emtests/test_if.rs b/tests/emtests/test_if.rs deleted file mode 100644 index b0204454e..000000000 --- a/tests/emtests/test_if.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_if() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_if.wasm", - "test_if", - vec![], - "../emscripten_resources/emtests/test_if.out" - ); -} diff --git a/tests/emtests/test_if_else.rs b/tests/emtests/test_if_else.rs deleted file mode 100644 index 7f7eed1d9..000000000 --- a/tests/emtests/test_if_else.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_if_else() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_if_else.wasm", - "test_if_else", - vec![], - "../emscripten_resources/emtests/test_if_else.out" - ); -} diff --git a/tests/emtests/test_indirectbr.rs b/tests/emtests/test_indirectbr.rs deleted file mode 100644 index a02864e17..000000000 --- a/tests/emtests/test_indirectbr.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_indirectbr() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_indirectbr.wasm", - "test_indirectbr", - vec![], - "../emscripten_resources/emtests/test_indirectbr.out" - ); -} diff --git a/tests/emtests/test_indirectbr_many.rs b/tests/emtests/test_indirectbr_many.rs deleted file mode 100644 index 6deddfc0f..000000000 --- a/tests/emtests/test_indirectbr_many.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_indirectbr_many() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_indirectbr_many.wasm", - "test_indirectbr_many", - vec![], - "../emscripten_resources/emtests/test_indirectbr_many.out" - ); -} diff --git a/tests/emtests/test_isnan.rs b/tests/emtests/test_isnan.rs deleted file mode 100644 index d33419f4a..000000000 --- a/tests/emtests/test_isnan.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_isnan() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_isnan.wasm", - "test_isnan", - vec![], - "../emscripten_resources/emtests/test_isnan.out" - ); -} diff --git a/tests/emtests/test_libcextra.rs b/tests/emtests/test_libcextra.rs deleted file mode 100644 index ea5381c97..000000000 --- a/tests/emtests/test_libcextra.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_libcextra() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_libcextra.wasm", - "test_libcextra", - vec![], - "../emscripten_resources/emtests/test_libcextra.out" - ); -} diff --git a/tests/emtests/test_libgen.rs b/tests/emtests/test_libgen.rs deleted file mode 100644 index 89489d4ae..000000000 --- a/tests/emtests/test_libgen.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_libgen() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_libgen.wasm", - "test_libgen", - vec![], - "../emscripten_resources/emtests/test_libgen.out" - ); -} diff --git a/tests/emtests/test_literal_negative_zero.rs b/tests/emtests/test_literal_negative_zero.rs deleted file mode 100644 index 3a02206aa..000000000 --- a/tests/emtests/test_literal_negative_zero.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_literal_negative_zero() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_literal_negative_zero.wasm", - "test_literal_negative_zero", - vec![], - "../emscripten_resources/emtests/test_literal_negative_zero.out" - ); -} diff --git a/tests/emtests/test_llrint.rs b/tests/emtests/test_llrint.rs deleted file mode 100644 index 4c6114fad..000000000 --- a/tests/emtests/test_llrint.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_llrint() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_llrint.wasm", - "test_llrint", - vec![], - "../emscripten_resources/emtests/test_llrint.out" - ); -} diff --git a/tests/emtests/test_llvm_fabs.rs b/tests/emtests/test_llvm_fabs.rs deleted file mode 100644 index 33c2cb183..000000000 --- a/tests/emtests/test_llvm_fabs.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_llvm_fabs() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_llvm_fabs.wasm", - "test_llvm_fabs", - vec![], - "../emscripten_resources/emtests/test_llvm_fabs.out" - ); -} diff --git a/tests/emtests/test_llvm_intrinsics.rs b/tests/emtests/test_llvm_intrinsics.rs deleted file mode 100644 index 3227d71cc..000000000 --- a/tests/emtests/test_llvm_intrinsics.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_llvm_intrinsics() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_llvm_intrinsics.wasm", - "test_llvm_intrinsics", - vec![], - "../emscripten_resources/emtests/test_llvm_intrinsics.out" - ); -} diff --git a/tests/emtests/test_llvmswitch.rs b/tests/emtests/test_llvmswitch.rs deleted file mode 100644 index 5a0dfa058..000000000 --- a/tests/emtests/test_llvmswitch.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_llvmswitch() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_llvmswitch.wasm", - "test_llvmswitch", - vec![], - "../emscripten_resources/emtests/test_llvmswitch.out" - ); -} diff --git a/tests/emtests/test_longjmp.rs b/tests/emtests/test_longjmp.rs deleted file mode 100644 index 67b76c704..000000000 --- a/tests/emtests/test_longjmp.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_longjmp() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_longjmp.wasm", - "test_longjmp", - vec![], - "../emscripten_resources/emtests/test_longjmp.out" - ); -} diff --git a/tests/emtests/test_longjmp2.rs b/tests/emtests/test_longjmp2.rs deleted file mode 100644 index 3eeb77899..000000000 --- a/tests/emtests/test_longjmp2.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_longjmp2() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_longjmp2.wasm", - "test_longjmp2", - vec![], - "../emscripten_resources/emtests/test_longjmp2.out" - ); -} diff --git a/tests/emtests/test_longjmp3.rs b/tests/emtests/test_longjmp3.rs deleted file mode 100644 index c878374ba..000000000 --- a/tests/emtests/test_longjmp3.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_longjmp3() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_longjmp3.wasm", - "test_longjmp3", - vec![], - "../emscripten_resources/emtests/test_longjmp3.out" - ); -} diff --git a/tests/emtests/test_longjmp4.rs b/tests/emtests/test_longjmp4.rs deleted file mode 100644 index 7a05e1637..000000000 --- a/tests/emtests/test_longjmp4.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_longjmp4() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_longjmp4.wasm", - "test_longjmp4", - vec![], - "../emscripten_resources/emtests/test_longjmp4.out" - ); -} diff --git a/tests/emtests/test_longjmp_exc.rs b/tests/emtests/test_longjmp_exc.rs deleted file mode 100644 index 1fac03a3e..000000000 --- a/tests/emtests/test_longjmp_exc.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_longjmp_exc() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_longjmp_exc.wasm", - "test_longjmp_exc", - vec![], - "../emscripten_resources/emtests/test_longjmp_exc.out" - ); -} diff --git a/tests/emtests/test_longjmp_funcptr.rs b/tests/emtests/test_longjmp_funcptr.rs deleted file mode 100644 index e2a127d26..000000000 --- a/tests/emtests/test_longjmp_funcptr.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_longjmp_funcptr() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_longjmp_funcptr.wasm", - "test_longjmp_funcptr", - vec![], - "../emscripten_resources/emtests/test_longjmp_funcptr.out" - ); -} diff --git a/tests/emtests/test_longjmp_repeat.rs b/tests/emtests/test_longjmp_repeat.rs deleted file mode 100644 index 7f2f27b8e..000000000 --- a/tests/emtests/test_longjmp_repeat.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_longjmp_repeat() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_longjmp_repeat.wasm", - "test_longjmp_repeat", - vec![], - "../emscripten_resources/emtests/test_longjmp_repeat.out" - ); -} diff --git a/tests/emtests/test_longjmp_stacked.rs b/tests/emtests/test_longjmp_stacked.rs deleted file mode 100644 index 4d2fddd4d..000000000 --- a/tests/emtests/test_longjmp_stacked.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_longjmp_stacked() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_longjmp_stacked.wasm", - "test_longjmp_stacked", - vec![], - "../emscripten_resources/emtests/test_longjmp_stacked.out" - ); -} diff --git a/tests/emtests/test_longjmp_throw.rs b/tests/emtests/test_longjmp_throw.rs deleted file mode 100644 index 15b382f05..000000000 --- a/tests/emtests/test_longjmp_throw.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_longjmp_throw() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_longjmp_throw.wasm", - "test_longjmp_throw", - vec![], - "../emscripten_resources/emtests/test_longjmp_throw.out" - ); -} diff --git a/tests/emtests/test_longjmp_unwind.rs b/tests/emtests/test_longjmp_unwind.rs deleted file mode 100644 index 0c9780c41..000000000 --- a/tests/emtests/test_longjmp_unwind.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_longjmp_unwind() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_longjmp_unwind.wasm", - "test_longjmp_unwind", - vec![], - "../emscripten_resources/emtests/test_longjmp_unwind.out" - ); -} diff --git a/tests/emtests/test_loop.rs b/tests/emtests/test_loop.rs deleted file mode 100644 index c6c61ffd9..000000000 --- a/tests/emtests/test_loop.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_loop() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_loop.wasm", - "test_loop", - vec![], - "../emscripten_resources/emtests/test_loop.out" - ); -} diff --git a/tests/emtests/test_lower_intrinsics.rs b/tests/emtests/test_lower_intrinsics.rs deleted file mode 100644 index a5aa51c79..000000000 --- a/tests/emtests/test_lower_intrinsics.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_lower_intrinsics() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_lower_intrinsics.wasm", - "test_lower_intrinsics", - vec![], - "../emscripten_resources/emtests/test_lower_intrinsics.out" - ); -} diff --git a/tests/emtests/test_main_thread_async_em_asm.rs b/tests/emtests/test_main_thread_async_em_asm.rs deleted file mode 100644 index a76fbd4b8..000000000 --- a/tests/emtests/test_main_thread_async_em_asm.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_main_thread_async_em_asm() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_main_thread_async_em_asm.wasm", - "test_main_thread_async_em_asm", - vec![], - "../emscripten_resources/emtests/test_main_thread_async_em_asm.out" - ); -} diff --git a/tests/emtests/test_mainenv.rs b/tests/emtests/test_mainenv.rs deleted file mode 100644 index 9ce017731..000000000 --- a/tests/emtests/test_mainenv.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_mainenv() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_mainenv.wasm", - "test_mainenv", - vec![], - "../emscripten_resources/emtests/test_mainenv.out" - ); -} diff --git a/tests/emtests/test_mathfuncptr.rs b/tests/emtests/test_mathfuncptr.rs deleted file mode 100644 index 32da526b5..000000000 --- a/tests/emtests/test_mathfuncptr.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_mathfuncptr() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_mathfuncptr.wasm", - "test_mathfuncptr", - vec![], - "../emscripten_resources/emtests/test_mathfuncptr.out" - ); -} diff --git a/tests/emtests/test_memcpy2.rs b/tests/emtests/test_memcpy2.rs deleted file mode 100644 index 972d7b454..000000000 --- a/tests/emtests/test_memcpy2.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_memcpy2() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_memcpy2.wasm", - "test_memcpy2", - vec![], - "../emscripten_resources/emtests/test_memcpy2.out" - ); -} diff --git a/tests/emtests/test_memcpy3.rs b/tests/emtests/test_memcpy3.rs deleted file mode 100644 index 982a46dfd..000000000 --- a/tests/emtests/test_memcpy3.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_memcpy3() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_memcpy3.wasm", - "test_memcpy3", - vec![], - "../emscripten_resources/emtests/test_memcpy3.out" - ); -} diff --git a/tests/emtests/test_memcpy_memcmp.rs b/tests/emtests/test_memcpy_memcmp.rs deleted file mode 100644 index b45858f5c..000000000 --- a/tests/emtests/test_memcpy_memcmp.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_memcpy_memcmp() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_memcpy_memcmp.wasm", - "test_memcpy_memcmp", - vec![], - "../emscripten_resources/emtests/test_memcpy_memcmp.out" - ); -} diff --git a/tests/emtests/test_memmove.rs b/tests/emtests/test_memmove.rs deleted file mode 100644 index f839203a0..000000000 --- a/tests/emtests/test_memmove.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_memmove() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_memmove.wasm", - "test_memmove", - vec![], - "../emscripten_resources/emtests/test_memmove.out" - ); -} diff --git a/tests/emtests/test_memmove2.rs b/tests/emtests/test_memmove2.rs deleted file mode 100644 index 7230e0525..000000000 --- a/tests/emtests/test_memmove2.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_memmove2() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_memmove2.wasm", - "test_memmove2", - vec![], - "../emscripten_resources/emtests/test_memmove2.out" - ); -} diff --git a/tests/emtests/test_memmove3.rs b/tests/emtests/test_memmove3.rs deleted file mode 100644 index 2b746ee7e..000000000 --- a/tests/emtests/test_memmove3.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_memmove3() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_memmove3.wasm", - "test_memmove3", - vec![], - "../emscripten_resources/emtests/test_memmove3.out" - ); -} diff --git a/tests/emtests/test_memset.rs b/tests/emtests/test_memset.rs deleted file mode 100644 index ea9df5bda..000000000 --- a/tests/emtests/test_memset.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_memset() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_memset.wasm", - "test_memset", - vec![], - "../emscripten_resources/emtests/test_memset.out" - ); -} diff --git a/tests/emtests/test_mmap.rs b/tests/emtests/test_mmap.rs deleted file mode 100644 index 637398321..000000000 --- a/tests/emtests/test_mmap.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_mmap() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_mmap.wasm", - "test_mmap", - vec![], - "../emscripten_resources/emtests/test_mmap.out" - ); -} diff --git a/tests/emtests/test_negative_zero.rs b/tests/emtests/test_negative_zero.rs deleted file mode 100644 index 1cedcf0a9..000000000 --- a/tests/emtests/test_negative_zero.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_negative_zero() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_negative_zero.wasm", - "test_negative_zero", - vec![], - "../emscripten_resources/emtests/test_negative_zero.out" - ); -} diff --git a/tests/emtests/test_nested_struct_varargs.rs b/tests/emtests/test_nested_struct_varargs.rs deleted file mode 100644 index 3ccbebdc5..000000000 --- a/tests/emtests/test_nested_struct_varargs.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[test] -fn test_test_nested_struct_varargs() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_nested_struct_varargs.wasm", - "test_nested_struct_varargs", - vec![], - "../emscripten_resources/emtests/test_nested_struct_varargs.out" - ); -} diff --git a/tests/emtests/test_nl_types.rs b/tests/emtests/test_nl_types.rs deleted file mode 100644 index 0fa1df542..000000000 --- a/tests/emtests/test_nl_types.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_nl_types() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_nl_types.wasm", - "test_nl_types", - vec![], - "../emscripten_resources/emtests/test_nl_types.out" - ); -} diff --git a/tests/emtests/test_perrar.rs b/tests/emtests/test_perrar.rs deleted file mode 100644 index e63840b35..000000000 --- a/tests/emtests/test_perrar.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_perrar() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_perrar.wasm", - "test_perrar", - vec![], - "../emscripten_resources/emtests/test_perrar.out" - ); -} diff --git a/tests/emtests/test_phiundef.rs b/tests/emtests/test_phiundef.rs deleted file mode 100644 index a64ee38f8..000000000 --- a/tests/emtests/test_phiundef.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_phiundef() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_phiundef.wasm", - "test_phiundef", - vec![], - "../emscripten_resources/emtests/test_phiundef.out" - ); -} diff --git a/tests/emtests/test_pipe.rs b/tests/emtests/test_pipe.rs deleted file mode 100644 index 3f54695f1..000000000 --- a/tests/emtests/test_pipe.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_pipe() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_pipe.wasm", - "test_pipe", - vec![], - "../emscripten_resources/emtests/test_pipe.out" - ); -} diff --git a/tests/emtests/test_poll.rs b/tests/emtests/test_poll.rs deleted file mode 100644 index 261490787..000000000 --- a/tests/emtests/test_poll.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_poll() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_poll.wasm", - "test_poll", - vec![], - "../emscripten_resources/emtests/test_poll.out" - ); -} diff --git a/tests/emtests/test_posixtime.rs b/tests/emtests/test_posixtime.rs deleted file mode 100644 index d7fde99d9..000000000 --- a/tests/emtests/test_posixtime.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_posixtime() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_posixtime.wasm", - "test_posixtime", - vec![], - "../emscripten_resources/emtests/test_posixtime.out" - ); -} diff --git a/tests/emtests/test_printf_2.rs b/tests/emtests/test_printf_2.rs deleted file mode 100644 index 12e59941e..000000000 --- a/tests/emtests/test_printf_2.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_printf_2() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_printf_2.wasm", - "test_printf_2", - vec![], - "../emscripten_resources/emtests/test_printf_2.out" - ); -} diff --git a/tests/emtests/test_printf_more.rs b/tests/emtests/test_printf_more.rs deleted file mode 100644 index 7d5c75023..000000000 --- a/tests/emtests/test_printf_more.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_printf_more() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_printf_more.wasm", - "test_printf_more", - vec![], - "../emscripten_resources/emtests/test_printf_more.out" - ); -} diff --git a/tests/emtests/test_regex.rs b/tests/emtests/test_regex.rs deleted file mode 100644 index ca1004ea4..000000000 --- a/tests/emtests/test_regex.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_regex() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_regex.wasm", - "test_regex", - vec![], - "../emscripten_resources/emtests/test_regex.out" - ); -} diff --git a/tests/emtests/test_relocatable_void_function.rs b/tests/emtests/test_relocatable_void_function.rs deleted file mode 100644 index 7f8dbdf70..000000000 --- a/tests/emtests/test_relocatable_void_function.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_relocatable_void_function() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_relocatable_void_function.wasm", - "test_relocatable_void_function", - vec![], - "../emscripten_resources/emtests/test_relocatable_void_function.out" - ); -} diff --git a/tests/emtests/test_rounding.rs b/tests/emtests/test_rounding.rs deleted file mode 100644 index 4b7ea1540..000000000 --- a/tests/emtests/test_rounding.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_rounding() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_rounding.wasm", - "test_rounding", - vec![], - "../emscripten_resources/emtests/test_rounding.out" - ); -} diff --git a/tests/emtests/test_set_align.rs b/tests/emtests/test_set_align.rs deleted file mode 100644 index 602c7931f..000000000 --- a/tests/emtests/test_set_align.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_set_align() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_set_align.wasm", - "test_set_align", - vec![], - "../emscripten_resources/emtests/test_set_align.out" - ); -} diff --git a/tests/emtests/test_siglongjmp.rs b/tests/emtests/test_siglongjmp.rs deleted file mode 100644 index 02d8691b2..000000000 --- a/tests/emtests/test_siglongjmp.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_siglongjmp() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_siglongjmp.wasm", - "test_siglongjmp", - vec![], - "../emscripten_resources/emtests/test_siglongjmp.out" - ); -} diff --git a/tests/emtests/test_sintvars.rs b/tests/emtests/test_sintvars.rs deleted file mode 100644 index f244a99dc..000000000 --- a/tests/emtests/test_sintvars.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_sintvars() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_sintvars.wasm", - "test_sintvars", - vec![], - "../emscripten_resources/emtests/test_sintvars.out" - ); -} diff --git a/tests/emtests/test_sizeof.rs b/tests/emtests/test_sizeof.rs deleted file mode 100644 index 15d6c7c09..000000000 --- a/tests/emtests/test_sizeof.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_sizeof() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_sizeof.wasm", - "test_sizeof", - vec![], - "../emscripten_resources/emtests/test_sizeof.out" - ); -} diff --git a/tests/emtests/test_sscanf.rs b/tests/emtests/test_sscanf.rs deleted file mode 100644 index 94cca8504..000000000 --- a/tests/emtests/test_sscanf.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_sscanf() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_sscanf.wasm", - "test_sscanf", - vec![], - "../emscripten_resources/emtests/test_sscanf.out" - ); -} diff --git a/tests/emtests/test_sscanf_3.rs b/tests/emtests/test_sscanf_3.rs deleted file mode 100644 index 7351bd7fb..000000000 --- a/tests/emtests/test_sscanf_3.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_sscanf_3() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_sscanf_3.wasm", - "test_sscanf_3", - vec![], - "../emscripten_resources/emtests/test_sscanf_3.out" - ); -} diff --git a/tests/emtests/test_sscanf_4.rs b/tests/emtests/test_sscanf_4.rs deleted file mode 100644 index e11773e10..000000000 --- a/tests/emtests/test_sscanf_4.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_sscanf_4() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_sscanf_4.wasm", - "test_sscanf_4", - vec![], - "../emscripten_resources/emtests/test_sscanf_4.out" - ); -} diff --git a/tests/emtests/test_sscanf_5.rs b/tests/emtests/test_sscanf_5.rs deleted file mode 100644 index deda4ac80..000000000 --- a/tests/emtests/test_sscanf_5.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_sscanf_5() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_sscanf_5.wasm", - "test_sscanf_5", - vec![], - "../emscripten_resources/emtests/test_sscanf_5.out" - ); -} diff --git a/tests/emtests/test_sscanf_6.rs b/tests/emtests/test_sscanf_6.rs deleted file mode 100644 index 3ee05ed81..000000000 --- a/tests/emtests/test_sscanf_6.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_sscanf_6() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_sscanf_6.wasm", - "test_sscanf_6", - vec![], - "../emscripten_resources/emtests/test_sscanf_6.out" - ); -} diff --git a/tests/emtests/test_sscanf_caps.rs b/tests/emtests/test_sscanf_caps.rs deleted file mode 100644 index 3c52181e1..000000000 --- a/tests/emtests/test_sscanf_caps.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_sscanf_caps() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_sscanf_caps.wasm", - "test_sscanf_caps", - vec![], - "../emscripten_resources/emtests/test_sscanf_caps.out" - ); -} diff --git a/tests/emtests/test_sscanf_float.rs b/tests/emtests/test_sscanf_float.rs deleted file mode 100644 index ee0ce1706..000000000 --- a/tests/emtests/test_sscanf_float.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_sscanf_float() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_sscanf_float.wasm", - "test_sscanf_float", - vec![], - "../emscripten_resources/emtests/test_sscanf_float.out" - ); -} diff --git a/tests/emtests/test_sscanf_hex.rs b/tests/emtests/test_sscanf_hex.rs deleted file mode 100644 index 3381e8570..000000000 --- a/tests/emtests/test_sscanf_hex.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_sscanf_hex() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_sscanf_hex.wasm", - "test_sscanf_hex", - vec![], - "../emscripten_resources/emtests/test_sscanf_hex.out" - ); -} diff --git a/tests/emtests/test_sscanf_n.rs b/tests/emtests/test_sscanf_n.rs deleted file mode 100644 index b44e3fa1a..000000000 --- a/tests/emtests/test_sscanf_n.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_sscanf_n() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_sscanf_n.wasm", - "test_sscanf_n", - vec![], - "../emscripten_resources/emtests/test_sscanf_n.out" - ); -} diff --git a/tests/emtests/test_sscanf_other_whitespace.rs b/tests/emtests/test_sscanf_other_whitespace.rs deleted file mode 100644 index 0076a51f7..000000000 --- a/tests/emtests/test_sscanf_other_whitespace.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_sscanf_other_whitespace() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_sscanf_other_whitespace.wasm", - "test_sscanf_other_whitespace", - vec![], - "../emscripten_resources/emtests/test_sscanf_other_whitespace.out" - ); -} diff --git a/tests/emtests/test_sscanf_skip.rs b/tests/emtests/test_sscanf_skip.rs deleted file mode 100644 index 928aaebea..000000000 --- a/tests/emtests/test_sscanf_skip.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_sscanf_skip() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_sscanf_skip.wasm", - "test_sscanf_skip", - vec![], - "../emscripten_resources/emtests/test_sscanf_skip.out" - ); -} diff --git a/tests/emtests/test_sscanf_whitespace.rs b/tests/emtests/test_sscanf_whitespace.rs deleted file mode 100644 index 90257eee4..000000000 --- a/tests/emtests/test_sscanf_whitespace.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_sscanf_whitespace() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_sscanf_whitespace.wasm", - "test_sscanf_whitespace", - vec![], - "../emscripten_resources/emtests/test_sscanf_whitespace.out" - ); -} diff --git a/tests/emtests/test_stack_varargs.rs b/tests/emtests/test_stack_varargs.rs deleted file mode 100644 index 37344e56b..000000000 --- a/tests/emtests/test_stack_varargs.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_stack_varargs() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_stack_varargs.wasm", - "test_stack_varargs", - vec![], - "../emscripten_resources/emtests/test_stack_varargs.out" - ); -} diff --git a/tests/emtests/test_stack_void.rs b/tests/emtests/test_stack_void.rs deleted file mode 100644 index 99a9941b4..000000000 --- a/tests/emtests/test_stack_void.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_stack_void() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_stack_void.wasm", - "test_stack_void", - vec![], - "../emscripten_resources/emtests/test_stack_void.out" - ); -} diff --git a/tests/emtests/test_statvfs.rs b/tests/emtests/test_statvfs.rs deleted file mode 100644 index a60516039..000000000 --- a/tests/emtests/test_statvfs.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_statvfs() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_statvfs.wasm", - "test_statvfs", - vec![], - "../emscripten_resources/emtests/test_statvfs.out" - ); -} diff --git a/tests/emtests/test_std_cout_new.rs b/tests/emtests/test_std_cout_new.rs deleted file mode 100644 index 16f6dd997..000000000 --- a/tests/emtests/test_std_cout_new.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_std_cout_new() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_std_cout_new.wasm", - "test_std_cout_new", - vec![], - "../emscripten_resources/emtests/test_std_cout_new.out" - ); -} diff --git a/tests/emtests/test_strcasecmp.rs b/tests/emtests/test_strcasecmp.rs deleted file mode 100644 index b4bd4aa4a..000000000 --- a/tests/emtests/test_strcasecmp.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strcasecmp() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strcasecmp.wasm", - "test_strcasecmp", - vec![], - "../emscripten_resources/emtests/test_strcasecmp.out" - ); -} diff --git a/tests/emtests/test_strcmp_uni.rs b/tests/emtests/test_strcmp_uni.rs deleted file mode 100644 index 144344bb0..000000000 --- a/tests/emtests/test_strcmp_uni.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strcmp_uni() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strcmp_uni.wasm", - "test_strcmp_uni", - vec![], - "../emscripten_resources/emtests/test_strcmp_uni.out" - ); -} diff --git a/tests/emtests/test_strftime.rs b/tests/emtests/test_strftime.rs deleted file mode 100644 index 579505455..000000000 --- a/tests/emtests/test_strftime.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strftime() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strftime.wasm", - "test_strftime", - vec![], - "../emscripten_resources/emtests/test_strftime.out" - ); -} diff --git a/tests/emtests/test_strings.rs b/tests/emtests/test_strings.rs deleted file mode 100644 index 2b26e48d7..000000000 --- a/tests/emtests/test_strings.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strings() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strings.wasm", - "test_strings", - vec![], - "../emscripten_resources/emtests/test_strings.out" - ); -} diff --git a/tests/emtests/test_strndup.rs b/tests/emtests/test_strndup.rs deleted file mode 100644 index f05287fe2..000000000 --- a/tests/emtests/test_strndup.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strndup() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strndup.wasm", - "test_strndup", - vec![], - "../emscripten_resources/emtests/test_strndup.out" - ); -} diff --git a/tests/emtests/test_strptime_days.rs b/tests/emtests/test_strptime_days.rs deleted file mode 100644 index 20f835c50..000000000 --- a/tests/emtests/test_strptime_days.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strptime_days() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strptime_days.wasm", - "test_strptime_days", - vec![], - "../emscripten_resources/emtests/test_strptime_days.out" - ); -} diff --git a/tests/emtests/test_strptime_reentrant.rs b/tests/emtests/test_strptime_reentrant.rs deleted file mode 100644 index fcaf5e41b..000000000 --- a/tests/emtests/test_strptime_reentrant.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strptime_reentrant() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strptime_reentrant.wasm", - "test_strptime_reentrant", - vec![], - "../emscripten_resources/emtests/test_strptime_reentrant.out" - ); -} diff --git a/tests/emtests/test_strstr.rs b/tests/emtests/test_strstr.rs deleted file mode 100644 index 6f9f1198d..000000000 --- a/tests/emtests/test_strstr.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strstr() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strstr.wasm", - "test_strstr", - vec![], - "../emscripten_resources/emtests/test_strstr.out" - ); -} diff --git a/tests/emtests/test_strtod.rs b/tests/emtests/test_strtod.rs deleted file mode 100644 index 70901d0ca..000000000 --- a/tests/emtests/test_strtod.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strtod() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strtod.wasm", - "test_strtod", - vec![], - "../emscripten_resources/emtests/test_strtod.out" - ); -} diff --git a/tests/emtests/test_strtok.rs b/tests/emtests/test_strtok.rs deleted file mode 100644 index ea4b3ff68..000000000 --- a/tests/emtests/test_strtok.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strtok() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strtok.wasm", - "test_strtok", - vec![], - "../emscripten_resources/emtests/test_strtok.out" - ); -} diff --git a/tests/emtests/test_strtol_bin.rs b/tests/emtests/test_strtol_bin.rs deleted file mode 100644 index ec2f73f03..000000000 --- a/tests/emtests/test_strtol_bin.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strtol_bin() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strtol_bin.wasm", - "test_strtol_bin", - vec![], - "../emscripten_resources/emtests/test_strtol_bin.out" - ); -} diff --git a/tests/emtests/test_strtol_dec.rs b/tests/emtests/test_strtol_dec.rs deleted file mode 100644 index a1ef8941d..000000000 --- a/tests/emtests/test_strtol_dec.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strtol_dec() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strtol_dec.wasm", - "test_strtol_dec", - vec![], - "../emscripten_resources/emtests/test_strtol_dec.out" - ); -} diff --git a/tests/emtests/test_strtol_hex.rs b/tests/emtests/test_strtol_hex.rs deleted file mode 100644 index 5c7eb1d2f..000000000 --- a/tests/emtests/test_strtol_hex.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strtol_hex() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strtol_hex.wasm", - "test_strtol_hex", - vec![], - "../emscripten_resources/emtests/test_strtol_hex.out" - ); -} diff --git a/tests/emtests/test_strtol_oct.rs b/tests/emtests/test_strtol_oct.rs deleted file mode 100644 index 1893d178c..000000000 --- a/tests/emtests/test_strtol_oct.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strtol_oct() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strtol_oct.wasm", - "test_strtol_oct", - vec![], - "../emscripten_resources/emtests/test_strtol_oct.out" - ); -} diff --git a/tests/emtests/test_strtold.rs b/tests/emtests/test_strtold.rs deleted file mode 100644 index 1c2a8c391..000000000 --- a/tests/emtests/test_strtold.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strtold() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strtold.wasm", - "test_strtold", - vec![], - "../emscripten_resources/emtests/test_strtold.out" - ); -} diff --git a/tests/emtests/test_strtoll_bin.rs b/tests/emtests/test_strtoll_bin.rs deleted file mode 100644 index c7732d59d..000000000 --- a/tests/emtests/test_strtoll_bin.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strtoll_bin() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strtoll_bin.wasm", - "test_strtoll_bin", - vec![], - "../emscripten_resources/emtests/test_strtoll_bin.out" - ); -} diff --git a/tests/emtests/test_strtoll_dec.rs b/tests/emtests/test_strtoll_dec.rs deleted file mode 100644 index aaecfa8c7..000000000 --- a/tests/emtests/test_strtoll_dec.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strtoll_dec() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strtoll_dec.wasm", - "test_strtoll_dec", - vec![], - "../emscripten_resources/emtests/test_strtoll_dec.out" - ); -} diff --git a/tests/emtests/test_strtoll_hex.rs b/tests/emtests/test_strtoll_hex.rs deleted file mode 100644 index 3a1a2e173..000000000 --- a/tests/emtests/test_strtoll_hex.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strtoll_hex() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strtoll_hex.wasm", - "test_strtoll_hex", - vec![], - "../emscripten_resources/emtests/test_strtoll_hex.out" - ); -} diff --git a/tests/emtests/test_strtoll_oct.rs b/tests/emtests/test_strtoll_oct.rs deleted file mode 100644 index 92e3b2ed9..000000000 --- a/tests/emtests/test_strtoll_oct.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_strtoll_oct() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_strtoll_oct.wasm", - "test_strtoll_oct", - vec![], - "../emscripten_resources/emtests/test_strtoll_oct.out" - ); -} diff --git a/tests/emtests/test_struct_varargs.rs b/tests/emtests/test_struct_varargs.rs deleted file mode 100644 index d3249fd28..000000000 --- a/tests/emtests/test_struct_varargs.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_struct_varargs() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_struct_varargs.wasm", - "test_struct_varargs", - vec![], - "../emscripten_resources/emtests/test_struct_varargs.out" - ); -} diff --git a/tests/emtests/test_time_c.rs b/tests/emtests/test_time_c.rs deleted file mode 100644 index 2e30b49d2..000000000 --- a/tests/emtests/test_time_c.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_time_c() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_time_c.wasm", - "test_time_c", - vec![], - "../emscripten_resources/emtests/test_time_c.out" - ); -} diff --git a/tests/emtests/test_tracing.rs b/tests/emtests/test_tracing.rs deleted file mode 100644 index 6b59bb353..000000000 --- a/tests/emtests/test_tracing.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_tracing() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_tracing.wasm", - "test_tracing", - vec![], - "../emscripten_resources/emtests/test_tracing.out" - ); -} diff --git a/tests/emtests/test_transtrcase.rs b/tests/emtests/test_transtrcase.rs deleted file mode 100644 index 82b9737c5..000000000 --- a/tests/emtests/test_transtrcase.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_transtrcase() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_transtrcase.wasm", - "test_transtrcase", - vec![], - "../emscripten_resources/emtests/test_transtrcase.out" - ); -} diff --git a/tests/emtests/test_trickystring.rs b/tests/emtests/test_trickystring.rs deleted file mode 100644 index 5e3ffad05..000000000 --- a/tests/emtests/test_trickystring.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_trickystring() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_trickystring.wasm", - "test_trickystring", - vec![], - "../emscripten_resources/emtests/test_trickystring.out" - ); -} diff --git a/tests/emtests/test_uname.rs b/tests/emtests/test_uname.rs deleted file mode 100644 index 4a603992d..000000000 --- a/tests/emtests/test_uname.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_uname() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_uname.wasm", - "test_uname", - vec![], - "../emscripten_resources/emtests/test_uname.out" - ); -} diff --git a/tests/emtests/test_unary_literal.rs b/tests/emtests/test_unary_literal.rs deleted file mode 100644 index 9a21049d0..000000000 --- a/tests/emtests/test_unary_literal.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_unary_literal() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_unary_literal.wasm", - "test_unary_literal", - vec![], - "../emscripten_resources/emtests/test_unary_literal.out" - ); -} diff --git a/tests/emtests/test_utf.rs b/tests/emtests/test_utf.rs deleted file mode 100644 index b53e9b96e..000000000 --- a/tests/emtests/test_utf.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_utf() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_utf.wasm", - "test_utf", - vec![], - "../emscripten_resources/emtests/test_utf.out" - ); -} diff --git a/tests/emtests/test_varargs.rs b/tests/emtests/test_varargs.rs deleted file mode 100644 index 4c6145ca7..000000000 --- a/tests/emtests/test_varargs.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_varargs() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_varargs.wasm", - "test_varargs", - vec![], - "../emscripten_resources/emtests/test_varargs.out" - ); -} diff --git a/tests/emtests/test_varargs_multi.rs b/tests/emtests/test_varargs_multi.rs deleted file mode 100644 index 3ebcad109..000000000 --- a/tests/emtests/test_varargs_multi.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_varargs_multi() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_varargs_multi.wasm", - "test_varargs_multi", - vec![], - "../emscripten_resources/emtests/test_varargs_multi.out" - ); -} diff --git a/tests/emtests/test_vfs.rs b/tests/emtests/test_vfs.rs deleted file mode 100644 index d63e32084..000000000 --- a/tests/emtests/test_vfs.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_vfs() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_vfs.wasm", - "test_vfs", - vec![], - "../emscripten_resources/emtests/test_vfs.out" - ); -} diff --git a/tests/emtests/test_vprintf.rs b/tests/emtests/test_vprintf.rs deleted file mode 100644 index e7af22e8b..000000000 --- a/tests/emtests/test_vprintf.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_vprintf() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_vprintf.wasm", - "test_vprintf", - vec![], - "../emscripten_resources/emtests/test_vprintf.out" - ); -} diff --git a/tests/emtests/test_vsnprintf.rs b/tests/emtests/test_vsnprintf.rs deleted file mode 100644 index caab9d660..000000000 --- a/tests/emtests/test_vsnprintf.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_vsnprintf() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_vsnprintf.wasm", - "test_vsnprintf", - vec![], - "../emscripten_resources/emtests/test_vsnprintf.out" - ); -} diff --git a/tests/emtests/test_wprintf.rs b/tests/emtests/test_wprintf.rs deleted file mode 100644 index bcc8f45db..000000000 --- a/tests/emtests/test_wprintf.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_wprintf() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_wprintf.wasm", - "test_wprintf", - vec![], - "../emscripten_resources/emtests/test_wprintf.out" - ); -} diff --git a/tests/emtests/test_write_stdout_fileno.rs b/tests/emtests/test_write_stdout_fileno.rs deleted file mode 100644 index cc41e53cc..000000000 --- a/tests/emtests/test_write_stdout_fileno.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_write_stdout_fileno() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_write_stdout_fileno.wasm", - "test_write_stdout_fileno", - vec![], - "../emscripten_resources/emtests/test_write_stdout_fileno.out" - ); -} diff --git a/tests/emtests/test_zero_multiplication.rs b/tests/emtests/test_zero_multiplication.rs deleted file mode 100644 index 23b77dd49..000000000 --- a/tests/emtests/test_zero_multiplication.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_zero_multiplication() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_zero_multiplication.wasm", - "test_zero_multiplication", - vec![], - "../emscripten_resources/emtests/test_zero_multiplication.out" - ); -} diff --git a/tests/emtests/test_zerodiv.rs b/tests/emtests/test_zerodiv.rs deleted file mode 100644 index f267e3618..000000000 --- a/tests/emtests/test_zerodiv.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[test] -#[ignore] -fn test_test_zerodiv() { - assert_emscripten_output!( - "../emscripten_resources/emtests/test_zerodiv.wasm", - "test_zerodiv", - vec![], - "../emscripten_resources/emtests/test_zerodiv.out" - ); -} diff --git a/tests/exception_handling.rs b/tests/exception_handling.rs deleted file mode 100644 index d545b5cfb..000000000 --- a/tests/exception_handling.rs +++ /dev/null @@ -1,26 +0,0 @@ -mod runtime_core_tests; - -pub mod runtime_core_exception_handling { - use super::runtime_core_tests::{get_compiler, wat2wasm}; - use wasmer::compiler::compile_with; - use wasmer::imports; - - #[test] - fn exception_handling_works() { - const MODULE: &str = r#" -(module - (func (export "throw_trap") - unreachable - )) -"#; - - let wasm_binary = wat2wasm(MODULE.as_bytes()).expect("WAST not valid or malformed"); - let module = compile_with(&wasm_binary, &get_compiler()).unwrap(); - - let imports = imports! {}; - for _ in 0..2 { - let instance = module.instantiate(&imports).unwrap(); - assert!(instance.call("throw_trap", &[]).is_err()); - } - } -} diff --git a/tests/generate-emscripten-tests/src/emtests.rs b/tests/generate-emscripten-tests/src/emtests.rs index 824040861..478df8471 100644 --- a/tests/generate-emscripten-tests/src/emtests.rs +++ b/tests/generate-emscripten-tests/src/emtests.rs @@ -2,47 +2,48 @@ //! It will compile the files indicated in TESTS, to:executable and .wasm //! - Compile using cc and get the output from it (expected output) //! - Compile using emcc and get the .wasm from it (wasm) -//! - Generate the test that will compare the output of running the .wasm file -//! with wasmer with the expected output use glob::glob; -use std::collections::HashSet; use std::fs; use std::path::Path; use std::path::PathBuf; use std::process::Command; use std::fs::File; -use std::io::prelude::*; -use std::io::BufReader; - -static BANNER: &str = - "// Rust test file autogenerated with cargo build (generate-emscripten-tests). -// Please do NOT modify it by hand, as it will be reset on next build.\n"; const EXTENSIONS: [&str; 2] = ["c", "cpp"]; const EXCLUDES: [&str; 0] = []; -pub fn compile(file: &str, ignores: &HashSet) -> Option { +pub fn compile(file: &str) { let mut output_path = PathBuf::from(file); output_path.set_extension("out"); - // let output_str = output_path.to_str().unwrap(); + let output_str = output_path.to_str().unwrap(); + + println!("Compiling Emscripten file natively: {}", file); // Compile to .out - // Command::new("cc") - // .arg(file) - // .arg("-o") - // .arg(output_str) - // .output() - // .expect("failed to execute process"); + Command::new("cc") + .arg(file) + .arg("-o") + .arg(output_str) + .output() + .expect("failed to execute cc command"); // Get the result of .out - // let output = Command::new(output_str) - // .arg(output_str) - // .output() - // .expect("failed to execute process"); + let exec_output = Command::new(output_str).arg(output_str).output(); - // Remove executable - // fs::remove_file(output_str).unwrap(); + // Is fine if _output fails, as the original file might have + // `EM_ASM` javascript definitions inside. In that case, + // the program can't be run natively without JS, and we just + // want to skip any further execution. + if exec_output.is_err() { + println!(" -> Can't execute the file natively. Skipping emcc"); + return; + } else { + exec_output.unwrap(); + } + + // Remove executable, we don't care if it's successful or not + drop(fs::remove_file(output_str)); let mut output_path = PathBuf::from(file); output_path.set_extension("js"); @@ -60,6 +61,8 @@ pub fn compile(file: &str, ignores: &HashSet) -> Option { || file_metadata.modified().unwrap() >= wasm_file_metadata.unwrap().modified().unwrap() { // Compile to wasm + println!("Compiling Emscripten file: {}", file); + let _wasm_compilation = Command::new("emcc") .arg(file) .arg("-s") @@ -67,104 +70,23 @@ pub fn compile(file: &str, ignores: &HashSet) -> Option { .arg("-o") .arg(output_str) .output() - .expect("failed to execute process"); + .expect("failed to execute emcc process. Is `emcc` available in your system?"); // panic!("{:?}", wasm_compilation); // if output.stderr { // panic!("{}", output.stderr); // } - // Remove js file + // Remove js file if Path::new(output_str).is_file() { fs::remove_file(output_str).unwrap(); } else { println!("Output JS not found: {}", output_str); } } - - let mut output_path = PathBuf::from(file); - output_path.set_extension("output"); - let module_name = output_path - .file_stem() - .unwrap() - .to_str() - .unwrap() - .to_owned(); - - // - // let output_str = output_path.to_str().unwrap(); - - // Write the output to file - // fs::write(output_str, output.stdout).expect("Unable to write file"); - - let rs_module_name = module_name.to_lowercase(); - let rust_test_filepath = format!( - concat!(env!("CARGO_MANIFEST_DIR"), "/../emtests/{}.rs"), - rs_module_name.as_str() - ); - - let output_extension = if file.ends_with("c") || module_name.starts_with("test_") { - "out" - } else { - "txt" - }; - - let ignored = if ignores.contains(&module_name.to_lowercase()) { - "\n#[ignore]" - } else { - "" - }; - - let module_path = format!("../emscripten_resources/emtests/{}.wasm", module_name); - let test_output_path = format!( - "../emscripten_resources/emtests/{}.{}", - module_name, output_extension - ); - if !Path::new(&format!("{}/{}", env!("CARGO_MANIFEST_DIR"), &module_path)).is_file() { - println!("Path not found to test module: {}", module_path); - None - } else if !Path::new(&format!( - "{}/{}", - env!("CARGO_MANIFEST_DIR"), - &test_output_path - )) - .is_file() - { - println!("Path not found to test output: {}", test_output_path); - None - } else { - let contents = format!( - "#[test]{ignore} -fn test_{rs_module_name}() {{ - assert_emscripten_output!( - \"{module_path}\", - \"{rs_module_name}\", - vec![], - \"{test_output_path}\" - ); -}} -", - ignore = ignored, - module_path = module_path, - rs_module_name = rs_module_name, - test_output_path = test_output_path - ); - - fs::write(&rust_test_filepath, contents.as_bytes()).unwrap(); - - Some(rs_module_name) - } - // panic!("OUTPUT: {:?}", output); } pub fn build() { - let rust_test_modpath = concat!(env!("CARGO_MANIFEST_DIR"), "/../emtests/mod.rs"); - - let mut modules: Vec = Vec::new(); - // modules.reserve_exact(TESTS.len()); - - let ignores = read_ignore_list(); - for ext in EXTENSIONS.iter() { for entry in glob(&format!( concat!( @@ -179,41 +101,11 @@ pub fn build() { Ok(path) => { let test = path.to_str().unwrap(); if !EXCLUDES.iter().any(|e| test.ends_with(e)) { - if let Some(module_name) = compile(test, &ignores) { - modules.push(module_name); - } + compile(test); } } Err(e) => println!("{:?}", e), } } } - modules.sort(); - let mut modules: Vec = modules.iter().map(|m| format!("mod {};", m)).collect(); - assert!(modules.len() > 0, "Expected > 0 modules found"); - - modules.insert(0, BANNER.to_string()); - modules.insert(1, "// The _common module is not autogenerated, as it provides common macros for the emtests\n#[macro_use]\nmod _common;".to_string()); - // We add an empty line - modules.push("".to_string()); - - let modfile: String = modules.join("\n"); - let source = fs::read(&rust_test_modpath).unwrap(); - // We only modify the mod file if has changed - if source != modfile.as_bytes() { - fs::write(&rust_test_modpath, modfile.as_bytes()).unwrap(); - } -} - -const IGNORE_LIST_PATH: &str = concat!( - env!("CARGO_MANIFEST_DIR"), - "/../emscripten_resources/emtests/ignores.txt" -); -fn read_ignore_list() -> HashSet { - let f = File::open(IGNORE_LIST_PATH).unwrap(); - let f = BufReader::new(f); - f.lines() - .filter_map(Result::ok) - .map(|v| v.to_lowercase()) - .collect() } diff --git a/tests/generate-emscripten-tests/src/lib.rs b/tests/generate-emscripten-tests/src/lib.rs index 6bb96b9df..9c2be33ab 100644 --- a/tests/generate-emscripten-tests/src/lib.rs +++ b/tests/generate-emscripten-tests/src/lib.rs @@ -1,12 +1,3 @@ -use std::env; - mod emtests; -static EMTESTS_ENV_VAR: &str = "WASM_EMSCRIPTEN_GENERATE_EMTESTS"; - -pub fn build() { - println!("cargo:rerun-if-env-changed={}", EMTESTS_ENV_VAR); - if env::var(EMTESTS_ENV_VAR).unwrap_or("0".to_string()) == "1" { - emtests::build(); - } -} +pub use emtests::build; diff --git a/tests/generate-wasi-tests/Cargo.toml b/tests/generate-wasi-tests/Cargo.toml index 33ce01254..283e4c095 100644 --- a/tests/generate-wasi-tests/Cargo.toml +++ b/tests/generate-wasi-tests/Cargo.toml @@ -9,4 +9,6 @@ publish = false [dependencies] glob = "0.3" -tempfile = "3" \ No newline at end of file +tempfile = "3" +serde = "1.0.106" +serde_json = "1.0" diff --git a/tests/generate-wasi-tests/src/lib.rs b/tests/generate-wasi-tests/src/lib.rs index 3ee64ada5..4e5720fc2 100644 --- a/tests/generate-wasi-tests/src/lib.rs +++ b/tests/generate-wasi-tests/src/lib.rs @@ -1,25 +1,8 @@ -use std::env; +mod set_up_toolchain; +mod util; +mod wasi_version; +mod wasitests; -pub mod set_up_toolchain; -pub mod util; -pub mod wasi_version; -pub mod wasitests; - -static WASITESTS_ENV_VAR: &str = "WASM_WASI_GENERATE_WASITESTS"; -static WASITESTS_SET_UP_TOOLCHAIN: &str = "WASM_WASI_SET_UP_TOOLCHAIN"; -static WASITESTS_GENERATE_ALL: &str = "WASI_TEST_GENERATE_ALL"; - -pub fn build() { - //println!("cargo:rerun-if-changed=tests/wasi_test_resources/*.rs"); - println!("cargo:rerun-if-env-changed={}", WASITESTS_ENV_VAR); - println!("cargo:rerun-if-env-changed={}", WASITESTS_SET_UP_TOOLCHAIN); - println!("cargo:rerun-if-env-changed={}", WASITESTS_GENERATE_ALL); - let do_all_wasi_tests = util::should_operate_on_all_wasi_tests(); - if env::var(WASITESTS_SET_UP_TOOLCHAIN).unwrap_or("0".to_string()) == "1" { - set_up_toolchain::set_it_up(do_all_wasi_tests); - } - - if env::var(WASITESTS_ENV_VAR).unwrap_or("0".to_string()) == "1" { - wasitests::build(do_all_wasi_tests); - } -} +pub use crate::set_up_toolchain::install_toolchains; +pub use crate::wasi_version::{WasiVersion, ALL_WASI_VERSIONS, LATEST_WASI_VERSION}; +pub use crate::wasitests::{build, WasiOptions, WasiTest}; diff --git a/tests/generate-wasi-tests/src/set_up_toolchain.rs b/tests/generate-wasi-tests/src/set_up_toolchain.rs index 80cf88447..53d6aedfd 100644 --- a/tests/generate-wasi-tests/src/set_up_toolchain.rs +++ b/tests/generate-wasi-tests/src/set_up_toolchain.rs @@ -12,19 +12,22 @@ fn install_toolchain(toolchain_name: &str) { .output() .expect("Failed to install toolchain with rustup"); util::print_info_on_error(&rustup_out, "TOOLCHAIN INSTALL FAILED"); + + println!("Installing rustup WASI target"); + let rustup_out = Command::new("rustup") + .arg(format!("+{}", toolchain_name)) + .arg("target") + .arg("add") + .arg("wasm32-wasi") + .output() + .expect("Failed to wasi target in Rust toolchain"); + util::print_info_on_error(&rustup_out, "WASI TARGET IN TOOLCHAIN INSTAL FAILED"); } -pub fn set_it_up(only_latest: bool) { +pub fn install_toolchains(wasi_versions: &[WasiVersion]) { println!("Setting up system to generate the WASI tests."); println!("WARNING: this may use a lot of disk space."); - let wasi_versions = if only_latest { - println!("Only installing the toolchain for the latest WASI version"); - LATEST_WASI_VERSION - } else { - println!("Installing the toolchain for all WASI versions"); - ALL_WASI_VERSIONS - }; for wasi_version in wasi_versions { install_toolchain(wasi_version.get_compiler_toolchain()); } diff --git a/tests/generate-wasi-tests/src/util.rs b/tests/generate-wasi-tests/src/util.rs index b2d9ad14b..7ce1e1c53 100644 --- a/tests/generate-wasi-tests/src/util.rs +++ b/tests/generate-wasi-tests/src/util.rs @@ -11,12 +11,3 @@ pub fn print_info_on_error(output: &std::process::Output, context: &str) { ); } } - -/// Whether or not we should operate on all WASI tests or not -pub fn should_operate_on_all_wasi_tests() -> bool { - std::env::var("WASI_TEST_GENERATE_ALL") - .ok() - .and_then(|s| s.parse::().ok()) - .unwrap_or(0) - == 1 -} diff --git a/tests/generate-wasi-tests/src/wasitests.rs b/tests/generate-wasi-tests/src/wasitests.rs index 10caae9e0..9ffd9b450 100644 --- a/tests/generate-wasi-tests/src/wasitests.rs +++ b/tests/generate-wasi-tests/src/wasitests.rs @@ -6,27 +6,27 @@ //! with wasmer with the expected output use glob::glob; -use std::collections::HashSet; use std::fs; use std::path::{Path, PathBuf}; use std::process::Command; -use std::fs::File; +use std::io; use std::io::prelude::*; -use std::io::{self, BufReader}; use super::util; use super::wasi_version::*; - -static BANNER: &str = "// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build.\n"; +use serde::{Deserialize, Serialize}; /// Compile and execute the test file as native code, saving the results to be /// compared against later. /// /// This function attempts to clean up its output after it executes it. -fn generate_native_output(temp_dir: &Path, file: &str, normalized_name: &str) -> io::Result<()> { +fn generate_native_output( + temp_dir: &Path, + file: &str, + normalized_name: &str, + args: &[String], +) -> io::Result { let executable_path = temp_dir.join(normalized_name); println!( "Compiling program {} to native at {}", @@ -36,6 +36,7 @@ fn generate_native_output(temp_dir: &Path, file: &str, normalized_name: &str) -> let native_out = Command::new("rustc") .arg(file) .arg("-o") + .args(args) .arg(&executable_path) .output() .expect("Failed to compile program to native code"); @@ -68,12 +69,12 @@ fn generate_native_output(temp_dir: &Path, file: &str, normalized_name: &str) -> .expect("Failed to execute native program"); util::print_info_on_error(&result, "NATIVE PROGRAM FAILED"); - let mut output_path = PathBuf::from(file); - output_path.set_extension("out"); + // let mut output_path = PathBuf::from(file); + // output_path.set_extension("out"); - println!("Writing output to {}", output_path.to_string_lossy()); - fs::write(&output_path, result.stdout)?; - Ok(()) + // println!("Writing output to {}", output_path.to_string_lossy()); + // fs::write(&output_path, result.stdout)?; + Ok(String::from_utf8(result.stdout).unwrap()) } /// compile the Wasm file for the given version of WASI @@ -120,16 +121,19 @@ fn compile_wasm_for_version( &wasm_out_name.to_string_lossy(), version.get_compiler_toolchain() ); - let wasm_compilation_out = Command::new("rustc") + let mut command = Command::new("rustc"); + + command .arg(format!("+{}", version.get_compiler_toolchain())) .arg("--target=wasm32-wasi") .arg("-C") .arg("opt-level=z") .arg(&temp_wasi_rs_file_name) .arg("-o") - .arg(&wasm_out_name) - .output() - .expect("Failed to compile program to wasm"); + .arg(&wasm_out_name); + println!("Command {:?}", command); + + let wasm_compilation_out = command.output().expect("Failed to compile program to wasm"); util::print_info_on_error(&wasm_compilation_out, "WASM COMPILATION"); println!( "Removing file `{}`", @@ -154,101 +158,11 @@ fn compile_wasm_for_version( Ok(wasm_out_name) } -fn generate_test_file( - file: &str, - rs_module_name: &str, - wasm_out_name: &str, - version: WasiVersion, - ignores: &HashSet, -) -> io::Result { - let test_name = format!("{}_{}", version.get_directory_name(), rs_module_name); - let ignored = if ignores.contains(&test_name) || ignores.contains(rs_module_name) { - "\n#[ignore]" - } else { - "" - }; - - let src_code = fs::read_to_string(file)?; - let args: Args = extract_args_from_source_file(&src_code).unwrap_or_default(); - - let mapdir_args = { - let mut out_str = String::new(); - out_str.push_str("vec!["); - for (alias, real_dir) in args.mapdir { - out_str.push_str(&format!( - "(\"{}\".to_string(), ::std::path::PathBuf::from(\"{}\")),", - alias, real_dir - )); - } - out_str.push_str("]"); - out_str - }; - - let envvar_args = { - let mut out_str = String::new(); - out_str.push_str("vec!["); - - for entry in args.envvars { - out_str.push_str(&format!("\"{}={}\".to_string(),", entry.0, entry.1)); - } - - out_str.push_str("]"); - out_str - }; - - let dir_args = { - let mut out_str = String::new(); - out_str.push_str("vec!["); - - for entry in args.po_dirs { - out_str.push_str(&format!("std::path::PathBuf::from(\"{}\"),", entry)); - } - - out_str.push_str("]"); - out_str - }; - - let contents = format!( - "{banner} - -#[test]{ignore} -fn test_{test_name}() {{ - assert_wasi_output!( - \"{module_path}\", - \"{test_name}\", - {dir_args}, - {mapdir_args}, - {envvar_args}, - \"{test_output_path}\" - ); -}} -", - banner = BANNER, - ignore = ignored, - module_path = format!("../wasi_test_resources/{}.wasm", wasm_out_name), - test_name = &test_name, - test_output_path = format!("../wasi_test_resources/{}.out", rs_module_name), - dir_args = dir_args, - mapdir_args = mapdir_args, - envvar_args = envvar_args - ); - let rust_test_filepath = format!( - concat!(env!("CARGO_MANIFEST_DIR"), "/../wasitests/{}.rs"), - &test_name, - ); - fs::write(&rust_test_filepath, contents.as_bytes())?; - - Ok(test_name) -} - /// Returns the a Vec of the test modules created -fn compile( - temp_dir: &Path, - file: &str, - ignores: &HashSet, - wasi_versions: &[WasiVersion], -) -> Vec { - // TODO: hook up compile_wasm_for_version, etc with new args +fn compile(temp_dir: &Path, file: &str, wasi_versions: &[WasiVersion]) { + let src_code: String = fs::read_to_string(file).unwrap(); + let options: WasiOptions = extract_args_from_source_file(&src_code).unwrap_or_default(); + assert!(file.ends_with(".rs")); let rs_mod_name = { Path::new(&file.to_lowercase()) @@ -258,117 +172,81 @@ fn compile( .to_string() }; let base_dir = Path::new(file).parent().unwrap(); - generate_native_output(temp_dir, &file, &rs_mod_name).expect("Generate native output"); + let output = generate_native_output(temp_dir, &file, &rs_mod_name, &options.args) + .expect("Generate native output"); + + let test = WasiTest { output, options }; + let test_serialized = serde_json::to_string_pretty(&test).unwrap(); wasi_versions .into_iter() .map(|&version| { + let out_dir = base_dir.join(version.get_directory_name()); + if !out_dir.exists() { + fs::create_dir(&out_dir).unwrap(); + } + let wasm_out_name = { + let mut wasm_out_name = out_dir.join(rs_mod_name.clone()); + wasm_out_name.set_extension("out"); + wasm_out_name + }; + println!("Writing test output to {}", wasm_out_name.to_string_lossy()); + fs::write(&wasm_out_name, test_serialized.clone()).unwrap(); + + println!("Compiling wasm version {:?}", version); compile_wasm_for_version(temp_dir, file, base_dir, &rs_mod_name, version) .expect(&format!("Could not compile Wasm to WASI version {:?}, perhaps you need to install the `{}` rust toolchain", version, version.get_compiler_toolchain())); - let wasm_out_relative_path = { - let base_path = PathBuf::from(version.get_directory_name()); - base_path.join(&rs_mod_name) - }; - let wasm_out_name = wasm_out_relative_path.to_string_lossy(); - - generate_test_file(file, &rs_mod_name, &wasm_out_name, version, ignores) - .expect(&format!("generate test file {}", &rs_mod_name)) - }).collect::>() -} - -fn run_prelude(should_gen_all: bool) -> &'static [WasiVersion] { - if should_gen_all { - println!( - "Generating WASI tests for all versions of WASI. Run with WASI_TEST_GENERATE_ALL=0 to only generate the latest tests." - ); - } else { - println!( - "Generating WASI tests for the latest version of WASI. Run with WASI_TEST_GENERATE_ALL=1 to generate all versions of the tests." - ); - } - - if should_gen_all { - ALL_WASI_VERSIONS - } else { - LATEST_WASI_VERSION - } + }).for_each(drop); // Do nothing with it, but let the iterator be consumed/iterated. } const WASI_TEST_SRC_DIR: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../wasi_test_resources/*.rs"); -pub fn build(should_gen_all: bool) { - let rust_test_modpath = concat!(env!("CARGO_MANIFEST_DIR"), "/../wasitests/mod.rs"); - - let mut modules: Vec = Vec::new(); - let wasi_versions = run_prelude(should_gen_all); - +pub fn build(wasi_versions: &[WasiVersion]) { let temp_dir = tempfile::TempDir::new().unwrap(); - let ignores = read_ignore_list(); for entry in glob(WASI_TEST_SRC_DIR).unwrap() { match entry { Ok(path) => { let test = path.to_str().unwrap(); - modules.extend(compile(temp_dir.path(), test, &ignores, wasi_versions)); + compile(temp_dir.path(), test, wasi_versions); } Err(e) => println!("{:?}", e), } } - println!("All modules generated. Generating test harness."); - modules.sort(); - let mut modules: Vec = modules.iter().map(|m| format!("mod {};", m)).collect(); - assert!(modules.len() > 0, "Expected > 0 modules found"); + println!("All modules generated."); +} - modules.insert(0, BANNER.to_string()); - modules.insert(1, "// The _common module is not autogenerated. It provides common macros for the wasitests\n#[macro_use]\nmod _common;".to_string()); - // We add an empty line - modules.push("".to_string()); +/// This is the structure of the `.out` file +#[derive(Debug, Default, Serialize, Deserialize)] +pub struct WasiTest { + /// The program expected output + pub output: String, + /// The program options + pub options: WasiOptions, +} - let modfile: String = modules.join("\n"); - let should_regen: bool = { - if let Ok(mut f) = fs::File::open(&rust_test_modpath) { - let mut s = String::new(); - f.read_to_string(&mut s).unwrap(); - s != modfile - } else { - false - } - }; - if should_regen { - println!("Writing to `{}`", &rust_test_modpath); - let mut test_harness_file = fs::OpenOptions::new() - .write(true) - .create(true) - .truncate(true) - .open(&rust_test_modpath) - .unwrap(); - test_harness_file.write_all(modfile.as_bytes()).unwrap(); +/// The options provied when executed a WASI Wasm program +#[derive(Debug, Default, Serialize, Deserialize)] +pub struct WasiOptions { + /// Mapped pre-opened dirs + pub mapdir: Vec<(String, String)>, + /// Environment vars + pub env: Vec<(String, String)>, + /// Program arguments + pub args: Vec, + /// Pre-opened directories + pub dir: Vec, +} + +impl WasiOptions { + /// Constructs WasiOptions given a json string + pub fn from_str(buffer: &str) -> Result { + serde_json::from_str(buffer).map_err(|e| format!("Can't get options from bufer")) } } -const IGNORE_LIST_PATH: &str = concat!( - env!("CARGO_MANIFEST_DIR"), - "/../wasi_test_resources/ignores.txt" -); -fn read_ignore_list() -> HashSet { - let f = File::open(IGNORE_LIST_PATH).unwrap(); - let f = BufReader::new(f); - f.lines() - .filter_map(Result::ok) - .map(|v| v.to_lowercase()) - .collect() -} - -#[derive(Debug, Default)] -struct Args { - pub mapdir: Vec<(String, String)>, - pub envvars: Vec<(String, String)>, - /// pre-opened directories - pub po_dirs: Vec, -} - -/// Pulls args to the program out of a comment at the top of the file starting with "// Args:" -fn extract_args_from_source_file(source_code: &str) -> Option { - if source_code.starts_with("// Args:") { - let mut args = Args::default(); +/// Pulls args to the program out of a comment at the top of the file starting with "// WasiOptions:" +fn extract_args_from_source_file(source_code: &str) -> Option { + if source_code.starts_with("// WASI:") { + let mut args = WasiOptions::default(); for arg_line in source_code .lines() .skip(1) @@ -403,16 +281,19 @@ fn extract_args_from_source_file(source_code: &str) -> Option { } "env" => { if let [name, val] = &tokenized[1].split('=').collect::>()[..] { - args.envvars.push((name.to_string(), val.to_string())); + args.env.push((name.to_string(), val.to_string())); } else { eprintln!("Parse error in env {} not parsed correctly", &tokenized[1]); } } "dir" => { - args.po_dirs.push(tokenized[1].to_string()); + args.dir.push(tokenized[1].to_string()); + } + "arg" => { + args.args.push(tokenized[1].to_string()); } e => { - eprintln!("WARN: comment arg: {} is not supported", e); + eprintln!("WARN: comment arg: `{}` is not supported", e); } } } diff --git a/tests/ignores.txt b/tests/ignores.txt index 7a4bd7ba5..88e3f5741 100644 --- a/tests/ignores.txt +++ b/tests/ignores.txt @@ -81,6 +81,7 @@ llvm::spec::simd_binaryen on unix # Temporary llvm::spec::simd llvm::spec::simd_binaryen +llvm::spec::imports # Singlepass singlepass::spec::simd # SIMD not implemented @@ -100,3 +101,129 @@ singlepass::spec::traps on aarch64 # NaN canonicalization is not yet implemented for aarch64. singlepass::spec::wasmer on aarch64 + + +# Emscripten + +emscripten::test_ccall +emscripten::test_demangle_stacks +emscripten::emscripten_get_compiler_setting +emscripten::fs_exports +emscripten::getvalue_setvalue +emscripten::legacy_exported_runtime_numbers +emscripten::modularize_closure_pre +emscripten::stackalloc +emscripten::test_demangle_stacks_noassert +emscripten::test_dlmalloc_partial_2 +emscripten::test_em_asm +emscripten::test_em_asm_2 +emscripten::test_em_asm_parameter_pack +emscripten::test_em_asm_signatures +emscripten::test_em_asm_unicode +emscripten::test_em_asm_unused_arguments +emscripten::test_em_js +emscripten::test_emscripten_api +emscripten::test_exceptions_2 +emscripten::test_exceptions_convert +emscripten::test_exceptions_destroy_virtual +emscripten::test_exceptions_multi +emscripten::test_exceptions_std +emscripten::test_exceptions_white_list +emscripten::test_fast_math +emscripten::test_float_builtins +emscripten::test_getopt +emscripten::test_getopt_long +emscripten::test_getloadavg +emscripten::test_i16_emcc_intrinsic +emscripten::test_i64 +emscripten::test_i64_7z +emscripten::test_i64_varargs +emscripten::test_indirectbr_many +emscripten::test_llvm_intrinsics +emscripten::test_longjmp_exc +emscripten::test_lower_intrinsics +emscripten::test_main_thread_async_em_asm +emscripten::test_mainenv +emscripten::test_mathfuncptr +emscripten::test_memcpy_memcmp +emscripten::test_mmap +emscripten::test_perrar +emscripten::test_poll +emscripten::test_posixtime +emscripten::test_siglongjmp +emscripten::test_sscanf_hex +emscripten::test_sscanf_whitespace +emscripten::test_sscanf_other_whitespace +emscripten::test_sscanf_skip +emscripten::test_stack_varargs +emscripten::test_stack_void +emscripten::test_statvfs +emscripten::test_strings +emscripten::test_strptime_days +emscripten::test_strtold +emscripten::test_tracing +emscripten::test_uname +emscripten::test_utf +emscripten::test_varargs_multi +emscripten::test_varargs +emscripten::test_zero_multiplication +emscripten::test_strftime +emscripten::test_wprintf +emscripten::test_std_cout_new +emscripten::test_strptime_reentrant +emscripten::test_gmtime +emscripten::test_time_c +emscripten::test_execvp +emscripten::test_nl_types +emscripten::test_phiundef +emscripten::test_pipe +emscripten::test_printf_2 +emscripten::test_printf_more +emscripten::test_regex +emscripten::test_relocatable_void_function +emscripten::test_rounding +emscripten::test_set_align +emscripten::test_sintvars +emscripten::test_sizeof +emscripten::test_sscanf +emscripten::test_sscanf_3 +emscripten::test_sscanf_4 +emscripten::test_sscanf_5 +emscripten::test_sscanf_6 +emscripten::test_sscanf_caps +emscripten::test_sscanf_float +emscripten::test_sscanf_n +emscripten::test_strcasecmp +emscripten::test_strcmp_uni +emscripten::test_strndup +emscripten::test_strstr +emscripten::test_strtod +emscripten::test_strtok +emscripten::test_strtol_bin +emscripten::test_strtol_dec +emscripten::test_strtol_hex +emscripten::test_strtol_oct +emscripten::test_strtoll_bin +emscripten::test_strtoll_dec +emscripten::test_strtoll_hex +emscripten::test_strtoll_oct +emscripten::test_struct_varargs +emscripten::test_transtrcase +emscripten::test_trickystring +emscripten::test_unary_literal +emscripten::test_vfs +emscripten::test_vprintf +emscripten::test_vsnprintf +emscripten::test_write_stdout_fileno +emscripten::test_zerodiv + + +# WASI + +wasi::snapshot1::fd_read +wasi::snapshot1::poll_oneoff +wasi::snapshot1::fd_pread +wasi::snapshot1::fd_close +wasi::snapshot1::fd_allocate +wasi::snapshot1::close_preopen_fd +wasi::snapshot1::envvar diff --git a/tests/imports.rs b/tests/imports.rs index dbf99f6ac..fdde910fe 100644 --- a/tests/imports.rs +++ b/tests/imports.rs @@ -1,47 +1,42 @@ -mod runtime_core_tests; +use std::{convert::TryInto, sync::Arc}; +use wabt::wat2wasm; +use wasmer::compiler::{compile_with, compiler_for_backend, Backend}; +use wasmer::error::RuntimeError; +use wasmer::units::Pages; +use wasmer::wasm::{ + DynFunc, Func, FuncSig, Global, Instance, Memory, MemoryDescriptor, Type, Value, +}; +use wasmer::{imports, vm, DynamicFunc}; -#[cfg(test)] -pub mod runtime_core_imports { +fn runtime_core_new_api_works(backend: Backend) { + let wasm = r#" + (module + (type $type (func (param i32) (result i32))) + (global (export "my_global") i32 (i32.const 45)) + (func (export "add_one") (type $type) + (i32.add (get_local 0) + (i32.const 1))) + (func (export "double") (type $type) + (i32.mul (get_local 0) + (i32.const 2))) + )"#; + let wasm_binary = wat2wasm(wasm.as_bytes()).expect("WAST not valid or malformed"); + let compiler = compiler_for_backend(backend).expect("Backend not recognized"); + let module = compile_with(&wasm_binary, &*compiler).unwrap(); + let import_object = imports! {}; + let instance = module.instantiate(&import_object).unwrap(); - use super::runtime_core_tests::{get_compiler, wat2wasm}; - use std::{convert::TryInto, sync::Arc}; - use wasmer::compiler::compile_with; - use wasmer::error::RuntimeError; - use wasmer::units::Pages; - use wasmer::wasm::{ - DynFunc, Func, FuncSig, Global, Instance, Memory, MemoryDescriptor, Type, Value, - }; - use wasmer::{imports, vm, DynamicFunc}; + let my_global: Global = instance.exports.get("my_global").unwrap(); + assert_eq!(my_global.get(), Value::I32(45)); + let double: Func = instance.exports.get("double").unwrap(); + assert_eq!(double.call(5).unwrap(), 10); + let add_one: DynFunc = instance.exports.get("add_one").unwrap(); + assert_eq!(add_one.call(&[Value::I32(5)]).unwrap(), &[Value::I32(6)]); + let add_one_memory: Result = instance.exports.get("my_global"); + assert!(add_one_memory.is_err()); +} - #[test] - fn runtime_core_new_api_works() { - let wasm = r#" -(module - (type $type (func (param i32) (result i32))) - (global (export "my_global") i32 (i32.const 45)) - (func (export "add_one") (type $type) - (i32.add (get_local 0) - (i32.const 1))) - (func (export "double") (type $type) - (i32.mul (get_local 0) - (i32.const 2))) -)"#; - let wasm_binary = wat2wasm(wasm.as_bytes()).expect("WAST not valid or malformed"); - let module = compile_with(&wasm_binary, &get_compiler()).unwrap(); - let import_object = imports! {}; - let instance = module.instantiate(&import_object).unwrap(); - - let my_global: Global = instance.exports.get("my_global").unwrap(); - assert_eq!(my_global.get(), Value::I32(45)); - let double: Func = instance.exports.get("double").unwrap(); - assert_eq!(double.call(5).unwrap(), 10); - let add_one: DynFunc = instance.exports.get("add_one").unwrap(); - assert_eq!(add_one.call(&[Value::I32(5)]).unwrap(), &[Value::I32(6)]); - let add_one_memory: Result = instance.exports.get("my_global"); - assert!(add_one_memory.is_err()); - } - - macro_rules! call_and_assert { +macro_rules! call_and_assert { ($instance:ident, $function:ident( $( $inputs:ty ),* ) -> $output:ty, ( $( $arguments:expr ),* ) == $expected_value:expr) => { #[allow(unused_parens)] let $function: Func<( $( $inputs ),* ), $output> = $instance.exports.get(stringify!($function)).expect(concat!("Failed to get the `", stringify!($function), "` export function.")); @@ -86,389 +81,427 @@ pub mod runtime_core_imports { ), } }; + } + +/// The shift that is set in the instance memory. The value is part of +/// the result returned by the imported functions if the memory is +/// read properly. +const SHIFT: i32 = 10; + +/// The shift that is captured in the environment of a closure. The +/// value is part of the result returned by the imported function if +/// the closure captures its environment properly. +#[allow(non_upper_case_globals)] +const shift: i32 = 100; + +#[cfg(all(unix, target_arch = "x86_64"))] +fn imported_functions_forms(backend: Backend, test: &dyn Fn(&Instance)) { + const MODULE: &str = r#" + (module + (type $type (func (param i32) (result i32))) + (import "env" "memory" (memory 1 1)) + (import "env" "callback_fn" (func $callback_fn (type $type))) + (import "env" "callback_closure" (func $callback_closure (type $type))) + (import "env" "callback_fn_dynamic" (func $callback_fn_dynamic (type $type))) + (import "env" "callback_fn_dynamic_panic" (func $callback_fn_dynamic_panic (type $type))) + (import "env" "callback_closure_dynamic_0" (func $callback_closure_dynamic_0)) + (import "env" "callback_closure_dynamic_1" (func $callback_closure_dynamic_1 (param i32) (result i32))) + (import "env" "callback_closure_dynamic_2" (func $callback_closure_dynamic_2 (param i32 i64) (result i64))) + (import "env" "callback_closure_dynamic_3" (func $callback_closure_dynamic_3 (param i32 i64 f32) (result f32))) + (import "env" "callback_closure_dynamic_4" (func $callback_closure_dynamic_4 (param i32 i64 f32 f64) (result f64))) + (import "env" "callback_closure_with_env" (func $callback_closure_with_env (type $type))) + (import "env" "callback_fn_with_vmctx" (func $callback_fn_with_vmctx (type $type))) + (import "env" "callback_closure_with_vmctx" (func $callback_closure_with_vmctx (type $type))) + (import "env" "callback_closure_with_vmctx_and_env" (func $callback_closure_with_vmctx_and_env (type $type))) + (import "env" "callback_fn_trap" (func $callback_fn_trap (type $type))) + (import "env" "callback_closure_trap" (func $callback_closure_trap (type $type))) + (import "env" "callback_fn_trap_with_vmctx" (func $callback_fn_trap_with_vmctx (type $type))) + (import "env" "callback_closure_trap_with_vmctx" (func $callback_closure_trap_with_vmctx (type $type))) + (import "env" "callback_closure_trap_with_vmctx_and_env" (func $callback_closure_trap_with_vmctx_and_env (type $type))) + + (func (export "function_fn") (type $type) + get_local 0 + call $callback_fn) + + (func (export "function_closure") (type $type) + get_local 0 + call $callback_closure) + + (func (export "function_fn_dynamic") (type $type) + get_local 0 + call $callback_fn_dynamic) + + (func (export "function_fn_dynamic_panic") (type $type) + get_local 0 + call $callback_fn_dynamic_panic) + + (func (export "function_closure_dynamic_0") + call $callback_closure_dynamic_0) + + (func (export "function_closure_dynamic_1") (param i32) (result i32) + get_local 0 + call $callback_closure_dynamic_1) + + (func (export "function_closure_dynamic_2") (param i32 i64) (result i64) + get_local 0 + get_local 1 + call $callback_closure_dynamic_2) + + (func (export "function_closure_dynamic_3") (param i32 i64 f32) (result f32) + get_local 0 + get_local 1 + get_local 2 + call $callback_closure_dynamic_3) + + (func (export "function_closure_dynamic_4") (param i32 i64 f32 f64) (result f64) + get_local 0 + get_local 1 + get_local 2 + get_local 3 + call $callback_closure_dynamic_4) + + (func (export "function_closure_with_env") (type $type) + get_local 0 + call $callback_closure_with_env) + + (func (export "function_fn_with_vmctx") (type $type) + get_local 0 + call $callback_fn_with_vmctx) + + (func (export "function_closure_with_vmctx") (type $type) + get_local 0 + call $callback_closure_with_vmctx) + + (func (export "function_closure_with_vmctx_and_env") (type $type) + get_local 0 + call $callback_closure_with_vmctx_and_env) + + (func (export "function_fn_trap") (type $type) + get_local 0 + call $callback_fn_trap) + + (func (export "function_closure_trap") (type $type) + get_local 0 + call $callback_closure_trap) + + (func (export "function_fn_trap_with_vmctx") (type $type) + get_local 0 + call $callback_fn_trap_with_vmctx) + + (func (export "function_closure_trap_with_vmctx") (type $type) + get_local 0 + call $callback_closure_trap_with_vmctx) + + (func (export "function_closure_trap_with_vmctx_and_env") (type $type) + get_local 0 + call $callback_closure_trap_with_vmctx_and_env)) + "#; + + let wasm_binary = wat2wasm(MODULE.as_bytes()).expect("WAST not valid or malformed"); + let compiler = compiler_for_backend(backend).expect("Backend not recognized"); + let module = compile_with(&wasm_binary, &*compiler).unwrap(); + let memory_descriptor = MemoryDescriptor::new(Pages(1), Some(Pages(1)), false).unwrap(); + let memory = Memory::new(memory_descriptor).unwrap(); + + memory.view()[0].set(SHIFT); + + let import_object = imports! { + "env" => { + "memory" => memory.clone(), + + // Regular function. + "callback_fn" => Func::new(callback_fn), + + // Closure without a captured environment. + "callback_closure" => Func::new(|n: i32| -> Result { + Ok(n + 1) + }), + + // Regular polymorphic function. + "callback_fn_dynamic" => DynamicFunc::new( + Arc::new(FuncSig::new(vec![Type::I32], vec![Type::I32])), + callback_fn_dynamic, + ), + + // Polymorphic function that panics. + "callback_fn_dynamic_panic" => DynamicFunc::new( + Arc::new(FuncSig::new(vec![Type::I32], vec![Type::I32])), + callback_fn_dynamic_panic, + ), + + // Polymorphic closure “closures”. + "callback_closure_dynamic_0" => DynamicFunc::new( + Arc::new(FuncSig::new(vec![], vec![])), + |_, inputs: &[Value]| -> Vec { + assert!(inputs.is_empty()); + + vec![] + } + ), + "callback_closure_dynamic_1" => DynamicFunc::new( + Arc::new(FuncSig::new(vec![Type::I32], vec![Type::I32])), + move |vmctx: &mut vm::Ctx, inputs: &[Value]| -> Vec { + assert_eq!(inputs.len(), 1); + + let memory = vmctx.memory(0); + let shift_ = shift + memory.view::()[0].get(); + let n: i32 = (&inputs[0]).try_into().unwrap(); + + vec![Value::I32(shift_ + n)] + } + ), + "callback_closure_dynamic_2" => DynamicFunc::new( + Arc::new(FuncSig::new(vec![Type::I32, Type::I64], vec![Type::I64])), + move |vmctx: &mut vm::Ctx, inputs: &[Value]| -> Vec { + assert_eq!(inputs.len(), 2); + + let memory = vmctx.memory(0); + let shift_ = shift + memory.view::()[0].get(); + let i: i32 = (&inputs[0]).try_into().unwrap(); + let j: i64 = (&inputs[1]).try_into().unwrap(); + + vec![Value::I64(shift_ as i64 + i as i64 + j)] + } + ), + "callback_closure_dynamic_3" => DynamicFunc::new( + Arc::new(FuncSig::new(vec![Type::I32, Type::I64, Type::F32], vec![Type::F32])), + move |vmctx: &mut vm::Ctx, inputs: &[Value]| -> Vec { + assert_eq!(inputs.len(), 3); + + let memory = vmctx.memory(0); + let shift_ = shift + memory.view::()[0].get(); + let i: i32 = (&inputs[0]).try_into().unwrap(); + let j: i64 = (&inputs[1]).try_into().unwrap(); + let k: f32 = (&inputs[2]).try_into().unwrap(); + + vec![Value::F32(shift_ as f32 + i as f32 + j as f32 + k)] + } + ), + "callback_closure_dynamic_4" => DynamicFunc::new( + Arc::new(FuncSig::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![Type::F64])), + move |vmctx: &mut vm::Ctx, inputs: &[Value]| -> Vec { + assert_eq!(inputs.len(), 4); + + let memory = vmctx.memory(0); + let shift_ = shift + memory.view::()[0].get(); + let i: i32 = (&inputs[0]).try_into().unwrap(); + let j: i64 = (&inputs[1]).try_into().unwrap(); + let k: f32 = (&inputs[2]).try_into().unwrap(); + let l: f64 = (&inputs[3]).try_into().unwrap(); + + vec![Value::F64(shift_ as f64 + i as f64 + j as f64 + k as f64 + l)] + } + ), + + // Closure with a captured environment (a single variable + an instance of `Memory`). + "callback_closure_with_env" => Func::new(move |n: i32| -> Result { + let shift_ = shift + memory.view::()[0].get(); + + Ok(shift_ + n + 1) + }), + + // Regular function with an explicit `vmctx`. + "callback_fn_with_vmctx" => Func::new(callback_fn_with_vmctx), + + // Closure without a captured environment but with an explicit `vmctx`. + "callback_closure_with_vmctx" => Func::new(|vmctx: &mut vm::Ctx, n: i32| -> Result { + let memory = vmctx.memory(0); + let shift_: i32 = memory.view()[0].get(); + + Ok(shift_ + n + 1) + }), + + // Closure with a captured environment (a single variable) and with an explicit `vmctx`. + "callback_closure_with_vmctx_and_env" => Func::new(move |vmctx: &mut vm::Ctx, n: i32| -> Result { + let memory = vmctx.memory(0); + let shift_ = shift + memory.view::()[0].get(); + + Ok(shift_ + n + 1) + }), + + // Trap a regular function. + "callback_fn_trap" => Func::new(callback_fn_trap), + + // Trap a closure without a captured environment. + "callback_closure_trap" => Func::new(|n: i32| -> Result { + Err(format!("bar {}", n + 1)) + }), + + // Trap a regular function with an explicit `vmctx`. + "callback_fn_trap_with_vmctx" => Func::new(callback_fn_trap_with_vmctx), + + // Trap a closure without a captured environment but with an explicit `vmctx`. + "callback_closure_trap_with_vmctx" => Func::new(|vmctx: &mut vm::Ctx, n: i32| -> Result { + let memory = vmctx.memory(0); + let shift_: i32 = memory.view()[0].get(); + + Err(format!("qux {}", shift_ + n + 1)) + }), + + // Trap a closure with a captured environment (a single variable) and with an explicit `vmctx`. + "callback_closure_trap_with_vmctx_and_env" => Func::new(move |vmctx: &mut vm::Ctx, n: i32| -> Result { + let memory = vmctx.memory(0); + let shift_ = shift + memory.view::()[0].get(); + + Err(format!("! {}", shift_ + n + 1)) + }), + }, + }; + let instance = module.instantiate(&import_object).unwrap(); + + test(&instance); } - /// The shift that is set in the instance memory. The value is part of - /// the result returned by the imported functions if the memory is - /// read properly. - const SHIFT: i32 = 10; +fn callback_fn(n: i32) -> Result { + Ok(n + 1) +} - /// The shift that is captured in the environment of a closure. The - /// value is part of the result returned by the imported function if - /// the closure captures its environment properly. - #[allow(non_upper_case_globals)] - const shift: i32 = 100; - - #[cfg(all(unix, target_arch = "x86_64"))] - fn imported_functions_forms(test: &dyn Fn(&Instance)) { - const MODULE: &str = r#" -(module - (type $type (func (param i32) (result i32))) - (import "env" "memory" (memory 1 1)) - (import "env" "callback_fn" (func $callback_fn (type $type))) - (import "env" "callback_closure" (func $callback_closure (type $type))) - (import "env" "callback_fn_dynamic" (func $callback_fn_dynamic (type $type))) - (import "env" "callback_fn_dynamic_panic" (func $callback_fn_dynamic_panic (type $type))) - (import "env" "callback_closure_dynamic_0" (func $callback_closure_dynamic_0)) - (import "env" "callback_closure_dynamic_1" (func $callback_closure_dynamic_1 (param i32) (result i32))) - (import "env" "callback_closure_dynamic_2" (func $callback_closure_dynamic_2 (param i32 i64) (result i64))) - (import "env" "callback_closure_dynamic_3" (func $callback_closure_dynamic_3 (param i32 i64 f32) (result f32))) - (import "env" "callback_closure_dynamic_4" (func $callback_closure_dynamic_4 (param i32 i64 f32 f64) (result f64))) - (import "env" "callback_closure_with_env" (func $callback_closure_with_env (type $type))) - (import "env" "callback_fn_with_vmctx" (func $callback_fn_with_vmctx (type $type))) - (import "env" "callback_closure_with_vmctx" (func $callback_closure_with_vmctx (type $type))) - (import "env" "callback_closure_with_vmctx_and_env" (func $callback_closure_with_vmctx_and_env (type $type))) - (import "env" "callback_fn_trap" (func $callback_fn_trap (type $type))) - (import "env" "callback_closure_trap" (func $callback_closure_trap (type $type))) - (import "env" "callback_fn_trap_with_vmctx" (func $callback_fn_trap_with_vmctx (type $type))) - (import "env" "callback_closure_trap_with_vmctx" (func $callback_closure_trap_with_vmctx (type $type))) - (import "env" "callback_closure_trap_with_vmctx_and_env" (func $callback_closure_trap_with_vmctx_and_env (type $type))) - - (func (export "function_fn") (type $type) - get_local 0 - call $callback_fn) - - (func (export "function_closure") (type $type) - get_local 0 - call $callback_closure) - - (func (export "function_fn_dynamic") (type $type) - get_local 0 - call $callback_fn_dynamic) - - (func (export "function_fn_dynamic_panic") (type $type) - get_local 0 - call $callback_fn_dynamic_panic) - - (func (export "function_closure_dynamic_0") - call $callback_closure_dynamic_0) - - (func (export "function_closure_dynamic_1") (param i32) (result i32) - get_local 0 - call $callback_closure_dynamic_1) - - (func (export "function_closure_dynamic_2") (param i32 i64) (result i64) - get_local 0 - get_local 1 - call $callback_closure_dynamic_2) - - (func (export "function_closure_dynamic_3") (param i32 i64 f32) (result f32) - get_local 0 - get_local 1 - get_local 2 - call $callback_closure_dynamic_3) - - (func (export "function_closure_dynamic_4") (param i32 i64 f32 f64) (result f64) - get_local 0 - get_local 1 - get_local 2 - get_local 3 - call $callback_closure_dynamic_4) - - (func (export "function_closure_with_env") (type $type) - get_local 0 - call $callback_closure_with_env) - - (func (export "function_fn_with_vmctx") (type $type) - get_local 0 - call $callback_fn_with_vmctx) - - (func (export "function_closure_with_vmctx") (type $type) - get_local 0 - call $callback_closure_with_vmctx) - - (func (export "function_closure_with_vmctx_and_env") (type $type) - get_local 0 - call $callback_closure_with_vmctx_and_env) - - (func (export "function_fn_trap") (type $type) - get_local 0 - call $callback_fn_trap) - - (func (export "function_closure_trap") (type $type) - get_local 0 - call $callback_closure_trap) - - (func (export "function_fn_trap_with_vmctx") (type $type) - get_local 0 - call $callback_fn_trap_with_vmctx) - - (func (export "function_closure_trap_with_vmctx") (type $type) - get_local 0 - call $callback_closure_trap_with_vmctx) - - (func (export "function_closure_trap_with_vmctx_and_env") (type $type) - get_local 0 - call $callback_closure_trap_with_vmctx_and_env)) -"#; - - let wasm_binary = wat2wasm(MODULE.as_bytes()).expect("WAST not valid or malformed"); - let module = compile_with(&wasm_binary, &get_compiler()).unwrap(); - let memory_descriptor = MemoryDescriptor::new(Pages(1), Some(Pages(1)), false).unwrap(); - let memory = Memory::new(memory_descriptor).unwrap(); - - memory.view()[0].set(SHIFT); - - let import_object = imports! { - "env" => { - "memory" => memory.clone(), - - // Regular function. - "callback_fn" => Func::new(callback_fn), - - // Closure without a captured environment. - "callback_closure" => Func::new(|n: i32| -> Result { - Ok(n + 1) - }), - - // Regular polymorphic function. - "callback_fn_dynamic" => DynamicFunc::new( - Arc::new(FuncSig::new(vec![Type::I32], vec![Type::I32])), - callback_fn_dynamic, - ), - - // Polymorphic function that panics. - "callback_fn_dynamic_panic" => DynamicFunc::new( - Arc::new(FuncSig::new(vec![Type::I32], vec![Type::I32])), - callback_fn_dynamic_panic, - ), - - // Polymorphic closure “closures”. - "callback_closure_dynamic_0" => DynamicFunc::new( - Arc::new(FuncSig::new(vec![], vec![])), - |_, inputs: &[Value]| -> Vec { - assert!(inputs.is_empty()); - - vec![] - } - ), - "callback_closure_dynamic_1" => DynamicFunc::new( - Arc::new(FuncSig::new(vec![Type::I32], vec![Type::I32])), - move |vmctx: &mut vm::Ctx, inputs: &[Value]| -> Vec { - assert_eq!(inputs.len(), 1); - - let memory = vmctx.memory(0); - let shift_ = shift + memory.view::()[0].get(); - let n: i32 = (&inputs[0]).try_into().unwrap(); - - vec![Value::I32(shift_ + n)] - } - ), - "callback_closure_dynamic_2" => DynamicFunc::new( - Arc::new(FuncSig::new(vec![Type::I32, Type::I64], vec![Type::I64])), - move |vmctx: &mut vm::Ctx, inputs: &[Value]| -> Vec { - assert_eq!(inputs.len(), 2); - - let memory = vmctx.memory(0); - let shift_ = shift + memory.view::()[0].get(); - let i: i32 = (&inputs[0]).try_into().unwrap(); - let j: i64 = (&inputs[1]).try_into().unwrap(); - - vec![Value::I64(shift_ as i64 + i as i64 + j)] - } - ), - "callback_closure_dynamic_3" => DynamicFunc::new( - Arc::new(FuncSig::new(vec![Type::I32, Type::I64, Type::F32], vec![Type::F32])), - move |vmctx: &mut vm::Ctx, inputs: &[Value]| -> Vec { - assert_eq!(inputs.len(), 3); - - let memory = vmctx.memory(0); - let shift_ = shift + memory.view::()[0].get(); - let i: i32 = (&inputs[0]).try_into().unwrap(); - let j: i64 = (&inputs[1]).try_into().unwrap(); - let k: f32 = (&inputs[2]).try_into().unwrap(); - - vec![Value::F32(shift_ as f32 + i as f32 + j as f32 + k)] - } - ), - "callback_closure_dynamic_4" => DynamicFunc::new( - Arc::new(FuncSig::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![Type::F64])), - move |vmctx: &mut vm::Ctx, inputs: &[Value]| -> Vec { - assert_eq!(inputs.len(), 4); - - let memory = vmctx.memory(0); - let shift_ = shift + memory.view::()[0].get(); - let i: i32 = (&inputs[0]).try_into().unwrap(); - let j: i64 = (&inputs[1]).try_into().unwrap(); - let k: f32 = (&inputs[2]).try_into().unwrap(); - let l: f64 = (&inputs[3]).try_into().unwrap(); - - vec![Value::F64(shift_ as f64 + i as f64 + j as f64 + k as f64 + l)] - } - ), - - // Closure with a captured environment (a single variable + an instance of `Memory`). - "callback_closure_with_env" => Func::new(move |n: i32| -> Result { - let shift_ = shift + memory.view::()[0].get(); - - Ok(shift_ + n + 1) - }), - - // Regular function with an explicit `vmctx`. - "callback_fn_with_vmctx" => Func::new(callback_fn_with_vmctx), - - // Closure without a captured environment but with an explicit `vmctx`. - "callback_closure_with_vmctx" => Func::new(|vmctx: &mut vm::Ctx, n: i32| -> Result { - let memory = vmctx.memory(0); - let shift_: i32 = memory.view()[0].get(); - - Ok(shift_ + n + 1) - }), - - // Closure with a captured environment (a single variable) and with an explicit `vmctx`. - "callback_closure_with_vmctx_and_env" => Func::new(move |vmctx: &mut vm::Ctx, n: i32| -> Result { - let memory = vmctx.memory(0); - let shift_ = shift + memory.view::()[0].get(); - - Ok(shift_ + n + 1) - }), - - // Trap a regular function. - "callback_fn_trap" => Func::new(callback_fn_trap), - - // Trap a closure without a captured environment. - "callback_closure_trap" => Func::new(|n: i32| -> Result { - Err(format!("bar {}", n + 1)) - }), - - // Trap a regular function with an explicit `vmctx`. - "callback_fn_trap_with_vmctx" => Func::new(callback_fn_trap_with_vmctx), - - // Trap a closure without a captured environment but with an explicit `vmctx`. - "callback_closure_trap_with_vmctx" => Func::new(|vmctx: &mut vm::Ctx, n: i32| -> Result { - let memory = vmctx.memory(0); - let shift_: i32 = memory.view()[0].get(); - - Err(format!("qux {}", shift_ + n + 1)) - }), - - // Trap a closure with a captured environment (a single variable) and with an explicit `vmctx`. - "callback_closure_trap_with_vmctx_and_env" => Func::new(move |vmctx: &mut vm::Ctx, n: i32| -> Result { - let memory = vmctx.memory(0); - let shift_ = shift + memory.view::()[0].get(); - - Err(format!("! {}", shift_ + n + 1)) - }), - }, - }; - let instance = module.instantiate(&import_object).unwrap(); - - test(&instance); +fn callback_fn_dynamic(_: &mut vm::Ctx, inputs: &[Value]) -> Vec { + match inputs[0] { + Value::I32(x) => vec![Value::I32(x + 1)], + _ => unreachable!(), } +} - fn callback_fn(n: i32) -> Result { - Ok(n + 1) - } +fn callback_fn_dynamic_panic(_: &mut vm::Ctx, _: &[Value]) -> Vec { + panic!("test"); +} - fn callback_fn_dynamic(_: &mut vm::Ctx, inputs: &[Value]) -> Vec { - match inputs[0] { - Value::I32(x) => vec![Value::I32(x + 1)], - _ => unreachable!(), - } - } +fn callback_fn_with_vmctx(vmctx: &mut vm::Ctx, n: i32) -> Result { + let memory = vmctx.memory(0); + let shift_: i32 = memory.view()[0].get(); - fn callback_fn_dynamic_panic(_: &mut vm::Ctx, _: &[Value]) -> Vec { - panic!("test"); - } + Ok(shift_ + n + 1) +} - fn callback_fn_with_vmctx(vmctx: &mut vm::Ctx, n: i32) -> Result { - let memory = vmctx.memory(0); - let shift_: i32 = memory.view()[0].get(); +fn callback_fn_trap(n: i32) -> Result { + Err(format!("foo {}", n + 1)) +} - Ok(shift_ + n + 1) - } +fn callback_fn_trap_with_vmctx(vmctx: &mut vm::Ctx, n: i32) -> Result { + let memory = vmctx.memory(0); + let shift_: i32 = memory.view()[0].get(); - fn callback_fn_trap(n: i32) -> Result { - Err(format!("foo {}", n + 1)) - } + Err(format!("baz {}", shift_ + n + 1)) +} - fn callback_fn_trap_with_vmctx(vmctx: &mut vm::Ctx, n: i32) -> Result { - let memory = vmctx.memory(0); - let shift_: i32 = memory.view()[0].get(); - - Err(format!("baz {}", shift_ + n + 1)) - } - - macro_rules! test { - ($test_name:ident, $function:ident( $( $inputs:ty ),* ) -> $output:ty, ( $( $arguments:expr ),* ) == $expected_value:expr) => { +macro_rules! test { + ($backend:expr, $test_name:ident, $function:ident( $( $inputs:ty ),* ) -> $output:ty, ( $( $arguments:expr ),* ) == $expected_value:expr) => { #[cfg(all(unix, target_arch = "x86_64"))] #[test] fn $test_name() { - imported_functions_forms(&|instance| { + imported_functions_forms($backend, &|instance| { call_and_assert!(instance, $function( $( $inputs ),* ) -> $output, ( $( $arguments ),* ) == $expected_value); }); } }; + } + +macro_rules! tests_for_backend { + ($backend:expr) => { + test!($backend, test_fn, function_fn(i32) -> i32, (1) == Ok(2)); + test!($backend, test_closure, function_closure(i32) -> i32, (1) == Ok(2)); + test!($backend, test_fn_dynamic, function_fn_dynamic(i32) -> i32, (1) == Ok(2)); + test!($backend, test_fn_dynamic_panic, function_fn_dynamic_panic(i32) -> i32, (1) == Err(RuntimeError(Box::new("test")))); + test!( + $backend, + test_closure_dynamic_0, + function_closure_dynamic_0(()) -> (), + () == Ok(()) + ); + test!( + $backend, + test_closure_dynamic_1, + function_closure_dynamic_1(i32) -> i32, + (1) == Ok(1 + shift + SHIFT) + ); + test!( + $backend, + test_closure_dynamic_2, + function_closure_dynamic_2(i32, i64) -> i64, + (1, 2) == Ok(1 + 2 + shift as i64 + SHIFT as i64) + ); + test!( + $backend, + test_closure_dynamic_3, + function_closure_dynamic_3(i32, i64, f32) -> f32, + (1, 2, 3.) == Ok(1. + 2. + 3. + shift as f32 + SHIFT as f32) + ); + test!( + $backend, + test_closure_dynamic_4, + function_closure_dynamic_4(i32, i64, f32, f64) -> f64, + (1, 2, 3., 4.) == Ok(1. + 2. + 3. + 4. + shift as f64 + SHIFT as f64) + ); + test!( + $backend, + test_closure_with_env, + function_closure_with_env(i32) -> i32, + (1) == Ok(2 + shift + SHIFT) + ); + test!($backend, test_fn_with_vmctx, function_fn_with_vmctx(i32) -> i32, (1) == Ok(2 + SHIFT)); + test!( + $backend, + test_closure_with_vmctx, + function_closure_with_vmctx(i32) -> i32, + (1) == Ok(2 + SHIFT) + ); + test!( + $backend, + test_closure_with_vmctx_and_env, + function_closure_with_vmctx_and_env(i32) -> i32, + (1) == Ok(2 + shift + SHIFT) + ); + test!( + $backend, + test_fn_trap, + function_fn_trap(i32) -> i32, + (1) == Err(RuntimeError(Box::new(format!("foo {}", 2)))) + ); + test!( + $backend, + test_closure_trap, + function_closure_trap(i32) -> i32, + (1) == Err(RuntimeError(Box::new(format!("bar {}", 2)))) + ); + test!( + $backend, + test_fn_trap_with_vmctx, + function_fn_trap_with_vmctx(i32) -> i32, + (1) == Err(RuntimeError(Box::new(format!("baz {}", 2 + SHIFT)))) + ); + test!( + $backend, + test_closure_trap_with_vmctx, + function_closure_trap_with_vmctx(i32) -> i32, + (1) == Err(RuntimeError(Box::new(format!("qux {}", 2 + SHIFT)))) + ); + test!( + $backend, + test_closure_trap_with_vmctx_and_env, + function_closure_trap_with_vmctx_and_env(i32) -> i32, + (1) == Err(RuntimeError(Box::new(format!("! {}", 2 + shift + SHIFT)))) + ); + } + } + +#[cfg(feature = "backend-singlepass")] +#[cfg(test)] +mod singlepass { + use super::*; + tests_for_backend!(Backend::Singlepass); } - test!(test_fn, function_fn(i32) -> i32, (1) == Ok(2)); - test!(test_closure, function_closure(i32) -> i32, (1) == Ok(2)); - test!(test_fn_dynamic, function_fn_dynamic(i32) -> i32, (1) == Ok(2)); - test!(test_fn_dynamic_panic, function_fn_dynamic_panic(i32) -> i32, (1) == Err(RuntimeError(Box::new("test")))); - test!( - test_closure_dynamic_0, - function_closure_dynamic_0(()) -> (), - () == Ok(()) -); - test!( - test_closure_dynamic_1, - function_closure_dynamic_1(i32) -> i32, - (1) == Ok(1 + shift + SHIFT) -); - test!( - test_closure_dynamic_2, - function_closure_dynamic_2(i32, i64) -> i64, - (1, 2) == Ok(1 + 2 + shift as i64 + SHIFT as i64) -); - test!( - test_closure_dynamic_3, - function_closure_dynamic_3(i32, i64, f32) -> f32, - (1, 2, 3.) == Ok(1. + 2. + 3. + shift as f32 + SHIFT as f32) -); - test!( - test_closure_dynamic_4, - function_closure_dynamic_4(i32, i64, f32, f64) -> f64, - (1, 2, 3., 4.) == Ok(1. + 2. + 3. + 4. + shift as f64 + SHIFT as f64) -); - test!( - test_closure_with_env, - function_closure_with_env(i32) -> i32, - (1) == Ok(2 + shift + SHIFT) -); - test!(test_fn_with_vmctx, function_fn_with_vmctx(i32) -> i32, (1) == Ok(2 + SHIFT)); - test!( - test_closure_with_vmctx, - function_closure_with_vmctx(i32) -> i32, - (1) == Ok(2 + SHIFT) -); - test!( - test_closure_with_vmctx_and_env, - function_closure_with_vmctx_and_env(i32) -> i32, - (1) == Ok(2 + shift + SHIFT) -); - test!( - test_fn_trap, - function_fn_trap(i32) -> i32, - (1) == Err(RuntimeError(Box::new(format!("foo {}", 2)))) -); - test!( - test_closure_trap, - function_closure_trap(i32) -> i32, - (1) == Err(RuntimeError(Box::new(format!("bar {}", 2)))) -); - test!( - test_fn_trap_with_vmctx, - function_fn_trap_with_vmctx(i32) -> i32, - (1) == Err(RuntimeError(Box::new(format!("baz {}", 2 + SHIFT)))) -); - test!( - test_closure_trap_with_vmctx, - function_closure_trap_with_vmctx(i32) -> i32, - (1) == Err(RuntimeError(Box::new(format!("qux {}", 2 + SHIFT)))) -); - test!( - test_closure_trap_with_vmctx_and_env, - function_closure_trap_with_vmctx_and_env(i32) -> i32, - (1) == Err(RuntimeError(Box::new(format!("! {}", 2 + shift + SHIFT)))) -); +#[cfg(feature = "backend-cranelift")] +#[cfg(test)] +mod cranelift { + use super::*; + tests_for_backend!(Backend::Cranelift); +} + +#[cfg(feature = "backend-llvm")] +#[cfg(test)] +mod llvm { + use super::*; + tests_for_backend!(Backend::LLVM); } diff --git a/tests/middleware_common.rs b/tests/middleware_common.rs index db0ee18f8..25b8d08dc 100644 --- a/tests/middleware_common.rs +++ b/tests/middleware_common.rs @@ -1,178 +1,199 @@ -#[cfg(all(test, any(feature = "backend-singlepass", feature = "backend-llvm")))] -mod tests { - use wabt::wat2wasm; +// use test_case::test_case; +// use wabt::wat2wasm; +// use wasmer::compiler::{compile_with, Compiler}; +// use wasmer::imports; +// use wasmer::wasm::Func; +// use wasmer_middleware_common::metering::*; +// use wasmer_runtime_core::codegen::ModuleCodeGenerator; +// use wasmer_runtime_core::codegen::{MiddlewareChain, StreamingCompiler}; +// use wasmer_runtime_core::fault::{pop_code_version, push_code_version}; +// use wasmer_runtime_core::state::CodeVersion; - use wasmer::compiler::{compile_with, Compiler}; - use wasmer::imports; - use wasmer::wasm::Func; - use wasmer_middleware_common::metering::*; - use wasmer_runtime_core::codegen::ModuleCodeGenerator; - use wasmer_runtime_core::codegen::{MiddlewareChain, StreamingCompiler}; - use wasmer_runtime_core::fault::{pop_code_version, push_code_version}; - use wasmer_runtime_core::state::CodeVersion; +// fn get_compiler(name: &str, limit: u64) -> impl Compiler { +// match name { +// #[cfg(feature = "backend-singlepass")] +// "singlepass" => { +// use wasmer_singlepass_backend::ModuleCodeGenerator as SinglepassMCG; +// StreamingCompiler = StreamingCompiler::new(move || { +// let mut chain = MiddlewareChain::new(); +// chain.push(Metering::new(limit)); +// chain +// }) +// }, +// #[cfg(feature = "backend-llvm")] +// "llvm" => { +// use wasmer_llvm_backend::ModuleCodeGenerator as LLVMMCG; +// StreamingCompiler = StreamingCompiler::new(move || { +// let mut chain = MiddlewareChain::new(); +// chain.push(Metering::new(limit)); +// chain +// }) +// } +// _ => panic!("Unimplemented backend"); +// } +// } - #[cfg(feature = "backend-llvm")] - use wasmer_llvm_backend::ModuleCodeGenerator as MCG; +// // Assemblyscript +// // export function add_to(x: i32, y: i32): i32 { +// // for(var i = 0; i < x; i++){ +// // if(i % 1 == 0){ +// // y += i; +// // } else { +// // y *= i +// // } +// // } +// // return y; +// // } +// static WAT: &'static str = r#" +// (module +// (type $t0 (func (param i32 i32) (result i32))) +// (type $t1 (func)) +// (func $add_to (export "add_to") (type $t0) (param $p0 i32) (param $p1 i32) (result i32) +// (local $l0 i32) +// block $B0 +// i32.const 0 +// set_local $l0 +// loop $L1 +// get_local $l0 +// get_local $p0 +// i32.lt_s +// i32.eqz +// br_if $B0 +// get_local $l0 +// i32.const 1 +// i32.rem_s +// i32.const 0 +// i32.eq +// if $I2 +// get_local $p1 +// get_local $l0 +// i32.add +// set_local $p1 +// else +// get_local $p1 +// get_local $l0 +// i32.mul +// set_local $p1 +// end +// get_local $l0 +// i32.const 1 +// i32.add +// set_local $l0 +// br $L1 +// unreachable +// end +// unreachable +// end +// get_local $p1) +// (func $f1 (type $t1)) +// (table $table (export "table") 1 anyfunc) +// (memory $memory (export "memory") 0) +// (global $g0 i32 (i32.const 8)) +// (elem (i32.const 0) $f1)) +// "#; - #[cfg(feature = "backend-singlepass")] - use wasmer_singlepass_backend::ModuleCodeGenerator as MCG; +// #[cfg(feature = "backend-singlepass")] +// mod singlepass { +// #[test] +// fn middleware_test_points_reduced_after_call() { +// super::middleware_test_points_reduced_after_call("singlepass") +// } +// #[test] +// fn middleware_test_traps_after_costly_call() { +// super::middleware_test_traps_after_costly_call("singlepass") +// } +// } - fn get_compiler(limit: u64) -> impl Compiler { - let c: StreamingCompiler = StreamingCompiler::new(move || { - let mut chain = MiddlewareChain::new(); - chain.push(Metering::new(limit)); - chain - }); - c - } +// #[cfg(feature = "backend-llvm")] +// mod llvm { +// #[test] +// fn middleware_test_points_reduced_after_call() { +// super::middleware_test_points_reduced_after_call("llvm") +// } +// #[test] +// fn middleware_test_traps_after_costly_call() { +// super::middleware_test_traps_after_costly_call("llvm") +// } +// } - #[cfg(not(any( - feature = "backend-llvm", - feature = "backend-cranelift", - feature = "backend-singlepass" - )))] - compile_error!("compiler not specified, activate a compiler via features"); +// fn middleware_test_points_reduced_after_call(backend: &'static str) { +// let wasm_binary = wat2wasm(WAT).unwrap(); - // Assemblyscript - // export function add_to(x: i32, y: i32): i32 { - // for(var i = 0; i < x; i++){ - // if(i % 1 == 0){ - // y += i; - // } else { - // y *= i - // } - // } - // return y; - // } - static WAT: &'static str = r#" - (module - (type $t0 (func (param i32 i32) (result i32))) - (type $t1 (func)) - (func $add_to (export "add_to") (type $t0) (param $p0 i32) (param $p1 i32) (result i32) - (local $l0 i32) - block $B0 - i32.const 0 - set_local $l0 - loop $L1 - get_local $l0 - get_local $p0 - i32.lt_s - i32.eqz - br_if $B0 - get_local $l0 - i32.const 1 - i32.rem_s - i32.const 0 - i32.eq - if $I2 - get_local $p1 - get_local $l0 - i32.add - set_local $p1 - else - get_local $p1 - get_local $l0 - i32.mul - set_local $p1 - end - get_local $l0 - i32.const 1 - i32.add - set_local $l0 - br $L1 - unreachable - end - unreachable - end - get_local $p1) - (func $f1 (type $t1)) - (table $table (export "table") 1 anyfunc) - (memory $memory (export "memory") 0) - (global $g0 i32 (i32.const 8)) - (elem (i32.const 0) $f1)) - "#; +// let limit = 100u64; - #[test] - fn middleware_test_points_reduced_after_call() { - let wasm_binary = wat2wasm(WAT).unwrap(); +// let compiler = get_compiler(backend, limit); +// let module = compile_with(&wasm_binary, &compiler).unwrap(); - let limit = 100u64; +// let import_object = imports! {}; +// let mut instance = module.instantiate(&import_object).unwrap(); - let compiler = get_compiler(limit); - let module = compile_with(&wasm_binary, &compiler).unwrap(); +// set_points_used(&mut instance, 0u64); - let import_object = imports! {}; - let mut instance = module.instantiate(&import_object).unwrap(); +// let add_to: Func<(i32, i32), i32> = instance.exports.get("add_to").unwrap(); - set_points_used(&mut instance, 0u64); +// let cv_pushed = if let Some(msm) = instance.module.runnable_module.get_module_state_map() { +// push_code_version(CodeVersion { +// baseline: true, +// msm: msm, +// base: instance.module.runnable_module.get_code().unwrap().as_ptr() as usize, +// backend: &backend, +// runnable_module: instance.module.runnable_module.clone(), +// }); +// true +// } else { +// false +// }; - let add_to: Func<(i32, i32), i32> = instance.exports.get("add_to").unwrap(); +// let value = add_to.call(3, 4).unwrap(); +// if cv_pushed { +// pop_code_version().unwrap(); +// } - let cv_pushed = if let Some(msm) = instance.module.runnable_module.get_module_state_map() { - push_code_version(CodeVersion { - baseline: true, - msm: msm, - base: instance.module.runnable_module.get_code().unwrap().as_ptr() as usize, - backend: MCG::backend_id(), - runnable_module: instance.module.runnable_module.clone(), - }); - true - } else { - false - }; +// // verify it returns the correct value +// assert_eq!(value, 7); - let value = add_to.call(3, 4).unwrap(); - if cv_pushed { - pop_code_version().unwrap(); - } +// // verify it used the correct number of points +// assert_eq!(get_points_used(&instance), 74); +// } - // verify it returns the correct value - assert_eq!(value, 7); +// fn middleware_test_traps_after_costly_call(backend: &'static str) { +// let wasm_binary = wat2wasm(WAT).unwrap(); - // verify it used the correct number of points - assert_eq!(get_points_used(&instance), 74); - } +// let limit = 100u64; - #[test] - fn middleware_test_traps_after_costly_call() { - let wasm_binary = wat2wasm(WAT).unwrap(); +// let compiler = get_compiler(backend, limit); +// let module = compile_with(&wasm_binary, &compiler).unwrap(); - let limit = 100u64; +// let import_object = imports! {}; +// let mut instance = module.instantiate(&import_object).unwrap(); - let compiler = get_compiler(limit); - let module = compile_with(&wasm_binary, &compiler).unwrap(); +// set_points_used(&mut instance, 0u64); - let import_object = imports! {}; - let mut instance = module.instantiate(&import_object).unwrap(); +// let add_to: Func<(i32, i32), i32> = instance.exports.get("add_to").unwrap(); - set_points_used(&mut instance, 0u64); +// let cv_pushed = if let Some(msm) = instance.module.runnable_module.get_module_state_map() { +// push_code_version(CodeVersion { +// baseline: true, +// msm: msm, +// base: instance.module.runnable_module.get_code().unwrap().as_ptr() as usize, +// backend: &backend, +// runnable_module: instance.module.runnable_module.clone(), +// }); +// true +// } else { +// false +// }; +// let result = add_to.call(10_000_000, 4); +// if cv_pushed { +// pop_code_version().unwrap(); +// } - let add_to: Func<(i32, i32), i32> = instance.exports.get("add_to").unwrap(); +// let err = result.unwrap_err(); +// assert!(err +// .0 +// .downcast_ref::() +// .is_some()); - let cv_pushed = if let Some(msm) = instance.module.runnable_module.get_module_state_map() { - push_code_version(CodeVersion { - baseline: true, - msm: msm, - base: instance.module.runnable_module.get_code().unwrap().as_ptr() as usize, - backend: MCG::backend_id(), - runnable_module: instance.module.runnable_module.clone(), - }); - true - } else { - false - }; - let result = add_to.call(10_000_000, 4); - if cv_pushed { - pop_code_version().unwrap(); - } - - let err = result.unwrap_err(); - assert!(err - .0 - .downcast_ref::() - .is_some()); - - // verify it used the correct number of points - assert_eq!(get_points_used(&instance), 109); // Used points will be slightly more than `limit` because of the way we do gas checking. - } -} +// // verify it used the correct number of points +// assert_eq!(get_points_used(&instance), 109); // Used points will be slightly more than `limit` because of the way we do gas checking. +// } diff --git a/tests/spectest.rs b/tests/spectest.rs index 737f0178f..d83ea2b48 100644 --- a/tests/spectest.rs +++ b/tests/spectest.rs @@ -1,3 +1,5 @@ +mod utils; + use std::path::Path; #[cfg(not(any( @@ -10,27 +12,21 @@ use anyhow::bail; use wasmer::compiler::Backend; use wasmer_wast::Wast; +// The generated tests (from build.rs) look like: // #[cfg(test)] -// mod spectests { -// mod cranelift { +// mod singlepass { +// mod spec { // #[test] -// fn address() -> Result<(), String> { -// crate::run_wast("tests/spectests/address.wast", "llvm") +// fn address() -> anyhow::Result<()> { +// crate::run_wast("tests/spectests/address.wast", "singlepass") // } // } // } -include!(concat!(env!("OUT_DIR"), "/generated_tests.rs")); +include!(concat!(env!("OUT_DIR"), "/generated_spectests.rs")); fn run_wast(wast_path: &str, backend: &str) -> anyhow::Result<()> { - let backend = match backend { - #[cfg(feature = "backend-singlepass")] - "singlepass" => Backend::Singlepass, - #[cfg(feature = "backend-cranelift")] - "cranelift" => Backend::Cranelift, - #[cfg(feature = "backend-llvm")] - "llvm" => Backend::LLVM, - _ => bail!("Backend {} not found", backend), - }; + println!("Running wast {} with {}", wast_path, backend); + let backend = utils::get_backend_from_str(backend)?; let mut wast = Wast::new_with_spectest(backend); let path = Path::new(wast_path); wast.run_file(path) diff --git a/tests/test-generator/src/lib.rs b/tests/test-generator/src/lib.rs index 1b927d5a1..94c593ffe 100644 --- a/tests/test-generator/src/lib.rs +++ b/tests/test-generator/src/lib.rs @@ -9,7 +9,7 @@ use anyhow::Context; use std::collections::HashSet; use std::fmt::Write; -use std::fs::{DirEntry, File}; +use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::{Path, PathBuf}; use target_lexicon::Triple; @@ -24,7 +24,15 @@ pub struct Testsuite { impl Testsuite { fn ignore_current(&self) -> bool { let full = self.path.join("::"); - self.ignores.contains(&full) + if self.ignores.contains(&full) { + return true; + } + for ignore in self.ignores.iter() { + if full.contains(ignore) { + return true; + } + } + false } } @@ -161,3 +169,17 @@ pub fn with_test_module( out.path.pop().unwrap(); Ok(result) } + +pub fn with_backends( + mut out: &mut Testsuite, + backends: &[&str], + f: impl Fn(&mut Testsuite) -> anyhow::Result<()> + Copy, +) -> anyhow::Result<()> { + for compiler in backends.iter() { + writeln!(out.buffer, "#[cfg(feature=\"backend-{}\")]", compiler)?; + writeln!(out.buffer, "#[cfg(test)]")?; + writeln!(out.buffer, "#[allow(non_snake_case)]")?; + with_test_module(&mut out, &compiler, f)?; + } + Ok(()) +} diff --git a/tests/utils/backend.rs b/tests/utils/backend.rs new file mode 100644 index 000000000..1522f6f9a --- /dev/null +++ b/tests/utils/backend.rs @@ -0,0 +1,20 @@ +use anyhow::{bail, Result}; +use wasmer::compiler::Backend; + +/// Gets a `Backend` given a string. +/// +/// # Errors +/// +/// This function errors if the backend doesn't exist or +/// is not enabled. +pub fn get_backend_from_str(backend: &str) -> Result { + match backend { + #[cfg(feature = "backend-singlepass")] + "singlepass" => Ok(Backend::Singlepass), + #[cfg(feature = "backend-cranelift")] + "cranelift" => Ok(Backend::Cranelift), + #[cfg(feature = "backend-llvm")] + "llvm" => Ok(Backend::LLVM), + _ => bail!("Backend {} not found", backend), + } +} diff --git a/tests/utils/mod.rs b/tests/utils/mod.rs index 76ae6804f..090911e36 100644 --- a/tests/utils/mod.rs +++ b/tests/utils/mod.rs @@ -1,2 +1,5 @@ -pub mod file_descriptor; +mod backend; +mod file_descriptor; pub mod stdio; + +pub use backend::get_backend_from_str; diff --git a/tests/wasi_test_resources/close_preopen_fd.out b/tests/wasi_test_resources/close_preopen_fd.out deleted file mode 100644 index e6e9b9f67..000000000 --- a/tests/wasi_test_resources/close_preopen_fd.out +++ /dev/null @@ -1,3 +0,0 @@ -accessing preopen fd was a success -Closing preopen fd was a success -accessing closed preopen fd was an EBADF error: true diff --git a/tests/wasi_test_resources/close_preopen_fd.rs b/tests/wasi_test_resources/close_preopen_fd.rs index 025c355fa..d5ffac3cc 100644 --- a/tests/wasi_test_resources/close_preopen_fd.rs +++ b/tests/wasi_test_resources/close_preopen_fd.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // mapdir: hamlet:tests/wasi_test_resources/test_fs/hamlet use std::fs; diff --git a/tests/wasi_test_resources/create_dir.out b/tests/wasi_test_resources/create_dir.out deleted file mode 100644 index cc1a8aa2c..000000000 --- a/tests/wasi_test_resources/create_dir.out +++ /dev/null @@ -1,5 +0,0 @@ -Test file exists: false -Dir exists: false -Dir exists: false -Dir exists: false -Success diff --git a/tests/wasi_test_resources/create_dir.rs b/tests/wasi_test_resources/create_dir.rs index 21e07d619..a33305cbf 100644 --- a/tests/wasi_test_resources/create_dir.rs +++ b/tests/wasi_test_resources/create_dir.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // dir: . use std::fs; diff --git a/tests/wasi_test_resources/envvar.out b/tests/wasi_test_resources/envvar.out deleted file mode 100644 index 67848f4f4..000000000 --- a/tests/wasi_test_resources/envvar.out +++ /dev/null @@ -1,6 +0,0 @@ -Env vars: -CAT=2 -DOG=1 -DOG Ok("1") -DOG_TYPE Err(NotPresent) -SET VAR Ok("HELLO") diff --git a/tests/wasi_test_resources/envvar.rs b/tests/wasi_test_resources/envvar.rs index a5d8982c6..184611477 100644 --- a/tests/wasi_test_resources/envvar.rs +++ b/tests/wasi_test_resources/envvar.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // env: DOG=1 // env: CAT=2 diff --git a/tests/wasi_test_resources/fd_allocate.out b/tests/wasi_test_resources/fd_allocate.out deleted file mode 100644 index d8a0f88c3..000000000 --- a/tests/wasi_test_resources/fd_allocate.out +++ /dev/null @@ -1,2 +0,0 @@ -171 -1405 diff --git a/tests/wasi_test_resources/fd_allocate.rs b/tests/wasi_test_resources/fd_allocate.rs index 75118502a..4cedd79fc 100644 --- a/tests/wasi_test_resources/fd_allocate.rs +++ b/tests/wasi_test_resources/fd_allocate.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // mapdir: .:tests/wasi_test_resources/test_fs/temp use std::fs; diff --git a/tests/wasi_test_resources/fd_append.out b/tests/wasi_test_resources/fd_append.out deleted file mode 100644 index e9d92ef26..000000000 --- a/tests/wasi_test_resources/fd_append.out +++ /dev/null @@ -1 +0,0 @@ -"Hello, world!\nGoodbye, world!\n" diff --git a/tests/wasi_test_resources/fd_append.rs b/tests/wasi_test_resources/fd_append.rs index 5cf2634c1..48cb5b5f9 100644 --- a/tests/wasi_test_resources/fd_append.rs +++ b/tests/wasi_test_resources/fd_append.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // mapdir: .:tests/wasi_test_resources/test_fs/temp use std::fs::OpenOptions; diff --git a/tests/wasi_test_resources/fd_close.out b/tests/wasi_test_resources/fd_close.out deleted file mode 100644 index 53c9c2727..000000000 --- a/tests/wasi_test_resources/fd_close.out +++ /dev/null @@ -1,3 +0,0 @@ -Successfully closed file! -Successfully closed stderr! -Successfully closed stdin! diff --git a/tests/wasi_test_resources/fd_close.rs b/tests/wasi_test_resources/fd_close.rs index 2004ebaa2..67ca874eb 100644 --- a/tests/wasi_test_resources/fd_close.rs +++ b/tests/wasi_test_resources/fd_close.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // mapdir: .:tests/wasi_test_resources/test_fs/hamlet use std::fs; diff --git a/tests/wasi_test_resources/fd_pread.out b/tests/wasi_test_resources/fd_pread.out deleted file mode 100644 index a83632aea..000000000 --- a/tests/wasi_test_resources/fd_pread.out +++ /dev/null @@ -1,9 +0,0 @@ - POLONIUS - - He will come straight. Look you lay home to him: - - POLONIUS - - He will come straight. Look you lay home to him: - -Read the same data? true \ No newline at end of file diff --git a/tests/wasi_test_resources/fd_pread.rs b/tests/wasi_test_resources/fd_pread.rs index e0dc0c6d4..57008b596 100644 --- a/tests/wasi_test_resources/fd_pread.rs +++ b/tests/wasi_test_resources/fd_pread.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // mapdir: .:tests/wasi_test_resources/test_fs/hamlet use std::fs; diff --git a/tests/wasi_test_resources/fd_read.out b/tests/wasi_test_resources/fd_read.out deleted file mode 100644 index f2b9f2169..000000000 --- a/tests/wasi_test_resources/fd_read.out +++ /dev/null @@ -1,3 +0,0 @@ -SCENE IV. The Queen's closet. - - Enter QUEEN GERTRUDE and POLO \ No newline at end of file diff --git a/tests/wasi_test_resources/fd_read.rs b/tests/wasi_test_resources/fd_read.rs index ac8e263db..ec28b104a 100644 --- a/tests/wasi_test_resources/fd_read.rs +++ b/tests/wasi_test_resources/fd_read.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // mapdir: .:tests/wasi_test_resources/test_fs/hamlet // this program is used in the pause/resume test diff --git a/tests/wasi_test_resources/fd_sync.out b/tests/wasi_test_resources/fd_sync.out deleted file mode 100644 index ccda92fc0..000000000 --- a/tests/wasi_test_resources/fd_sync.out +++ /dev/null @@ -1,2 +0,0 @@ -170 -1404 diff --git a/tests/wasi_test_resources/fd_sync.rs b/tests/wasi_test_resources/fd_sync.rs index 31489d9cf..502ee9db5 100644 --- a/tests/wasi_test_resources/fd_sync.rs +++ b/tests/wasi_test_resources/fd_sync.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // mapdir: .:tests/wasi_test_resources/test_fs/temp use std::fs; diff --git a/tests/wasi_test_resources/file_metadata.out b/tests/wasi_test_resources/file_metadata.out deleted file mode 100644 index 974bc1ff5..000000000 --- a/tests/wasi_test_resources/file_metadata.out +++ /dev/null @@ -1,3 +0,0 @@ -is dir: false -filetype: false true false -file info: 493 diff --git a/tests/wasi_test_resources/file_metadata.rs b/tests/wasi_test_resources/file_metadata.rs index 9ae25534e..d20c7d5ba 100644 --- a/tests/wasi_test_resources/file_metadata.rs +++ b/tests/wasi_test_resources/file_metadata.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // dir: . use std::fs; diff --git a/tests/wasi_test_resources/fs_sandbox_test.out b/tests/wasi_test_resources/fs_sandbox_test.out deleted file mode 100644 index e98c9da00..000000000 --- a/tests/wasi_test_resources/fs_sandbox_test.out +++ /dev/null @@ -1 +0,0 @@ -Reading the parent directory was okay? false diff --git a/tests/wasi_test_resources/fseek.out b/tests/wasi_test_resources/fseek.out deleted file mode 100644 index c9f09be6e..000000000 --- a/tests/wasi_test_resources/fseek.out +++ /dev/null @@ -1,11 +0,0 @@ -SCENE III. A room in Polonius' h -ouse. - - Enter LAERTES and OPH - And, sister, as the winds gi -r talk with the Lord Hamlet. - -uits, - Breathing like sanctif -is is for all: - I would not, diff --git a/tests/wasi_test_resources/fseek.rs b/tests/wasi_test_resources/fseek.rs index 571edd3c8..2eb1168e4 100644 --- a/tests/wasi_test_resources/fseek.rs +++ b/tests/wasi_test_resources/fseek.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // mapdir: .:tests/wasi_test_resources/test_fs/hamlet use std::fs; diff --git a/tests/wasi_test_resources/hello.out b/tests/wasi_test_resources/hello.out deleted file mode 100644 index af5626b4a..000000000 --- a/tests/wasi_test_resources/hello.out +++ /dev/null @@ -1 +0,0 @@ -Hello, world! diff --git a/tests/wasi_test_resources/ignores.txt b/tests/wasi_test_resources/ignores.txt deleted file mode 100644 index df00fac5b..000000000 --- a/tests/wasi_test_resources/ignores.txt +++ /dev/null @@ -1,6 +0,0 @@ -snapshot1_fd_read -snapshot1_poll_oneoff -snapshot1_fd_pread -snapshot1_fd_close -snapshot1_fd_allocate -snapshot1_close_preopen_fd diff --git a/tests/wasi_test_resources/isatty.out b/tests/wasi_test_resources/isatty.out deleted file mode 100644 index 497b57818..000000000 --- a/tests/wasi_test_resources/isatty.out +++ /dev/null @@ -1,3 +0,0 @@ -stdin: 1 -stdout: 1 -stderr: 1 diff --git a/tests/wasi_test_resources/mapdir.out b/tests/wasi_test_resources/mapdir.out deleted file mode 100644 index 8f5d6ad44..000000000 --- a/tests/wasi_test_resources/mapdir.out +++ /dev/null @@ -1,7 +0,0 @@ -"./README.md" -"./act1" -"./act2" -"./act3" -"./act4" -"./act5" -"./bookmarks" diff --git a/tests/wasi_test_resources/mapdir.rs b/tests/wasi_test_resources/mapdir.rs index d58a2b332..1dbfecbb8 100644 --- a/tests/wasi_test_resources/mapdir.rs +++ b/tests/wasi_test_resources/mapdir.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // mapdir: .:tests/wasi_test_resources/test_fs/hamlet use std::fs; diff --git a/tests/wasi_test_resources/path_link.out b/tests/wasi_test_resources/path_link.out deleted file mode 100644 index 53df012ad..000000000 --- a/tests/wasi_test_resources/path_link.out +++ /dev/null @@ -1,9 +0,0 @@ -ACT V -SCENE I. A churchyard. - - Enter two Clowns, with spades, -ACT V -SCENE I. A churchyard. - - Enter two Clowns, with spades, -Path still exists diff --git a/tests/wasi_test_resources/path_link.rs b/tests/wasi_test_resources/path_link.rs index 7672a0511..ed5b08312 100644 --- a/tests/wasi_test_resources/path_link.rs +++ b/tests/wasi_test_resources/path_link.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // mapdir: act5:tests/wasi_test_resources/test_fs/hamlet/act5 // mapdir: temp:tests/wasi_test_resources/test_fs/temp diff --git a/tests/wasi_test_resources/path_rename.out b/tests/wasi_test_resources/path_rename.out deleted file mode 100644 index 7b44f5763..000000000 --- a/tests/wasi_test_resources/path_rename.out +++ /dev/null @@ -1,2 +0,0 @@ -The original file does not still exist! -柴犬 diff --git a/tests/wasi_test_resources/path_rename.rs b/tests/wasi_test_resources/path_rename.rs index 29fb88b93..b89158a30 100644 --- a/tests/wasi_test_resources/path_rename.rs +++ b/tests/wasi_test_resources/path_rename.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // mapdir: temp:tests/wasi_test_resources/test_fs/temp use std::fs; diff --git a/tests/wasi_test_resources/path_symlink.out b/tests/wasi_test_resources/path_symlink.out deleted file mode 100644 index 085a92816..000000000 --- a/tests/wasi_test_resources/path_symlink.out +++ /dev/null @@ -1,4 +0,0 @@ -ACT III -SCENE I. A room in the castle. - - Enter KING CLAUDIUS, diff --git a/tests/wasi_test_resources/path_symlink.rs b/tests/wasi_test_resources/path_symlink.rs index e06b4d16c..506f5cac5 100644 --- a/tests/wasi_test_resources/path_symlink.rs +++ b/tests/wasi_test_resources/path_symlink.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // mapdir: temp:tests/wasi_test_resources/test_fs/temp // mapdir: hamlet:tests/wasi_test_resources/test_fs/hamlet diff --git a/tests/wasi_test_resources/poll_oneoff.out b/tests/wasi_test_resources/poll_oneoff.out deleted file mode 100644 index 055f45f47..000000000 --- a/tests/wasi_test_resources/poll_oneoff.out +++ /dev/null @@ -1,5 +0,0 @@ -__wasi_event_t { userdata: 1193046, error: 0, type_: 1, u: __wasi_event_u { __wasi_event_fd_readwrite_t { nbytes: 2259, flags: 0 } } } -[__wasi_event_t { userdata: 1193046, error: 0, type_: 1, u: __wasi_event_u { __wasi_event_fd_readwrite_t { nbytes: 2259, flags: 0 } } }, __wasi_event_t { userdata: 1193046, error: 0, type_: 2, u: __wasi_event_u { __wasi_event_fd_readwrite_t { nbytes: 1234, flags: 0 } } }] -Stdin: OK -Stdout: OK -Stderr: OK diff --git a/tests/wasi_test_resources/poll_oneoff.rs b/tests/wasi_test_resources/poll_oneoff.rs index 177ff19ae..484190cae 100644 --- a/tests/wasi_test_resources/poll_oneoff.rs +++ b/tests/wasi_test_resources/poll_oneoff.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // mapdir: hamlet:tests/wasi_test_resources/test_fs/hamlet // mapdir: temp:tests/wasi_test_resources/test_fs/temp diff --git a/tests/wasi_test_resources/quine.out b/tests/wasi_test_resources/quine.out deleted file mode 100644 index 3d554e2e5..000000000 --- a/tests/wasi_test_resources/quine.out +++ /dev/null @@ -1,15 +0,0 @@ -// Args: -// dir: . - -use std::fs; -use std::io::Read; - -fn main() { - let mut this_file = - fs::File::open("tests/wasi_test_resources/quine.rs").expect("could not find src file"); - let md = this_file.metadata().unwrap(); - let mut in_str = String::new(); - this_file.read_to_string(&mut in_str).unwrap(); - println!("{}", in_str); -} - diff --git a/tests/wasi_test_resources/quine.rs b/tests/wasi_test_resources/quine.rs index 6ed0f24d1..632865f4a 100644 --- a/tests/wasi_test_resources/quine.rs +++ b/tests/wasi_test_resources/quine.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // dir: . use std::fs; diff --git a/tests/wasi_test_resources/readlink.out b/tests/wasi_test_resources/readlink.out deleted file mode 100644 index 547b33b18..000000000 --- a/tests/wasi_test_resources/readlink.out +++ /dev/null @@ -1,4 +0,0 @@ -../act1/scene2.txt -SCENE II. A room of state in the castle. - - Enter KING CLAUDIUS, QUEEN GERTRUDE, HAMLET, POLONIUS, LAERTES, VOLTIMAND, CORNELI diff --git a/tests/wasi_test_resources/readlink.rs b/tests/wasi_test_resources/readlink.rs index 66472b718..620de76cf 100644 --- a/tests/wasi_test_resources/readlink.rs +++ b/tests/wasi_test_resources/readlink.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // mapdir: .:tests/wasi_test_resources/test_fs/hamlet use std::io::Read; diff --git a/tests/wasi_test_resources/snapshot1/close_preopen_fd.out b/tests/wasi_test_resources/snapshot1/close_preopen_fd.out new file mode 100644 index 000000000..6d18d7b1a --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/close_preopen_fd.out @@ -0,0 +1,14 @@ +{ + "output": "accessing preopen fd was a success\nClosing preopen fd was a success\naccessing closed preopen fd was an EBADF error: true\n", + "options": { + "mapdir": [ + [ + "hamlet", + "tests/wasi_test_resources/test_fs/hamlet" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/close_preopen_fd.wasm b/tests/wasi_test_resources/snapshot1/close_preopen_fd.wasm index 8a2613e06..40941670d 100755 Binary files a/tests/wasi_test_resources/snapshot1/close_preopen_fd.wasm and b/tests/wasi_test_resources/snapshot1/close_preopen_fd.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/create_dir.out b/tests/wasi_test_resources/snapshot1/create_dir.out new file mode 100644 index 000000000..18902fcf9 --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/create_dir.out @@ -0,0 +1,11 @@ +{ + "output": "Test file exists: false\nDir exists: false\nDir exists: false\nDir exists: false\nSuccess\n", + "options": { + "mapdir": [], + "env": [], + "args": [], + "dir": [ + "." + ] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/create_dir.wasm b/tests/wasi_test_resources/snapshot1/create_dir.wasm index c971cd6c3..68903c17d 100755 Binary files a/tests/wasi_test_resources/snapshot1/create_dir.wasm and b/tests/wasi_test_resources/snapshot1/create_dir.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/envvar.out b/tests/wasi_test_resources/snapshot1/envvar.out new file mode 100644 index 000000000..d1fb3bf3f --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/envvar.out @@ -0,0 +1,18 @@ +{ + "output": "Env vars:\nCAT=2\nDOG=1\nDOG Ok(\"1\")\nDOG_TYPE Err(NotPresent)\nSET VAR Ok(\"HELLO\")\n", + "options": { + "mapdir": [], + "env": [ + [ + "DOG", + "1" + ], + [ + "CAT", + "2" + ] + ], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/envvar.wasm b/tests/wasi_test_resources/snapshot1/envvar.wasm index aac71d04b..4830904e0 100755 Binary files a/tests/wasi_test_resources/snapshot1/envvar.wasm and b/tests/wasi_test_resources/snapshot1/envvar.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/fd_allocate.out b/tests/wasi_test_resources/snapshot1/fd_allocate.out new file mode 100644 index 000000000..289e661d0 --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/fd_allocate.out @@ -0,0 +1,14 @@ +{ + "output": "171\n1405\n", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/temp" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/fd_allocate.wasm b/tests/wasi_test_resources/snapshot1/fd_allocate.wasm index f11f70f3e..bfebe5890 100755 Binary files a/tests/wasi_test_resources/snapshot1/fd_allocate.wasm and b/tests/wasi_test_resources/snapshot1/fd_allocate.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/fd_append.out b/tests/wasi_test_resources/snapshot1/fd_append.out new file mode 100644 index 000000000..8096400be --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/fd_append.out @@ -0,0 +1,14 @@ +{ + "output": "\"Hello, world!\\nGoodbye, world!\\n\"\n", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/temp" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/fd_append.wasm b/tests/wasi_test_resources/snapshot1/fd_append.wasm index b47494b32..0258a749b 100755 Binary files a/tests/wasi_test_resources/snapshot1/fd_append.wasm and b/tests/wasi_test_resources/snapshot1/fd_append.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/fd_close.out b/tests/wasi_test_resources/snapshot1/fd_close.out new file mode 100644 index 000000000..a2b472bb0 --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/fd_close.out @@ -0,0 +1,14 @@ +{ + "output": "Successfully closed file!\nSuccessfully closed stderr!\nSuccessfully closed stdin!\n", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/hamlet" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/fd_close.wasm b/tests/wasi_test_resources/snapshot1/fd_close.wasm index 5b70a4e94..d6be37050 100755 Binary files a/tests/wasi_test_resources/snapshot1/fd_close.wasm and b/tests/wasi_test_resources/snapshot1/fd_close.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/fd_pread.out b/tests/wasi_test_resources/snapshot1/fd_pread.out new file mode 100644 index 000000000..c3a1318a9 --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/fd_pread.out @@ -0,0 +1,14 @@ +{ + "output": " POLONIUS\n\n He will come straight. Look you lay home to him:\n\n POLONIUS\n\n He will come straight. Look you lay home to him:\n\nRead the same data? true", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/hamlet" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/fd_pread.wasm b/tests/wasi_test_resources/snapshot1/fd_pread.wasm index 486acf21b..c0d9c9466 100755 Binary files a/tests/wasi_test_resources/snapshot1/fd_pread.wasm and b/tests/wasi_test_resources/snapshot1/fd_pread.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/fd_read.out b/tests/wasi_test_resources/snapshot1/fd_read.out new file mode 100644 index 000000000..832ad65f2 --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/fd_read.out @@ -0,0 +1,14 @@ +{ + "output": "SCENE IV. The Queen's closet.\n\n Enter QUEEN GERTRUDE and POLO", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/hamlet" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/fd_read.wasm b/tests/wasi_test_resources/snapshot1/fd_read.wasm index aadd83906..d77985a72 100755 Binary files a/tests/wasi_test_resources/snapshot1/fd_read.wasm and b/tests/wasi_test_resources/snapshot1/fd_read.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/fd_sync.out b/tests/wasi_test_resources/snapshot1/fd_sync.out new file mode 100644 index 000000000..30f7e2352 --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/fd_sync.out @@ -0,0 +1,14 @@ +{ + "output": "170\n1404\n", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/temp" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/fd_sync.wasm b/tests/wasi_test_resources/snapshot1/fd_sync.wasm index 17a22ae63..2a7408ecc 100755 Binary files a/tests/wasi_test_resources/snapshot1/fd_sync.wasm and b/tests/wasi_test_resources/snapshot1/fd_sync.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/file_metadata.out b/tests/wasi_test_resources/snapshot1/file_metadata.out new file mode 100644 index 000000000..5c1cef48e --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/file_metadata.out @@ -0,0 +1,11 @@ +{ + "output": "is dir: false\nfiletype: false true false\nfile info: 493\n", + "options": { + "mapdir": [], + "env": [], + "args": [], + "dir": [ + "." + ] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/file_metadata.wasm b/tests/wasi_test_resources/snapshot1/file_metadata.wasm index 9efe732ab..62e21d30d 100755 Binary files a/tests/wasi_test_resources/snapshot1/file_metadata.wasm and b/tests/wasi_test_resources/snapshot1/file_metadata.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/fs_sandbox_test.out b/tests/wasi_test_resources/snapshot1/fs_sandbox_test.out new file mode 100644 index 000000000..0f024e9ed --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/fs_sandbox_test.out @@ -0,0 +1,9 @@ +{ + "output": "Reading the parent directory was okay? false\n", + "options": { + "mapdir": [], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/fs_sandbox_test.wasm b/tests/wasi_test_resources/snapshot1/fs_sandbox_test.wasm index 33237a18a..2d871f6a3 100755 Binary files a/tests/wasi_test_resources/snapshot1/fs_sandbox_test.wasm and b/tests/wasi_test_resources/snapshot1/fs_sandbox_test.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/fseek.out b/tests/wasi_test_resources/snapshot1/fseek.out new file mode 100644 index 000000000..cb64df644 --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/fseek.out @@ -0,0 +1,14 @@ +{ + "output": "SCENE III. A room in Polonius' h\nouse.\n\n Enter LAERTES and OPH\n And, sister, as the winds gi\nr talk with the Lord Hamlet.\n \nuits,\n Breathing like sanctif\nis is for all:\n I would not, \n", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/hamlet" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/fseek.wasm b/tests/wasi_test_resources/snapshot1/fseek.wasm index cc936afea..ae96416c3 100755 Binary files a/tests/wasi_test_resources/snapshot1/fseek.wasm and b/tests/wasi_test_resources/snapshot1/fseek.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/hello.out b/tests/wasi_test_resources/snapshot1/hello.out new file mode 100644 index 000000000..42d761059 --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/hello.out @@ -0,0 +1,9 @@ +{ + "output": "Hello, world!\n", + "options": { + "mapdir": [], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/hello.wasm b/tests/wasi_test_resources/snapshot1/hello.wasm index 3aeedc2bc..bd20ca799 100755 Binary files a/tests/wasi_test_resources/snapshot1/hello.wasm and b/tests/wasi_test_resources/snapshot1/hello.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/isatty.out b/tests/wasi_test_resources/snapshot1/isatty.out new file mode 100644 index 000000000..fde7e8671 --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/isatty.out @@ -0,0 +1,9 @@ +{ + "output": "stdin: 1\nstdout: 1\nstderr: 1\n", + "options": { + "mapdir": [], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/isatty.wasm b/tests/wasi_test_resources/snapshot1/isatty.wasm index 660c4ac8f..20699f781 100755 Binary files a/tests/wasi_test_resources/snapshot1/isatty.wasm and b/tests/wasi_test_resources/snapshot1/isatty.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/mapdir.out b/tests/wasi_test_resources/snapshot1/mapdir.out new file mode 100644 index 000000000..b46164a50 --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/mapdir.out @@ -0,0 +1,14 @@ +{ + "output": "\"./README.md\"\n\"./act1\"\n\"./act2\"\n\"./act3\"\n\"./act4\"\n\"./act5\"\n\"./bookmarks\"\n", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/hamlet" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/mapdir.wasm b/tests/wasi_test_resources/snapshot1/mapdir.wasm index d19f845f7..b68f79088 100755 Binary files a/tests/wasi_test_resources/snapshot1/mapdir.wasm and b/tests/wasi_test_resources/snapshot1/mapdir.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/path_link.out b/tests/wasi_test_resources/snapshot1/path_link.out new file mode 100644 index 000000000..c8fc9ef82 --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/path_link.out @@ -0,0 +1,18 @@ +{ + "output": "ACT V\nSCENE I. A churchyard.\n\n Enter two Clowns, with spades,\nACT V\nSCENE I. A churchyard.\n\n Enter two Clowns, with spades,\nPath still exists\n", + "options": { + "mapdir": [ + [ + "act5", + "tests/wasi_test_resources/test_fs/hamlet/act5" + ], + [ + "temp", + "tests/wasi_test_resources/test_fs/temp" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/path_link.wasm b/tests/wasi_test_resources/snapshot1/path_link.wasm index 8c95ec1e4..a8e2489ca 100755 Binary files a/tests/wasi_test_resources/snapshot1/path_link.wasm and b/tests/wasi_test_resources/snapshot1/path_link.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/path_rename.out b/tests/wasi_test_resources/snapshot1/path_rename.out new file mode 100644 index 000000000..de75f0df8 --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/path_rename.out @@ -0,0 +1,14 @@ +{ + "output": "The original file does not still exist!\n柴犬\n", + "options": { + "mapdir": [ + [ + "temp", + "tests/wasi_test_resources/test_fs/temp" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/path_rename.wasm b/tests/wasi_test_resources/snapshot1/path_rename.wasm index 82ae20757..f3db7674f 100755 Binary files a/tests/wasi_test_resources/snapshot1/path_rename.wasm and b/tests/wasi_test_resources/snapshot1/path_rename.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/path_symlink.out b/tests/wasi_test_resources/snapshot1/path_symlink.out new file mode 100644 index 000000000..5df1fc3ef --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/path_symlink.out @@ -0,0 +1,18 @@ +{ + "output": "ACT III\nSCENE I. A room in the castle.\n\n Enter KING CLAUDIUS,\n", + "options": { + "mapdir": [ + [ + "temp", + "tests/wasi_test_resources/test_fs/temp" + ], + [ + "hamlet", + "tests/wasi_test_resources/test_fs/hamlet" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/path_symlink.wasm b/tests/wasi_test_resources/snapshot1/path_symlink.wasm index 91f11643c..5c12de529 100755 Binary files a/tests/wasi_test_resources/snapshot1/path_symlink.wasm and b/tests/wasi_test_resources/snapshot1/path_symlink.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/poll_oneoff.out b/tests/wasi_test_resources/snapshot1/poll_oneoff.out new file mode 100644 index 000000000..1ef6a8f58 --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/poll_oneoff.out @@ -0,0 +1,18 @@ +{ + "output": "__wasi_event_t { userdata: 1193046, error: 0, type_: 1, u: __wasi_event_u { __wasi_event_fd_readwrite_t { nbytes: 2259, flags: 0 } } }\n[__wasi_event_t { userdata: 1193046, error: 0, type_: 1, u: __wasi_event_u { __wasi_event_fd_readwrite_t { nbytes: 2259, flags: 0 } } }, __wasi_event_t { userdata: 1193046, error: 0, type_: 2, u: __wasi_event_u { __wasi_event_fd_readwrite_t { nbytes: 1234, flags: 0 } } }]\nStdin: OK\nStdout: OK\nStderr: OK\n", + "options": { + "mapdir": [ + [ + "hamlet", + "tests/wasi_test_resources/test_fs/hamlet" + ], + [ + "temp", + "tests/wasi_test_resources/test_fs/temp" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/poll_oneoff.wasm b/tests/wasi_test_resources/snapshot1/poll_oneoff.wasm index 5937b2b7f..5f29017f4 100755 Binary files a/tests/wasi_test_resources/snapshot1/poll_oneoff.wasm and b/tests/wasi_test_resources/snapshot1/poll_oneoff.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/quine.out b/tests/wasi_test_resources/snapshot1/quine.out new file mode 100644 index 000000000..13bb98897 --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/quine.out @@ -0,0 +1,11 @@ +{ + "output": "// WASI:\n// dir: .\n\nuse std::fs;\nuse std::io::Read;\n\nfn main() {\n let mut this_file =\n fs::File::open(\"tests/wasi_test_resources/quine.rs\").expect(\"could not find src file\");\n let md = this_file.metadata().unwrap();\n let mut in_str = String::new();\n this_file.read_to_string(&mut in_str).unwrap();\n println!(\"{}\", in_str);\n}\n\n", + "options": { + "mapdir": [], + "env": [], + "args": [], + "dir": [ + "." + ] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/quine.wasm b/tests/wasi_test_resources/snapshot1/quine.wasm index aa9972562..b42142f10 100755 Binary files a/tests/wasi_test_resources/snapshot1/quine.wasm and b/tests/wasi_test_resources/snapshot1/quine.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/readlink.out b/tests/wasi_test_resources/snapshot1/readlink.out new file mode 100644 index 000000000..b972f8e02 --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/readlink.out @@ -0,0 +1,14 @@ +{ + "output": "../act1/scene2.txt\nSCENE II. A room of state in the castle.\n\n Enter KING CLAUDIUS, QUEEN GERTRUDE, HAMLET, POLONIUS, LAERTES, VOLTIMAND, CORNELI\n", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/hamlet" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/readlink.wasm b/tests/wasi_test_resources/snapshot1/readlink.wasm index f1a1e9952..1d6c523ef 100755 Binary files a/tests/wasi_test_resources/snapshot1/readlink.wasm and b/tests/wasi_test_resources/snapshot1/readlink.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/wasi_sees_virtual_root.out b/tests/wasi_test_resources/snapshot1/wasi_sees_virtual_root.out new file mode 100644 index 000000000..b894d9af4 --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/wasi_sees_virtual_root.out @@ -0,0 +1,22 @@ +{ + "output": "\"/act1\"\n\"/act1-again\"\n\"/act2\"\n\"/act1\"\n\"/act1-again\"\n\"/act2\"\n\"/act1\"\n\"/act1-again\"\n\"/act2\"\n\"/act1\"\n\"/act1-again\"\n\"/act2\"\nROOT IS SAFE\n", + "options": { + "mapdir": [ + [ + "act1", + "tests/wasi_test_resources/test_fs/hamlet/act1" + ], + [ + "act2", + "tests/wasi_test_resources/test_fs/hamlet/act2" + ], + [ + "act1-again", + "tests/wasi_test_resources/test_fs/hamlet/act1" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/wasi_sees_virtual_root.wasm b/tests/wasi_test_resources/snapshot1/wasi_sees_virtual_root.wasm index 8b5ab8ef9..caf94094a 100755 Binary files a/tests/wasi_test_resources/snapshot1/wasi_sees_virtual_root.wasm and b/tests/wasi_test_resources/snapshot1/wasi_sees_virtual_root.wasm differ diff --git a/tests/wasi_test_resources/snapshot1/writing.out b/tests/wasi_test_resources/snapshot1/writing.out new file mode 100644 index 000000000..aa3a006f9 --- /dev/null +++ b/tests/wasi_test_resources/snapshot1/writing.out @@ -0,0 +1,22 @@ +{ + "output": "abcdefghijklmnopqrstuvwxyz\nfile is gone\n", + "options": { + "mapdir": [ + [ + "act1", + "tests/wasi_test_resources/test_fs/hamlet/act1" + ], + [ + "act2", + "tests/wasi_test_resources/test_fs/hamlet/act2" + ], + [ + "act1-again", + "tests/wasi_test_resources/test_fs/hamlet/act1" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/snapshot1/writing.wasm b/tests/wasi_test_resources/snapshot1/writing.wasm index d1c9e04e0..a4065019c 100755 Binary files a/tests/wasi_test_resources/snapshot1/writing.wasm and b/tests/wasi_test_resources/snapshot1/writing.wasm differ diff --git a/tests/wasi_test_resources/unstable/close_preopen_fd.out b/tests/wasi_test_resources/unstable/close_preopen_fd.out new file mode 100644 index 000000000..6d18d7b1a --- /dev/null +++ b/tests/wasi_test_resources/unstable/close_preopen_fd.out @@ -0,0 +1,14 @@ +{ + "output": "accessing preopen fd was a success\nClosing preopen fd was a success\naccessing closed preopen fd was an EBADF error: true\n", + "options": { + "mapdir": [ + [ + "hamlet", + "tests/wasi_test_resources/test_fs/hamlet" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/create_dir.out b/tests/wasi_test_resources/unstable/create_dir.out new file mode 100644 index 000000000..18902fcf9 --- /dev/null +++ b/tests/wasi_test_resources/unstable/create_dir.out @@ -0,0 +1,11 @@ +{ + "output": "Test file exists: false\nDir exists: false\nDir exists: false\nDir exists: false\nSuccess\n", + "options": { + "mapdir": [], + "env": [], + "args": [], + "dir": [ + "." + ] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/envvar.out b/tests/wasi_test_resources/unstable/envvar.out new file mode 100644 index 000000000..d1fb3bf3f --- /dev/null +++ b/tests/wasi_test_resources/unstable/envvar.out @@ -0,0 +1,18 @@ +{ + "output": "Env vars:\nCAT=2\nDOG=1\nDOG Ok(\"1\")\nDOG_TYPE Err(NotPresent)\nSET VAR Ok(\"HELLO\")\n", + "options": { + "mapdir": [], + "env": [ + [ + "DOG", + "1" + ], + [ + "CAT", + "2" + ] + ], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/fd_allocate.out b/tests/wasi_test_resources/unstable/fd_allocate.out new file mode 100644 index 000000000..289e661d0 --- /dev/null +++ b/tests/wasi_test_resources/unstable/fd_allocate.out @@ -0,0 +1,14 @@ +{ + "output": "171\n1405\n", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/temp" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/fd_append.out b/tests/wasi_test_resources/unstable/fd_append.out new file mode 100644 index 000000000..8096400be --- /dev/null +++ b/tests/wasi_test_resources/unstable/fd_append.out @@ -0,0 +1,14 @@ +{ + "output": "\"Hello, world!\\nGoodbye, world!\\n\"\n", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/temp" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/fd_close.out b/tests/wasi_test_resources/unstable/fd_close.out new file mode 100644 index 000000000..a2b472bb0 --- /dev/null +++ b/tests/wasi_test_resources/unstable/fd_close.out @@ -0,0 +1,14 @@ +{ + "output": "Successfully closed file!\nSuccessfully closed stderr!\nSuccessfully closed stdin!\n", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/hamlet" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/fd_pread.out b/tests/wasi_test_resources/unstable/fd_pread.out new file mode 100644 index 000000000..c3a1318a9 --- /dev/null +++ b/tests/wasi_test_resources/unstable/fd_pread.out @@ -0,0 +1,14 @@ +{ + "output": " POLONIUS\n\n He will come straight. Look you lay home to him:\n\n POLONIUS\n\n He will come straight. Look you lay home to him:\n\nRead the same data? true", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/hamlet" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/fd_read.out b/tests/wasi_test_resources/unstable/fd_read.out new file mode 100644 index 000000000..832ad65f2 --- /dev/null +++ b/tests/wasi_test_resources/unstable/fd_read.out @@ -0,0 +1,14 @@ +{ + "output": "SCENE IV. The Queen's closet.\n\n Enter QUEEN GERTRUDE and POLO", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/hamlet" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/fd_sync.out b/tests/wasi_test_resources/unstable/fd_sync.out new file mode 100644 index 000000000..30f7e2352 --- /dev/null +++ b/tests/wasi_test_resources/unstable/fd_sync.out @@ -0,0 +1,14 @@ +{ + "output": "170\n1404\n", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/temp" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/file_metadata.out b/tests/wasi_test_resources/unstable/file_metadata.out new file mode 100644 index 000000000..5c1cef48e --- /dev/null +++ b/tests/wasi_test_resources/unstable/file_metadata.out @@ -0,0 +1,11 @@ +{ + "output": "is dir: false\nfiletype: false true false\nfile info: 493\n", + "options": { + "mapdir": [], + "env": [], + "args": [], + "dir": [ + "." + ] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/fs_sandbox_test.out b/tests/wasi_test_resources/unstable/fs_sandbox_test.out new file mode 100644 index 000000000..0f024e9ed --- /dev/null +++ b/tests/wasi_test_resources/unstable/fs_sandbox_test.out @@ -0,0 +1,9 @@ +{ + "output": "Reading the parent directory was okay? false\n", + "options": { + "mapdir": [], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/fseek.out b/tests/wasi_test_resources/unstable/fseek.out new file mode 100644 index 000000000..cb64df644 --- /dev/null +++ b/tests/wasi_test_resources/unstable/fseek.out @@ -0,0 +1,14 @@ +{ + "output": "SCENE III. A room in Polonius' h\nouse.\n\n Enter LAERTES and OPH\n And, sister, as the winds gi\nr talk with the Lord Hamlet.\n \nuits,\n Breathing like sanctif\nis is for all:\n I would not, \n", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/hamlet" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/hello.out b/tests/wasi_test_resources/unstable/hello.out new file mode 100644 index 000000000..42d761059 --- /dev/null +++ b/tests/wasi_test_resources/unstable/hello.out @@ -0,0 +1,9 @@ +{ + "output": "Hello, world!\n", + "options": { + "mapdir": [], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/isatty.out b/tests/wasi_test_resources/unstable/isatty.out new file mode 100644 index 000000000..fde7e8671 --- /dev/null +++ b/tests/wasi_test_resources/unstable/isatty.out @@ -0,0 +1,9 @@ +{ + "output": "stdin: 1\nstdout: 1\nstderr: 1\n", + "options": { + "mapdir": [], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/mapdir.out b/tests/wasi_test_resources/unstable/mapdir.out new file mode 100644 index 000000000..b46164a50 --- /dev/null +++ b/tests/wasi_test_resources/unstable/mapdir.out @@ -0,0 +1,14 @@ +{ + "output": "\"./README.md\"\n\"./act1\"\n\"./act2\"\n\"./act3\"\n\"./act4\"\n\"./act5\"\n\"./bookmarks\"\n", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/hamlet" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/path_link.out b/tests/wasi_test_resources/unstable/path_link.out new file mode 100644 index 000000000..c8fc9ef82 --- /dev/null +++ b/tests/wasi_test_resources/unstable/path_link.out @@ -0,0 +1,18 @@ +{ + "output": "ACT V\nSCENE I. A churchyard.\n\n Enter two Clowns, with spades,\nACT V\nSCENE I. A churchyard.\n\n Enter two Clowns, with spades,\nPath still exists\n", + "options": { + "mapdir": [ + [ + "act5", + "tests/wasi_test_resources/test_fs/hamlet/act5" + ], + [ + "temp", + "tests/wasi_test_resources/test_fs/temp" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/path_rename.out b/tests/wasi_test_resources/unstable/path_rename.out new file mode 100644 index 000000000..de75f0df8 --- /dev/null +++ b/tests/wasi_test_resources/unstable/path_rename.out @@ -0,0 +1,14 @@ +{ + "output": "The original file does not still exist!\n柴犬\n", + "options": { + "mapdir": [ + [ + "temp", + "tests/wasi_test_resources/test_fs/temp" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/path_symlink.out b/tests/wasi_test_resources/unstable/path_symlink.out new file mode 100644 index 000000000..5df1fc3ef --- /dev/null +++ b/tests/wasi_test_resources/unstable/path_symlink.out @@ -0,0 +1,18 @@ +{ + "output": "ACT III\nSCENE I. A room in the castle.\n\n Enter KING CLAUDIUS,\n", + "options": { + "mapdir": [ + [ + "temp", + "tests/wasi_test_resources/test_fs/temp" + ], + [ + "hamlet", + "tests/wasi_test_resources/test_fs/hamlet" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/poll_oneoff.out b/tests/wasi_test_resources/unstable/poll_oneoff.out new file mode 100644 index 000000000..1ef6a8f58 --- /dev/null +++ b/tests/wasi_test_resources/unstable/poll_oneoff.out @@ -0,0 +1,18 @@ +{ + "output": "__wasi_event_t { userdata: 1193046, error: 0, type_: 1, u: __wasi_event_u { __wasi_event_fd_readwrite_t { nbytes: 2259, flags: 0 } } }\n[__wasi_event_t { userdata: 1193046, error: 0, type_: 1, u: __wasi_event_u { __wasi_event_fd_readwrite_t { nbytes: 2259, flags: 0 } } }, __wasi_event_t { userdata: 1193046, error: 0, type_: 2, u: __wasi_event_u { __wasi_event_fd_readwrite_t { nbytes: 1234, flags: 0 } } }]\nStdin: OK\nStdout: OK\nStderr: OK\n", + "options": { + "mapdir": [ + [ + "hamlet", + "tests/wasi_test_resources/test_fs/hamlet" + ], + [ + "temp", + "tests/wasi_test_resources/test_fs/temp" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/quine.out b/tests/wasi_test_resources/unstable/quine.out new file mode 100644 index 000000000..13bb98897 --- /dev/null +++ b/tests/wasi_test_resources/unstable/quine.out @@ -0,0 +1,11 @@ +{ + "output": "// WASI:\n// dir: .\n\nuse std::fs;\nuse std::io::Read;\n\nfn main() {\n let mut this_file =\n fs::File::open(\"tests/wasi_test_resources/quine.rs\").expect(\"could not find src file\");\n let md = this_file.metadata().unwrap();\n let mut in_str = String::new();\n this_file.read_to_string(&mut in_str).unwrap();\n println!(\"{}\", in_str);\n}\n\n", + "options": { + "mapdir": [], + "env": [], + "args": [], + "dir": [ + "." + ] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/readlink.out b/tests/wasi_test_resources/unstable/readlink.out new file mode 100644 index 000000000..b972f8e02 --- /dev/null +++ b/tests/wasi_test_resources/unstable/readlink.out @@ -0,0 +1,14 @@ +{ + "output": "../act1/scene2.txt\nSCENE II. A room of state in the castle.\n\n Enter KING CLAUDIUS, QUEEN GERTRUDE, HAMLET, POLONIUS, LAERTES, VOLTIMAND, CORNELI\n", + "options": { + "mapdir": [ + [ + ".", + "tests/wasi_test_resources/test_fs/hamlet" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/wasi_sees_virtual_root.out b/tests/wasi_test_resources/unstable/wasi_sees_virtual_root.out new file mode 100644 index 000000000..b894d9af4 --- /dev/null +++ b/tests/wasi_test_resources/unstable/wasi_sees_virtual_root.out @@ -0,0 +1,22 @@ +{ + "output": "\"/act1\"\n\"/act1-again\"\n\"/act2\"\n\"/act1\"\n\"/act1-again\"\n\"/act2\"\n\"/act1\"\n\"/act1-again\"\n\"/act2\"\n\"/act1\"\n\"/act1-again\"\n\"/act2\"\nROOT IS SAFE\n", + "options": { + "mapdir": [ + [ + "act1", + "tests/wasi_test_resources/test_fs/hamlet/act1" + ], + [ + "act2", + "tests/wasi_test_resources/test_fs/hamlet/act2" + ], + [ + "act1-again", + "tests/wasi_test_resources/test_fs/hamlet/act1" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/unstable/writing.out b/tests/wasi_test_resources/unstable/writing.out new file mode 100644 index 000000000..aa3a006f9 --- /dev/null +++ b/tests/wasi_test_resources/unstable/writing.out @@ -0,0 +1,22 @@ +{ + "output": "abcdefghijklmnopqrstuvwxyz\nfile is gone\n", + "options": { + "mapdir": [ + [ + "act1", + "tests/wasi_test_resources/test_fs/hamlet/act1" + ], + [ + "act2", + "tests/wasi_test_resources/test_fs/hamlet/act2" + ], + [ + "act1-again", + "tests/wasi_test_resources/test_fs/hamlet/act1" + ] + ], + "env": [], + "args": [], + "dir": [] + } +} \ No newline at end of file diff --git a/tests/wasi_test_resources/wasi_sees_virtual_root.out b/tests/wasi_test_resources/wasi_sees_virtual_root.out deleted file mode 100644 index f9e5ca114..000000000 --- a/tests/wasi_test_resources/wasi_sees_virtual_root.out +++ /dev/null @@ -1,13 +0,0 @@ -"/act1" -"/act1-again" -"/act2" -"/act1" -"/act1-again" -"/act2" -"/act1" -"/act1-again" -"/act2" -"/act1" -"/act1-again" -"/act2" -ROOT IS SAFE diff --git a/tests/wasi_test_resources/wasi_sees_virtual_root.rs b/tests/wasi_test_resources/wasi_sees_virtual_root.rs index bbbac4354..7a2188903 100644 --- a/tests/wasi_test_resources/wasi_sees_virtual_root.rs +++ b/tests/wasi_test_resources/wasi_sees_virtual_root.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // mapdir: act1:tests/wasi_test_resources/test_fs/hamlet/act1 // mapdir: act2:tests/wasi_test_resources/test_fs/hamlet/act2 // mapdir: act1-again:tests/wasi_test_resources/test_fs/hamlet/act1 diff --git a/tests/wasi_test_resources/writing.out b/tests/wasi_test_resources/writing.out deleted file mode 100644 index a471ade37..000000000 --- a/tests/wasi_test_resources/writing.out +++ /dev/null @@ -1,2 +0,0 @@ -abcdefghijklmnopqrstuvwxyz -file is gone diff --git a/tests/wasi_test_resources/writing.rs b/tests/wasi_test_resources/writing.rs index 846df14af..60efb9cff 100644 --- a/tests/wasi_test_resources/writing.rs +++ b/tests/wasi_test_resources/writing.rs @@ -1,4 +1,4 @@ -// Args: +// WASI: // mapdir: act1:tests/wasi_test_resources/test_fs/hamlet/act1 // mapdir: act2:tests/wasi_test_resources/test_fs/hamlet/act2 // mapdir: act1-again:tests/wasi_test_resources/test_fs/hamlet/act1 diff --git a/tests/wasitest.rs b/tests/wasitest.rs index ec5d6a311..03da5757c 100644 --- a/tests/wasitest.rs +++ b/tests/wasitest.rs @@ -1,2 +1,109 @@ -pub mod utils; -mod wasitests; +mod utils; +use crate::utils::stdio::StdioCapturer; +use serde::{Deserialize, Serialize}; +use wasmer::compiler::{compile_with, compiler_for_backend, Backend}; +use wasmer::Func; +use wasmer_wasi::state::WasiState; +use wasmer_wasi::{generate_import_object_from_state, get_wasi_version}; + +use lazy_static::lazy_static; +use std::sync::Mutex; +lazy_static! { + // We want to run wasi tests one by one + // Based from: https://stackoverflow.com/questions/51694017/how-can-i-avoid-running-some-tests-in-parallel + static ref WASI_LOCK: Mutex<()> = Mutex::new(()); +} + +/// This is the structure of the `.out` file +#[derive(Debug, Default, Serialize, Deserialize)] +pub struct WasiTest { + /// The program expected output + pub output: String, + /// The program options + pub options: WasiOptions, +} + +/// The options provied when executed a WASI Wasm program +#[derive(Debug, Default, Serialize, Deserialize)] +pub struct WasiOptions { + /// Mapped pre-opened dirs + pub mapdir: Vec<(String, String)>, + /// Environment vars + pub env: Vec<(String, String)>, + /// Program arguments + pub args: Vec, + /// Pre-opened directories + pub dir: Vec, +} + +// The generated tests (from build.rs) look like: +// #[cfg(test)] +// mod singlepass { +// mod wasi { +// #[test] +// fn hello() -> anyhow::Result<()> { +// crate::run_wasi( +// "tests/wasi_test_resources/snapshot1/hello.wasm", +// "tests/wasi_test_resources/snapshot1/hello.out", +// "singlepass" +// ) +// } +// } +// } +include!(concat!(env!("OUT_DIR"), "/generated_wasitests.rs")); + +fn run_wasi( + wasm_program_path: &str, + wasi_json_test_path: &str, + backend: &str, +) -> anyhow::Result<()> { + let _shared = WASI_LOCK.lock().unwrap_or_else(|e| e.into_inner()); + + let backend = utils::get_backend_from_str(backend)?; + + let wasi_json_test = std::fs::read(wasi_json_test_path)?; + let wasitest: WasiTest = serde_json::from_slice(&wasi_json_test)?; + + let wasm_binary = std::fs::read(wasm_program_path)?; + let compiler = compiler_for_backend(backend).expect("Backend not recognized"); + let module = compile_with(&wasm_binary, &*compiler).unwrap(); + + let wasi_version = get_wasi_version(&module, true).expect("WASI module"); + // println!("Executing WASI: {:?}", wasitest); + let mut state_builder = WasiState::new(""); + let wasi_state = state_builder + .envs(wasitest.options.env) + .args(wasitest.options.args) + .preopen_dirs(wasitest.options.dir)? + .map_dirs(wasitest.options.mapdir)? + .build()?; + + let import_object = generate_import_object_from_state(wasi_state, wasi_version); + + let instance = module + .instantiate(&import_object) + .map_err(|err| format!("Can't instantiate the WebAssembly module: {:?}", err)) + .unwrap(); // NOTE: Need to figure what the unwrap is for ?? + + let capturer = StdioCapturer::new(); + + let start: Func<(), ()> = instance + .exports + .get("_start") + .map_err(|e| format!("{:?}", e)) + .expect("start function in wasi module"); + + start.call().expect("execute the wasm"); + + let output = capturer.end().unwrap().0; + let expected_output = wasitest.output; + + assert!( + output.contains(&expected_output), + "Output: `{}` does not contain expected output: `{}`", + output, + expected_output + ); + + Ok(()) +} diff --git a/tests/wasitests/README.md b/tests/wasitests/README.md deleted file mode 100644 index 921f50c86..000000000 --- a/tests/wasitests/README.md +++ /dev/null @@ -1,5 +0,0 @@ -Most of the files here are generated. - -`_common.rs` is a file containing a macro that the generated tests use to avoid code duplication. - -If you want to add new features, edit `_common.rs` to change the macro or `tests/generate-wasi-tests` to change anything else. diff --git a/tests/wasitests/_common.rs b/tests/wasitests/_common.rs deleted file mode 100644 index bd11a407b..000000000 --- a/tests/wasitests/_common.rs +++ /dev/null @@ -1,80 +0,0 @@ -use std::env; -use wasmer::compiler::Backend; - -pub fn get_backend() -> Option { - #[cfg(feature = "backend-cranelift")] - { - if let Ok(v) = env::var("WASMER_TEST_CRANELIFT") { - if v == "1" { - return Some(Backend::Cranelift); - } - } - } - #[cfg(feature = "backend-llvm")] - { - if let Ok(v) = env::var("WASMER_TEST_LLVM") { - if v == "1" { - return Some(Backend::LLVM); - } - } - } - #[cfg(feature = "backend-singlepass")] - { - if let Ok(v) = env::var("WASMER_TEST_SINGLEPASS") { - if v == "1" { - return Some(Backend::Singlepass); - } - } - } - - None -} - -macro_rules! assert_wasi_output { - ($file:expr, $name:expr, $po_dir_args: expr, $mapdir_args:expr, $envvar_args:expr, $expected:expr) => {{ - use crate::utils::stdio::StdioCapturer; - use wasmer::Func; - use wasmer_wasi::{generate_import_object_for_version, get_wasi_version}; - - let wasm_bytes = include_bytes!($file); - let backend = $crate::wasitests::_common::get_backend().expect("Please set one of `WASMER_TEST_CRANELIFT`, `WASMER_TEST_LLVM`, or `WASMER_TEST_SINGELPASS` to `1`."); - let compiler = wasmer::compiler::compiler_for_backend(backend).expect("The desired compiler was not found!"); - - let module = wasmer::compiler::compile_with_config_with(&wasm_bytes[..], Default::default(), &*compiler).expect("WASM can't be compiled"); - - let wasi_version = get_wasi_version(&module, true).expect("WASI module"); - - let import_object = generate_import_object_for_version( - wasi_version, - vec![$name.into()], - vec![], - $po_dir_args, - $mapdir_args, - ); - - let instance = module - .instantiate(&import_object) - .map_err(|err| format!("Can't instantiate the WebAssembly module: {:?}", err)) - .unwrap(); // NOTE: Need to figure what the unwrap is for ?? - - let capturer = StdioCapturer::new(); - - let start: Func<(), ()> = instance - .exports - .get("_start") - .map_err(|e| format!("{:?}", e)) - .expect("start function in wasi module"); - - start.call().expect("execute the wasm"); - - let output = capturer.end().unwrap().0; - let expected_output = include_str!($expected); - - assert!( - output.contains(expected_output), - "Output: `{}` does not contain expected output: `{}`", - output, - expected_output - ); - }}; -} diff --git a/tests/wasitests/mod.rs b/tests/wasitests/mod.rs deleted file mode 100644 index e3fafa621..000000000 --- a/tests/wasitests/mod.rs +++ /dev/null @@ -1,53 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -// The _common module is not autogenerated. It provides common macros for the wasitests -#[macro_use] -mod _common; -mod snapshot1_close_preopen_fd; -mod snapshot1_create_dir; -mod snapshot1_envvar; -mod snapshot1_fd_allocate; -mod snapshot1_fd_append; -mod snapshot1_fd_close; -mod snapshot1_fd_pread; -mod snapshot1_fd_read; -mod snapshot1_fd_sync; -mod snapshot1_file_metadata; -mod snapshot1_fs_sandbox_test; -mod snapshot1_fseek; -mod snapshot1_hello; -mod snapshot1_isatty; -mod snapshot1_mapdir; -mod snapshot1_path_link; -mod snapshot1_path_rename; -mod snapshot1_path_symlink; -mod snapshot1_poll_oneoff; -mod snapshot1_quine; -mod snapshot1_readlink; -mod snapshot1_wasi_sees_virtual_root; -mod snapshot1_writing; -mod unstable_close_preopen_fd; -mod unstable_create_dir; -mod unstable_envvar; -mod unstable_fd_allocate; -mod unstable_fd_append; -mod unstable_fd_close; -mod unstable_fd_pread; -mod unstable_fd_read; -mod unstable_fd_sync; -mod unstable_file_metadata; -mod unstable_fs_sandbox_test; -mod unstable_fseek; -mod unstable_hello; -mod unstable_isatty; -mod unstable_mapdir; -mod unstable_path_link; -mod unstable_path_rename; -mod unstable_path_symlink; -mod unstable_poll_oneoff; -mod unstable_quine; -mod unstable_readlink; -mod unstable_wasi_sees_virtual_root; -mod unstable_writing; diff --git a/tests/wasitests/snapshot1_close_preopen_fd.rs b/tests/wasitests/snapshot1_close_preopen_fd.rs deleted file mode 100644 index 232d4ec0b..000000000 --- a/tests/wasitests/snapshot1_close_preopen_fd.rs +++ /dev/null @@ -1,19 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -#[ignore] -fn test_snapshot1_close_preopen_fd() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/close_preopen_fd.wasm", - "snapshot1_close_preopen_fd", - vec![], - vec![( - "hamlet".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ),], - vec![], - "../wasi_test_resources/close_preopen_fd.out" - ); -} diff --git a/tests/wasitests/snapshot1_create_dir.rs b/tests/wasitests/snapshot1_create_dir.rs deleted file mode 100644 index bb665e296..000000000 --- a/tests/wasitests/snapshot1_create_dir.rs +++ /dev/null @@ -1,15 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_snapshot1_create_dir() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/create_dir.wasm", - "snapshot1_create_dir", - vec![std::path::PathBuf::from("."),], - vec![], - vec![], - "../wasi_test_resources/create_dir.out" - ); -} diff --git a/tests/wasitests/snapshot1_envvar.rs b/tests/wasitests/snapshot1_envvar.rs deleted file mode 100644 index cecf52017..000000000 --- a/tests/wasitests/snapshot1_envvar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_snapshot1_envvar() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/envvar.wasm", - "snapshot1_envvar", - vec![], - vec![], - vec!["DOG=1".to_string(), "CAT=2".to_string(),], - "../wasi_test_resources/envvar.out" - ); -} diff --git a/tests/wasitests/snapshot1_fd_allocate.rs b/tests/wasitests/snapshot1_fd_allocate.rs deleted file mode 100644 index 631adc917..000000000 --- a/tests/wasitests/snapshot1_fd_allocate.rs +++ /dev/null @@ -1,19 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -#[ignore] -fn test_snapshot1_fd_allocate() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/fd_allocate.wasm", - "snapshot1_fd_allocate", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/temp") - ),], - vec![], - "../wasi_test_resources/fd_allocate.out" - ); -} diff --git a/tests/wasitests/snapshot1_fd_append.rs b/tests/wasitests/snapshot1_fd_append.rs deleted file mode 100644 index 800cb1ad3..000000000 --- a/tests/wasitests/snapshot1_fd_append.rs +++ /dev/null @@ -1,18 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_snapshot1_fd_append() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/fd_append.wasm", - "snapshot1_fd_append", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/temp") - ),], - vec![], - "../wasi_test_resources/fd_append.out" - ); -} diff --git a/tests/wasitests/snapshot1_fd_close.rs b/tests/wasitests/snapshot1_fd_close.rs deleted file mode 100644 index 76494cd16..000000000 --- a/tests/wasitests/snapshot1_fd_close.rs +++ /dev/null @@ -1,19 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -#[ignore] -fn test_snapshot1_fd_close() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/fd_close.wasm", - "snapshot1_fd_close", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ),], - vec![], - "../wasi_test_resources/fd_close.out" - ); -} diff --git a/tests/wasitests/snapshot1_fd_pread.rs b/tests/wasitests/snapshot1_fd_pread.rs deleted file mode 100644 index 2c0f01956..000000000 --- a/tests/wasitests/snapshot1_fd_pread.rs +++ /dev/null @@ -1,19 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -#[ignore] -fn test_snapshot1_fd_pread() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/fd_pread.wasm", - "snapshot1_fd_pread", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ),], - vec![], - "../wasi_test_resources/fd_pread.out" - ); -} diff --git a/tests/wasitests/snapshot1_fd_read.rs b/tests/wasitests/snapshot1_fd_read.rs deleted file mode 100644 index 68c7d3a8a..000000000 --- a/tests/wasitests/snapshot1_fd_read.rs +++ /dev/null @@ -1,19 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -#[ignore] -fn test_snapshot1_fd_read() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/fd_read.wasm", - "snapshot1_fd_read", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ),], - vec![], - "../wasi_test_resources/fd_read.out" - ); -} diff --git a/tests/wasitests/snapshot1_fd_sync.rs b/tests/wasitests/snapshot1_fd_sync.rs deleted file mode 100644 index abda06f32..000000000 --- a/tests/wasitests/snapshot1_fd_sync.rs +++ /dev/null @@ -1,18 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_snapshot1_fd_sync() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/fd_sync.wasm", - "snapshot1_fd_sync", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/temp") - ),], - vec![], - "../wasi_test_resources/fd_sync.out" - ); -} diff --git a/tests/wasitests/snapshot1_file_metadata.rs b/tests/wasitests/snapshot1_file_metadata.rs deleted file mode 100644 index 9a15fcdfc..000000000 --- a/tests/wasitests/snapshot1_file_metadata.rs +++ /dev/null @@ -1,15 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_snapshot1_file_metadata() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/file_metadata.wasm", - "snapshot1_file_metadata", - vec![std::path::PathBuf::from("."),], - vec![], - vec![], - "../wasi_test_resources/file_metadata.out" - ); -} diff --git a/tests/wasitests/snapshot1_fs_sandbox_test.rs b/tests/wasitests/snapshot1_fs_sandbox_test.rs deleted file mode 100644 index 80bac2752..000000000 --- a/tests/wasitests/snapshot1_fs_sandbox_test.rs +++ /dev/null @@ -1,15 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_snapshot1_fs_sandbox_test() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/fs_sandbox_test.wasm", - "snapshot1_fs_sandbox_test", - vec![], - vec![], - vec![], - "../wasi_test_resources/fs_sandbox_test.out" - ); -} diff --git a/tests/wasitests/snapshot1_fseek.rs b/tests/wasitests/snapshot1_fseek.rs deleted file mode 100644 index 6258e07fe..000000000 --- a/tests/wasitests/snapshot1_fseek.rs +++ /dev/null @@ -1,18 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_snapshot1_fseek() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/fseek.wasm", - "snapshot1_fseek", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ),], - vec![], - "../wasi_test_resources/fseek.out" - ); -} diff --git a/tests/wasitests/snapshot1_hello.rs b/tests/wasitests/snapshot1_hello.rs deleted file mode 100644 index 0522b9344..000000000 --- a/tests/wasitests/snapshot1_hello.rs +++ /dev/null @@ -1,15 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_snapshot1_hello() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/hello.wasm", - "snapshot1_hello", - vec![], - vec![], - vec![], - "../wasi_test_resources/hello.out" - ); -} diff --git a/tests/wasitests/snapshot1_isatty.rs b/tests/wasitests/snapshot1_isatty.rs deleted file mode 100644 index 192628454..000000000 --- a/tests/wasitests/snapshot1_isatty.rs +++ /dev/null @@ -1,15 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_snapshot1_isatty() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/isatty.wasm", - "snapshot1_isatty", - vec![], - vec![], - vec![], - "../wasi_test_resources/isatty.out" - ); -} diff --git a/tests/wasitests/snapshot1_mapdir.rs b/tests/wasitests/snapshot1_mapdir.rs deleted file mode 100644 index 9ac9074d1..000000000 --- a/tests/wasitests/snapshot1_mapdir.rs +++ /dev/null @@ -1,18 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_snapshot1_mapdir() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/mapdir.wasm", - "snapshot1_mapdir", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ),], - vec![], - "../wasi_test_resources/mapdir.out" - ); -} diff --git a/tests/wasitests/snapshot1_path_link.rs b/tests/wasitests/snapshot1_path_link.rs deleted file mode 100644 index c919c3458..000000000 --- a/tests/wasitests/snapshot1_path_link.rs +++ /dev/null @@ -1,24 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_snapshot1_path_link() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/path_link.wasm", - "snapshot1_path_link", - vec![], - vec![ - ( - "act5".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet/act5") - ), - ( - "temp".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/temp") - ), - ], - vec![], - "../wasi_test_resources/path_link.out" - ); -} diff --git a/tests/wasitests/snapshot1_path_rename.rs b/tests/wasitests/snapshot1_path_rename.rs deleted file mode 100644 index 406c4b6f6..000000000 --- a/tests/wasitests/snapshot1_path_rename.rs +++ /dev/null @@ -1,18 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_snapshot1_path_rename() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/path_rename.wasm", - "snapshot1_path_rename", - vec![], - vec![( - "temp".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/temp") - ),], - vec![], - "../wasi_test_resources/path_rename.out" - ); -} diff --git a/tests/wasitests/snapshot1_path_symlink.rs b/tests/wasitests/snapshot1_path_symlink.rs deleted file mode 100644 index f5f2c8c4c..000000000 --- a/tests/wasitests/snapshot1_path_symlink.rs +++ /dev/null @@ -1,24 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_snapshot1_path_symlink() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/path_symlink.wasm", - "snapshot1_path_symlink", - vec![], - vec![ - ( - "temp".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/temp") - ), - ( - "hamlet".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ), - ], - vec![], - "../wasi_test_resources/path_symlink.out" - ); -} diff --git a/tests/wasitests/snapshot1_poll_oneoff.rs b/tests/wasitests/snapshot1_poll_oneoff.rs deleted file mode 100644 index be7f55b9a..000000000 --- a/tests/wasitests/snapshot1_poll_oneoff.rs +++ /dev/null @@ -1,25 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -#[ignore] -fn test_snapshot1_poll_oneoff() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/poll_oneoff.wasm", - "snapshot1_poll_oneoff", - vec![], - vec![ - ( - "hamlet".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ), - ( - "temp".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/temp") - ), - ], - vec![], - "../wasi_test_resources/poll_oneoff.out" - ); -} diff --git a/tests/wasitests/snapshot1_quine.rs b/tests/wasitests/snapshot1_quine.rs deleted file mode 100644 index 8ba0cd8d0..000000000 --- a/tests/wasitests/snapshot1_quine.rs +++ /dev/null @@ -1,15 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_snapshot1_quine() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/quine.wasm", - "snapshot1_quine", - vec![std::path::PathBuf::from("."),], - vec![], - vec![], - "../wasi_test_resources/quine.out" - ); -} diff --git a/tests/wasitests/snapshot1_readlink.rs b/tests/wasitests/snapshot1_readlink.rs deleted file mode 100644 index ec97fce81..000000000 --- a/tests/wasitests/snapshot1_readlink.rs +++ /dev/null @@ -1,18 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_snapshot1_readlink() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/readlink.wasm", - "snapshot1_readlink", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ),], - vec![], - "../wasi_test_resources/readlink.out" - ); -} diff --git a/tests/wasitests/snapshot1_wasi_sees_virtual_root.rs b/tests/wasitests/snapshot1_wasi_sees_virtual_root.rs deleted file mode 100644 index 87a33b022..000000000 --- a/tests/wasitests/snapshot1_wasi_sees_virtual_root.rs +++ /dev/null @@ -1,28 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_snapshot1_wasi_sees_virtual_root() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/wasi_sees_virtual_root.wasm", - "snapshot1_wasi_sees_virtual_root", - vec![], - vec![ - ( - "act1".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet/act1") - ), - ( - "act2".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet/act2") - ), - ( - "act1-again".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet/act1") - ), - ], - vec![], - "../wasi_test_resources/wasi_sees_virtual_root.out" - ); -} diff --git a/tests/wasitests/snapshot1_writing.rs b/tests/wasitests/snapshot1_writing.rs deleted file mode 100644 index 971142fbd..000000000 --- a/tests/wasitests/snapshot1_writing.rs +++ /dev/null @@ -1,28 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_snapshot1_writing() { - assert_wasi_output!( - "../wasi_test_resources/snapshot1/writing.wasm", - "snapshot1_writing", - vec![], - vec![ - ( - "act1".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet/act1") - ), - ( - "act2".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet/act2") - ), - ( - "act1-again".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet/act1") - ), - ], - vec![], - "../wasi_test_resources/writing.out" - ); -} diff --git a/tests/wasitests/unstable_close_preopen_fd.rs b/tests/wasitests/unstable_close_preopen_fd.rs deleted file mode 100644 index 2945d14aa..000000000 --- a/tests/wasitests/unstable_close_preopen_fd.rs +++ /dev/null @@ -1,18 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_close_preopen_fd() { - assert_wasi_output!( - "../wasi_test_resources/unstable/close_preopen_fd.wasm", - "unstable_close_preopen_fd", - vec![], - vec![( - "hamlet".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ),], - vec![], - "../wasi_test_resources/close_preopen_fd.out" - ); -} diff --git a/tests/wasitests/unstable_create_dir.rs b/tests/wasitests/unstable_create_dir.rs deleted file mode 100644 index 47f51d212..000000000 --- a/tests/wasitests/unstable_create_dir.rs +++ /dev/null @@ -1,15 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_create_dir() { - assert_wasi_output!( - "../wasi_test_resources/unstable/create_dir.wasm", - "unstable_create_dir", - vec![std::path::PathBuf::from("."),], - vec![], - vec![], - "../wasi_test_resources/create_dir.out" - ); -} diff --git a/tests/wasitests/unstable_envvar.rs b/tests/wasitests/unstable_envvar.rs deleted file mode 100644 index b4088afbe..000000000 --- a/tests/wasitests/unstable_envvar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_envvar() { - assert_wasi_output!( - "../wasi_test_resources/unstable/envvar.wasm", - "unstable_envvar", - vec![], - vec![], - vec!["DOG=1".to_string(), "CAT=2".to_string(),], - "../wasi_test_resources/envvar.out" - ); -} diff --git a/tests/wasitests/unstable_fd_allocate.rs b/tests/wasitests/unstable_fd_allocate.rs deleted file mode 100644 index 2a55ac499..000000000 --- a/tests/wasitests/unstable_fd_allocate.rs +++ /dev/null @@ -1,18 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_fd_allocate() { - assert_wasi_output!( - "../wasi_test_resources/unstable/fd_allocate.wasm", - "unstable_fd_allocate", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/temp") - ),], - vec![], - "../wasi_test_resources/fd_allocate.out" - ); -} diff --git a/tests/wasitests/unstable_fd_append.rs b/tests/wasitests/unstable_fd_append.rs deleted file mode 100644 index f5c5b8c8f..000000000 --- a/tests/wasitests/unstable_fd_append.rs +++ /dev/null @@ -1,18 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_fd_append() { - assert_wasi_output!( - "../wasi_test_resources/unstable/fd_append.wasm", - "unstable_fd_append", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/temp") - ),], - vec![], - "../wasi_test_resources/fd_append.out" - ); -} diff --git a/tests/wasitests/unstable_fd_close.rs b/tests/wasitests/unstable_fd_close.rs deleted file mode 100644 index 3114823a9..000000000 --- a/tests/wasitests/unstable_fd_close.rs +++ /dev/null @@ -1,18 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_fd_close() { - assert_wasi_output!( - "../wasi_test_resources/unstable/fd_close.wasm", - "unstable_fd_close", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ),], - vec![], - "../wasi_test_resources/fd_close.out" - ); -} diff --git a/tests/wasitests/unstable_fd_pread.rs b/tests/wasitests/unstable_fd_pread.rs deleted file mode 100644 index 9725a0409..000000000 --- a/tests/wasitests/unstable_fd_pread.rs +++ /dev/null @@ -1,18 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_fd_pread() { - assert_wasi_output!( - "../wasi_test_resources/unstable/fd_pread.wasm", - "unstable_fd_pread", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ),], - vec![], - "../wasi_test_resources/fd_pread.out" - ); -} diff --git a/tests/wasitests/unstable_fd_read.rs b/tests/wasitests/unstable_fd_read.rs deleted file mode 100644 index fbfba15b0..000000000 --- a/tests/wasitests/unstable_fd_read.rs +++ /dev/null @@ -1,18 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_fd_read() { - assert_wasi_output!( - "../wasi_test_resources/unstable/fd_read.wasm", - "unstable_fd_read", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ),], - vec![], - "../wasi_test_resources/fd_read.out" - ); -} diff --git a/tests/wasitests/unstable_fd_sync.rs b/tests/wasitests/unstable_fd_sync.rs deleted file mode 100644 index 020b545f5..000000000 --- a/tests/wasitests/unstable_fd_sync.rs +++ /dev/null @@ -1,18 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_fd_sync() { - assert_wasi_output!( - "../wasi_test_resources/unstable/fd_sync.wasm", - "unstable_fd_sync", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/temp") - ),], - vec![], - "../wasi_test_resources/fd_sync.out" - ); -} diff --git a/tests/wasitests/unstable_file_metadata.rs b/tests/wasitests/unstable_file_metadata.rs deleted file mode 100644 index 91ba1bc29..000000000 --- a/tests/wasitests/unstable_file_metadata.rs +++ /dev/null @@ -1,15 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_file_metadata() { - assert_wasi_output!( - "../wasi_test_resources/unstable/file_metadata.wasm", - "unstable_file_metadata", - vec![std::path::PathBuf::from("."),], - vec![], - vec![], - "../wasi_test_resources/file_metadata.out" - ); -} diff --git a/tests/wasitests/unstable_fs_sandbox_test.rs b/tests/wasitests/unstable_fs_sandbox_test.rs deleted file mode 100644 index 82048a3c8..000000000 --- a/tests/wasitests/unstable_fs_sandbox_test.rs +++ /dev/null @@ -1,15 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_fs_sandbox_test() { - assert_wasi_output!( - "../wasi_test_resources/unstable/fs_sandbox_test.wasm", - "unstable_fs_sandbox_test", - vec![], - vec![], - vec![], - "../wasi_test_resources/fs_sandbox_test.out" - ); -} diff --git a/tests/wasitests/unstable_fseek.rs b/tests/wasitests/unstable_fseek.rs deleted file mode 100644 index 282c67de7..000000000 --- a/tests/wasitests/unstable_fseek.rs +++ /dev/null @@ -1,18 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_fseek() { - assert_wasi_output!( - "../wasi_test_resources/unstable/fseek.wasm", - "unstable_fseek", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ),], - vec![], - "../wasi_test_resources/fseek.out" - ); -} diff --git a/tests/wasitests/unstable_hello.rs b/tests/wasitests/unstable_hello.rs deleted file mode 100644 index 93f662906..000000000 --- a/tests/wasitests/unstable_hello.rs +++ /dev/null @@ -1,15 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_hello() { - assert_wasi_output!( - "../wasi_test_resources/unstable/hello.wasm", - "unstable_hello", - vec![], - vec![], - vec![], - "../wasi_test_resources/hello.out" - ); -} diff --git a/tests/wasitests/unstable_isatty.rs b/tests/wasitests/unstable_isatty.rs deleted file mode 100644 index 9313980db..000000000 --- a/tests/wasitests/unstable_isatty.rs +++ /dev/null @@ -1,15 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_isatty() { - assert_wasi_output!( - "../wasi_test_resources/unstable/isatty.wasm", - "unstable_isatty", - vec![], - vec![], - vec![], - "../wasi_test_resources/isatty.out" - ); -} diff --git a/tests/wasitests/unstable_mapdir.rs b/tests/wasitests/unstable_mapdir.rs deleted file mode 100644 index 69b51e609..000000000 --- a/tests/wasitests/unstable_mapdir.rs +++ /dev/null @@ -1,18 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_mapdir() { - assert_wasi_output!( - "../wasi_test_resources/unstable/mapdir.wasm", - "unstable_mapdir", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ),], - vec![], - "../wasi_test_resources/mapdir.out" - ); -} diff --git a/tests/wasitests/unstable_path_link.rs b/tests/wasitests/unstable_path_link.rs deleted file mode 100644 index 340fa3c55..000000000 --- a/tests/wasitests/unstable_path_link.rs +++ /dev/null @@ -1,24 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_path_link() { - assert_wasi_output!( - "../wasi_test_resources/unstable/path_link.wasm", - "unstable_path_link", - vec![], - vec![ - ( - "act5".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet/act5") - ), - ( - "temp".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/temp") - ), - ], - vec![], - "../wasi_test_resources/path_link.out" - ); -} diff --git a/tests/wasitests/unstable_path_rename.rs b/tests/wasitests/unstable_path_rename.rs deleted file mode 100644 index 51c194d17..000000000 --- a/tests/wasitests/unstable_path_rename.rs +++ /dev/null @@ -1,18 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_path_rename() { - assert_wasi_output!( - "../wasi_test_resources/unstable/path_rename.wasm", - "unstable_path_rename", - vec![], - vec![( - "temp".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/temp") - ),], - vec![], - "../wasi_test_resources/path_rename.out" - ); -} diff --git a/tests/wasitests/unstable_path_symlink.rs b/tests/wasitests/unstable_path_symlink.rs deleted file mode 100644 index 2bafcd8b0..000000000 --- a/tests/wasitests/unstable_path_symlink.rs +++ /dev/null @@ -1,24 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_path_symlink() { - assert_wasi_output!( - "../wasi_test_resources/unstable/path_symlink.wasm", - "unstable_path_symlink", - vec![], - vec![ - ( - "temp".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/temp") - ), - ( - "hamlet".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ), - ], - vec![], - "../wasi_test_resources/path_symlink.out" - ); -} diff --git a/tests/wasitests/unstable_poll_oneoff.rs b/tests/wasitests/unstable_poll_oneoff.rs deleted file mode 100644 index 00e9d8fd2..000000000 --- a/tests/wasitests/unstable_poll_oneoff.rs +++ /dev/null @@ -1,24 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_poll_oneoff() { - assert_wasi_output!( - "../wasi_test_resources/unstable/poll_oneoff.wasm", - "unstable_poll_oneoff", - vec![], - vec![ - ( - "hamlet".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ), - ( - "temp".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/temp") - ), - ], - vec![], - "../wasi_test_resources/poll_oneoff.out" - ); -} diff --git a/tests/wasitests/unstable_quine.rs b/tests/wasitests/unstable_quine.rs deleted file mode 100644 index ea0adac47..000000000 --- a/tests/wasitests/unstable_quine.rs +++ /dev/null @@ -1,15 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_quine() { - assert_wasi_output!( - "../wasi_test_resources/unstable/quine.wasm", - "unstable_quine", - vec![std::path::PathBuf::from("."),], - vec![], - vec![], - "../wasi_test_resources/quine.out" - ); -} diff --git a/tests/wasitests/unstable_readlink.rs b/tests/wasitests/unstable_readlink.rs deleted file mode 100644 index c9a15afef..000000000 --- a/tests/wasitests/unstable_readlink.rs +++ /dev/null @@ -1,18 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_readlink() { - assert_wasi_output!( - "../wasi_test_resources/unstable/readlink.wasm", - "unstable_readlink", - vec![], - vec![( - ".".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet") - ),], - vec![], - "../wasi_test_resources/readlink.out" - ); -} diff --git a/tests/wasitests/unstable_wasi_sees_virtual_root.rs b/tests/wasitests/unstable_wasi_sees_virtual_root.rs deleted file mode 100644 index 68affa54c..000000000 --- a/tests/wasitests/unstable_wasi_sees_virtual_root.rs +++ /dev/null @@ -1,28 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_wasi_sees_virtual_root() { - assert_wasi_output!( - "../wasi_test_resources/unstable/wasi_sees_virtual_root.wasm", - "unstable_wasi_sees_virtual_root", - vec![], - vec![ - ( - "act1".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet/act1") - ), - ( - "act2".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet/act2") - ), - ( - "act1-again".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet/act1") - ), - ], - vec![], - "../wasi_test_resources/wasi_sees_virtual_root.out" - ); -} diff --git a/tests/wasitests/unstable_writing.rs b/tests/wasitests/unstable_writing.rs deleted file mode 100644 index e3124333d..000000000 --- a/tests/wasitests/unstable_writing.rs +++ /dev/null @@ -1,28 +0,0 @@ -// !!! THIS IS A GENERATED FILE !!! -// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME -// Files autogenerated with cargo build. - -#[test] -fn test_unstable_writing() { - assert_wasi_output!( - "../wasi_test_resources/unstable/writing.wasm", - "unstable_writing", - vec![], - vec![ - ( - "act1".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet/act1") - ), - ( - "act2".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet/act2") - ), - ( - "act1-again".to_string(), - ::std::path::PathBuf::from("tests/wasi_test_resources/test_fs/hamlet/act1") - ), - ], - vec![], - "../wasi_test_resources/writing.out" - ); -}