Skip to content

Commit

Permalink
Try #1380:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Apr 14, 2020
2 parents 6661ca7 + 7f0c15b commit 280723c
Show file tree
Hide file tree
Showing 23 changed files with 1,124 additions and 2,117 deletions.
40 changes: 35 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,23 @@ members = [
"examples/parallel",
"examples/plugin-for-example",
"examples/parallel-guest",
"tests/test-generator",
"tests/generate-wasi-tests",
"tests/generate-emscripten-tests",
"tests/wast",
]

[build-dependencies]
wabt = "0.9.1"
anyhow = "1.0.19"
generate-emscripten-tests = { path = "tests/generate-emscripten-tests" }
generate-wasi-tests = { path = "tests/generate-wasi-tests" }
test-generator = { path = "tests/test-generator" }
glob = "0.3"
rustc_version = "0.2"

[dev-dependencies]
anyhow = "1.0.19"
wasmer-wast = { path = "tests/wast" }
criterion = "0.3"
glob = "0.3"
libc = "0.2.60" # for `tests/dev-utils`'s Stdout capturing
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ generate: generate-emtests generate-wasitests

# Spectests
spectests-singlepass:
WASMER_TEST_SINGLEPASS=1 cargo test test_run_spectests --release --no-default-features --features "wasi backend-singlepass" -- --nocapture --test-threads 1
WASMER_TEST_SINGLEPASS=1 cargo test singlepass::spec --release --no-default-features --features "wasi backend-singlepass"

spectests-cranelift:
WASMER_TEST_CRANELFIT=1 cargo test test_run_spectests --release --no-default-features --features "wasi backend-cranelift" -- --nocapture
WASMER_TEST_CRANELFIT=1 cargo test cranelift::spec --release --no-default-features --features "wasi backend-cranelift"

spectests-llvm:
WASMER_TEST_LLVM=1 cargo test test_run_spectests --release --no-default-features --features "wasi backend-llvm wasmer-llvm-backend/test" -- --nocapture
WASMER_TEST_LLVM=1 cargo test llvm::spec --release --no-default-features --features "wasi backend-llvm wasmer-llvm-backend/test"

spectests-all:
WASMER_TEST_CRANELIFT=1 WASMER_TEST_LLVM=1 WASMER_TEST_SINGLEPASS=1 \
cargo test test_run_spectests --release --no-default-features --features "wasi backend-cranelift backend-singlepass backend-llvm wasmer-llvm-backend/test" -- --nocapture --test-threads 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
Expand Down
102 changes: 101 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,108 @@
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,
};

/// Given a Testsuite and a path, process the path in case is a wast
/// file.
fn wast_processor(out: &mut Testsuite, p: PathBuf) -> Option<Test> {
let ext = p.extension()?;
// Only look at wast files.
if ext != "wast" {
return None;
}

// Ignore files starting with `.`, which could be editor temporary files
if p.file_stem()?.to_str()?.starts_with(".") {
return None;
}

let testname = extract_name(&p);
let body = format!(
"crate::run_wast(r#\"{}\"#, \"{}\")",
p.display(),
out.path.get(0).unwrap()
);

Some(Test {
name: testname.to_string(),
body: body.to_string(),
})
}

fn main() -> anyhow::Result<()> {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=test/ignores.txt");

fn main() {
generate_wasi_tests::build();
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 {
buffer: String::new(),
path: vec![],
ignores: ignores,
};

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(())
})?;
Ok(())
})?;
}

// 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)?;
drop(Command::new("rustfmt").arg(&output).status());
Ok(())
}
5 changes: 5 additions & 0 deletions lib/runtime-core/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ impl ImportObject {
}
out
}

/// Returns true if the ImportObject contains namespace with the provided name.
pub fn contains_namespace(&self, name: &str) -> bool {
self.map.lock().unwrap().borrow().contains_key(name)
}
}

