Repository: bytecodealliance/wasmtime
Pull request #8829 (2024-06-17 22:00:48)

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.

<!--
Please make sure you include the following information:

- If this work has been discussed elsewhere, please include a link to that
  conversation. If it was discussed in an issue, just mention "issue #...".

- Explain why this change is needed. If the details are in an issue already,
  this can be brief.

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->



Patch:
diff --git a/crates/wasi/src/host/filesystem.rs b/crates/wasi/src/host/filesystem.rs
index 78dcbec41..d3ac08f77 100644
--- a/crates/wasi/src/host/filesystem.rs
+++ b/crates/wasi/src/host/filesystem.rs
@@ -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);
diff --git a/crates/wasi/src/preview1.rs b/crates/wasi/src/preview1.rs
index ac58c7428..ee4178c9c 100644
--- a/crates/wasi/src/preview1.rs
+++ b/crates/wasi/src/preview1.rs
@@ -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;
@@ -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)]
@@ -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)]
@@ -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)]
@@ -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())
     }
 }
 


Test patch:
diff --git a/tests/all/wasi_testsuite.rs b/tests/all/wasi_testsuite.rs
index 9928182b0..2b02c7223 100644
--- a/tests/all/wasi_testsuite.rs
+++ b/tests/all/wasi_testsuite.rs
@@ -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",
         &[],
@@ -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");
             }
         }
@@ -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)?;
         }
diff --git a/tests/wasi_testsuite/wasi-common b/tests/wasi_testsuite/wasi-common
index 09517e50c..2fec29ea6 160000
--- a/tests/wasi_testsuite/wasi-common
+++ b/tests/wasi_testsuite/wasi-common
@@ -1,1 +1,1 @@
-Subproject commit 09517e50cc47179208f9c681772a6eba617fbddd
+Subproject commit 2fec29ea6de1244c124f7fe3bfe9f2946113f66e