2024-03-27 21:55:09 +00:00
|
|
|
//@ only-wasm32-wasip1
|
2024-03-27 22:02:45 +00:00
|
|
|
//@ needs-wasmtime
|
2024-03-27 21:55:09 +00:00
|
|
|
|
2024-06-23 17:31:08 -04:00
|
|
|
use run_make_support::{cmd, rustc};
|
2024-03-06 12:39:07 -08:00
|
|
|
use std::path::Path;
|
|
|
|
|
|
|
|
fn main() {
|
2024-03-13 21:52:23 +00:00
|
|
|
rustc().input("foo.rs").target("wasm32-wasip1").run();
|
|
|
|
|
2024-06-07 14:10:27 +02:00
|
|
|
let file = Path::new("foo.wasm");
|
2024-03-06 12:39:07 -08:00
|
|
|
|
|
|
|
run(&file, "return_two_i32", "1\n2\n");
|
|
|
|
run(&file, "return_two_i64", "3\n4\n");
|
|
|
|
run(&file, "return_two_f32", "5\n6\n");
|
|
|
|
run(&file, "return_two_f64", "7\n8\n");
|
|
|
|
run(&file, "return_mishmash", "9\n10\n11\n12\n13\n14\n");
|
|
|
|
run(&file, "call_imports", "");
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run(file: &Path, method: &str, expected_output: &str) {
|
2024-06-23 17:31:08 -04:00
|
|
|
cmd("wasmtime")
|
2024-03-06 12:39:07 -08:00
|
|
|
.arg("run")
|
|
|
|
.arg("--preload=host=host.wat")
|
|
|
|
.arg("--invoke")
|
|
|
|
.arg(method)
|
|
|
|
.arg(file)
|
2024-06-23 17:31:08 -04:00
|
|
|
.run()
|
|
|
|
.assert_stdout_equals(expected_output);
|
2024-03-06 12:39:07 -08:00
|
|
|
}
|