Separate testing per compiler

This commit is contained in:
Syrus
2020-06-09 14:33:12 -07:00
parent f8fbb33b00
commit a68bcf95ed
11 changed files with 776 additions and 986 deletions

View File

@ -65,6 +65,7 @@ anyhow = "1.0"
blake3 = "0.3"
lazy_static = "1.4"
test-utils = { path = "tests/lib/test-utils" }
# test-macros = { path = "tests/lib/test-macros" }
wasmer-engine-dummy = { path = "tests/lib/engine-dummy" }
[features]
@ -106,5 +107,16 @@ llvm = [
"compiler",
]
# Testing features
test-singlepass = [
"singlepass",
]
test-cranelift = [
"cranelift",
]
test-llvm = [
"llvm",
]
# [profile.release]
# lto = "fat"

View File

@ -93,8 +93,21 @@ build-capi-llvm:
# Testing #
###########
test:
cargo test --release $(compiler_features)
test: $(foreach compiler,$(compilers),test-$(compiler)) test-packages
test-singlepass:
cargo test --release $(compiler_features) --features "test-singlepass"
test-cranelift:
cargo test --release $(compiler_features) --features "test-cranelift"
test-llvm:
cargo test --release $(compiler_features) --features "test-llvm"
test-packages:
cargo test -p wasmer --release
cargo test -p wasmer-runtime --release
cargo test -p wasm-common --release
test-capi-singlepass: build-capi-singlepass
cargo test --manifest-path lib/c-api/Cargo.toml --release \

View File

