mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-25 06:31:32 +00:00
Add new llvm-backend-test crate.
This commit is contained in:
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -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"
|
||||
|
@ -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",
|
||||
|
1
Makefile
1
Makefile
@ -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
|
||||
|
||||
|
||||
|
15
lib/llvm-backend-tests/Cargo.toml
Normal file
15
lib/llvm-backend-tests/Cargo.toml
Normal 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]
|
7
lib/llvm-backend-tests/src/lib.rs
Normal file
7
lib/llvm-backend-tests/src/lib.rs
Normal 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()
|
||||
}
|
22
lib/llvm-backend-tests/tests/compile.rs
Normal file
22
lib/llvm-backend-tests/tests/compile.rs
Normal 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();
|
||||
}
|
Reference in New Issue
Block a user