Skip to content

Commit 4faffa9

Browse files
authored
Update Wasmi specific Wast testsuite (#1685)
* update Wasmi specific testsuite * update Wasmi specific Wast testsuite * update wasmi-wast submodule
1 parent 465f427 commit 4faffa9

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

crates/wast/src/lib.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,33 @@ impl WastRunner {
136136
Ok(())
137137
}
138138

139+
/// Sets up the Wasmi specific testsuite module for `self`.
140+
pub fn register_wasmitest(&mut self) -> Result<(), wasmi::Error> {
141+
self.linker.func_wrap("wasmitest", "identity-0", || {})?;
142+
self.linker
143+
.func_wrap("wasmitest", "identity-1", |v0: i64| -> i64 { v0 })?;
144+
self.linker.func_wrap(
145+
"wasmitest",
146+
"identity-2",
147+
|v0: i64, v1: i64| -> (i64, i64) { (v0, v1) },
148+
)?;
149+
self.linker
150+
.func_wrap("wasmitest", "offset-1", |v0: i64| -> i64 { v0 + 1 })?;
151+
self.linker
152+
.func_wrap("wasmitest", "offset-2", |v0: i64, v1: i64| -> (i64, i64) {
153+
(v0 + 1, v1 + 2)
154+
})?;
155+
self.linker
156+
.func_wrap("wasmitest", "sum-3", |v0: i64, v1: i64, v2: i64| -> i64 {
157+
v0.wrapping_add(v1).wrapping_add(v2)
158+
})?;
159+
self.linker
160+
.func_wrap("wasmitest", "iota-3", |v0: i64| -> (i64, i64, i64) {
161+
(v0.wrapping_add(1), v0.wrapping_add(2), v0.wrapping_add(3))
162+
})?;
163+
Ok(())
164+
}
165+
139166
/// Converts the [`WastArgCore`][`wast::core::WastArgCore`] into a [`wasmi::Val`] if possible.
140167
fn value(&mut self, value: &WastArgCore) -> Option<Val> {
141168
use wasmi::{ExternRef, Func, Ref};

crates/wast/tests/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ fn process_wast(path: &'static str, wast: &'static str, config: Config) {
77
if let Err(error) = runner.register_spectest() {
88
panic!("{path}: failed to setup Wasm spectest module: {error}");
99
}
10+
if let Err(error) = runner.register_wasmitest() {
11+
panic!("{path}: failed to setup Wasmi test module: {error:?}");
12+
}
1013
if let Err(error) = runner.process_directives(path, wast) {
1114
panic!("{error:#}")
1215
}
@@ -182,6 +185,7 @@ macro_rules! foreach_test {
182185
fn spec_wide_arithmetic("spec/proposals/wide-arithmetic/wide-arithmetic");
183186

184187
// Wasmi specific test cases and regression tests.
188+
fn wasmi_fibonacci("wasmi/tests/fibonacci");
185189
fn wasmi_wide_arithmetic("wasmi/tests/wide-arithmetic");
186190
fn wasmi_replace_result("wasmi/tests/replace-result");
187191
fn wasmi_local_tee("wasmi/tests/local-tee");
@@ -192,6 +196,10 @@ macro_rules! foreach_test {
192196
fn wasmi_many_inout("wasmi/tests/many-inout");
193197
fn wasmi_copy_span("wasmi/tests/copy-span");
194198
fn wasmi_audit("wasmi/tests/audit");
199+
fn wasmi_call("wasmi/tests/call");
200+
fn wasmi_call_indirect("wasmi/tests/call-indirect");
201+
fn wasmi_return_call("wasmi/tests/return-call");
202+
fn wasmi_return_call_indirect("wasmi/tests/return-call-indirect");
195203
// Wasmi: binary operators
196204
fn wasmi_i32_add("wasmi/tests/op/i32-add");
197205
fn wasmi_i32_sub("wasmi/tests/op/i32-sub");

0 commit comments

Comments
 (0)