@ -2,12 +2,12 @@
//! This tests checks that the provided functions (both native and
//! dynamic ones) work properly.
wasmer_compilers! {
use wasmer::*;
use anyhow::Result;
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
use crate::utils::get_store;
use anyhow::Result;
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
use wasmer::*;
fn get_module(store: &Store) -> Result<Module> {
fn get_module(store: &Store) -> Result<Module> {
let wat = r#"
(import "host" "0" (func))
(import "host" "1" (func (param i32) (result i32)))
@ -35,10 +35,10 @@ wasmer_compilers! {
let module = Module::new(&store, &wat)?;
Ok(module)
}
}
#[test]
fn dynamic_function() -> Result<()> {
#[test]
fn dynamic_function() -> Result<()> {
let store = get_store();
let module = get_module(&store)?;
static HITS: AtomicUsize = AtomicUsize::new(0);
@ -75,11 +75,10 @@ wasmer_compilers! {
)?;
assert_eq!(HITS.load(SeqCst), 4);
Ok(())
}
}
#[test]
fn dynamic_function_with_env() -> Result<()> {
#[test]
fn dynamic_function_with_env() -> Result<()> {
let store = get_store();
let module = get_module(&store)?;
@ -117,10 +116,10 @@ wasmer_compilers! {
)?;
assert_eq!(env.load(SeqCst), 4);
Ok(())
}
}
#[test]
fn native_function() -> Result<()> {
#[test]
fn native_function() -> Result<()> {
let store = get_store();
let module = get_module(&store)?;
@ -155,10 +154,10 @@ wasmer_compilers! {
)?;
assert_eq!(HITS.load(SeqCst), 4);
Ok(())
}
}
#[test]
fn native_function_with_env() -> Result<()> {
#[test]
fn native_function_with_env() -> Result<()> {
let store = get_store();
let module = get_module(&store)?;
@ -193,5 +192,4 @@ wasmer_compilers! {
)?;
assert_eq!(env.load(SeqCst), 4);
Ok(())
}
}

View File

@ -1,66 +0,0 @@
#[macro_export]
macro_rules! wasmer_compilers {
{ $($code:item)* } => {
#[cfg(feature = "singlepass")]
#[cfg(test)]
mod singlepass {
use std::sync::Arc;
use wasmer::{Features, Store, Tunables};
use wasmer_engine_jit::JITEngine;
use test_utils::get_compiler_config_from_str;
#[allow(dead_code)]
fn get_store() -> Store {
let features = Features::default();
let try_nan_canonicalization = false;
let compiler_config =
get_compiler_config_from_str("singlepass", try_nan_canonicalization, features);
let tunables = Tunables::for_target(compiler_config.target().triple());
let store = Store::new(Arc::new(JITEngine::new(compiler_config, tunables)));
store
}
$($code)*
}
#[cfg(feature = "cranelift")]
#[cfg(test)]
mod cranelift {
use std::sync::Arc;
use wasmer::{Features, Store, Tunables};
use wasmer_engine_jit::JITEngine;
use test_utils::get_compiler_config_from_str;
#[allow(dead_code)]
fn get_store() -> Store {
let features = Features::default();
let try_nan_canonicalization = false;
let compiler_config =
get_compiler_config_from_str("cranelift", try_nan_canonicalization, features);
let tunables = Tunables::for_target(compiler_config.target().triple());
let store = Store::new(Arc::new(JITEngine::new(compiler_config, tunables)));
store
}
$($code)*
}
#[cfg(feature = "llvm")]
#[cfg(test)]
mod llvm {
use std::sync::Arc;
use wasmer::{Features, Store, Tunables};
use wasmer_engine_jit::JITEngine;
use test_utils::get_compiler_config_from_str;
#[allow(dead_code)]
fn get_store() -> Store {
let features = Features::default();
let try_nan_canonicalization = false;
let compiler_config =
get_compiler_config_from_str("llvm", try_nan_canonicalization, features);
let tunables = Tunables::for_target(compiler_config.target().triple());
let store = Store::new(Arc::new(JITEngine::new(compiler_config, tunables)));
store
}
$($code)*
}
};
}

View File

@ -2,11 +2,7 @@
//! implementation, such as: singlepass, cranelift or llvm depending
//! on what's available on the target.
#[macro_use]
mod macros;
mod imports;
mod multi_value_imports;
mod traps;
mod wast;
#[macro_use]
extern crate lazy_static;
mod utils;

View File

@ -2,185 +2,8 @@
//! This tests checks that the provided functions (both native and
//! dynamic ones) work properly.
use std::collections::HashSet;
// These tests are skipped because they are known failing.
lazy_static! {
static ref SKIP_TESTS: HashSet<&'static str> = [
// https://github.com/bytecodealliance/wasmtime/issues/1178
(concat!(module_path!(), "::cranelift::test_mvr_f32_f32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_f32_f32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_f32_f32_f32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_f32_f32_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_f32_f64::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_f32_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_f32_i32_f32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_f32_i32_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_f32_i64::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_f64_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_i32_f32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_i32_f32_f32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_i32_f32_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_i32_f64::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_i32_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_i32_i32_f32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_i32_i32_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_i32_i64::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_i64_f32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f32_i64_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f64_f32_f32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f64_f32_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f64_i32_f32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_f64_i32_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i32_f32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i32_f32_f32_f32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i32_f32_f32_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i32_f32_f64::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i32_f64_f32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i32_f64_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i32_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i32_i32_f32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i32_i32_f32_f32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i32_i32_f32_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i32_i32_f64::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i32_i32_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i32_i32_i32_f32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i32_i32_i32_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i32_i32_i64::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i32_i64_f32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i32_i64_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i64_f32_i32::native")),
(concat!(module_path!(), "::cranelift::test_mvr_i64_i32_i32::native")),
// Multi-value is not implemented in singlepass yet.
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32_f32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32_f32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32_f32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32_f32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32_f64::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32_f64::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32_i32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32_i32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32_i32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32_i32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32_i64::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f32_i64::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f64::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f64::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f64_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f64_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f64_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_f64_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32_f32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32_f32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32_f32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32_f32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32_f64::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32_f64::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32_i32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32_i32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32_i32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32_i32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32_i64::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i32_i64::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i64::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i64::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i64_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i64_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i64_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f32_i64_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f64_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f64_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f64_f32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f64_f32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f64_f32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f64_f32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f64_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f64_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f64_i32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f64_i32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_f64_i32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_f64_i32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32_f32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32_f32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32_f32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32_f32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32_f64::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32_f64::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32_i32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32_i32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32_i32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32_i32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32_i64::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f32_i64::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f64::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f64::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f64_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f64_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f64_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_f64_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_f32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_f32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_f32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_f32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_f64::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_f64::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_i32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_i32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_i32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_i32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_i32_i32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_i32_i32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_i64::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i32_i64::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i64::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i64::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i64_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i64_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i64_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i32_i64_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i64_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i64_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i64_f32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i64_f32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i64_f32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i64_f32_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i64_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i64_i32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i64_i32_f32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i64_i32_f32::native")),
(concat!(module_path!(), "::singlepass::test_mvr_i64_i32_i32::dynamic")),
(concat!(module_path!(), "::singlepass::test_mvr_i64_i32_i32::native")),
]
.iter()
.copied()
.collect();
}
use crate::utils::get_store;
use wasmer::*;
macro_rules! mvr_test {
($test_name:ident, $( $result_type:ty ),* ) => {
@ -214,13 +37,8 @@ macro_rules! mvr_test {
}
#[test]
#[cfg_attr(any(feature = "test-cranelift", feature="test-singlepass"), ignore)]
fn native() -> anyhow::Result<()> {
dbg!(concat!(module_path!(), "::native"));
if crate::multi_value_imports::SKIP_TESTS.contains(concat!(module_path!(), "::native")) {
println!("skipped");
return Ok(());
}
let store = get_store();
let module = get_module(&store)?;
let instance = wasmer::Instance::new(
@ -245,12 +63,8 @@ macro_rules! mvr_test {
}
#[test]
#[cfg_attr(feature="test-singlepass", ignore)]
fn dynamic() -> anyhow::Result<()> {
if crate::multi_value_imports::SKIP_TESTS.contains(concat!(module_path!(), "::dynamic")) {
println!("skipped");
return Ok(());
}
let store = get_store();
let module = get_module(&store)?;
let instance = wasmer::Instance::new(
@ -272,13 +86,12 @@ macro_rules! mvr_test {
}
}
wasmer_compilers! {
trait ExpectedExpr {
trait ExpectedExpr {
fn expected_value(n: i32) -> Self;
fn expected_val(n: i32) -> wasmer::Val;
fn expected_valtype() -> wasmer::ValType;
}
impl ExpectedExpr for i32 {
}
impl ExpectedExpr for i32 {
fn expected_value(n: i32) -> i32 {
n + 1
}
@ -288,8 +101,8 @@ wasmer_compilers! {
fn expected_valtype() -> wasmer::ValType {
wasmer::ValType::I32
}
}
impl ExpectedExpr for i64 {
}
impl ExpectedExpr for i64 {
fn expected_value(n: i32) -> i64 {
n as i64 + 2i64
}
@ -299,8 +112,8 @@ wasmer_compilers! {
fn expected_valtype() -> wasmer::ValType {
wasmer::ValType::I64
}
}
impl ExpectedExpr for f32 {
}
impl ExpectedExpr for f32 {
fn expected_value(n: i32) -> f32 {
n as f32 * 0.1
}
@ -310,8 +123,8 @@ wasmer_compilers! {
fn expected_valtype() -> wasmer::ValType {
wasmer::ValType::F32
}
}
impl ExpectedExpr for f64 {
}
impl ExpectedExpr for f64 {
fn expected_value(n: i32) -> f64 {
n as f64 * 0.12
}
@ -321,75 +134,74 @@ wasmer_compilers! {
fn expected_valtype() -> wasmer::ValType {
wasmer::ValType::F64
}
}
mvr_test!(test_mvr_i32_i32, i32, i32);
mvr_test!(test_mvr_i32_f32, i32, f32);
mvr_test!(test_mvr_f32_i32, f32, i32);
mvr_test!(test_mvr_f32_f32, f32, f32);
mvr_test!(test_mvr_i64_i32, i64, i32);
mvr_test!(test_mvr_i64_f32, i64, f32);
mvr_test!(test_mvr_f64_i32, f64, i32);
mvr_test!(test_mvr_f64_f32, f64, f32);
mvr_test!(test_mvr_i32_i64, i32, i64);
mvr_test!(test_mvr_f32_i64, f32, i64);
mvr_test!(test_mvr_i32_f64, i32, f64);
mvr_test!(test_mvr_f32_f64, f32, f64);
mvr_test!(test_mvr_i32_i32_i32, i32, i32, i32);
mvr_test!(test_mvr_i32_i32_f32, i32, i32, f32);
mvr_test!(test_mvr_i32_f32_i32, i32, f32, i32);
mvr_test!(test_mvr_i32_f32_f32, i32, f32, f32);
mvr_test!(test_mvr_f32_i32_i32, f32, i32, i32);
mvr_test!(test_mvr_f32_i32_f32, f32, i32, f32);
mvr_test!(test_mvr_f32_f32_i32, f32, f32, i32);
mvr_test!(test_mvr_f32_f32_f32, f32, f32, f32);
mvr_test!(test_mvr_i32_i32_i64, i32, i32, i64);
mvr_test!(test_mvr_i32_f32_i64, i32, f32, i64);
mvr_test!(test_mvr_f32_i32_i64, f32, i32, i64);
mvr_test!(test_mvr_f32_f32_i64, f32, f32, i64);
mvr_test!(test_mvr_i32_i32_f64, i32, i32, f64);
mvr_test!(test_mvr_i32_f32_f64, i32, f32, f64);
mvr_test!(test_mvr_f32_i32_f64, f32, i32, f64);
mvr_test!(test_mvr_f32_f32_f64, f32, f32, f64);
mvr_test!(test_mvr_i32_i64_i32, i32, i64, i32);
mvr_test!(test_mvr_i32_i64_f32, i32, i64, f32);
mvr_test!(test_mvr_f32_i64_i32, f32, i64, i32);
mvr_test!(test_mvr_f32_i64_f32, f32, i64, f32);
mvr_test!(test_mvr_i32_f64_i32, i32, f64, i32);
mvr_test!(test_mvr_i32_f64_f32, i32, f64, f32);
mvr_test!(test_mvr_f32_f64_i32, f32, f64, i32);
mvr_test!(test_mvr_f32_f64_f32, f32, f64, f32);
mvr_test!(test_mvr_i64_i32_i32, i64, i32, i32);
mvr_test!(test_mvr_i64_i32_f32, i64, i32, f32);
mvr_test!(test_mvr_i64_f32_i32, i64, f32, i32);
mvr_test!(test_mvr_i64_f32_f32, i64, f32, f32);
mvr_test!(test_mvr_f64_i32_i32, f64, i32, i32);
mvr_test!(test_mvr_f64_i32_f32, f64, i32, f32);
mvr_test!(test_mvr_f64_f32_i32, f64, f32, i32);
mvr_test!(test_mvr_f64_f32_f32, f64, f32, f32);
mvr_test!(test_mvr_i32_i32_i32_i32, i32, i32, i32, i32);
mvr_test!(test_mvr_i32_i32_i32_f32, i32, i32, i32, f32);
mvr_test!(test_mvr_i32_i32_f32_i32, i32, i32, f32, i32);
mvr_test!(test_mvr_i32_i32_f32_f32, i32, i32, f32, f32);
mvr_test!(test_mvr_i32_f32_i32_i32, i32, f32, i32, i32);
mvr_test!(test_mvr_i32_f32_i32_f32, i32, f32, i32, f32);
mvr_test!(test_mvr_i32_f32_f32_i32, i32, f32, f32, i32);
mvr_test!(test_mvr_i32_f32_f32_f32, i32, f32, f32, f32);
mvr_test!(test_mvr_f32_i32_i32_i32, f32, i32, i32, i32);
mvr_test!(test_mvr_f32_i32_i32_f32, f32, i32, i32, f32);
mvr_test!(test_mvr_f32_i32_f32_i32, f32, i32, f32, i32);
mvr_test!(test_mvr_f32_i32_f32_f32, f32, i32, f32, f32);
mvr_test!(test_mvr_f32_f32_i32_i32, f32, f32, i32, i32);
mvr_test!(test_mvr_f32_f32_i32_f32, f32, f32, i32, f32);
mvr_test!(test_mvr_f32_f32_f32_i32, f32, f32, f32, i32);
mvr_test!(test_mvr_f32_f32_f32_f32, f32, f32, f32, f32);
mvr_test!(test_mvr_i32_i32_i32_i32_i32, i32, i32, i32, i32, i32);
}
mvr_test!(test_mvr_i32_i32, i32, i32);
mvr_test!(test_mvr_i32_f32, i32, f32);
mvr_test!(test_mvr_f32_i32, f32, i32);
mvr_test!(test_mvr_f32_f32, f32, f32);
mvr_test!(test_mvr_i64_i32, i64, i32);
mvr_test!(test_mvr_i64_f32, i64, f32);
mvr_test!(test_mvr_f64_i32, f64, i32);
mvr_test!(test_mvr_f64_f32, f64, f32);
mvr_test!(test_mvr_i32_i64, i32, i64);
mvr_test!(test_mvr_f32_i64, f32, i64);
mvr_test!(test_mvr_i32_f64, i32, f64);
mvr_test!(test_mvr_f32_f64, f32, f64);
mvr_test!(test_mvr_i32_i32_i32, i32, i32, i32);
mvr_test!(test_mvr_i32_i32_f32, i32, i32, f32);
mvr_test!(test_mvr_i32_f32_i32, i32, f32, i32);
mvr_test!(test_mvr_i32_f32_f32, i32, f32, f32);
mvr_test!(test_mvr_f32_i32_i32, f32, i32, i32);
mvr_test!(test_mvr_f32_i32_f32, f32, i32, f32);
mvr_test!(test_mvr_f32_f32_i32, f32, f32, i32);
mvr_test!(test_mvr_f32_f32_f32, f32, f32, f32);
mvr_test!(test_mvr_i32_i32_i64, i32, i32, i64);
mvr_test!(test_mvr_i32_f32_i64, i32, f32, i64);
mvr_test!(test_mvr_f32_i32_i64, f32, i32, i64);
mvr_test!(test_mvr_f32_f32_i64, f32, f32, i64);
mvr_test!(test_mvr_i32_i32_f64, i32, i32, f64);
mvr_test!(test_mvr_i32_f32_f64, i32, f32, f64);
mvr_test!(test_mvr_f32_i32_f64, f32, i32, f64);
mvr_test!(test_mvr_f32_f32_f64, f32, f32, f64);
mvr_test!(test_mvr_i32_i64_i32, i32, i64, i32);
mvr_test!(test_mvr_i32_i64_f32, i32, i64, f32);
mvr_test!(test_mvr_f32_i64_i32, f32, i64, i32);
mvr_test!(test_mvr_f32_i64_f32, f32, i64, f32);
mvr_test!(test_mvr_i32_f64_i32, i32, f64, i32);
mvr_test!(test_mvr_i32_f64_f32, i32, f64, f32);
mvr_test!(test_mvr_f32_f64_i32, f32, f64, i32);
mvr_test!(test_mvr_f32_f64_f32, f32, f64, f32);
mvr_test!(test_mvr_i64_i32_i32, i64, i32, i32);
mvr_test!(test_mvr_i64_i32_f32, i64, i32, f32);
mvr_test!(test_mvr_i64_f32_i32, i64, f32, i32);
mvr_test!(test_mvr_i64_f32_f32, i64, f32, f32);
mvr_test!(test_mvr_f64_i32_i32, f64, i32, i32);
mvr_test!(test_mvr_f64_i32_f32, f64, i32, f32);
mvr_test!(test_mvr_f64_f32_i32, f64, f32, i32);
mvr_test!(test_mvr_f64_f32_f32, f64, f32, f32);
mvr_test!(test_mvr_i32_i32_i32_i32, i32, i32, i32, i32);
mvr_test!(test_mvr_i32_i32_i32_f32, i32, i32, i32, f32);
mvr_test!(test_mvr_i32_i32_f32_i32, i32, i32, f32, i32);
mvr_test!(test_mvr_i32_i32_f32_f32, i32, i32, f32, f32);
mvr_test!(test_mvr_i32_f32_i32_i32, i32, f32, i32, i32);
mvr_test!(test_mvr_i32_f32_i32_f32, i32, f32, i32, f32);
mvr_test!(test_mvr_i32_f32_f32_i32, i32, f32, f32, i32);
mvr_test!(test_mvr_i32_f32_f32_f32, i32, f32, f32, f32);
mvr_test!(test_mvr_f32_i32_i32_i32, f32, i32, i32, i32);
mvr_test!(test_mvr_f32_i32_i32_f32, f32, i32, i32, f32);
mvr_test!(test_mvr_f32_i32_f32_i32, f32, i32, f32, i32);
mvr_test!(test_mvr_f32_i32_f32_f32, f32, i32, f32, f32);
mvr_test!(test_mvr_f32_f32_i32_i32, f32, f32, i32, i32);
mvr_test!(test_mvr_f32_f32_i32_f32, f32, f32, i32, f32);
mvr_test!(test_mvr_f32_f32_f32_i32, f32, f32, f32, i32);
mvr_test!(test_mvr_f32_f32_f32_f32, f32, f32, f32, f32);
mvr_test!(test_mvr_i32_i32_i32_i32_i32, i32, i32, i32, i32, i32);

View File

@ -1,10 +1,10 @@
wasmer_compilers! {
use anyhow::Result;
use std::panic::{self, AssertUnwindSafe};
use wasmer::*;
use crate::utils::get_store;
use anyhow::Result;
use std::panic::{self, AssertUnwindSafe};
use wasmer::*;
#[test]
fn test_trap_return() -> Result<()> {
#[test]
fn test_trap_return() -> Result<()> {
let store = get_store();
let wat = r#"
(module
@ -36,11 +36,11 @@ wasmer_compilers! {
assert_eq!(e.message(), "test 123");
Ok(())
}
}
#[test]
#[ignore]
fn test_trap_trace() -> Result<()> {
#[test]
#[cfg_attr(any(feature = "test-singlepass", feature = "test-llvm"), ignore)]
fn test_trap_trace() -> Result<()> {
let store = get_store();
let wat = r#"
(module $hello_mod
@ -73,10 +73,10 @@ wasmer_compilers! {
);
Ok(())
}
}
#[test]
fn test_trap_trace_cb() -> Result<()> {
#[test]
fn test_trap_trace_cb() -> Result<()> {
let store = get_store();
let wat = r#"
(module $hello_mod
@ -116,10 +116,11 @@ wasmer_compilers! {
assert_eq!(e.message(), "cb throw");
Ok(())
}
}
#[test]
fn test_trap_stack_overflow() -> Result<()> {
#[test]
#[cfg_attr(any(feature = "test-singlepass", feature = "test-llvm"), ignore)]
fn test_trap_stack_overflow() -> Result<()> {
let store = get_store();
let wat = r#"
(module $rec_mod
@ -137,7 +138,7 @@ wasmer_compilers! {
let e = run_func.call(&[]).err().expect("error calling function");
let trace = e.trace();
// assert!(trace.len() >= 32);
assert!(trace.len() >= 32);
for i in 0..trace.len() {
assert_eq!(trace[i].module_name(), "rec_mod");
assert_eq!(trace[i].func_index(), 0);
@ -146,11 +147,11 @@ wasmer_compilers! {
assert!(e.message().contains("call stack exhausted"));
Ok(())
}
}
#[test]
#[ignore]
fn trap_display_pretty() -> Result<()> {
#[test]
#[cfg_attr(any(feature = "test-singlepass", feature = "test-llvm"), ignore)]
fn trap_display_pretty() -> Result<()> {
let store = get_store();
let wat = r#"
(module $m
@ -179,11 +180,11 @@ RuntimeError: unreachable
at <unnamed> (m[3]:0x31)"
);
Ok(())
}
}
#[test]
#[ignore]
fn trap_display_multi_module() -> Result<()> {
#[test]
#[cfg_attr(any(feature = "test-singlepass", feature = "test-llvm"), ignore)]
fn trap_display_multi_module() -> Result<()> {
let store = get_store();
let wat = r#"
(module $a
@ -232,10 +233,10 @@ RuntimeError: unreachable
at <unnamed> (b[2]:0x2e)"
);
Ok(())
}
}
#[test]
fn trap_start_function_import() -> Result<()> {
#[test]
fn trap_start_function_import() -> Result<()> {
let store = get_store();
let binary = r#"
(module $a
@ -265,10 +266,10 @@ RuntimeError: unreachable
}
Ok(())
}
}
#[test]
fn rust_panic_import() -> Result<()> {
#[test]
fn rust_panic_import() -> Result<()> {
let store = get_store();
let binary = r#"
(module $a
@ -310,10 +311,10 @@ RuntimeError: unreachable
// Some(&"this is another panic")
// );
Ok(())
}
}
#[test]
fn rust_panic_start_function() -> Result<()> {
#[test]
fn rust_panic_start_function() -> Result<()> {
let store = get_store();
let binary = r#"
(module $a
@ -355,10 +356,10 @@ RuntimeError: unreachable
Some(&"this is another panic")
);
Ok(())
}
}
#[test]
fn mismatched_arguments() -> Result<()> {
#[test]
fn mismatched_arguments() -> Result<()> {
let store = get_store();
let binary = r#"
(module $a
@ -384,11 +385,11 @@ RuntimeError: unreachable
"Parameters of type [I32, I32] did not match signature [I32] -> []"
);
Ok(())
}
}
#[test]
#[ignore]
fn call_signature_mismatch() -> Result<()> {
#[test]
#[cfg_attr(any(feature = "test-singlepass", feature = "test-llvm"), ignore)]
fn call_signature_mismatch() -> Result<()> {
let store = get_store();
let binary = r#"
(module $a
@ -412,14 +413,14 @@ RuntimeError: unreachable
"\
RuntimeError: indirect call type mismatch
at foo (a[0]:0x30)\
"
"
);
Ok(())
}
}
#[ignore]
#[test]
fn start_trap_pretty() -> Result<()> {
#[ignore]
#[cfg_attr(any(feature = "test-singlepass", feature = "test-llvm"), ignore)]
fn start_trap_pretty() -> Result<()> {
let store = get_store();
let wat = r#"
(module $m
@ -444,13 +445,13 @@ RuntimeError: unreachable
at <unnamed> (m[1]:0x21)
at foo (m[2]:0x26)
at start (m[3]:0x2b)\
"
"
);
Ok(())
}
}
#[test]
fn present_after_module_drop() -> Result<()> {
#[test]
fn present_after_module_drop() -> Result<()> {
let store = get_store();
let module = Module::new(&store, r#"(func (export "foo") unreachable)"#)?;
let instance = Instance::new(&module, &imports! {})?;
@ -469,5 +470,4 @@ RuntimeError: unreachable
// assert_eq!(t.trace().len(), 1);
// assert_eq!(t.trace()[0].func_index(), 0);
}
}
}

29
tests/compilers/utils.rs Normal file
View File

@ -0,0 +1,29 @@
use std::sync::Arc;
use test_utils::get_compiler_config_from_str;
use wasmer::{Features, Store, Tunables};
use wasmer_engine_jit::JITEngine;
fn get_compiler_str() -> &'static str {
cfg_if::cfg_if! {
if #[cfg(feature = "test-cranelift")] {
"cranelift"
} else if #[cfg(feature = "test-llvm")] {
"llvm"
} else if #[cfg(feature = "test-singlepass")] {
"singlepass"
}
else {
compile_error!("No compiler chosen for the tests")
}
}
}
pub fn get_store() -> Store {
let features = Features::default();
let try_nan_canonicalization = false;
let compiler_config =
get_compiler_config_from_str(get_compiler_str(), try_nan_canonicalization, features);
let tunables = Tunables::for_target(compiler_config.target().triple());
let store = Store::new(Arc::new(JITEngine::new(compiler_config, tunables)));
store
}

View File

@ -169,7 +169,7 @@ pub fn with_features(
f: impl Fn(&mut Testsuite) -> anyhow::Result<()> + Copy,
) -> anyhow::Result<()> {
for compiler in features.iter() {
writeln!(out.buffer, "#[cfg(feature=\"{}\")]", compiler)?;
writeln!(out.buffer, "#[cfg(feature=\"test-{}\")]", compiler)?;
writeln!(out.buffer, "#[cfg(test)]")?;
writeln!(out.buffer, "#[allow(non_snake_case)]")?;
with_test_module(&mut out, &compiler, f)?;

View File

@ -20,11 +20,7 @@ pub fn wast_processor(out: &mut Testsuite, p: PathBuf) -> Option<Test> {
let compiler = out.path.get(0).unwrap();
// The implementation of `run_wast` lives in /tests/spectest.rs
let body = format!(
"crate::wast::run_wast(r#\"{}\"#, \"{}\")",
p.display(),
compiler
);
let body = format!("crate::run_wast(r#\"{}\"#, \"{}\")", p.display(), compiler);
Some(Test {
name: testname,