Add new llvm-backend-test crate.

This commit is contained in:
Nick Lewycky
2019-11-22 16:33:16 -08:00
parent 2433d365af
commit 85666fc522
6 changed files with 56 additions and 0 deletions

10
Cargo.lock generated
View File

@ -1464,6 +1464,16 @@ dependencies = [
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasmer-llvm-backend-tests"
version = "0.10.2"
dependencies = [
"wabt 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-llvm-backend 0.11.0",
"wasmer-runtime 0.11.0",
"wasmer-runtime-core 0.11.0",
]
[[package]]
name = "wasmer-middleware-common"
version = "0.11.0"

View File

@ -50,6 +50,7 @@ members = [
"lib/win-exception-handler",
"lib/runtime-c-api",
"lib/llvm-backend",
"lib/llvm-backend-tests",
"lib/wasi",
"lib/middleware-common",
"lib/kernel-loader",

View File

@ -97,6 +97,7 @@ cranelift: spectests-cranelift emtests-cranelift middleware-cranelift wasitests-
llvm: spectests-llvm emtests-llvm wasitests-llvm
cargo test -p wasmer-llvm-backend --release
cargo test -p wasmer-llvm-backend-tests --release
cargo test -p wasmer-runtime-core-tests --release --no-default-features --features backend-llvm

View File

@ -0,0 +1,15 @@
[package]
name = "wasmer-llvm-backend-tests"
version = "0.10.2"
authors = ["Nick Lewycky <nick@wasmer.io>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
wabt = "0.9.1"
wasmer-runtime-core = { path = "../runtime-core", version = "0.11.0" }
wasmer-runtime = { path = "../runtime", version = "0.11.0" }
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.11.0", features = ["test"] }
[features]

View File

@ -0,0 +1,7 @@
pub use wabt::wat2wasm;
use wasmer_llvm_backend::LLVMCompiler;
use wasmer_runtime_core::backend::Compiler;
pub fn get_compiler() -> impl Compiler {
LLVMCompiler::new()
}

View File

@ -0,0 +1,22 @@
use wasmer_llvm_backend_tests::{get_compiler, wat2wasm};
use wasmer_runtime::imports;
use wasmer_runtime_core::compile_with;
#[test]
fn crash_return_with_float_on_stack() {
const MODULE: &str = r#"
(module
(type (;0;) (func))
(type (;1;) (func (param f64) (result f64)))
(func $_start (type 0))
(func $fmod (type 1) (param f64) (result f64)
local.get 0
f64.const 0x0p+0 (;=0;)
f64.mul
return)
)
"#;
let wasm_binary = wat2wasm(MODULE.as_bytes()).expect("WAST not valid or malformed");
let module = compile_with(&wasm_binary, &get_compiler()).unwrap();
let instance = module.instantiate(&imports! {}).unwrap();
}