Skip to content

Commit

Permalink
Add support for "on native" and "on jit" to the ignores.txt.
Browse files Browse the repository at this point in the history
Extend test-no-traps feature to cover tests/compiler/traps.rs and enable it
when testing with the native engine.

Turn on testing native engine as part of make test.
  • Loading branch information
nlewycky committed Oct 14, 2020
1 parent 38ebdb9 commit 773ab17
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,11 @@ test-llvm = [

test-native = [
"native",
"test-generator/test-native",
]
test-jit = [
"jit",
"test-generator/test-jit",
]

# Disable trap asserts in the WAST tests. This is useful for running the tests in a
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ build-capi-llvm:
# Testing #
###########

test: $(foreach compiler,$(compilers),test-$(compiler)-jit) test-packages test-examples test-deprecated
test: $(foreach compiler,$(compilers),test-$(compiler)-jit test-$(compiler)-native) test-packages test-examples test-deprecated

# Singlepass and native engine don't work together, this rule does nothing.
test-singlepass-native:
Expand All @@ -104,13 +104,13 @@ test-singlepass-jit:
cargo test --release $(compiler_features) --features "test-singlepass test-jit"

test-cranelift-native:
cargo test --release $(compiler_features) --features "test-cranelift test-native"
cargo test --release $(compiler_features) --features "test-cranelift test-native test-no-traps"

test-cranelift-jit:
cargo test --release $(compiler_features) --features "test-cranelift test-jit"

test-llvm-native:
cargo test --release $(compiler_features) --features "test-llvm test-native"
cargo test --release $(compiler_features) --features "test-llvm test-native test-no-traps"

test-llvm-jit:
cargo test --release $(compiler_features) --features "test-llvm test-jit"
Expand Down
7 changes: 7 additions & 0 deletions tests/compilers/traps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fn test_trap_return() -> Result<()> {
Ok(())
}

#[cfg(not(feature = "test-no-traps"))]
#[test]
#[cfg_attr(feature = "test-singlepass", ignore)]
fn test_trap_trace() -> Result<()> {
Expand Down Expand Up @@ -117,6 +118,7 @@ fn test_trap_trace_cb() -> Result<()> {
Ok(())
}

#[cfg(not(feature = "test-no-traps"))]
#[test]
#[cfg_attr(feature = "test-singlepass", ignore)]
fn test_trap_stack_overflow() -> Result<()> {
Expand Down Expand Up @@ -148,6 +150,7 @@ fn test_trap_stack_overflow() -> Result<()> {
Ok(())
}

#[cfg(not(feature = "test-no-traps"))]
#[test]
#[cfg_attr(any(feature = "test-singlepass", feature = "test-llvm"), ignore)]
fn trap_display_pretty() -> Result<()> {
Expand Down Expand Up @@ -181,6 +184,7 @@ RuntimeError: unreachable
Ok(())
}

#[cfg(not(feature = "test-no-traps"))]
#[test]
#[cfg_attr(any(feature = "test-singlepass", feature = "test-llvm"), ignore)]
fn trap_display_multi_module() -> Result<()> {
Expand Down Expand Up @@ -386,6 +390,7 @@ fn mismatched_arguments() -> Result<()> {
Ok(())
}

#[cfg(not(feature = "test-no-traps"))]
#[test]
#[cfg_attr(any(feature = "test-singlepass", feature = "test-llvm"), ignore)]
fn call_signature_mismatch() -> Result<()> {
Expand Down Expand Up @@ -417,6 +422,7 @@ RuntimeError: indirect call type mismatch
Ok(())
}

#[cfg(not(feature = "test-no-traps"))]
#[test]
#[cfg_attr(any(feature = "test-singlepass", feature = "test-llvm"), ignore)]
fn start_trap_pretty() -> Result<()> {
Expand Down Expand Up @@ -449,6 +455,7 @@ RuntimeError: unreachable
Ok(())
}

#[cfg(not(feature = "test-no-traps"))]
#[test]
fn present_after_module_drop() -> Result<()> {
let store = get_store();
Expand Down
4 changes: 4 additions & 0 deletions tests/ignores.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ singlepass on windows # Singlepass is not yet supported on Windows
cranelift::spec::skip_stack_guard_page on darwin
llvm::spec::skip_stack_guard_page on darwin

# TODO: traps in native engine
cranelift::spec::linking on native
llvm::spec::linking on native

# Frontends

## WASI
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/test-generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ publish = false
[dependencies]
anyhow = "1.0"
target-lexicon = "0.10"

[features]
test-native = []
test-jit = []
13 changes: 11 additions & 2 deletions tests/lib/test-generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ pub fn build_ignores_from_textfile(path: PathBuf) -> anyhow::Result<Ignores> {
let file = File::open(path)?;
let reader = BufReader::new(file);
let host = Triple::host().to_string();
let engine = if cfg!(feature = "test-native") {
Some("native")
} else if cfg!(feature = "test-jit") {
Some("jit")
} else {
None
};
for line in reader.lines() {
let line = line.unwrap();
// If the line has a `#` we discard all the content that comes after
Expand Down Expand Up @@ -75,8 +82,10 @@ pub fn build_ignores_from_textfile(path: PathBuf) -> anyhow::Result<Ignores> {
}

// We skip the ignore if doesn't apply to the current
// host target
if target.map(|t| !host.contains(&t)).unwrap_or(false) {
// host target or engine
if target.clone().map(|t| !host.contains(&t)).unwrap_or(false)
&& target.clone() != engine.map(str::to_string)
{
continue;
}

Expand Down

0 comments on commit 773ab17

Please sign in to comment.