Skip to content

Commit

Permalink
Move most wasmtime tests into one test suite (#1544)
Browse files Browse the repository at this point in the history
* Move most wasmtime tests into one test suite

This commit moves most wasmtime tests into a single test suite which
gets compiled into one executable instead of having lots of test
executables. The goal here is to reduce disk space on CI, and this
should be achieved by having fewer executables which means fewer copies
of `libwasmtime.rlib` linked across binaries on the system. More
importantly though this means that DWARF debug information should only
be in one executable rather than duplicated across many.

* Share more build caches

Globally set `RUSTFLAGS` to `-Dwarnings` instead of individually so all
build steps share the same value.

* Allow some dead code in cranelift-codegen

Prevents having to fix all warnings for all possible feature
combinations, only the main ones which come up.

* Update some debug file paths
  • Loading branch information
alexcrichton authored Apr 17, 2020
1 parent a524f58 commit 4c82da4
Show file tree
Hide file tree
Showing 39 changed files with 48 additions and 33 deletions.
3 changes: 3 additions & 0 deletions .github/actions/install-rust/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ child_process.execFileSync('rustup', ['set', 'profile', 'minimal']);
child_process.execFileSync('rustup', ['update', toolchain, '--no-self-update']);
child_process.execFileSync('rustup', ['default', toolchain]);

// Deny warnings on CI to keep our code warning-free as it lands in-tree
console.log(`::set-env name=RUSTFLAGS::-D warnings`);

// Save disk space by avoiding incremental compilation, and also we don't use
// any caching so incremental wouldn't help anyway.
console.log(`::set-env name=CARGO_INCREMENTAL::0`);
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,12 @@ jobs:
- run: cargo test --features test-programs/test_programs --all --exclude lightbeam -- --nocapture
env:
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"

# Test debug (DWARF) related functionality.
- run: cargo test test_debug_dwarf_ -- --ignored --nocapture --test-threads 1
if: matrix.os == 'ubuntu-latest'
env:
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"

# Build and test lightbeam if we're using the nightly toolchain. Note that
# Lightbeam tests fail right now, but we don't want to block on that.
Expand Down
5 changes: 1 addition & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ libc = "0.2.60"
rayon = "1.2.1"

[dev-dependencies]
wasmtime-runtime = { path = "crates/runtime", version = "0.15.0" }
filecheck = "0.5.0"
more-asserts = "0.2.1"
test-programs = { path = "crates/test-programs" }
tempfile = "3.1.0"
filecheck = "0.5.0"
test-programs = { path = "crates/test-programs" }
wasmtime-fuzzing = { path = "crates/fuzzing" }
wasmtime-runtime = { path = "crates/runtime" }

[build-dependencies]
anyhow = "1.0.19"
Expand Down Expand Up @@ -79,3 +80,7 @@ vtune = ["wasmtime/vtune"]

[badges]
maintenance = { status = "actively-developed" }

[[test]]
name = "host_segfault"
harness = false
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ fn write_testsuite_tests(
writeln!(out, "fn r#{}() -> anyhow::Result<()> {{", &testname)?;
writeln!(
out,
"crate::run_wast(r#\"{}\"#, crate::Strategy::{})",
"crate::wast::run_wast(r#\"{}\"#, crate::wast::Strategy::{})",
path.display(),
strategy
)?;
Expand Down
7 changes: 7 additions & 0 deletions cranelift/codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
)
)]
#![no_std]
// Various bits and pieces of this crate might only be used for one platform or
// another, but it's not really too useful to learn about that all the time. On
// CI we build at least one version of this crate with `--features all-arch`
// which means we'll always detect truly dead code, otherwise if this is only
// built for one platform we don't have to worry too much about trimming
// everything down.
#![cfg_attr(not(feature = "all-arch"), allow(dead_code))]

#[allow(unused_imports)] // #[macro_use] is required for no_std
#[macro_use]
Expand Down
12 changes: 1 addition & 11 deletions crates/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@ wat = { version = "1.0.10", optional = true }
winapi = "0.3.7"

