Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Remove tests duplicated by existing `*.wast` tests (#15037)

Alex Crichtonc25ec14e5f2a
diff --git a/tests/all/component_model/async.rs b/tests/all/component_model/async.rs
index 02d65bfc47..d5c7c75010 100644
--- a/tests/all/component_model/async.rs
+++ b/tests/all/component_model/async.rs
@@ -14,47 +14,6 @@ use wasmtime::component::{TaskGroupHook, TaskGroupId};
use wasmtime::{Config, Engine, Store, StoreContextMut, Trap, component::*};
use wasmtime_component_util::REALLOC_AND_FREE;
-/// This is super::func::thunks, except with an async store.
-#[tokio::test]
-#[cfg_attr(miri, ignore)]
-async fn smoke() -> Result<()> {
- let component = r#"
- (component
- (core module $m
- (func (export "thunk"))
- (func (export "thunk-trap") unreachable)
- )
- (core instance $i (instantiate $m))
- (func (export "thunk")
- (canon lift (core func $i "thunk"))
- )
- (func (export "thunk-trap")
- (canon lift (core func $i "thunk-trap"))
- )
- )
- "#;
-
- let engine = super::async_engine();
- let component = Component::new(&engine, component)?;
- let mut store = Store::new(&engine, ());
- let instance = Linker::new(&engine)
- .instantiate_async(&mut store, &component)
- .await?;
-
- let thunk = instance.get_typed_func::<(), ()>(&mut store, "thunk")?;
-
- thunk.call_async(&mut store, ()).await?;
-
- let err = instance
- .get_typed_func::<(), ()>(&mut store, "thunk-trap")?
- .call_async(&mut store, ())
- .await
- .unwrap_err();
- assert_eq!(err.downcast::<Trap>()?, Trap::UnreachableCodeReached);
-
- Ok(())
-}
-
#[tokio::test(flavor = "current_thread")]
async fn run_concurrent_yields_during_high_priority_work() -> Result<()> {
const TASKS: usize = 256;
diff --git a/tests/all/component_model/func.rs b/tests/all/component_model/func.rs
index 8065ee5cb1..45ce954f92 100644
--- a/tests/all/component_model/func.rs
+++ b/tests/all/component_model/func.rs
@@ -538,40 +538,6 @@ fn floats() -> Result<()> {
Ok(())
}
-#[test]
-fn bools() -> Result<()> {
- let component = r#"
- (component
- (core module $m
- (func (export "pass") (param i32) (result i32) local.get 0)
- )
- (core instance $i (instantiate $m))
-
- (func (export "u32-to-bool") (param "a" u32) (result bool)
- (canon lift (core func $i "pass"))
- )
- (func (export "bool-to-u32") (param "a" bool) (result u32)
- (canon lift (core func $i "pass"))
- )
- )
- "#;
-
- let engine = super::engine();
- let component = Component::new(&engine, component)?;
- let mut store = Store::new(&engine, ());
- let instance = Linker::new(&engine).instantiate(&mut store, &component)?;
- let u32_to_bool = instance.get_typed_func::<(u32,), (bool,)>(&mut store, "u32-to-bool")?;
- let bool_to_u32 = instance.get_typed_func::<(bool,), (u32,)>(&mut store, "bool-to-u32")?;
-
- assert_eq!(bool_to_u32.call(&mut store, (false,))?, (0,));
- assert_eq!(bool_to_u32.call(&mut store, (true,))?, (1,));
- assert_eq!(u32_to_bool.call(&mut store, (0,))?, (false,));
- assert_eq!(u32_to_bool.call(&mut store, (1,))?, (true,));
- assert_eq!(u32_to_bool.call(&mut store, (2,))?, (true,));
-
- Ok(())
-}
-
#[test]
fn chars() -> Result<()> {
let component = r#"
diff --git a/tests/all/component_model/resources.rs b/tests/all/component_model/resources.rs
index 0ffbb482f1..6ebef706bd 100644
--- a/tests/all/component_model/resources.rs
+++ b/tests/all/component_model/resources.rs
@@ -214,41 +214,6 @@ fn resource_any() -> Result<()> {
Ok(())
}
-#[test]
-fn mismatch_intrinsics() -> Result<()> {
- let engine = super::engine();
- let c = Component::new(
- &engine,
- r#"
- (component
- (type $t' (resource (rep i32)))
- (type $u' (resource (rep i32)))
-
- (export $t "t" (type $t'))
- (export $u "u" (type $u'))
-
- ;; note the mismatch where this is an intrinsic for `u` but
- ;; we're typing it as `t`
- (core func $t_ctor (canon resource.new $u))
-
- (func (export "ctor") (param "x" u32) (result (own $t))
- (canon lift (core func $t_ctor)))
- )
- "#,
- )?;
-
- let mut store = Store::new(&engine, ());
- let i = Linker::new(&engine).instantiate(&mut store, &c)?;
- let ctor = i.get_typed_func::<(u32,), (ResourceAny,)>(&mut store, "ctor")?;
- assert_eq!(
- ctor.call(&mut store, (100,)).unwrap_err().to_string(),
- "handle index 1 used with the wrong type, expected guest-defined \
- resource but found a different guest-defined resource",
- );
-
- Ok(())
-}
-
#[test]
fn mismatch_resource_types() -> Result<()> {
let engine = super::engine();
@@ -729,47 +694,6 @@ fn reenter_during_import() -> Result<()> {
Ok(())
}
-#[test]
-fn active_borrows_at_end_of_call() -> Result<()> {
- let engine = super::engine();
- let c = Component::new(
- &engine,
- r#"
- (component
- (import "t" (type $t (sub resource)))
-
- (core module $m
- (func (export "f") (param i32))
- )
- (core instance $i (instantiate $m))
-
- (func (export "f") (param "x" (borrow $t))
- (canon lift (core func $i "f")))
- )
- "#,
- )?;
-
- struct MyType;
-
- let mut store = Store::new(&engine, ());
- let mut linker = Linker::new(&engine);
- linker
- .root()
- .resource("t", ResourceType::host::<MyType>(), |_, _| Ok(()))?;
- let i = linker.instantiate(&mut store, &c)?;
-
- let f = i.get_typed_func::<(&Resource<MyType>,), ()>(&mut store, "f")?;
-
- let resource = Resource::new_own(1);
- let err = f.call(&mut store, (&resource,)).unwrap_err();
- assert_eq!(
- err.to_string(),
- "borrow handles still remain at the end of the call",
- );
-
- Ok(())
-}
-
#[test]
fn thread_through_borrow() -> Result<()> {
let engine = super::engine();
diff --git a/tests/all/func.rs b/tests/all/func.rs
index 39a2f2e8e3..e76fdc9f8a 100644
--- a/tests/all/func.rs
+++ b/tests/all/func.rs
@@ -5,35 +5,6 @@ use wasmtime::bail;
use wasmtime::*;
use wasmtime_test_macros::wasmtime_test;
-#[wasmtime_test]
-#[cfg_attr(miri, ignore)]
-fn call_wasm_to_wasm(config: &mut Config) -> Result<()> {
- let wasm = wat::parse_str(
- r#"
- (module
- (func (result i32 i32 i32)
- i32.const 1
- i32.const 2
- i32.const 3
- )
- (func (export "run") (result i32 i32 i32)
- call 0
- )
- )
- "#,
- )?;
- let engine = Engine::new(&config)?;
- let mut store = Store::<()>::new(&engine, ());
- let module = Module::new(store.engine(), &wasm)?;
- let instance = Instance::new(&mut store, &module, &[])?;
- let func = instance
- .get_typed_func::<(), (i32, i32, i32)>(&mut store, "run")
- .unwrap();
- let results = func.call(&mut store, ())?;
- assert_eq!(results, (1, 2, 3));
- Ok(())
-}
-
#[wasmtime_test]
#[cfg_attr(miri, ignore)]
fn call_wasm_to_native(config: &mut Config) -> Result<()> {
diff --git a/tests/all/funcref.rs b/tests/all/funcref.rs
index 55508253f3..352d24353d 100644
--- a/tests/all/funcref.rs
+++ b/tests/all/funcref.rs
@@ -77,31 +77,6 @@ fn pass_funcref_in_and_out_of_wasm() -> wasmtime::Result<()> {
Ok(())
}
-#[test]
-#[cfg_attr(miri, ignore)]
-fn receive_null_funcref_from_wasm() -> wasmtime::Result<()> {
- let (mut store, module) = ref_types_module(
- false,
- r#"
- (module
- (func (export "get-null") (result funcref)
- ref.null func
- )
- )
- "#,
- )?;
-
- let instance = Instance::new(&mut store, &module, &[])?;
- let get_null = instance.get_func(&mut store, "get-null").unwrap();
-
- let mut results = [Val::I32(0)];
- get_null.call(&mut store, &[], &mut results)?;
- let result_func = results[0].unwrap_funcref();
- assert!(result_func.is_none());
-
- Ok(())
-}
-
#[test]
fn wrong_store() -> wasmtime::Result<()> {
let dropped = Arc::new(AtomicBool::new(false));
diff --git a/tests/all/instance.rs b/tests/all/instance.rs
index 3db93f11c1..312a9b160c 100644
--- a/tests/all/instance.rs
+++ b/tests/all/instance.rs
@@ -12,27 +12,6 @@ fn wrong_import_numbers() -> Result<()> {
Ok(())
}
-#[test]
-#[cfg_attr(miri, ignore)]
-fn initializes_linear_memory() -> Result<()> {
- // Test for https://github.com/bytecodealliance/wasmtime/issues/2784
- let wat = r#"
- (module
- (memory (export "memory") 2)
- (data (i32.const 0) "Hello World!")
- )"#;
- let module = Module::new(&Engine::default(), wat)?;
-
- let mut store = Store::new(module.engine(), ());
- let instance = Instance::new(&mut store, &module, &[])?;
- let memory = instance.get_memory(&mut store, "memory").unwrap();
-
- let mut bytes = [0; 12];
- memory.read(&store, 0, &mut bytes)?;
- assert_eq!(bytes, "Hello World!".as_bytes());
- Ok(())
-}
-
#[test]
#[cfg_attr(miri, ignore)]
#[cfg(target_pointer_width = "64")]
diff --git a/tests/all/linker.rs b/tests/all/linker.rs
index b16af64c95..55673d6786 100644
--- a/tests/all/linker.rs
+++ b/tests/all/linker.rs
@@ -4,25 +4,6 @@ use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
use wasmtime::*;
-#[test]
-#[cfg_attr(miri, ignore)]
-fn link_undefined() -> Result<()> {
- let mut store = Store::<()>::default();
- let linker = Linker::new(store.engine());
- let module = Module::new(store.engine(), r#"(module (import "" "" (func)))"#)?;
- assert!(linker.instantiate(&mut store, &module).is_err());
- let module = Module::new(store.engine(), r#"(module (import "" "" (global i32)))"#)?;
- assert!(linker.instantiate(&mut store, &module).is_err());
- let module = Module::new(store.engine(), r#"(module (import "" "" (memory 1)))"#)?;
- assert!(linker.instantiate(&mut store, &module).is_err());
- let module = Module::new(
- store.engine(),
- r#"(module (import "" "" (table 1 funcref)))"#,
- )?;
- assert!(linker.instantiate(&mut store, &module).is_err());
- Ok(())
-}
-
#[test]
#[cfg_attr(miri, ignore)]
fn test_unknown_import_error() -> Result<()> {
diff --git a/tests/all/module.rs b/tests/all/module.rs
index b97d71f6a9..04e98a99c9 100644
--- a/tests/all/module.rs
+++ b/tests/all/module.rs
@@ -733,75 +733,3 @@ fn deserialize_raw_fails_for_native() {
);
}
}
-
-#[cfg(all(
- any(target_os = "macos", target_os = "linux"),
- target_arch = "x86_64",
- not(miri)
-))]
-mod native_unwind {
- use wasmtime::{Config, Engine, Module, Result};
-
- // On macOS aarch64, the system unwinder currently stops before reaching the
- // guest, including without bulk registration. Exercise the host/guest transition
- // on x86-64 macOS and Linux until that separate process-ABI issue is fixed.
- #[test]
- fn native_unwind_walks_nested_wasm_frames() -> Result<()> {
- use wasmtime::{Caller, Func, Inlining, Instance, Store, Strategy};
-
- let mut config = Config::new();
- config
- .strategy(Strategy::Cranelift)
- .native_unwind_info(true)
- .compiler_inlining(Inlining::No);
- let engine = Engine::new(&config)?;
- // Post-call arithmetic keeps each guest caller live instead of tail calling.
- let module = Module::new(
- &engine,
- r#"(module
- (import "" "capture" (func $capture (result i32)))
- (func $inner (result i32) call $capture i32.const 1 i32.add)
- (func $middle (result i32) call $inner i32.const 2 i32.add)
- (func $run (export "run") (result i32) call $middle i32.const 4 i32.add))"#,
- )?;
- let start = module.text().as_ptr() as usize;
- let functions = module
- .functions()
- .map(|f| (f.name, start + f.offset, f.len))
- .collect::<Vec<_>>();
- let mut store = Store::new(&engine, Vec::<usize>::with_capacity(128));
- let capture = Func::wrap(&mut store, |mut caller: Caller<'_, Vec<usize>>| {
- backtrace::trace(|frame| {
- let frames = caller.data_mut();
- // Stop before growing the buffer to avoid allocating in the callback.
- if frames.len() == frames.capacity() {
- return false;
- }
- frames.push(frame.ip() as usize);
- true
- });
- 10_i32
- });
- let instance = Instance::new(&mut store, &module, &[capture.into()])?;
- assert_eq!(
- instance
- .get_typed_func::<(), i32>(&mut store, "run")?
- .call(&mut store, ())?,
- 17
- );
- let names = store
- .data()
- .iter()
- .filter_map(|pc| {
- // Return addresses point after the call instruction. Match actual
- // guest functions, not any trampoline inside the module's text.
- functions
- .iter()
- .find(|(_, start, len)| *pc > *start && *pc <= start + len)
- .map(|(name, _, _)| name.as_deref().unwrap_or_default())
- })
- .collect::<Vec<_>>();
- assert_eq!(names, ["inner", "middle", "run"]);
- Ok(())
- }
-}
diff --git a/tests/all/threads.rs b/tests/all/threads.rs
index dc4bf4635a..a8113876f4 100644
--- a/tests/all/threads.rs
+++ b/tests/all/threads.rs
@@ -40,33 +40,6 @@ fn shared_memory_failed_creation() -> Result<()> {
Ok(())
}
-#[test]
-#[cfg_attr(miri, ignore)]
-fn test_instantiate_shared_memory() -> Result<()> {
- let wat = r#"(module (memory 1 1 shared))"#;
- let Some(engine) = engine() else {
- return Ok(());
- };
- let module = Module::new(&engine, wat)?;
- let mut store = Store::new(&engine, ());
- let _instance = Instance::new(&mut store, &module, &[])?;
- Ok(())
-}
-
-#[test]
-#[cfg_attr(miri, ignore)]
-fn test_import_shared_memory() -> Result<()> {
- let wat = r#"(module (import "env" "memory" (memory 1 5 shared)))"#;
- let Some(engine) = engine() else {
- return Ok(());
- };
- let module = Module::new(&engine, wat)?;
- let mut store = Store::new(&engine, ());
- let shared_memory = SharedMemory::new(&engine, MemoryType::shared(1, 5)?)?;
- let _instance = Instance::new(&mut store, &module, &[shared_memory.into()])?;
- Ok(())
-}
-
#[test]
#[cfg_attr(miri, ignore)]
fn test_export_shared_memory() -> Result<()> {
diff --git a/tests/misc_testsuite/component-model/types.wast b/tests/misc_testsuite/component-model/types.wast
index df4e12fce9..5ddff06a14 100644
--- a/tests/misc_testsuite/component-model/types.wast
+++ b/tests/misc_testsuite/component-model/types.wast
@@ -124,7 +124,10 @@
(func (export "i-to-s8") (param "a" u32) (result s8) (canon lift (core func $m "")))
(func (export "i-to-u16") (param "a" u32) (result u16) (canon lift (core func $m "")))
(func (export "i-to-s16") (param "a" u32) (result s16) (canon lift (core func $m "")))
+ (func (export "b-to-i") (param "a" bool) (result u32) (canon lift (core func $m "")))
)
+(assert_return (invoke "b-to-i" (bool.const false)) (u32.const 0))
+(assert_return (invoke "b-to-i" (bool.const true)) (u32.const 1))
(assert_return (invoke "i-to-b" (u32.const 0)) (bool.const false))
(assert_return (invoke "i-to-b" (u32.const 1)) (bool.const true))
(assert_return (invoke "i-to-b" (u32.const 2)) (bool.const true))