From dfa6247075b6bceeb4d20982ff351419726357bf Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Fri, 3 Apr 2020 14:24:40 -0700 Subject: [PATCH] Move spectests, wrap up test restructure --- Cargo.lock | 12 --- Cargo.toml | 2 +- Makefile | 75 ++++++++---------- benches/metering_benchmark.rs | 5 +- examples/plugin.rs | 3 +- .../examples => examples}/simple/main.rs | 0 .../examples => examples}/simple/simple.wasm | Bin lib/spectests/Cargo.toml | 28 ------- tests/middleware_common.rs | 7 +- .../examples/test.rs => tests/override.rs | 13 ++- {lib/spectests/tests => tests}/spectest.rs | 16 ++-- .../spectest_semantics.rs | 0 {lib/spectests => tests}/spectests/LICENSE | 0 {lib => tests}/spectests/README.md | 0 .../spectests/address.wast | 0 {lib/spectests => tests}/spectests/align.wast | 0 .../spectests => tests}/spectests/atomic.wast | 0 .../spectests/binary-leb128.wast | 0 .../spectests => tests}/spectests/binary.wast | 0 {lib/spectests => tests}/spectests/block.wast | 0 {lib/spectests => tests}/spectests/br.wast | 0 {lib/spectests => tests}/spectests/br_if.wast | 0 .../spectests/br_table.wast | 0 .../spectests/break-drop.wast | 0 {lib/spectests => tests}/spectests/call.wast | 0 .../spectests/call_indirect.wast | 0 .../spectests/comments.wast | Bin {lib/spectests => tests}/spectests/const.wast | 0 .../spectests/conversions.wast | 0 .../spectests => tests}/spectests/custom.wast | 0 {lib/spectests => tests}/spectests/data.wast | 0 {lib/spectests => tests}/spectests/elem.wast | 0 .../spectests/endianness.wast | 0 .../tests => tests/spectests}/excludes.txt | 0 .../spectests/exports.wast | 0 {lib/spectests => tests}/spectests/f32.wast | 0 .../spectests/f32_bitwise.wast | 0 .../spectests/f32_cmp.wast | 0 {lib/spectests => tests}/spectests/f64.wast | 0 .../spectests/f64_bitwise.wast | 0 .../spectests/f64_cmp.wast | 0 {lib/spectests => tests}/spectests/fac.wast | 0 .../spectests/float_exprs.wast | 0 .../spectests/float_literals.wast | 0 .../spectests/float_memory.wast | 0 .../spectests/float_misc.wast | 0 .../spectests/forward.wast | 0 {lib/spectests => tests}/spectests/func.wast | 0 .../spectests/func_ptrs.wast | 0 .../spectests/globals.wast | 0 {lib/spectests => tests}/spectests/i32.wast | 0 {lib/spectests => tests}/spectests/i64.wast | 0 {lib/spectests => tests}/spectests/if.wast | 0 .../spectests/imports.wast | 0 .../spectests/inline-module.wast | 0 .../spectests/int_exprs.wast | 0 .../spectests/int_literals.wast | 0 .../spectests => tests}/spectests/labels.wast | 0 .../spectests/left-to-right.wast | 0 .../spectests/linking.wast | 0 {lib/spectests => tests}/spectests/load.wast | 0 .../spectests/local_get.wast | 0 .../spectests/local_set.wast | 0 .../spectests/local_tee.wast | 0 {lib/spectests => tests}/spectests/loop.wast | 0 .../spectests => tests}/spectests/memory.wast | 0 .../spectests/memory_grow.wast | 0 .../spectests/memory_redundancy.wast | 0 .../spectests/memory_size.wast | 0 .../spectests/memory_trap.wast | 0 {lib/spectests => tests}/spectests/names.wast | 0 {lib/spectests => tests}/spectests/nop.wast | 0 .../spectests => tests}/spectests/return.wast | 0 .../spectests => tests}/spectests/select.wast | 0 {lib/spectests => tests}/spectests/simd.wast | 0 .../spectests/simd_binaryen.wast | 0 .../spectests/skip-stack-guard-page.wast | 0 {lib/spectests => tests}/spectests/stack.wast | 0 {lib/spectests => tests}/spectests/start.wast | 0 {lib/spectests => tests}/spectests/store.wast | 0 .../spectests => tests}/spectests/switch.wast | 0 {lib/spectests => tests}/spectests/token.wast | 0 {lib/spectests => tests}/spectests/traps.wast | 0 {lib/spectests => tests}/spectests/type.wast | 0 .../spectests/unreachable.wast | 0 .../spectests/unreached-invalid.wast | 0 .../spectests => tests}/spectests/unwind.wast | 0 .../spectests/utf8-custom-section-id.wast | 0 .../spectests/utf8-import-field.wast | 0 .../spectests/utf8-import-module.wast | 0 .../spectests/utf8-invalid-encoding.wast | 0 .../spectests => tests}/spectests/wasmer.wast | 0 tests/wasitests/README.md | 2 +- 93 files changed, 60 insertions(+), 103 deletions(-) rename {lib/spectests/examples => examples}/simple/main.rs (100%) rename {lib/spectests/examples => examples}/simple/simple.wasm (100%) delete mode 100644 lib/spectests/Cargo.toml rename lib/spectests/examples/test.rs => tests/override.rs (84%) rename {lib/spectests/tests => tests}/spectest.rs (99%) rename lib/spectests/tests/semantics.rs => tests/spectest_semantics.rs (100%) rename {lib/spectests => tests}/spectests/LICENSE (100%) rename {lib => tests}/spectests/README.md (100%) rename {lib/spectests => tests}/spectests/address.wast (100%) rename {lib/spectests => tests}/spectests/align.wast (100%) rename {lib/spectests => tests}/spectests/atomic.wast (100%) rename {lib/spectests => tests}/spectests/binary-leb128.wast (100%) rename {lib/spectests => tests}/spectests/binary.wast (100%) rename {lib/spectests => tests}/spectests/block.wast (100%) rename {lib/spectests => tests}/spectests/br.wast (100%) rename {lib/spectests => tests}/spectests/br_if.wast (100%) rename {lib/spectests => tests}/spectests/br_table.wast (100%) rename {lib/spectests => tests}/spectests/break-drop.wast (100%) rename {lib/spectests => tests}/spectests/call.wast (100%) rename {lib/spectests => tests}/spectests/call_indirect.wast (100%) rename {lib/spectests => tests}/spectests/comments.wast (100%) rename {lib/spectests => tests}/spectests/const.wast (100%) rename {lib/spectests => tests}/spectests/conversions.wast (100%) rename {lib/spectests => tests}/spectests/custom.wast (100%) rename {lib/spectests => tests}/spectests/data.wast (100%) rename {lib/spectests => tests}/spectests/elem.wast (100%) rename {lib/spectests => tests}/spectests/endianness.wast (100%) rename {lib/spectests/tests => tests/spectests}/excludes.txt (100%) rename {lib/spectests => tests}/spectests/exports.wast (100%) rename {lib/spectests => tests}/spectests/f32.wast (100%) rename {lib/spectests => tests}/spectests/f32_bitwise.wast (100%) rename {lib/spectests => tests}/spectests/f32_cmp.wast (100%) rename {lib/spectests => tests}/spectests/f64.wast (100%) rename {lib/spectests => tests}/spectests/f64_bitwise.wast (100%) rename {lib/spectests => tests}/spectests/f64_cmp.wast (100%) rename {lib/spectests => tests}/spectests/fac.wast (100%) rename {lib/spectests => tests}/spectests/float_exprs.wast (100%) rename {lib/spectests => tests}/spectests/float_literals.wast (100%) rename {lib/spectests => tests}/spectests/float_memory.wast (100%) rename {lib/spectests => tests}/spectests/float_misc.wast (100%) rename {lib/spectests => tests}/spectests/forward.wast (100%) rename {lib/spectests => tests}/spectests/func.wast (100%) rename {lib/spectests => tests}/spectests/func_ptrs.wast (100%) rename {lib/spectests => tests}/spectests/globals.wast (100%) rename {lib/spectests => tests}/spectests/i32.wast (100%) rename {lib/spectests => tests}/spectests/i64.wast (100%) rename {lib/spectests => tests}/spectests/if.wast (100%) rename {lib/spectests => tests}/spectests/imports.wast (100%) rename {lib/spectests => tests}/spectests/inline-module.wast (100%) rename {lib/spectests => tests}/spectests/int_exprs.wast (100%) rename {lib/spectests => tests}/spectests/int_literals.wast (100%) rename {lib/spectests => tests}/spectests/labels.wast (100%) rename {lib/spectests => tests}/spectests/left-to-right.wast (100%) rename {lib/spectests => tests}/spectests/linking.wast (100%) rename {lib/spectests => tests}/spectests/load.wast (100%) rename {lib/spectests => tests}/spectests/local_get.wast (100%) rename {lib/spectests => tests}/spectests/local_set.wast (100%) rename {lib/spectests => tests}/spectests/local_tee.wast (100%) rename {lib/spectests => tests}/spectests/loop.wast (100%) rename {lib/spectests => tests}/spectests/memory.wast (100%) rename {lib/spectests => tests}/spectests/memory_grow.wast (100%) rename {lib/spectests => tests}/spectests/memory_redundancy.wast (100%) rename {lib/spectests => tests}/spectests/memory_size.wast (100%) rename {lib/spectests => tests}/spectests/memory_trap.wast (100%) rename {lib/spectests => tests}/spectests/names.wast (100%) rename {lib/spectests => tests}/spectests/nop.wast (100%) rename {lib/spectests => tests}/spectests/return.wast (100%) rename {lib/spectests => tests}/spectests/select.wast (100%) rename {lib/spectests => tests}/spectests/simd.wast (100%) rename {lib/spectests => tests}/spectests/simd_binaryen.wast (100%) rename {lib/spectests => tests}/spectests/skip-stack-guard-page.wast (100%) rename {lib/spectests => tests}/spectests/stack.wast (100%) rename {lib/spectests => tests}/spectests/start.wast (100%) rename {lib/spectests => tests}/spectests/store.wast (100%) rename {lib/spectests => tests}/spectests/switch.wast (100%) rename {lib/spectests => tests}/spectests/token.wast (100%) rename {lib/spectests => tests}/spectests/traps.wast (100%) rename {lib/spectests => tests}/spectests/type.wast (100%) rename {lib/spectests => tests}/spectests/unreachable.wast (100%) rename {lib/spectests => tests}/spectests/unreached-invalid.wast (100%) rename {lib/spectests => tests}/spectests/unwind.wast (100%) rename {lib/spectests => tests}/spectests/utf8-custom-section-id.wast (100%) rename {lib/spectests => tests}/spectests/utf8-import-field.wast (100%) rename {lib/spectests => tests}/spectests/utf8-import-module.wast (100%) rename {lib/spectests => tests}/spectests/utf8-invalid-encoding.wast (100%) rename {lib/spectests => tests}/spectests/wasmer.wast (100%) diff --git a/Cargo.lock b/Cargo.lock index 411584b20..8dbcf3c21 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2962,18 +2962,6 @@ dependencies = [ "wasmer-runtime-core", ] -[[package]] -name = "wasmer-spectests" -version = "0.16.2" -dependencies = [ - "glob 0.3.0", - "wabt", - "wasmer-clif-backend", - "wasmer-llvm-backend", - "wasmer-runtime", - "wasmer-singlepass-backend", -] - [[package]] name = "wasmer-wasi" version = "0.16.2" diff --git a/Cargo.toml b/Cargo.toml index b339becb3..d52f780fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,6 @@ members = [ "lib/runtime", "lib/runtime-core", "lib/emscripten", - "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", @@ -110,6 +109,7 @@ managed = ["backend-singlepass", "wasmer-runtime-core/managed"] [[example]] name = "plugin" +required-features = ["wasi"] crate-type = ["bin"] [[example]] diff --git a/Makefile b/Makefile index ffeb9c8bf..736746e63 100644 --- a/Makefile +++ b/Makefile @@ -1,104 +1,95 @@ .PHONY: spectests emtests clean build install lint precommit docs examples # Generate files -generate-spectests: - WASMER_RUNTIME_GENERATE_SPECTESTS=1 cargo build -p wasmer-runtime-core --release \ - && echo "formatting" \ - && cargo fmt - generate-emtests: - WASM_EMSCRIPTEN_GENERATE_EMTESTS=1 cargo build -p wasmer-emscripten-tests --release \ + WASM_EMSCRIPTEN_GENERATE_EMTESTS=1 cargo build --release \ && echo "formatting" \ && cargo fmt # To generate WASI tests you'll need to have the correct versions of the Rust nightly # toolchain installed, see `WasiVersion::get_compiler_toolchain` in -# `lib/wasi-tests/build/wasi_version.rs` +# `tests/generate-wasi-tests/src/wasi_version.rs` # # or run `make wasitests-setup-toolchain` or `make wasitests-setup-toolchain-all` generate-wasitests: wasitests-setup - WASM_WASI_GENERATE_WASITESTS=1 cargo build -p wasmer-wasi-tests --release -vv \ + WASM_WASI_GENERATE_WASITESTS=1 cargo build --release -vv \ && echo "formatting" \ && cargo fmt generate-wasitests-all: wasitests-setup - WASI_TEST_GENERATE_ALL=1 WASM_WASI_GENERATE_WASITESTS=1 cargo build -p wasmer-wasi-tests --release -vv \ + WASI_TEST_GENERATE_ALL=1 WASM_WASI_GENERATE_WASITESTS=1 cargo build --release -vv \ && echo "formatting" \ && cargo fmt -spectests-generate: generate-spectests emtests-generate: generate-emtests wasitests-generate: generate-wasitests wasitests-setup-toolchain: wasitests-setup - WASITESTS_SET_UP_TOOLCHAIN=1 cargo build -p wasmer-wasi-tests --release -vv + WASITESTS_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 -p wasmer-wasi-tests --release -vv + WASI_TEST_GENERATE_ALL=1 WASITESTS_SET_UP_TOOLCHAIN=1 cargo build --release -vv -generate: generate-spectests generate-emtests generate-wasitests +generate: generate-emtests generate-wasitests # Spectests spectests-singlepass: - cargo test --manifest-path lib/spectests/Cargo.toml --release --features singlepass -- --nocapture --test-threads 1 + cargo test test_run_spectests --release --no-default-features --features "wasi backend-singlepass" -- --nocapture --test-threads 1 spectests-cranelift: - cargo test --manifest-path lib/spectests/Cargo.toml --release --features clif -- --nocapture + cargo test test_run_spectests --release --no-default-features --features "wasi backend-cranelift" -- --nocapture spectests-llvm: - cargo test --manifest-path lib/spectests/Cargo.toml --release --features llvm -- --nocapture + cargo test test_run_spectests --release --no-default-features --features "wasi backend-llvm" -- --nocapture spectests: spectests-singlepass spectests-cranelift spectests-llvm # Emscripten tests emtests-singlepass: - cargo test --manifest-path lib/emscripten-tests/Cargo.toml --release --features singlepass -- --test-threads=1 + cargo test emtest --release --no-default-features --features "wasi backend-singlepass" -- --test-threads=1 emtests-cranelift: - cargo test --manifest-path lib/emscripten-tests/Cargo.toml --release --features clif -- --test-threads=1 + cargo test emtest --release --no-default-features --features "wasi backend-cranelift" -- --test-threads=1 emtests-llvm: - cargo test --manifest-path lib/emscripten-tests/Cargo.toml --release --features llvm -- --test-threads=1 + cargo test emtest --release --no-default-features --features "wasi backend-llvm" -- --test-threads=1 emtests-unit: - cargo test --manifest-path lib/emscripten/Cargo.toml --release + cargo test emscripten --release emtests: emtests-unit emtests-singlepass emtests-cranelift emtests-llvm # Middleware tests middleware-singlepass: - cargo test --manifest-path lib/middleware-common-tests/Cargo.toml --release --features singlepass + cargo test middleware --release --no-default-features --features "wasi backend-singlepass" middleware-cranelift: - cargo test --manifest-path lib/middleware-common-tests/Cargo.toml --release --features clif + cargo test middleware --release --no-default-features --features "wasi backend-cranelift" middleware-llvm: - cargo test --manifest-path lib/middleware-common-tests/Cargo.toml --release --features llvm + cargo test middleware --release --no-default-features --features "wasi backend-llvm" middleware: middleware-singlepass middleware-cranelift middleware-llvm # Wasitests wasitests-setup: -# force cargo to rerun the build.rs step - touch lib/wasi-tests/build/mod.rs - rm -rf lib/wasi-tests/wasitests/test_fs/temp - mkdir -p lib/wasi-tests/wasitests/test_fs/temp + rm -rf tests/wasi_test_resources/test_fs/temp + mkdir -p tests/wasi_test_resources/test_fs/temp wasitests-singlepass: wasitests-setup - cargo test --manifest-path lib/wasi-tests/Cargo.toml --release --features singlepass -- --test-threads=1 + cargo test wasitest --release --no-default-features --features "wasi singlepass" -- --test-threads=1 wasitests-cranelift: wasitests-setup - cargo test --manifest-path lib/wasi-tests/Cargo.toml --release --features clif -- --test-threads=1 --nocapture + cargo test wasitest --release --no-default-features --features "wasi backend-cranelift" -- --test-threads=1 --nocapture wasitests-llvm: wasitests-setup - cargo test --manifest-path lib/wasi-tests/Cargo.toml --release --features llvm -- --test-threads=1 + cargo test wasitest --release --no-default-features --features "wasi backend-llvm" -- --test-threads=1 wasitests-unit: wasitests-setup - cargo test --manifest-path lib/wasi-tests/Cargo.toml --release --features clif -- --test-threads=1 --nocapture cargo test --manifest-path lib/wasi/Cargo.toml --release wasitests: wasitests-unit wasitests-singlepass wasitests-cranelift wasitests-llvm @@ -107,16 +98,16 @@ wasitests: wasitests-unit wasitests-singlepass wasitests-cranelift wasitests-llv # Backends singlepass: spectests-singlepass emtests-singlepass middleware-singlepass wasitests-singlepass cargo test -p wasmer-singlepass-backend --release - cargo test --manifest-path lib/runtime-core-tests/Cargo.toml --release --no-default-features --features backend-singlepass + cargo test --release --no-default-features --features "wasi backend-singlepass" cranelift: spectests-cranelift emtests-cranelift middleware-cranelift wasitests-cranelift cargo test -p wasmer-clif-backend --release - cargo test -p wasmer-runtime-core-tests --release + cargo test --release --no-default-features --features "wasi backend-cranelift" llvm: spectests-llvm emtests-llvm wasitests-llvm cargo test -p wasmer-llvm-backend --release - cargo test -p wasmer-llvm-backend-tests --release - cargo test --manifest-path lib/runtime-core-tests/Cargo.toml --release --no-default-features --features backend-llvm + cargo test llvm --release --no-default-features --features "wasi backend-llvm" + cargo test --release --no-default-features --features "wasi backend-llvm" # All tests @@ -160,12 +151,10 @@ test-capi: test-capi-singlepass test-capi-cranelift test-capi-llvm test-capi-ems capi-test: test-capi test-rest: - cargo test --release -p api-tests cargo test --release -p wasmer-dev-utils cargo test --release -p wasmer-interface-types cargo test --release -p wasmer-kernel-loader cargo test --release -p kernel-net - cargo test --release -p wasmer-llvm-backend-tests cargo test --release -p wasmer-runtime cargo test --release -p wasmer-runtime-core cargo test --release -p wasmer-wasi-experimental-io-devices @@ -175,7 +164,7 @@ test: spectests emtests middleware wasitests test-rest examples test-android: ci/run-docker.sh x86_64-linux-android --manifest-path=lib/singlepass-backend/Cargo.toml - ci/run-docker.sh x86_64-linux-android --manifest-path=lib/runtime-core-tests/Cargo.toml + ci/run-docker.sh x86_64-linux-android # Integration tests integration-tests: release-clif examples @@ -207,8 +196,7 @@ check-bench-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" \ - --exclude wasmer-singlepass-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader \ - --exclude wasmer-middleware-common-tests + --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" \ --exclude wasmer-singlepass-backend --exclude wasmer-clif-backend --exclude wasmer-kernel-loader @@ -217,7 +205,7 @@ check-bench: check-bench-singlepass check-bench-llvm # TODO: We wanted `--workspace --exclude wasmer-runtime`, but can't due # to https://github.com/rust-lang/cargo/issues/6745 . -NOT_RUNTIME_CRATES = -p wasmer-clif-backend -p wasmer-singlepass-backend -p wasmer-middleware-common -p wasmer-runtime-core -p wasmer-emscripten -p wasmer-llvm-backend -p wasmer-wasi -p wasmer-kernel-loader -p wasmer-dev-utils -p wasmer-wasi-tests -p wasmer-middleware-common-tests -p wasmer-emscripten-tests -p wasmer-interface-types +NOT_RUNTIME_CRATES = -p wasmer-clif-backend -p wasmer-singlepass-backend -p wasmer-middleware-common -p wasmer-runtime-core -p wasmer-emscripten -p wasmer-llvm-backend -p wasmer-wasi -p wasmer-kernel-loader -p wasmer-dev-utils -p wasmer-interface-types RUNTIME_CHECK = cargo check --manifest-path lib/runtime/Cargo.toml --no-default-features check: check-bench cargo check $(NOT_RUNTIME_CRATES) @@ -298,8 +286,7 @@ bench-singlepass: --exclude wasmer-clif-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader bench-clif: cargo bench --all --no-default-features --features "backend-cranelift" \ - --exclude wasmer-singlepass-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader \ - --exclude wasmer-middleware-common-tests + --exclude wasmer-singlepass-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader bench-llvm: cargo bench --all --no-default-features --features "backend-llvm" \ --exclude wasmer-singlepass-backend --exclude wasmer-clif-backend --exclude wasmer-kernel-loader @@ -354,7 +341,7 @@ publish-release: # cargo install cargo-deps # must install graphviz for `dot` dep-graph: - cargo deps --optional-deps --filter wasmer-wasi wasmer-wasi-tests wasmer-kernel-loader wasmer-dev-utils wasmer-llvm-backend wasmer-emscripten wasmer-emscripten-tests wasmer-runtime-core wasmer-runtime wasmer-middleware-common wasmer-middleware-common-tests wasmer-singlepass-backend wasmer-clif-backend wasmer --manifest-path Cargo.toml | dot -Tpng > wasmer_depgraph.png + cargo deps --optional-deps --filter wasmer-wasi wasmer-kernel-loader wasmer-dev-utils wasmer-llvm-backend wasmer-emscripten wasmer-runtime-core wasmer-runtime wasmer-middleware-common wasmer-singlepass-backend wasmer-clif-backend wasmer --manifest-path Cargo.toml | dot -Tpng > wasmer_depgraph.png docs-capi: cd lib/runtime-c-api/ && doxygen doxyfile diff --git a/benches/metering_benchmark.rs b/benches/metering_benchmark.rs index 838df4940..4a4ee51be 100644 --- a/benches/metering_benchmark.rs +++ b/benches/metering_benchmark.rs @@ -169,9 +169,8 @@ fn get_compiler(limit: u64, metering: bool) -> impl Compiler { )))] compile_error!("compiler not specified, activate a compiler via features"); -#[cfg(feature = "backend-cranelift")] fn get_compiler(_limit: u64, metering: bool) -> impl Compiler { - compile_error!("cranelift does not implement metering"); + unimplemented!("cranelift does not implement metering"); use wasmer_clif_backend::CraneliftCompiler; CraneliftCompiler::new() } @@ -226,5 +225,7 @@ fn bench_metering(c: &mut Criterion) { ); } +#[cfg(not(feature = "backend-cranelift"))] criterion_group!(benches, bench_metering); +#[cfg(not(feature = "backend-cranelift"))] criterion_main!(benches); diff --git a/examples/plugin.rs b/examples/plugin.rs index 2695119ae..8d9dc8995 100644 --- a/examples/plugin.rs +++ b/examples/plugin.rs @@ -1,6 +1,5 @@ use serde::{Deserialize, Serialize}; -use wasmer_runtime::{compile, func, imports, Func}; -use wasmer_runtime_core::vm::Ctx; +use wasmer_runtime::{compile, func, imports, Ctx, Func}; use wasmer_wasi::{ generate_import_object_for_version, state::{self, WasiFile, WasiFsError}, diff --git a/lib/spectests/examples/simple/main.rs b/examples/simple/main.rs similarity index 100% rename from lib/spectests/examples/simple/main.rs rename to examples/simple/main.rs diff --git a/lib/spectests/examples/simple/simple.wasm b/examples/simple/simple.wasm similarity index 100% rename from lib/spectests/examples/simple/simple.wasm rename to examples/simple/simple.wasm diff --git a/lib/spectests/Cargo.toml b/lib/spectests/Cargo.toml deleted file mode 100644 index a4b6576ce..000000000 --- a/lib/spectests/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "wasmer-spectests" -version = "0.16.2" -description = "Wasmer spectests library" -license = "MIT" -authors = ["The Wasmer Engineering Team "] -repository = "https://github.com/wasmerio/wasmer" -edition = "2018" - -[dependencies] -glob = "0.3" -wasmer-runtime = { path = "../runtime", version = "0.16.2", default-features = false} -wasmer-clif-backend = { path = "../clif-backend", version = "0.16.2", optional = true} -wasmer-llvm-backend = { path = "../llvm-backend", version = "0.16.2", features = ["test"], optional = true } -wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.16.2", optional = true } - -[build-dependencies] -wabt = "0.9.1" - -[dev-dependencies] -wabt = "0.9.1" - -[features] -default = ["fast-tests"] -fast-tests = [] -clif = ["wasmer-clif-backend", "wasmer-runtime/default-backend-cranelift"] -singlepass = ["wasmer-singlepass-backend", "wasmer-runtime/default-backend-singlepass"] -llvm = ["wasmer-llvm-backend", "wasmer-runtime/default-backend-llvm"] diff --git a/tests/middleware_common.rs b/tests/middleware_common.rs index d5e20a1b9..96e241632 100644 --- a/tests/middleware_common.rs +++ b/tests/middleware_common.rs @@ -15,9 +15,6 @@ mod tests { #[cfg(feature = "backend-singlepass")] use wasmer_singlepass_backend::ModuleCodeGenerator as MCG; - #[cfg(feature = "backend-cranelift")] - compile_error!("cranelift does not implement metering yet"); - fn get_compiler(limit: u64) -> impl Compiler { let c: StreamingCompiler = StreamingCompiler::new(move || { let mut chain = MiddlewareChain::new(); @@ -94,7 +91,7 @@ mod tests { "#; #[test] - fn test_points_reduced_after_call() { + fn middleware_test_points_reduced_after_call() { let wasm_binary = wat2wasm(WAT).unwrap(); let limit = 100u64; @@ -135,7 +132,7 @@ mod tests { } #[test] - fn test_traps_after_costly_call() { + fn middleware_test_traps_after_costly_call() { use wasmer_runtime_core::error::RuntimeError; let wasm_binary = wat2wasm(WAT).unwrap(); diff --git a/lib/spectests/examples/test.rs b/tests/override.rs similarity index 84% rename from lib/spectests/examples/test.rs rename to tests/override.rs index eff7793b9..ee299ff16 100644 --- a/lib/spectests/examples/test.rs +++ b/tests/override.rs @@ -1,9 +1,16 @@ use wabt::wat2wasm; -use wasmer_runtime::{compile, ImportObject, Instance}; +use wasmer_runtime::{compile, DynFunc, ImportObject, Instance, Value}; -fn main() { +#[test] +fn override_works() { let instance = create_module_1(); - let result = instance.call("call-overwritten-element", &[]); + let result = instance + .exports + .get::("call-overwritten-element") + .unwrap() + .call(&[]) + .unwrap(); + assert_eq!(result, vec![Value::I32(66)]); println!("result: {:?}", result); } diff --git a/lib/spectests/tests/spectest.rs b/tests/spectest.rs similarity index 99% rename from lib/spectests/tests/spectest.rs rename to tests/spectest.rs index 1748816ed..5fc126cfa 100644 --- a/lib/spectests/tests/spectest.rs +++ b/tests/spectest.rs @@ -72,17 +72,17 @@ mod tests { } } - #[cfg(feature = "clif")] + #[cfg(feature = "backend-cranelift")] fn get_compiler_name() -> &'static str { "clif" } - #[cfg(feature = "llvm")] + #[cfg(feature = "backend-llvm")] fn get_compiler_name() -> &'static str { "llvm" } - #[cfg(feature = "singlepass")] + #[cfg(feature = "backend-singlepass")] fn get_compiler_name() -> &'static str { "singlepass" } @@ -216,7 +216,11 @@ mod tests { } } - #[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))] + #[cfg(not(any( + feature = "backend-llvm", + feature = "backend-cranelift", + feature = "backend-singlepass" + )))] fn get_compiler_name() -> &'static str { panic!("compiler not specified, activate a compiler via features"); "unknown" @@ -1293,8 +1297,9 @@ mod tests { fn read_excludes() -> (HashMap>, HashSet) { let mut excludes_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); excludes_path.push("tests"); + excludes_path.push("spectests"); excludes_path.push("excludes.txt"); - let input = File::open(excludes_path).unwrap(); + let input = File::open(dbg!(excludes_path)).unwrap(); let buffered = BufReader::new(input); let mut result = HashMap::new(); let mut file_excludes = HashSet::new(); @@ -1375,6 +1380,7 @@ mod tests { let (excludes, file_excludes) = read_excludes(); let mut glob_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + glob_path.push("tests"); glob_path.push("spectests"); glob_path.push("*.wast"); diff --git a/lib/spectests/tests/semantics.rs b/tests/spectest_semantics.rs similarity index 100% rename from lib/spectests/tests/semantics.rs rename to tests/spectest_semantics.rs diff --git a/lib/spectests/spectests/LICENSE b/tests/spectests/LICENSE similarity index 100% rename from lib/spectests/spectests/LICENSE rename to tests/spectests/LICENSE diff --git a/lib/spectests/README.md b/tests/spectests/README.md similarity index 100% rename from lib/spectests/README.md rename to tests/spectests/README.md diff --git a/lib/spectests/spectests/address.wast b/tests/spectests/address.wast similarity index 100% rename from lib/spectests/spectests/address.wast rename to tests/spectests/address.wast diff --git a/lib/spectests/spectests/align.wast b/tests/spectests/align.wast similarity index 100% rename from lib/spectests/spectests/align.wast rename to tests/spectests/align.wast diff --git a/lib/spectests/spectests/atomic.wast b/tests/spectests/atomic.wast similarity index 100% rename from lib/spectests/spectests/atomic.wast rename to tests/spectests/atomic.wast diff --git a/lib/spectests/spectests/binary-leb128.wast b/tests/spectests/binary-leb128.wast similarity index 100% rename from lib/spectests/spectests/binary-leb128.wast rename to tests/spectests/binary-leb128.wast diff --git a/lib/spectests/spectests/binary.wast b/tests/spectests/binary.wast similarity index 100% rename from lib/spectests/spectests/binary.wast rename to tests/spectests/binary.wast diff --git a/lib/spectests/spectests/block.wast b/tests/spectests/block.wast similarity index 100% rename from lib/spectests/spectests/block.wast rename to tests/spectests/block.wast diff --git a/lib/spectests/spectests/br.wast b/tests/spectests/br.wast similarity index 100% rename from lib/spectests/spectests/br.wast rename to tests/spectests/br.wast diff --git a/lib/spectests/spectests/br_if.wast b/tests/spectests/br_if.wast similarity index 100% rename from lib/spectests/spectests/br_if.wast rename to tests/spectests/br_if.wast diff --git a/lib/spectests/spectests/br_table.wast b/tests/spectests/br_table.wast similarity index 100% rename from lib/spectests/spectests/br_table.wast rename to tests/spectests/br_table.wast diff --git a/lib/spectests/spectests/break-drop.wast b/tests/spectests/break-drop.wast similarity index 100% rename from lib/spectests/spectests/break-drop.wast rename to tests/spectests/break-drop.wast diff --git a/lib/spectests/spectests/call.wast b/tests/spectests/call.wast similarity index 100% rename from lib/spectests/spectests/call.wast rename to tests/spectests/call.wast diff --git a/lib/spectests/spectests/call_indirect.wast b/tests/spectests/call_indirect.wast similarity index 100% rename from lib/spectests/spectests/call_indirect.wast rename to tests/spectests/call_indirect.wast diff --git a/lib/spectests/spectests/comments.wast b/tests/spectests/comments.wast similarity index 100% rename from lib/spectests/spectests/comments.wast rename to tests/spectests/comments.wast diff --git a/lib/spectests/spectests/const.wast b/tests/spectests/const.wast similarity index 100% rename from lib/spectests/spectests/const.wast rename to tests/spectests/const.wast diff --git a/lib/spectests/spectests/conversions.wast b/tests/spectests/conversions.wast similarity index 100% rename from lib/spectests/spectests/conversions.wast rename to tests/spectests/conversions.wast diff --git a/lib/spectests/spectests/custom.wast b/tests/spectests/custom.wast similarity index 100% rename from lib/spectests/spectests/custom.wast rename to tests/spectests/custom.wast diff --git a/lib/spectests/spectests/data.wast b/tests/spectests/data.wast similarity index 100% rename from lib/spectests/spectests/data.wast rename to tests/spectests/data.wast diff --git a/lib/spectests/spectests/elem.wast b/tests/spectests/elem.wast similarity index 100% rename from lib/spectests/spectests/elem.wast rename to tests/spectests/elem.wast diff --git a/lib/spectests/spectests/endianness.wast b/tests/spectests/endianness.wast similarity index 100% rename from lib/spectests/spectests/endianness.wast rename to tests/spectests/endianness.wast diff --git a/lib/spectests/tests/excludes.txt b/tests/spectests/excludes.txt similarity index 100% rename from lib/spectests/tests/excludes.txt rename to tests/spectests/excludes.txt diff --git a/lib/spectests/spectests/exports.wast b/tests/spectests/exports.wast similarity index 100% rename from lib/spectests/spectests/exports.wast rename to tests/spectests/exports.wast diff --git a/lib/spectests/spectests/f32.wast b/tests/spectests/f32.wast similarity index 100% rename from lib/spectests/spectests/f32.wast rename to tests/spectests/f32.wast diff --git a/lib/spectests/spectests/f32_bitwise.wast b/tests/spectests/f32_bitwise.wast similarity index 100% rename from lib/spectests/spectests/f32_bitwise.wast rename to tests/spectests/f32_bitwise.wast diff --git a/lib/spectests/spectests/f32_cmp.wast b/tests/spectests/f32_cmp.wast similarity index 100% rename from lib/spectests/spectests/f32_cmp.wast rename to tests/spectests/f32_cmp.wast diff --git a/lib/spectests/spectests/f64.wast b/tests/spectests/f64.wast similarity index 100% rename from lib/spectests/spectests/f64.wast rename to tests/spectests/f64.wast diff --git a/lib/spectests/spectests/f64_bitwise.wast b/tests/spectests/f64_bitwise.wast similarity index 100% rename from lib/spectests/spectests/f64_bitwise.wast rename to tests/spectests/f64_bitwise.wast diff --git a/lib/spectests/spectests/f64_cmp.wast b/tests/spectests/f64_cmp.wast similarity index 100% rename from lib/spectests/spectests/f64_cmp.wast rename to tests/spectests/f64_cmp.wast diff --git a/lib/spectests/spectests/fac.wast b/tests/spectests/fac.wast similarity index 100% rename from lib/spectests/spectests/fac.wast rename to tests/spectests/fac.wast diff --git a/lib/spectests/spectests/float_exprs.wast b/tests/spectests/float_exprs.wast similarity index 100% rename from lib/spectests/spectests/float_exprs.wast rename to tests/spectests/float_exprs.wast diff --git a/lib/spectests/spectests/float_literals.wast b/tests/spectests/float_literals.wast similarity index 100% rename from lib/spectests/spectests/float_literals.wast rename to tests/spectests/float_literals.wast diff --git a/lib/spectests/spectests/float_memory.wast b/tests/spectests/float_memory.wast similarity index 100% rename from lib/spectests/spectests/float_memory.wast rename to tests/spectests/float_memory.wast diff --git a/lib/spectests/spectests/float_misc.wast b/tests/spectests/float_misc.wast similarity index 100% rename from lib/spectests/spectests/float_misc.wast rename to tests/spectests/float_misc.wast diff --git a/lib/spectests/spectests/forward.wast b/tests/spectests/forward.wast similarity index 100% rename from lib/spectests/spectests/forward.wast rename to tests/spectests/forward.wast diff --git a/lib/spectests/spectests/func.wast b/tests/spectests/func.wast similarity index 100% rename from lib/spectests/spectests/func.wast rename to tests/spectests/func.wast diff --git a/lib/spectests/spectests/func_ptrs.wast b/tests/spectests/func_ptrs.wast similarity index 100% rename from lib/spectests/spectests/func_ptrs.wast rename to tests/spectests/func_ptrs.wast diff --git a/lib/spectests/spectests/globals.wast b/tests/spectests/globals.wast similarity index 100% rename from lib/spectests/spectests/globals.wast rename to tests/spectests/globals.wast diff --git a/lib/spectests/spectests/i32.wast b/tests/spectests/i32.wast similarity index 100% rename from lib/spectests/spectests/i32.wast rename to tests/spectests/i32.wast diff --git a/lib/spectests/spectests/i64.wast b/tests/spectests/i64.wast similarity index 100% rename from lib/spectests/spectests/i64.wast rename to tests/spectests/i64.wast diff --git a/lib/spectests/spectests/if.wast b/tests/spectests/if.wast similarity index 100% rename from lib/spectests/spectests/if.wast rename to tests/spectests/if.wast diff --git a/lib/spectests/spectests/imports.wast b/tests/spectests/imports.wast similarity index 100% rename from lib/spectests/spectests/imports.wast rename to tests/spectests/imports.wast diff --git a/lib/spectests/spectests/inline-module.wast b/tests/spectests/inline-module.wast similarity index 100% rename from lib/spectests/spectests/inline-module.wast rename to tests/spectests/inline-module.wast diff --git a/lib/spectests/spectests/int_exprs.wast b/tests/spectests/int_exprs.wast similarity index 100% rename from lib/spectests/spectests/int_exprs.wast rename to tests/spectests/int_exprs.wast diff --git a/lib/spectests/spectests/int_literals.wast b/tests/spectests/int_literals.wast similarity index 100% rename from lib/spectests/spectests/int_literals.wast rename to tests/spectests/int_literals.wast diff --git a/lib/spectests/spectests/labels.wast b/tests/spectests/labels.wast similarity index 100% rename from lib/spectests/spectests/labels.wast rename to tests/spectests/labels.wast diff --git a/lib/spectests/spectests/left-to-right.wast b/tests/spectests/left-to-right.wast similarity index 100% rename from lib/spectests/spectests/left-to-right.wast rename to tests/spectests/left-to-right.wast diff --git a/lib/spectests/spectests/linking.wast b/tests/spectests/linking.wast similarity index 100% rename from lib/spectests/spectests/linking.wast rename to tests/spectests/linking.wast diff --git a/lib/spectests/spectests/load.wast b/tests/spectests/load.wast similarity index 100% rename from lib/spectests/spectests/load.wast rename to tests/spectests/load.wast diff --git a/lib/spectests/spectests/local_get.wast b/tests/spectests/local_get.wast similarity index 100% rename from lib/spectests/spectests/local_get.wast rename to tests/spectests/local_get.wast diff --git a/lib/spectests/spectests/local_set.wast b/tests/spectests/local_set.wast similarity index 100% rename from lib/spectests/spectests/local_set.wast rename to tests/spectests/local_set.wast diff --git a/lib/spectests/spectests/local_tee.wast b/tests/spectests/local_tee.wast similarity index 100% rename from lib/spectests/spectests/local_tee.wast rename to tests/spectests/local_tee.wast diff --git a/lib/spectests/spectests/loop.wast b/tests/spectests/loop.wast similarity index 100% rename from lib/spectests/spectests/loop.wast rename to tests/spectests/loop.wast diff --git a/lib/spectests/spectests/memory.wast b/tests/spectests/memory.wast similarity index 100% rename from lib/spectests/spectests/memory.wast rename to tests/spectests/memory.wast diff --git a/lib/spectests/spectests/memory_grow.wast b/tests/spectests/memory_grow.wast similarity index 100% rename from lib/spectests/spectests/memory_grow.wast rename to tests/spectests/memory_grow.wast diff --git a/lib/spectests/spectests/memory_redundancy.wast b/tests/spectests/memory_redundancy.wast similarity index 100% rename from lib/spectests/spectests/memory_redundancy.wast rename to tests/spectests/memory_redundancy.wast diff --git a/lib/spectests/spectests/memory_size.wast b/tests/spectests/memory_size.wast similarity index 100% rename from lib/spectests/spectests/memory_size.wast rename to tests/spectests/memory_size.wast diff --git a/lib/spectests/spectests/memory_trap.wast b/tests/spectests/memory_trap.wast similarity index 100% rename from lib/spectests/spectests/memory_trap.wast rename to tests/spectests/memory_trap.wast diff --git a/lib/spectests/spectests/names.wast b/tests/spectests/names.wast similarity index 100% rename from lib/spectests/spectests/names.wast rename to tests/spectests/names.wast diff --git a/lib/spectests/spectests/nop.wast b/tests/spectests/nop.wast similarity index 100% rename from lib/spectests/spectests/nop.wast rename to tests/spectests/nop.wast diff --git a/lib/spectests/spectests/return.wast b/tests/spectests/return.wast similarity index 100% rename from lib/spectests/spectests/return.wast rename to tests/spectests/return.wast diff --git a/lib/spectests/spectests/select.wast b/tests/spectests/select.wast similarity index 100% rename from lib/spectests/spectests/select.wast rename to tests/spectests/select.wast diff --git a/lib/spectests/spectests/simd.wast b/tests/spectests/simd.wast similarity index 100% rename from lib/spectests/spectests/simd.wast rename to tests/spectests/simd.wast diff --git a/lib/spectests/spectests/simd_binaryen.wast b/tests/spectests/simd_binaryen.wast similarity index 100% rename from lib/spectests/spectests/simd_binaryen.wast rename to tests/spectests/simd_binaryen.wast diff --git a/lib/spectests/spectests/skip-stack-guard-page.wast b/tests/spectests/skip-stack-guard-page.wast similarity index 100% rename from lib/spectests/spectests/skip-stack-guard-page.wast rename to tests/spectests/skip-stack-guard-page.wast diff --git a/lib/spectests/spectests/stack.wast b/tests/spectests/stack.wast similarity index 100% rename from lib/spectests/spectests/stack.wast rename to tests/spectests/stack.wast diff --git a/lib/spectests/spectests/start.wast b/tests/spectests/start.wast similarity index 100% rename from lib/spectests/spectests/start.wast rename to tests/spectests/start.wast diff --git a/lib/spectests/spectests/store.wast b/tests/spectests/store.wast similarity index 100% rename from lib/spectests/spectests/store.wast rename to tests/spectests/store.wast diff --git a/lib/spectests/spectests/switch.wast b/tests/spectests/switch.wast similarity index 100% rename from lib/spectests/spectests/switch.wast rename to tests/spectests/switch.wast diff --git a/lib/spectests/spectests/token.wast b/tests/spectests/token.wast similarity index 100% rename from lib/spectests/spectests/token.wast rename to tests/spectests/token.wast diff --git a/lib/spectests/spectests/traps.wast b/tests/spectests/traps.wast similarity index 100% rename from lib/spectests/spectests/traps.wast rename to tests/spectests/traps.wast diff --git a/lib/spectests/spectests/type.wast b/tests/spectests/type.wast similarity index 100% rename from lib/spectests/spectests/type.wast rename to tests/spectests/type.wast diff --git a/lib/spectests/spectests/unreachable.wast b/tests/spectests/unreachable.wast similarity index 100% rename from lib/spectests/spectests/unreachable.wast rename to tests/spectests/unreachable.wast diff --git a/lib/spectests/spectests/unreached-invalid.wast b/tests/spectests/unreached-invalid.wast similarity index 100% rename from lib/spectests/spectests/unreached-invalid.wast rename to tests/spectests/unreached-invalid.wast diff --git a/lib/spectests/spectests/unwind.wast b/tests/spectests/unwind.wast similarity index 100% rename from lib/spectests/spectests/unwind.wast rename to tests/spectests/unwind.wast diff --git a/lib/spectests/spectests/utf8-custom-section-id.wast b/tests/spectests/utf8-custom-section-id.wast similarity index 100% rename from lib/spectests/spectests/utf8-custom-section-id.wast rename to tests/spectests/utf8-custom-section-id.wast diff --git a/lib/spectests/spectests/utf8-import-field.wast b/tests/spectests/utf8-import-field.wast similarity index 100% rename from lib/spectests/spectests/utf8-import-field.wast rename to tests/spectests/utf8-import-field.wast diff --git a/lib/spectests/spectests/utf8-import-module.wast b/tests/spectests/utf8-import-module.wast similarity index 100% rename from lib/spectests/spectests/utf8-import-module.wast rename to tests/spectests/utf8-import-module.wast diff --git a/lib/spectests/spectests/utf8-invalid-encoding.wast b/tests/spectests/utf8-invalid-encoding.wast similarity index 100% rename from lib/spectests/spectests/utf8-invalid-encoding.wast rename to tests/spectests/utf8-invalid-encoding.wast diff --git a/lib/spectests/spectests/wasmer.wast b/tests/spectests/wasmer.wast similarity index 100% rename from lib/spectests/spectests/wasmer.wast rename to tests/spectests/wasmer.wast diff --git a/tests/wasitests/README.md b/tests/wasitests/README.md index c7d135cca..921f50c86 100644 --- a/tests/wasitests/README.md +++ b/tests/wasitests/README.md @@ -2,4 +2,4 @@ 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` and `wasi-tests/build/wasitests.rs` to use the changed macro. +If you want to add new features, edit `_common.rs` to change the macro or `tests/generate-wasi-tests` to change anything else.