[dev-dependencies]
# for wasmtime.rs
wasi-common = { path = "../wasi-common", version = "0.15.0" }
pretty_env_logger = "0.4.0"
rayon = "1.2.1"
file-per-thread-logger = "0.1.1"
wat = "1.0.10"
tempfile = "3.1"
tempfile = "3.0"

[badges]
maintenance = { status = "actively-developed" }
Expand All @@ -53,7 +47,3 @@ jitdump = ["wasmtime-jit/jitdump"]

# Enables support for the `VTune` profiler
vtune = ["wasmtime-jit/vtune"]

[[test]]
name = "host-segfault"
harness = false
5 changes: 2 additions & 3 deletions crates/fuzzing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ pub(crate) fn init_fuzzing() {
INIT.call_once(|| {
let _ = env_logger::try_init();

rayon::ThreadPoolBuilder::new()
let _ = rayon::ThreadPoolBuilder::new()
.num_threads(1)
.build_global()
.expect("should only initialize the rayon thread pool once!");
.build_global();
})
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/debug/lldb.rs → tests/all/debug/lldb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub fn test_debug_dwarf_lldb() -> Result<()> {
let output = lldb_with_script(
&[
"-g",
"tests/debug/testsuite/fib-wasm.wasm",
"tests/all/debug/testsuite/fib-wasm.wasm",
"--invoke",
"fib",
"3",
Expand Down Expand Up @@ -105,7 +105,7 @@ pub fn test_debug_dwarf_ptr() -> Result<()> {
"-g",
"--opt-level",
"0",
"tests/debug/testsuite/reverse-str.wasm",
"tests/all/debug/testsuite/reverse-str.wasm",
],
r#"b reverse-str.c:9
r
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/debug/translate.rs → tests/all/debug/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn check_wasm(wasm_path: &str, directives: &str) -> Result<()> {
))]
fn test_debug_dwarf_translate() -> Result<()> {
check_wasm(
"tests/debug/testsuite/fib-wasm.wasm",
"tests/all/debug/testsuite/fib-wasm.wasm",
r##"
check: DW_TAG_compile_unit
# We have "fib" function
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions crates/fuzzing/tests/regressions.rs → tests/all/fuzzing.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
//! Regression tests for bugs found via fuzzing.
//!
//! The `#[test]` goes in here, the Wasm binary goes in
//! `./regressions/some-descriptive-name.wasm`, and then the `#[test]` should
//! `./fuzzing/some-descriptive-name.wasm`, and then the `#[test]` should
//! use the Wasm binary by including it via
//! `include_bytes!("./regressions/some-descriptive-name.wasm")`.
//! `include_bytes!("./fuzzing/some-descriptive-name.wasm")`.
use wasmtime::{Config, Strategy};
use wasmtime_fuzzing::oracles;

#[test]
fn instantiate_empty_module() {
let data = wat::parse_str(include_str!("./regressions/empty.wat")).unwrap();
let data = wat::parse_str(include_str!("./fuzzing/empty.wat")).unwrap();
oracles::instantiate(&data, Strategy::Auto);
}

#[test]
fn instantiate_empty_module_with_memory() {
let data = wat::parse_str(include_str!("./regressions/empty_with_memory.wat")).unwrap();
let data = wat::parse_str(include_str!("./fuzzing/empty_with_memory.wat")).unwrap();
oracles::instantiate(&data, Strategy::Auto);
}

#[test]
fn instantiate_module_that_compiled_to_x64_has_register_32() {
let mut config = Config::new();
config.debug_info(true);
let data = wat::parse_str(include_str!("./regressions/issue694.wat")).unwrap();
let data = wat::parse_str(include_str!("./fuzzing/issue694.wat")).unwrap();
oracles::instantiate_with_config(&data, config);
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This directory contains `.wasm` binaries generated during fuzzing that uncovered
a bug, and which we now use as regression tests in `../regressions.rs`.
a bug, and which we now use as regression tests in `../fuzzing.rs`.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions tests/all/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
mod cli_tests;
mod custom_signal_handler;
mod debug;
mod externals;
mod func;
mod fuzzing;
mod globals;
mod import_calling_export;
mod import_indexes;
mod instance;
mod invoke_func_via_table;
mod linker;
mod memory_creator;
mod name;
mod traps;
mod wast;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 4c82da4

Please sign in to comment.