mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-04 18:10:18 +00:00
Fix emtests and wasitests to use the correct backend
This commit is contained in:
parent
b6011d5dc4
commit
3579d0d445
20
Makefile
20
Makefile
@ -53,13 +53,13 @@ spectests: spectests-singlepass spectests-cranelift spectests-llvm
|
||||
|
||||
# Emscripten tests
|
||||
emtests-singlepass:
|
||||
cargo test emtest --release --no-default-features --features "wasi backend-singlepass" -- --test-threads=1
|
||||
WASMER_TEST_SINGLEPASS=1 cargo test emtest --release --no-default-features --features "wasi backend-singlepass" -- --test-threads=1
|
||||
|
||||
emtests-cranelift:
|
||||
cargo test emtest --release --no-default-features --features "wasi backend-cranelift" -- --test-threads=1
|
||||
WASMER_TEST_CRANELIFT=1 cargo test emtest --release --no-default-features --features "wasi backend-cranelift" -- --test-threads=1
|
||||
|
||||
emtests-llvm:
|
||||
cargo test emtest --release --no-default-features --features "wasi backend-llvm" -- --test-threads=1
|
||||
WASMER_TEST_LLVM=1 cargo test emtest --release --no-default-features --features "wasi backend-llvm" -- --test-threads=1
|
||||
|
||||
emtests-unit:
|
||||
cargo test emscripten --release
|
||||
@ -86,13 +86,13 @@ wasitests-setup:
|
||||
mkdir -p tests/wasi_test_resources/test_fs/temp
|
||||
|
||||
wasitests-singlepass: wasitests-setup
|
||||
cargo test wasitest --release --no-default-features --features "wasi backend-singlepass" -- --test-threads=1
|
||||
WASMER_TEST_SINGLEPASS=1 cargo test wasitest --release --no-default-features --features "wasi backend-singlepass" -- --test-threads=1
|
||||
|
||||
wasitests-cranelift: wasitests-setup
|
||||
cargo test wasitest --release --no-default-features --features "wasi backend-cranelift" -- --test-threads=1 --nocapture
|
||||
WASMER_TEST_CRANELIFT=1 cargo test wasitest --release --no-default-features --features "wasi backend-cranelift" -- --test-threads=1 --nocapture
|
||||
|
||||
wasitests-llvm: wasitests-setup
|
||||
cargo test wasitest --release --no-default-features --features "wasi backend-llvm" -- --test-threads=1
|
||||
WASMER_TEST_LLVM=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/Cargo.toml --release
|
||||
@ -174,9 +174,9 @@ test-android:
|
||||
# Integration tests
|
||||
integration-tests: release-clif examples
|
||||
echo "Running Integration Tests"
|
||||
./integration_tests/lua/test.sh
|
||||
./integration_tests/nginx/test.sh
|
||||
./integration_tests/cowsay/test.sh
|
||||
./tests/integration_tests/lua/test.sh
|
||||
./tests/integration_tests/nginx/test.sh
|
||||
./tests/integration_tests/cowsay/test.sh
|
||||
|
||||
examples:
|
||||
cargo run --example plugin
|
||||
@ -287,12 +287,14 @@ release-llvm:
|
||||
cargo build --release --features backend-llvm,experimental-io-devices
|
||||
|
||||
bench-singlepass:
|
||||
# NOTE this will run some benchmarks using clif; TODO: fix this
|
||||
cargo bench --all --no-default-features --features "backend-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
|
||||
bench-llvm:
|
||||
# NOTE this will run some benchmarks using clif; TODO: fix this
|
||||
cargo bench --all --no-default-features --features "backend-llvm" \
|
||||
--exclude wasmer-singlepass-backend --exclude wasmer-clif-backend --exclude wasmer-kernel-loader
|
||||
|
||||
|
@ -1,3 +1,35 @@
|
||||
use std::env;
|
||||
use wasmer_runtime::Backend;
|
||||
|
||||
pub fn get_backend() -> Option<Backend> {
|
||||
#[cfg(feature = "backend-cranelift")]
|
||||
{
|
||||
if let Ok(v) = env::var("WASMER_TEST_CLIF") {
|
||||
if v == "1" {
|
||||
return Some(Backend::Cranelift);
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "backend-llvm")]
|
||||
{
|
||||
if let Ok(v) = env::var("WASMER_TEST_LLVM") {
|
||||
if v == "1" {
|
||||
return Some(Backend::LLVM);
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "backend-singlepass")]
|
||||
{
|
||||
if let Ok(v) = env::var("WASMER_TEST_SINGLEPASS") {
|
||||
if v == "1" {
|
||||
return Some(Backend::Singlepass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
macro_rules! assert_emscripten_output {
|
||||
($file:expr, $name:expr, $args:expr, $expected:expr) => {{
|
||||
|
||||
@ -5,16 +37,14 @@ macro_rules! assert_emscripten_output {
|
||||
EmscriptenGlobals,
|
||||
generate_emscripten_env,
|
||||
};
|
||||
use wasmer_runtime::compile;
|
||||
use wasmer_dev_utils::stdio::StdioCapturer;
|
||||
|
||||
let wasm_bytes = include_bytes!($file);
|
||||
let backend = $crate::emtests::_common::get_backend().expect("Please set one of `WASMER_TEST_CLIF`, `WASMER_TEST_LLVM`, or `WASMER_TEST_SINGELPASS` to `1`.");
|
||||
let compiler = wasmer_runtime::compiler_for_backend(backend).expect("The desired compiler was not found!");
|
||||
|
||||
let module = compile(&wasm_bytes[..])
|
||||
.expect("WASM can't be compiled");
|
||||
let module = wasmer_runtime::compile_with_config_with(&wasm_bytes[..], Default::default(), &*compiler).expect("WASM can't be compiled");
|
||||
|
||||
// let module = compile(&wasm_bytes[..])
|
||||
// .map_err(|err| format!("Can't create the WebAssembly module: {}", err)).unwrap(); // NOTE: Need to figure what the unwrap is for ??
|
||||
let mut emscripten_globals = EmscriptenGlobals::new(&module).expect("globals are valid");
|
||||
let import_object = generate_emscripten_env(&mut emscripten_globals);
|
||||
|
||||
|
@ -1,3 +1,35 @@
|
||||
use std::env;
|
||||
use wasmer_runtime::Backend;
|
||||
|
||||
pub fn get_backend() -> Option<Backend> {
|
||||
#[cfg(feature = "backend-cranelift")]
|
||||
{
|
||||
if let Ok(v) = env::var("WASMER_TEST_CLIF") {
|
||||
if v == "1" {
|
||||
return Some(Backend::Cranelift);
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "backend-llvm")]
|
||||
{
|
||||
if let Ok(v) = env::var("WASMER_TEST_LLVM") {
|
||||
if v == "1" {
|
||||
return Some(Backend::LLVM);
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "backend-singlepass")]
|
||||
{
|
||||
if let Ok(v) = env::var("WASMER_TEST_SINGLEPASS") {
|
||||
if v == "1" {
|
||||
return Some(Backend::Singlepass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
macro_rules! assert_wasi_output {
|
||||
($file:expr, $name:expr, $po_dir_args: expr, $mapdir_args:expr, $envvar_args:expr, $expected:expr) => {{
|
||||
use wasmer_dev_utils::stdio::StdioCapturer;
|
||||
@ -5,8 +37,10 @@ macro_rules! assert_wasi_output {
|
||||
use wasmer_wasi::{generate_import_object_for_version, get_wasi_version};
|
||||
|
||||
let wasm_bytes = include_bytes!($file);
|
||||
let backend = $crate::wasitests::_common::get_backend().expect("Please set one of `WASMER_TEST_CLIF`, `WASMER_TEST_LLVM`, or `WASMER_TEST_SINGELPASS` to `1`.");
|
||||
let compiler = wasmer_runtime::compiler_for_backend(backend).expect("The desired compiler was not found!");
|
||||
|
||||
let module = wasmer_runtime::compile(&wasm_bytes[..]).expect("WASM can't be compiled");
|
||||
let module = wasmer_runtime::compile_with_config_with(&wasm_bytes[..], Default::default(), &*compiler).expect("WASM can't be compiled");
|
||||
|
||||
let wasi_version = get_wasi_version(&module, true).expect("WASI module");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user