Skip to content

Commit

Permalink
Update how tests are skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Jan 6, 2025
1 parent c512743 commit c904df2
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 21 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ wasmtime-test-macros = { path = "crates/test-macros" }
pulley-interpreter = { workspace = true, features = ["disas"] }
wasmtime-wast-util = { path = 'crates/wast-util' }
wasm-encoder = { workspace = true }
cranelift-native = { workspace = true }

[target.'cfg(windows)'.dev-dependencies]
windows-sys = { workspace = true, features = ["Win32_System_Memory"] }
Expand Down
9 changes: 8 additions & 1 deletion cranelift/filetests/src/function_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,6 @@ extern "C" fn __cranelift_x86_pshufb(a: __m128i, b: __m128i) -> __m128i {
}

#[cfg(test)]
#[cfg(target_pointer_width = "64")] // 32-bit platforms not supported at this time
mod test {
use super::*;
use cranelift_reader::{parse_functions, parse_test, ParseOptions};
Expand All @@ -622,6 +621,10 @@ mod test {

#[test]
fn nop() {
// Skip this test when cranelift doesn't support the native platform.
if cranelift_native::builder().is_err() {
return;
}
let code = String::from(
"
test run
Expand Down Expand Up @@ -656,6 +659,10 @@ mod test {

#[test]
fn trampolines() {
// Skip this test when cranelift doesn't support the native platform.
if cranelift_native::builder().is_err() {
return;
}
let function = parse(
"
function %test(f32, i8, i64x2, i8) -> f32x4, i64 {
Expand Down
4 changes: 3 additions & 1 deletion cranelift/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,14 @@ fn create_target_isa(isa_spec: &IsaSpec) -> Result<OwnedTargetIsa> {
}

#[cfg(test)]
#[cfg(target_pointer_width = "64")] // 32-bit platforms not supported yet
mod test {
use super::*;

#[test]
fn nop() {
if cranelift_native::builder().is_err() {
return;
}
let code = String::from(
"
function %test() -> i8 {
Expand Down
7 changes: 4 additions & 3 deletions crates/cranelift/src/debug/transform/address_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ impl AddressTransform {
}

#[cfg(test)]
#[cfg(target_pointer_width = "64")]
pub fn mock(
module_map: &wasmtime_environ::PrimaryMap<
wasmtime_environ::DefinedFuncIndex,
Expand Down Expand Up @@ -661,8 +660,6 @@ impl AddressTransform {
}

#[cfg(test)]
#[cfg(target_pointer_width = "64")] // cranelift doesn't support native 32-bit
// platforms
mod tests {
use super::{build_function_lookup, get_wasm_code_offset, AddressTransform};
use crate::{CompiledFunctionMetadata, FunctionAddressMap};
Expand Down Expand Up @@ -787,6 +784,10 @@ mod tests {

#[test]
fn test_addr_translate() {
// Ignore this test if cranelift doesn't support the native platform.
if cranelift_native::builder().is_err() {
return;
}
let func = CompiledFunctionMetadata {
address_map: create_simple_func(11),
..Default::default()
Expand Down
7 changes: 5 additions & 2 deletions crates/cranelift/src/debug/transform/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,6 @@ impl std::fmt::Debug for JumpTargetMarker {

#[cfg(test)]
#[expect(trivial_numeric_casts, reason = "macro-generated code")]
#[cfg(target_pointer_width = "64")] // cranelift doesn't support native 32-bit
// platforms
mod tests {
use super::{
compile_expression, AddressTransform, CompiledExpression, CompiledExpressionPart,
Expand Down Expand Up @@ -1224,6 +1222,11 @@ mod tests {
use super::ValueLabelRangesBuilder;
use crate::debug::ModuleMemoryOffset;

// Ignore this test if cranelift doesn't support the native platform.
if cranelift_native::builder().is_err() {
return;
}

let addr_tr = create_mock_address_transform();
let (value_ranges, value_labels) = create_mock_value_ranges();
let fi = FunctionFrameInfo {
Expand Down
5 changes: 4 additions & 1 deletion tests/all/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2073,8 +2073,11 @@ after empty
}

#[test]
#[cfg(target_pointer_width = "64")] // cranelift only supports 64-bit platforms
fn settings_command() -> Result<()> {
// Skip this test on platforms that Cranelift doesn't support.
if cranelift_native::builder().is_err() {
return Ok(());
}
let output = run_wasmtime(&["settings"])?;
assert!(output.contains("Cranelift settings for target"));
Ok(())
Expand Down
17 changes: 6 additions & 11 deletions tests/all/gc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use super::ref_types_module;
use super::skip_pooling_allocator_tests;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering::SeqCst};
use std::sync::Arc;
use wasmtime::*;
Expand Down Expand Up @@ -280,11 +279,9 @@ fn global_drops_externref() -> Result<()> {
let _ = env_logger::try_init();
test_engine(&Engine::default())?;

if !skip_pooling_allocator_tests() {
test_engine(&Engine::new(
Config::new().allocation_strategy(InstanceAllocationStrategy::pooling()),
)?)?;
}
let mut config = Config::new();
config.allocation_strategy(crate::small_pool_config());
test_engine(&Engine::new(&config)?)?;

return Ok(());

Expand Down Expand Up @@ -331,11 +328,9 @@ fn table_drops_externref() -> Result<()> {
let _ = env_logger::try_init();
test_engine(&Engine::default())?;

if !skip_pooling_allocator_tests() {
test_engine(&Engine::new(
Config::new().allocation_strategy(InstanceAllocationStrategy::pooling()),
)?)?;
}
let mut config = Config::new();
config.allocation_strategy(crate::small_pool_config());
test_engine(&Engine::new(&config)?)?;

return Ok(());

Expand Down
2 changes: 1 addition & 1 deletion tests/all/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub(crate) fn skip_pooling_allocator_tests() -> bool {
// There are a couple of issues when running the pooling allocator tests under QEMU:
// - high memory usage that may exceed the limits imposed by the environment (e.g. CI)
// - https://github.com/bytecodealliance/wasmtime/pull/2518#issuecomment-747280133
cfg!(target_pointer_width = "32") || std::env::var("WASMTIME_TEST_NO_HOG_MEMORY").is_ok()
std::env::var("WASMTIME_TEST_NO_HOG_MEMORY").is_ok()
}

/// Get the default pooling allocator configuration for tests, which is a
Expand Down
6 changes: 5 additions & 1 deletion tests/host_segfault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,14 @@ fn run_test(name: &str, stack_overflow: StackOverflow) {
}

match stack_overflow {
// If the host stack overflows then the result should always indicate a
// stack overflow. If the guest stack overflows then that won't actually
// trigger an overflow when Cranelift doesn't have native support
// because Pulley is used in that case.
StackOverflow::Host | StackOverflow::Wasm => {
let native_stack_overflow = is_stack_overflow(&output.status, &stderr);
let expect_native_overflow =
stack_overflow == StackOverflow::Host || cfg!(target_pointer_width = "64");
stack_overflow == StackOverflow::Host || cranelift_native::builder().is_ok();

if native_stack_overflow == expect_native_overflow {
assert!(
Expand Down

0 comments on commit c904df2

Please sign in to comment.