Skip to content

Commit

Permalink
machinst x64: add testing to the CI;
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjbvr committed Jul 30, 2020
1 parent 39ea641 commit 79abcdb
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 2 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/main.yml
Expand Up @@ -269,6 +269,45 @@ jobs:
env:
RUST_BACKTRACE: 1

# Perform all tests (debug mode) for `wasmtime` with the experimental x64
# backend. This runs on the nightly channel of Rust (because of issues with
# unifying Cargo features on stable) on Ubuntu.
test_x64:
name: Test x64 new backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: ./.github/actions/install-rust
with:
toolchain: nightly-2020-07-27
- uses: ./.github/actions/define-llvm-env

# Install wasm32 targets in order to build various tests throughout the
# repo
- run: rustup target add wasm32-wasi
- run: rustup target add wasm32-unknown-unknown

# Build and test all features except for lightbeam
- run: |
cargo \
-Zfeatures=all -Zpackage-features \
test \
--features test-programs/test_programs \
--features experimental_x64 \
--all \
--exclude lightbeam \
--exclude peepmatic \
--exclude peepmatic-automata \
--exclude peepmatic-fuzzing \
--exclude peepmatic-macro \
--exclude peepmatic-runtime \
--exclude peepmatic-test
env:
RUST_BACKTRACE: 1
# Verify that cranelift's code generation is deterministic
meta_determinist_check:
name: Meta deterministic check
Expand Down
22 changes: 21 additions & 1 deletion build.rs
Expand Up @@ -151,7 +151,12 @@ fn write_testsuite_tests(
let testname = extract_name(path);

writeln!(out, "#[test]")?;
if ignore(testsuite, &testname, strategy) {
if experimental_x64_should_panic(testsuite, &testname, strategy) {
writeln!(
out,
r#"#[cfg_attr(feature = "experimental_x64", should_panic)]"#
)?;
} else if ignore(testsuite, &testname, strategy) {
writeln!(out, "#[ignore]")?;
}
writeln!(out, "fn r#{}() {{", &testname)?;
Expand All @@ -167,6 +172,21 @@ fn write_testsuite_tests(
Ok(())
}

/// For experimental_x64 backend features that are not supported yet, mark tests as panicking, so
/// they stop "passing" once the features are properly implemented.
fn experimental_x64_should_panic(testsuite: &str, testname: &str, strategy: &str) -> bool {
if !cfg!(feature = "experimental_x64") || strategy != "Cranelift" {
return false;
}

match (testsuite, testname) {
("simd", _) => return true,
_ => {}
}

false
}

/// Ignore tests that aren't supported yet.
fn ignore(testsuite: &str, testname: &str, strategy: &str) -> bool {
let target = env::var("TARGET").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/isa/x64/lower.rs
Expand Up @@ -347,7 +347,7 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
};

match op {
Opcode::Iconst | Opcode::Null => {
Opcode::Iconst | Opcode::Bconst | Opcode::Null => {
if let Some(w64) = iri_to_u64_imm(ctx, insn) {
let dst_is_64 = w64 > 0x7fffffff;
let dst = output_to_reg(ctx, outputs[0]);
Expand Down
2 changes: 2 additions & 0 deletions cranelift/codegen/src/isa/x86/unwind/systemv.rs
Expand Up @@ -397,6 +397,7 @@ mod tests {
use target_lexicon::triple;

#[test]
#[cfg_attr(feature = "x64", should_panic)] // TODO #2079
fn test_simple_func() {
let isa = lookup(triple!("x86_64"))
.expect("expect x86 ISA")
Expand Down Expand Up @@ -439,6 +440,7 @@ mod tests {
}

#[test]
#[cfg_attr(feature = "x64", should_panic)] // TODO #2079
fn test_multi_return_func() {
let isa = lookup(triple!("x86_64"))
.expect("expect x86 ISA")
Expand Down
3 changes: 3 additions & 0 deletions cranelift/codegen/src/isa/x86/unwind/winx64.rs
Expand Up @@ -158,6 +158,7 @@ mod tests {
}

#[test]
#[cfg_attr(feature = "x64", should_panic)] // TODO #2079
fn test_small_alloc() {
let isa = lookup(triple!("x86_64"))
.expect("expect x86 ISA")
Expand Down Expand Up @@ -215,6 +216,7 @@ mod tests {
}

#[test]
#[cfg_attr(feature = "x64", should_panic)] // TODO #2079
fn test_medium_alloc() {
let isa = lookup(triple!("x86_64"))
.expect("expect x86 ISA")
Expand Down Expand Up @@ -276,6 +278,7 @@ mod tests {
}

#[test]
#[cfg_attr(feature = "x64", should_panic)] // TODO #2079
fn test_large_alloc() {
let isa = lookup(triple!("x86_64"))
.expect("expect x86 ISA")
Expand Down
1 change: 1 addition & 0 deletions cranelift/tests/filetests.rs
@@ -1,4 +1,5 @@
#[test]
#[cfg_attr(feature = "experimental_x64", should_panic)] // TODO #2079
fn filetests() {
// Run all the filetests in the following directories.
cranelift_filetests::run(false, false, &["filetests".into(), "docs".into()])
Expand Down
6 changes: 6 additions & 0 deletions crates/wiggle/macro/Cargo.toml
Expand Up @@ -14,6 +14,12 @@ include = ["src/**/*", "LICENSE"]
proc-macro = true
test = false

# This has been added to make testing of the experimental_x64 feature possible,
# working around a Cargo nightly bug: once
# https://github.com/rust-lang/cargo/issues/8563 has been fixed, we should be
# able to revert it.
doctest = false

[dependencies]
wiggle-generate = { path = "../generate", version = "0.19.0" }
witx = { path = "../../wasi-common/WASI/tools/witx", version = "0.8.5" }
Expand Down
1 change: 1 addition & 0 deletions tests/all/gc.rs
Expand Up @@ -373,6 +373,7 @@ fn gc_during_gc_when_passing_refs_into_wasm() -> anyhow::Result<()> {
}

#[test]
#[cfg_attr(feature = "experimental_x64", ignore)] // TODO #2079 investigate.
fn gc_during_gc_from_many_table_gets() -> anyhow::Result<()> {
let (store, module) = ref_types_module(
r#"
Expand Down
1 change: 1 addition & 0 deletions tests/all/iloop.rs
Expand Up @@ -99,6 +99,7 @@ fn loop_interrupt_from_afar() -> anyhow::Result<()> {
}

#[test]
#[cfg_attr(feature = "experimental_x64", ignore)] // TODO #2079 interrupts in wasmtime
fn function_interrupt_from_afar() -> anyhow::Result<()> {
// Create an instance which calls an imported function on each iteration of
// the loop so we can count the number of loop iterations we've executed so
Expand Down
1 change: 1 addition & 0 deletions tests/all/stack_overflow.rs
Expand Up @@ -2,6 +2,7 @@ use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
use wasmtime::*;

#[test]
#[cfg_attr(feature = "experimental_x64", ignore)] // TODO #2079 require probe stacks
fn host_always_has_some_stack() -> anyhow::Result<()> {
static HITS: AtomicUsize = AtomicUsize::new(0);
// assume hosts always have at least 512k of stack
Expand Down
11 changes: 11 additions & 0 deletions tests/all/traps.rs
Expand Up @@ -32,6 +32,7 @@ fn test_trap_return() -> Result<()> {

#[test]
#[cfg_attr(target_arch = "aarch64", ignore)] // FIXME(#1642)
#[cfg_attr(feature = "experimental_x64", ignore)] // FIXME(#2078)
fn test_trap_trace() -> Result<()> {
let store = Store::default();
let wat = r#"
Expand Down Expand Up @@ -74,6 +75,7 @@ fn test_trap_trace() -> Result<()> {

#[test]
#[cfg_attr(target_arch = "aarch64", ignore)] // FIXME(#1642)
#[cfg_attr(feature = "experimental_x64", ignore)] // FIXME(#2078)
fn test_trap_trace_cb() -> Result<()> {
let store = Store::default();
let wat = r#"
Expand Down Expand Up @@ -110,6 +112,7 @@ fn test_trap_trace_cb() -> Result<()> {

#[test]
#[cfg_attr(target_arch = "aarch64", ignore)] // FIXME(#1642)
#[cfg_attr(feature = "experimental_x64", ignore)] // FIXME(#2078)
fn test_trap_stack_overflow() -> Result<()> {
let store = Store::default();
let wat = r#"
Expand Down Expand Up @@ -142,6 +145,7 @@ fn test_trap_stack_overflow() -> Result<()> {

#[test]
#[cfg_attr(target_arch = "aarch64", ignore)] // FIXME(#1642)
#[cfg_attr(feature = "experimental_x64", ignore)] // FIXME(#2078)
fn trap_display_pretty() -> Result<()> {
let store = Store::default();
let wat = r#"
Expand Down Expand Up @@ -174,6 +178,7 @@ wasm backtrace:

#[test]
#[cfg_attr(target_arch = "aarch64", ignore)] // FIXME(#1642)
#[cfg_attr(feature = "experimental_x64", ignore)] // FIXME(#2078)
fn trap_display_multi_module() -> Result<()> {
let store = Store::default();
let wat = r#"
Expand Down Expand Up @@ -219,6 +224,7 @@ wasm backtrace:

#[test]
#[cfg_attr(target_arch = "aarch64", ignore)] // FIXME(#1642)
#[cfg_attr(feature = "experimental_x64", ignore)] // FIXME(#2078)
fn trap_start_function_import() -> Result<()> {
let store = Store::default();
let binary = wat::parse_str(
Expand Down Expand Up @@ -246,6 +252,7 @@ fn trap_start_function_import() -> Result<()> {

#[test]
#[cfg_attr(target_arch = "aarch64", ignore)] // FIXME(#1642)
#[cfg_attr(feature = "experimental_x64", ignore)] // FIXME(#2078)
fn rust_panic_import() -> Result<()> {
let store = Store::default();
let binary = wat::parse_str(
Expand Down Expand Up @@ -291,6 +298,7 @@ fn rust_panic_import() -> Result<()> {

#[test]
#[cfg_attr(target_arch = "aarch64", ignore)] // FIXME(#1642)
#[cfg_attr(feature = "experimental_x64", ignore)] // FIXME(#2078)
fn rust_panic_start_function() -> Result<()> {
let store = Store::default();
let binary = wat::parse_str(
Expand Down Expand Up @@ -325,6 +333,7 @@ fn rust_panic_start_function() -> Result<()> {

#[test]
#[cfg_attr(target_arch = "aarch64", ignore)] // FIXME(#1642)
#[cfg_attr(feature = "experimental_x64", ignore)] // FIXME(#2078)
fn mismatched_arguments() -> Result<()> {
let store = Store::default();
let binary = wat::parse_str(
Expand Down Expand Up @@ -357,6 +366,7 @@ fn mismatched_arguments() -> Result<()> {

#[test]
#[cfg_attr(target_arch = "aarch64", ignore)] // FIXME(#1642)
#[cfg_attr(feature = "experimental_x64", ignore)] // FIXME(#2078)
fn call_signature_mismatch() -> Result<()> {
let store = Store::default();
let binary = wat::parse_str(
Expand Down Expand Up @@ -388,6 +398,7 @@ fn call_signature_mismatch() -> Result<()> {

#[test]
#[cfg_attr(target_arch = "aarch64", ignore)] // FIXME(#1642)
#[cfg_attr(feature = "experimental_x64", ignore)] // FIXME(#2078)
fn start_trap_pretty() -> Result<()> {
let store = Store::default();
let wat = r#"
Expand Down

0 comments on commit 79abcdb

Please sign in to comment.