2024-03-27 16:55:09 -05:00
|
|
|
//@ only-wasm32-wasip1
|
2024-03-27 17:02:45 -05:00
|
|
|
//@ needs-wasmtime
|
2024-03-27 16:55:09 -05:00
|
|
|
|
2024-03-13 16:52:23 -05:00
|
|
|
use run_make_support::{rustc, tmp_dir};
|
2024-03-06 14:39:07 -06:00
|
|
|
use std::path::Path;
|
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
fn main() {
|
2024-03-13 16:52:23 -05:00
|
|
|
rustc().input("foo.rs").target("wasm32-wasip1").run();
|
|
|
|
|
|
|
|
let file = tmp_dir().join("foo.wasm");
|
2024-03-06 14:39:07 -06: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) {
|
|
|
|
let output = Command::new("wasmtime")
|
|
|
|
.arg("run")
|
|
|
|
.arg("--preload=host=host.wat")
|
|
|
|
.arg("--invoke")
|
|
|
|
.arg(method)
|
|
|
|
.arg(file)
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
assert_eq!(expected_output, String::from_utf8_lossy(&output.stdout));
|
|
|
|
}
|