Skip to content

Commit 4296987

Browse files
bors[bot]nlewycky
andauthored
Merge #1712
1712: Make it possible to run spectests with engine-native. r=nlewycky a=nlewycky Co-authored-by: Nick Lewycky <[email protected]> Co-authored-by: nlewycky <[email protected]>
2 parents fff5366 + 84c140e commit 4296987

File tree

4 files changed

+63
-15
lines changed

4 files changed

+63
-15
lines changed

Cargo.toml

+7
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ test-llvm = [
129129
"llvm",
130130
]
131131

132+
test-native = [
133+
"native",
134+
]
135+
test-jit = [
136+
"jit",
137+
]
138+
132139
# Disable trap asserts in the WAST tests. This is useful for running the tests in a
133140
# context where signal handling is a problem, such as tarpaulin for code coverage.
134141
test-no-traps = ["wasmer-wast/test-no-traps"]

Makefile

+17-7
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,26 @@ build-capi-llvm:
9494
# Testing #
9595
###########
9696

97-
test: $(foreach compiler,$(compilers),test-$(compiler)) test-packages test-examples test-deprecated
97+
test: $(foreach compiler,$(compilers),test-$(compiler)-jit) test-packages test-examples test-deprecated
9898

99-
test-singlepass:
100-
cargo test --release $(compiler_features) --features "test-singlepass"
99+
# Singlepass and native engine don't work together, this rule does nothing.
100+
test-singlepass-native:
101+
@:
101102

102-
test-cranelift:
103-
cargo test --release $(compiler_features) --features "test-cranelift"
103+
test-singlepass-jit:
104+
cargo test --release $(compiler_features) --features "test-singlepass test-jit"
104105

105-
test-llvm:
106-
cargo test --release $(compiler_features) --features "test-llvm"
106+
test-cranelift-native:
107+
cargo test --release $(compiler_features) --features "test-cranelift test-native"
108+
109+
test-cranelift-jit:
110+
cargo test --release $(compiler_features) --features "test-cranelift test-jit"
111+
112+
test-llvm-native:
113+
cargo test --release $(compiler_features) --features "test-llvm test-native"
114+
115+
test-llvm-jit:
116+
cargo test --release $(compiler_features) --features "test-llvm test-jit"
107117

108118
test-packages:
109119
cargo test -p wasmer --release

tests/compilers/utils.rs

+19
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ use std::sync::Arc;
22
use wasmer::{FunctionMiddlewareGenerator, Store};
33
use wasmer_compiler::CompilerConfig;
44
use wasmer_engine::Engine;
5+
#[cfg(feature = "test-jit")]
56
use wasmer_engine_jit::JIT;
7+
#[cfg(feature = "test-native")]
8+
use wasmer_engine_native::Native;
69

710
pub fn get_compiler(canonicalize_nans: bool) -> impl CompilerConfig {
811
cfg_if::cfg_if! {
@@ -32,10 +35,16 @@ pub fn get_compiler(canonicalize_nans: bool) -> impl CompilerConfig {
3235
}
3336
}
3437

38+
#[cfg(feature = "test-jit")]
3539
pub fn get_engine() -> impl Engine {
3640
let compiler_config = get_compiler(false);
3741
JIT::new(&compiler_config).engine()
3842
}
43+
#[cfg(feature = "test-native")]
44+
pub fn get_engine() -> impl Engine {
45+
let mut compiler_config = get_compiler(false);
46+
Native::new(&mut compiler_config).engine()
47+
}
3948

4049
pub fn get_store() -> Store {
4150
Store::new(&get_engine())
@@ -48,10 +57,20 @@ pub fn get_store_with_middlewares<I: Iterator<Item = Arc<dyn FunctionMiddlewareG
4857
for x in middlewares {
4958
compiler_config.push_middleware(x);
5059
}
60+
#[cfg(feature = "test-jit")]
5161
let engine = JIT::new(&compiler_config).engine();
62+
#[cfg(feature = "test-native")]
63+
let engine = Native::new(&mut compiler_config).engine();
5264
Store::new(&engine)
5365
}
5466

67+
#[cfg(feature = "test-jit")]
5568
pub fn get_headless_store() -> Store {
5669
Store::new(&JIT::headless().engine())
70+
// Store::new(&Native::headless().engine())
71+
}
72+
73+
#[cfg(feature = "test-native")]
74+
pub fn get_headless_store() -> Store {
75+
Store::new(&Native::headless().engine())
5776
}

tests/compilers/wast.rs

+20-8
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
use crate::utils::get_compiler;
44
use std::path::Path;
55
use wasmer::{Features, Store};
6-
#[cfg(feature = "jit")]
6+
#[cfg(feature = "test-jit")]
77
use wasmer_engine_jit::JIT;
8-
// #[cfg(feature = "native")]
9-
// use wasmer_engine_native::NativeEngine;
8+
#[cfg(feature = "test-native")]
9+
use wasmer_engine_native::Native;
1010
use wasmer_wast::Wast;
1111

1212
// The generated tests (from build.rs) look like:
@@ -28,6 +28,22 @@ fn _native_prefixer(bytes: &[u8]) -> String {
2828
format!("{}", hash.to_hex())
2929
}
3030

31+
#[cfg(feature = "test-jit")]
32+
fn get_store(features: Features, try_nan_canonicalization: bool) -> Store {
33+
let compiler_config = get_compiler(try_nan_canonicalization);
34+
Store::new(&JIT::new(&compiler_config).features(features).engine())
35+
}
36+
37+
#[cfg(feature = "test-native")]
38+
fn get_store(features: Features, try_nan_canonicalization: bool) -> Store {
39+
let mut compiler_config = get_compiler(try_nan_canonicalization);
40+
Store::new(
41+
&Native::new(&mut compiler_config)
42+
.features(features)
43+
.engine(),
44+
)
45+
}
46+
3147
pub fn run_wast(wast_path: &str, compiler: &str) -> anyhow::Result<()> {
3248
println!(
3349
"Running wast `{}` with the {} compiler",
@@ -45,11 +61,7 @@ pub fn run_wast(wast_path: &str, compiler: &str) -> anyhow::Result<()> {
4561
}
4662
#[cfg(feature = "test-singlepass")]
4763
features.multi_value(false);
48-
let compiler_config = get_compiler(try_nan_canonicalization);
49-
let store = Store::new(&JIT::new(&compiler_config).features(features).engine());
50-
// let mut native = NativeEngine::new(compiler_config, tunables);
51-
// native.set_deterministic_prefixer(native_prefixer);
52-
// let store = Store::new(&native);
64+
let store = get_store(features, try_nan_canonicalization);
5365
let mut wast = Wast::new_with_spectest(store);
5466
if is_simd {
5567
// We allow this, so tests can be run properly for `simd_const` test.

0 commit comments

Comments
 (0)