-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
bugIncorrect behavior in the current implementation that needs fixingIncorrect behavior in the current implementation that needs fixing
Description
Test Case
smartcore_wasi_lib.wasm - https://easyupload.io/7l8u6z
test1.txt
Steps to Reproduce
Just run the wasm file in the same folder as test1.txt
.
wasmtime run --dir=. smartcore_wasi_lib.wasm --invoke load_model test1.txt test2.txt
Expected Results
A new file inside ./
with the name test2.txt
and the same contents as test1.txt
.
Actual Results
$ wasmtime run --dir=. smartcore_wasi_lib.wasm --invoke load_model test1.txt test2.txt
error opening input test1.txt: failed to find a pre-opened file descriptor through which "test1.txt" could be opened
Versions and Environment
Wasmtime version or commit: 0.26.0
Operating system: Ubuntu 20.04
Architecture: x86_64
Extra Info
This is the example for WASI from https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-tutorial.md
Here's the code:
use std::fs;
use std::io::{Read, Write};
use std::env;
fn process(input_fname: &str, output_fname: &str) -> Result<(), String> {
let mut input_file = fs::File::open(input_fname)
.map_err(|err| format!("error opening input {}: {}", input_fname, err))?;
let mut contents = Vec::new();
input_file
.read_to_end(&mut contents)
.map_err(|err| format!("read error: {}", err))?;
let mut output_file = fs::File::create(output_fname)
.map_err(|err| format!("error opening output {}: {}", output_fname, err))?;
output_file
.write_all(&contents)
.map_err(|err| format!("write error: {}", err))
}
#[no_mangle]
pub fn load_model() -> () {
let args: Vec<String> = env::args().collect();
let program = args[0].clone();
if args.len() < 3 {
eprintln!("usage: {} <input_file> <output_file>", program);
return;
}
if let Err(err) = process(&args[1], &args[2]) {
eprintln!("{}", err)
}
}
And compiled via cargo build --target=wasm32-wasi --release
Metadata
Metadata
Assignees
Labels
bugIncorrect behavior in the current implementation that needs fixingIncorrect behavior in the current implementation that needs fixing