pass a test, dubiously

This commit is contained in:
Pat Hickey
2020-12-14 19:46:09 -08:00
parent c16e731455
commit 04805fcc5f
9 changed files with 400 additions and 134 deletions

View File

@@ -105,14 +105,7 @@ mod wasi_tests {
)?;
writeln!(out, " use super::{{runtime, utils, setup_log}};")?;
for dir_entry in dir_entries {
let test_path = dir_entry.path();
let stemstr = test_path
.file_stem()
.expect("file_stem")
.to_str()
.expect("to_str");
write_testsuite_tests(out, &test_path, testsuite)?;
write_testsuite_tests(out, &dir_entry.path(), testsuite)?;
}
writeln!(out, "}}")?;
Ok(())

View File

@@ -1,12 +1,8 @@
use anyhow::Context;
use std::convert::TryFrom;
use std::fs::File;
use std::path::Path;
use wasi_c2::{
virt::pipe::{ReadPipe, WritePipe},
WasiCtx,
};
use wasmtime::{Config, Engine, Linker, Module, Store};
use wasi_c2::virt::pipe::{ReadPipe, WritePipe};
use wasmtime::{Linker, Module, Store};
pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> anyhow::Result<()> {
let stdout = WritePipe::new_in_memory();
@@ -27,6 +23,7 @@ pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> any
.stderr(Box::new(stderr.clone()));
if let Some(workspace) = workspace {
println!("preopen: {:?}", workspace);
let dirfd =
File::open(workspace).context(format!("error while preopening {:?}", workspace))?;
let preopen_dir = unsafe { cap_std::fs::Dir::from_std_file(dirfd) };
@@ -67,15 +64,3 @@ pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> any
}
}
}
#[cfg(unix)]
fn reader_to_file(reader: os_pipe::PipeReader) -> File {
use std::os::unix::prelude::*;
unsafe { File::from_raw_fd(reader.into_raw_fd()) }
}
#[cfg(windows)]
fn reader_to_file(reader: os_pipe::PipeReader) -> File {
use std::os::windows::prelude::*;
unsafe { File::from_raw_handle(reader.into_raw_handle()) }
}