Skip to content

Commit

Permalink
Update the wasi_testsuite submodule (bytecodealliance#8829)
Browse files Browse the repository at this point in the history
* Update the wasi_testsuite submodule

This commit updates the wasi_testsuite submodule which we haven't
updated in a little over a year and applies a few small fixes but mostly
ignores new tests.

* Add another ignore#
  • Loading branch information
alexcrichton authored Jun 18, 2024
1 parent 3171ef6 commit 864fdb6
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 9 deletions.
2 changes: 1 addition & 1 deletion crates/wasi/src/host/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ where
}

if oflags.contains(OpenFlags::TRUNCATE) {
opts.truncate(true);
opts.truncate(true).write(true);
}
if flags.contains(DescriptorFlags::READ) {
opts.read(true);
Expand Down
17 changes: 13 additions & 4 deletions crates/wasi/src/preview1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,7 @@ impl wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiP1Ctx {
let mut fs_rights_base = types::Rights::all();
if let types::Filetype::Directory = fs_filetype {
fs_rights_base &= !types::Rights::FD_SEEK;
fs_rights_base &= !types::Rights::FD_FILESTAT_SET_SIZE;
}
if !flags.contains(filesystem::DescriptorFlags::READ) {
fs_rights_base &= !types::Rights::FD_READ;
Expand Down Expand Up @@ -2742,7 +2743,9 @@ impl wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiP1Ctx {
fd: types::Fd,
flags: types::Fdflags,
) -> Result<types::Fd, types::Error> {
todo!("preview1 sock_accept is not implemented")
tracing::warn!("preview1 sock_accept is not implemented");
self.transact()?.get_descriptor(fd)?;
Err(types::Errno::Notsock.into())
}

#[allow(unused_variables)]
Expand All @@ -2754,7 +2757,9 @@ impl wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiP1Ctx {
ri_data: types::IovecArray,
ri_flags: types::Riflags,
) -> Result<(types::Size, types::Roflags), types::Error> {
todo!("preview1 sock_recv is not implemented")
tracing::warn!("preview1 sock_recv is not implemented");
self.transact()?.get_descriptor(fd)?;
Err(types::Errno::Notsock.into())
}

#[allow(unused_variables)]
Expand All @@ -2766,7 +2771,9 @@ impl wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiP1Ctx {
si_data: types::CiovecArray,
_si_flags: types::Siflags,
) -> Result<types::Size, types::Error> {
todo!("preview1 sock_send is not implemented")
tracing::warn!("preview1 sock_send is not implemented");
self.transact()?.get_descriptor(fd)?;
Err(types::Errno::Notsock.into())
}

#[allow(unused_variables)]
Expand All @@ -2777,7 +2784,9 @@ impl wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiP1Ctx {
fd: types::Fd,
how: types::Sdflags,
) -> Result<(), types::Error> {
todo!("preview1 sock_shutdown is not implemented")
tracing::warn!("preview1 sock_shutdown is not implemented");
self.transact()?.get_descriptor(fd)?;
Err(types::Errno::Notsock.into())
}
}

Expand Down
36 changes: 33 additions & 3 deletions tests/all/wasi_testsuite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,25 @@ fn wasi_testsuite() -> Result<()> {
// `cargo test wasi_testsuite -- --nocapture`. The printed output will show
// the expected result, the actual result, and a command to replicate the
// failure from the command line.
const WASI_COMMON_IGNORE_LIST: &[&str] = &["fd_advise.wasm"];
const WASI_COMMON_IGNORE_LIST: &[&str] = &[
// Uses functions not supported in Wasmtime due to portability concerns
"fd_advise.wasm",
"file_allocate.wasm",
// #8828
"remove_directory_trailing_slashes.wasm",
// Working with rights which are removed from wasmtime
"truncation_rights.wasm",
"fd_fdstat_set_rights.wasm",
"path_open_preopen.wasm",
"path_link.wasm",
// This test wants an operation to fail that wasmtime thinks is valid
"renumber.wasm",
// Works with FDFLAGS_SYNC which isn't supported
"path_filestat.wasm",
// this test asserts semantics of pwrite which don't match Linux so
// ignore the test for now.
"pwrite-with-append.wasm",
];
run_all(
"tests/wasi_testsuite/wasi-common",
&[],
Expand Down Expand Up @@ -65,7 +83,19 @@ fn run_all(testsuite_dir: &str, extra_flags: &[&str], ignore: &[&str]) -> Result
if spec != result {
println!(" command: {cmd:?}");
println!(" spec: {spec:#?}");
println!(" result: {result:#?}");
println!(" result.status: {}", result.status);
if !result.stdout.is_empty() {
println!(
" result.stdout:\n {}",
String::from_utf8_lossy(&result.stdout).replace("\n", "\n ")
);
}
if !result.stderr.is_empty() {
println!(
" result.stderr:\n {}",
String::from_utf8_lossy(&result.stderr).replace("\n", "\n ")
);
}
panic!("FAILED! The result does not match the specification");
}
}
Expand Down Expand Up @@ -133,7 +163,7 @@ fn clean_garbage(testsuite_dir: &str) -> Result<()> {
for path in list_files(testsuite_dir, is_garbage) {
println!("Removing {}", path.display());
if path.is_dir() {
fs::remove_dir(path)?;
fs::remove_dir_all(path)?;
} else {
fs::remove_file(path)?;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/wasi_testsuite/wasi-common
Submodule wasi-common updated 133 files

0 comments on commit 864fdb6

Please sign in to comment.