Skip to content

Commit cb93726

Browse files
authored
Enable more tests on AArch64 (#2994)
Copyright (c) 2021, Arm Limited.
1 parent 443eb7a commit cb93726

9 files changed

Lines changed: 44 additions & 28 deletions

File tree

build.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,9 @@ fn write_testsuite_tests(
157157
writeln!(out, "#[test]")?;
158158
if x64_should_panic(testsuite, &testname, strategy) {
159159
writeln!(out, r#"#[should_panic]"#)?;
160-
} else if ignore(testsuite, &testname, strategy) {
160+
// Ignore when using QEMU for running tests (limited memory).
161+
} else if ignore(testsuite, &testname, strategy) || (pooling && platform_is_emulated()) {
161162
writeln!(out, "#[ignore]")?;
162-
} else if pooling {
163-
// Ignore on aarch64 due to using QEMU for running tests (limited memory)
164-
writeln!(out, r#"#[cfg_attr(target_arch = "aarch64", ignore)]"#)?;
165163
}
166164

167165
writeln!(
@@ -254,3 +252,7 @@ fn platform_is_x64() -> bool {
254252
fn platform_is_s390x() -> bool {
255253
env::var("CARGO_CFG_TARGET_ARCH").unwrap() == "s390x"
256254
}
255+
256+
fn platform_is_emulated() -> bool {
257+
env::var("WASMTIME_TEST_NO_HOG_MEMORY").unwrap_or_default() == "1"
258+
}

crates/debug/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ fn ensure_supported_elf_format(bytes: &[u8]) -> Result<Endianness, Error> {
116116
let e = header.endian().unwrap();
117117

118118
match header.e_machine.get(e) {
119+
EM_AARCH64 => (),
119120
EM_X86_64 => (),
120121
EM_S390 => (),
121122
machine => {

crates/runtime/src/instance/allocator/pooling.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1666,10 +1666,14 @@ mod test {
16661666
);
16671667
}
16681668

1669-
#[cfg_attr(target_arch = "aarch64", ignore)] // https://github.com/bytecodealliance/wasmtime/pull/2518#issuecomment-747280133
16701669
#[cfg(all(unix, target_pointer_width = "64", feature = "async"))]
16711670
#[test]
16721671
fn test_stack_zeroed() -> Result<()> {
1672+
// https://github.com/bytecodealliance/wasmtime/pull/2518#issuecomment-747280133
1673+
if std::env::var("WASMTIME_TEST_NO_HOG_MEMORY").is_ok() {
1674+
return Ok(());
1675+
}
1676+
16731677
let allocator = PoolingInstanceAllocator::new(
16741678
PoolingAllocationStrategy::NextAvailable,
16751679
ModuleLimits {

crates/wasmtime/src/module/serialization.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,6 @@ mod test {
673673
Ok(())
674674
}
675675

676-
#[cfg(target_arch = "x86_64")]
677676
#[test]
678677
fn test_isa_flags_mismatch() -> Result<()> {
679678
let engine = Engine::default();

tests/all/func.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,6 @@ fn func_write_nothing() -> anyhow::Result<()> {
455455
}
456456

457457
#[test]
458-
// Note: Cranelift only supports refrerence types (used in the wasm in this
459-
// test) on x64.
460-
#[cfg(target_arch = "x86_64")]
461458
fn return_cross_store_value() -> anyhow::Result<()> {
462459
let wasm = wat::parse_str(
463460
r#"
@@ -490,9 +487,6 @@ fn return_cross_store_value() -> anyhow::Result<()> {
490487
}
491488

492489
#[test]
493-
// Note: Cranelift only supports refrerence types (used in the wasm in this
494-
// test) on x64.
495-
#[cfg(target_arch = "x86_64")]
496490
fn pass_cross_store_arg() -> anyhow::Result<()> {
497491
let mut config = Config::new();
498492
config.wasm_reference_types(true);

tests/all/fuzzing.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ fn instantiate_empty_module_with_memory() {
2121
}
2222

2323
#[test]
24-
#[cfg_attr(target_arch = "aarch64", ignore)] // FIXME(#1523)
2524
fn instantiate_module_that_compiled_to_x64_has_register_32() {
2625
let mut config = Config::new();
2726
config.debug_info(true);

tests/all/gc.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use super::ref_types_module;
2+
use super::skip_pooling_allocator_tests;
23
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering::SeqCst};
34
use std::sync::Arc;
45
use wasmtime::*;
@@ -237,9 +238,12 @@ fn drop_externref_via_table_set() -> anyhow::Result<()> {
237238
#[test]
238239
fn global_drops_externref() -> anyhow::Result<()> {
239240
test_engine(&Engine::default())?;
240-
test_engine(&Engine::new(
241-
Config::new().allocation_strategy(InstanceAllocationStrategy::pooling()),
242-
)?)?;
241+
242+
if !skip_pooling_allocator_tests() {
243+
test_engine(&Engine::new(
244+
Config::new().allocation_strategy(InstanceAllocationStrategy::pooling()),
245+
)?)?;
246+
}
243247

244248
return Ok(());
245249

@@ -284,9 +288,12 @@ fn global_drops_externref() -> anyhow::Result<()> {
284288
#[cfg(not(feature = "old-x86-backend"))] // uses atomic instrs not implemented here
285289
fn table_drops_externref() -> anyhow::Result<()> {
286290
test_engine(&Engine::default())?;
287-
test_engine(&Engine::new(
288-
Config::new().allocation_strategy(InstanceAllocationStrategy::pooling()),
289-
)?)?;
291+
292+
if !skip_pooling_allocator_tests() {
293+
test_engine(&Engine::new(
294+
Config::new().allocation_strategy(InstanceAllocationStrategy::pooling()),
295+
)?)?;
296+
}
290297

291298
return Ok(());
292299

tests/all/main.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ mod debug;
55
mod externals;
66
mod fuel;
77
mod func;
8+
mod funcref;
89
mod fuzzing;
10+
mod gc;
911
mod globals;
1012
mod host_funcs;
1113
mod iloop;
@@ -29,14 +31,7 @@ mod table;
2931
mod traps;
3032
mod wast;
3133

32-
// TODO(#1886): Cranelift only supports reference types on x64.
33-
#[cfg(target_arch = "x86_64")]
34-
mod funcref;
35-
#[cfg(target_arch = "x86_64")]
36-
mod gc;
37-
3834
/// A helper to compile a module in a new store with reference types enabled.
39-
#[cfg(target_arch = "x86_64")]
4035
pub(crate) fn ref_types_module(
4136
source: &str,
4237
) -> anyhow::Result<(wasmtime::Store<()>, wasmtime::Module)> {
@@ -54,3 +49,11 @@ pub(crate) fn ref_types_module(
5449

5550
Ok((store, module))
5651
}
52+
53+
/// A helper determining whether the pooling allocator tests should be skipped.
54+
pub(crate) fn skip_pooling_allocator_tests() -> bool {
55+
// There are a couple of issues when running the pooling allocator tests under QEMU:
56+
// - high memory usage that may exceed the limits imposed by the environment (e.g. CI)
57+
// - https://github.com/bytecodealliance/wasmtime/pull/2518#issuecomment-747280133
58+
std::env::var("WASMTIME_TEST_NO_HOG_MEMORY").is_ok()
59+
}

tests/all/pooling_allocator.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use super::skip_pooling_allocator_tests;
12
use anyhow::Result;
23
use wasmtime::*;
34

@@ -187,8 +188,11 @@ fn memory_guard_page_trap() -> Result<()> {
187188
}
188189

189190
#[test]
190-
#[cfg_attr(target_arch = "aarch64", ignore)] // https://github.com/bytecodealliance/wasmtime/pull/2518#issuecomment-747280133
191191
fn memory_zeroed() -> Result<()> {
192+
if skip_pooling_allocator_tests() {
193+
return Ok(());
194+
}
195+
192196
let mut config = Config::new();
193197
config.allocation_strategy(InstanceAllocationStrategy::Pooling {
194198
strategy: PoolingAllocationStrategy::NextAvailable,
@@ -357,8 +361,11 @@ fn table_init() -> Result<()> {
357361
}
358362

359363
#[test]
360-
#[cfg_attr(target_arch = "aarch64", ignore)] // https://github.com/bytecodealliance/wasmtime/pull/2518#issuecomment-747280133
361364
fn table_zeroed() -> Result<()> {
365+
if skip_pooling_allocator_tests() {
366+
return Ok(());
367+
}
368+
362369
let mut config = Config::new();
363370
config.allocation_strategy(InstanceAllocationStrategy::Pooling {
364371
strategy: PoolingAllocationStrategy::NextAvailable,

0 commit comments

Comments
 (0)