* Reorganize wasi-misc-tests. Move wasi-misc-tests out of wasi-common, to break a dependency cycle; previously, wasmtime-* depended on wasi-common, but wasi-common dev-dependended on wasmtime-*. Now, wasi-common no longer dev-depends on wasmtime-*; instead, the tests are in their own crate which depends on wasi-common and on wasmtime-*. Also, rename wasi-misc-tests to wasi-tests for simplicity. This also removes the "wasm_tests" feature; it's replaced by the "test-programs" feature. * Update the CI script to use the new feature name. * Update the CI script to use the new feature name in one more place. * Change a `write!` to a `writeln!`.
26 lines
660 B
Rust
26 lines
660 B
Rust
pub mod utils;
|
|
pub mod wasi_wrappers;
|
|
|
|
use libc;
|
|
use std::ffi::CString;
|
|
use std::io;
|
|
use wasi::wasi_unstable;
|
|
|
|
pub fn open_scratch_directory(path: &str) -> Result<wasi_unstable::Fd, String> {
|
|
// Open the scratch directory.
|
|
let dir_fd: wasi_unstable::Fd = unsafe {
|
|
let cstr = CString::new(path.as_bytes()).unwrap();
|
|
libc::open(cstr.as_ptr(), libc::O_RDONLY | libc::O_DIRECTORY)
|
|
} as wasi_unstable::Fd;
|
|
|
|
if (dir_fd as std::os::raw::c_int) < 0 {
|
|
Err(format!(
|
|
"error opening scratch directory '{}': {}",
|
|
path,
|
|
io::Error::last_os_error()
|
|
))
|
|
} else {
|
|
Ok(dir_fd)
|
|
}
|
|
}
|