/// Iterator for an `ImportObject`'s exports.
Expand Down
2 changes: 1 addition & 1 deletion tests/emtest.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pub mod dev_utils;
mod emtests;
pub mod utils;
2 changes: 1 addition & 1 deletion tests/emtests/_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ macro_rules! assert_emscripten_output {
EmscriptenGlobals,
generate_emscripten_env,
};
use crate::dev_utils::stdio::StdioCapturer;
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`.");
Expand Down
101 changes: 101 additions & 0 deletions tests/ignores.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Cranelift
cranelift::spec::atomic # Threads not implemented
cranelift::spec::simd # SIMD not implemented
cranelift::spec::simd_binaryen # SIMD not implemented
cranelift::spec::linking

# Cranelift Windows
cranelift::spec::address on windows
cranelift::spec::call on windows
cranelift::spec::call_indirect on windows
cranelift::spec::conversions on windows
cranelift::spec::elem on windows
cranelift::spec::fac on windows
cranelift::spec::func_ptrs on windows
cranelift::spec::globals on windows
cranelift::spec::i32 on windows
cranelift::spec::i64 on windows
cranelift::spec::if on windows
cranelift::spec::imports on windows
cranelift::spec::int_exprs on windows
cranelift::spec::linking on windows
cranelift::spec::memory_grow on windows
cranelift::spec::memory_trap on windows
cranelift::spec::select on windows
cranelift::spec::stack-guard-page on windows
cranelift::spec::traps on windows
cranelift::spec::unreachable on windows
cranelift::spec::unwind on windows
cranelift::spec::binary-leb128 on windows
cranelift::spec::data on windows
cranelift::spec::align on windows
cranelift::spec::binary-leb128 on windows
cranelift::spec::binary on windows
cranelift::spec::comments on windows
cranelift::spec::const on windows
cranelift::spec::custom on windows
cranelift::spec::data on windows
cranelift::spec::exports on windows
cranelift::spec::func on windows
cranelift::spec::memory on windows
cranelift::spec::stack on windows
cranelift::spec::type on windows
cranelift::spec::data on windows

# LLVM
llvm::spec::linking

# LLVM AArch64
llvm::spec::atomic on aarch64 # Out of range relocations.
llvm::spec::stack-guard-page on aarch64 # Uncaught SIGSEGV only on release builds

# LLVM Windows
llvm::spec::address on windows
llvm::spec::align on windows
llvm::spec::call on windows
llvm::spec::br_table on windows
llvm::spec::call_indirect on windows
llvm::spec::conversions on windows
llvm::spec::elem on windows
llvm::spec::func_ptrs on windows
llvm::spec::const on windows
llvm::spec::globals on windows
llvm::spec::i32 on windows
llvm::spec::i64 on windows
llvm::spec::if on windows
llvm::spec::imports on windows
llvm::spec::int_exprs on windows
llvm::spec::linking on windows
llvm::spec::memory_grow on windows
llvm::spec::memory_trap on windows
llvm::spec::select on windows
llvm::spec::traps on windows
llvm::spec::unreachable on windows
llvm::spec::unwind on windows

# LLVM Linux after OSR - https,//github.com/wasmerio/wasmer/pull/567
llvm::spec::simd on unix
llvm::spec::simd_binaryen on unix

# Temporary
llvm::spec::simd
llvm::spec::simd_binaryen

# Singlepass
singlepass::spec::simd # SIMD not implemented
singlepass::spec::simd_binaryen # SIMD not implemented
singlepass::spec::linking

singlepass::spec::atomic on aarch64 # Threads not yet supported on singlepass

singlepass::spec::address

# These failures only happen on AArch64 and not on x86-64.
singlepass::spec::conversions on aarch64
singlepass::spec::i32 on aarch64
singlepass::spec::i64 on aarch64
singlepass::spec::int_exprs on aarch64
singlepass::spec::traps on aarch64

# NaN canonicalization is not yet implemented for aarch64.
singlepass::spec::wasmer on aarch64
Loading

0 comments on commit 280723c

Please sign in to comment.