diff --git a/.github/workflows/wasi.yml b/.github/workflows/wasi.yml index 6ceae79415..c82f9e01da 100644 --- a/.github/workflows/wasi.yml +++ b/.github/workflows/wasi.yml @@ -61,7 +61,7 @@ jobs: # caret diagnostics; the host test crate does have them, hence the # not(wasi_runner) in the cfg guarding every `mod diagnostics`. # TODO: add integration tests for these tools as WASI support is extended: - # cksum csplit dircolors fmt ls mv readlink + # csplit dircolors fmt ls mv readlink # rm seq sort split tsort # nproc is not part of the default feature set, so it needs to be # requested explicitly for the host test crate to compile its tests. @@ -69,7 +69,7 @@ jobs: UUTESTS_WASM_RUNNER=wasmtime \ cargo test --test tests --features nproc -- \ test_arch:: test_b2sum:: test_base32:: test_base64:: test_basenc:: \ - test_basename:: test_cat:: test_comm:: test_cp:: test_cut:: test_date:: \ + test_basename:: test_cat:: test_cksum:: test_comm:: test_cp:: test_cut:: test_date:: \ test_dir:: test_dirname:: test_echo:: test_expand:: test_expr:: \ test_factor:: test_false:: test_fold:: test_head:: test_join:: test_link:: test_ln:: \ test_ls::test_ls_a_dotdot_no_error_on_wasi \ diff --git a/docs/src/wasi-test-gaps.md b/docs/src/wasi-test-gaps.md index 4789ef03dc..cb2c132bc1 100644 --- a/docs/src/wasi-test-gaps.md +++ b/docs/src/wasi-test-gaps.md @@ -6,7 +6,7 @@ To find all annotated tests: `grep -rn 'wasi_runner, ignore' tests/` ## Tools not yet covered by integration tests -arch, b2sum, cat, cksum, cp, csplit, date, dir, dircolors, fmt, join, ls, md5sum, mkdir, mv, nproc, pathchk, pr, printenv, ptx, pwd, readlink, realpath, rm, rmdir, seq, sha1sum, sha224sum, sha256sum, sha384sum, sha512sum, shred, sleep, sort, split, tail, touch, tsort, uname, uniq, vdir, yes +arch, b2sum, cat, cp, csplit, date, dir, dircolors, fmt, join, ls, md5sum, mkdir, mv, nproc, pathchk, pr, printenv, ptx, pwd, readlink, realpath, rm, rmdir, seq, sha1sum, sha224sum, sha256sum, sha384sum, sha512sum, shred, sleep, sort, split, tail, touch, tsort, uname, uniq, vdir, yes ## WASI sandbox: host paths not visible diff --git a/tests/by-util/test_cksum.rs b/tests/by-util/test_cksum.rs index a5945481d5..b0d0156d73 100644 --- a/tests/by-util/test_cksum.rs +++ b/tests/by-util/test_cksum.rs @@ -1083,6 +1083,10 @@ fn test_check_error_incorrect_format() { #[cfg(unix)] #[test] +#[cfg_attr( + wasi_runner, + ignore = "WASI sandbox: host paths (/dev/null) not visible" +)] fn test_dev_null() { let scene = TestScenario::new(util_name!()); @@ -1144,7 +1148,7 @@ fn test_reset_binary() { .arg("--tag") .arg("--untagged") .arg("--algorithm=md5") - .arg(at.subdir.join("f")) + .arg("f") .succeeds() .stdout_contains("d41d8cd98f00b204e9800998ecf8427e *"); } @@ -1163,7 +1167,7 @@ fn test_reset_binary_but_set() { .arg("--untagged") .arg("--binary") .arg("--algorithm=md5") - .arg(at.subdir.join("f")) + .arg("f") .succeeds() .stdout_contains("d41d8cd98f00b204e9800998ecf8427e *"); } @@ -1179,7 +1183,7 @@ mod output_format { ucmd.arg("--text") .arg("--tag") .args(&["-a", "md5"]) - .arg(at.subdir.join("f")) + .arg("f") .fails(); } @@ -1191,7 +1195,7 @@ mod output_format { // --text without --untagged fails ucmd.arg("--text") .args(&["-a", "md5"]) - .arg(at.subdir.join("f")) + .arg("f") .fails_with_code(1) .stderr_contains("--text mode is only supported with --untagged"); } @@ -1205,7 +1209,7 @@ mod output_format { ucmd.arg("--text") .arg("--binary") .args(&["-a", "md5"]) - .arg(at.subdir.join("f")) + .arg("f") .succeeds() // No --untagged, tagged output is used .stdout_contains("f) = d41d8cd98f00b204e9800998ecf8427e"); @@ -1221,7 +1225,7 @@ mod output_format { .arg("--binary") .arg("--untagged") .args(&["-a", "md5"]) - .arg(at.subdir.join("f")) + .arg("f") .succeeds() // Untagged output is used .stdout_contains("d41d8cd98f00b204e9800998ecf8427e *"); @@ -1240,7 +1244,7 @@ fn test_binary_file() { .arg("--untagged") .arg("-b") .arg("--algorithm=md5") - .arg(at.subdir.join("f")) + .arg("f") .succeeds() .stdout_contains("d41d8cd98f00b204e9800998ecf8427e *"); @@ -1250,7 +1254,7 @@ fn test_binary_file() { .arg("--untagged") .arg("--binary") .arg("--algorithm=md5") - .arg(at.subdir.join("f")) + .arg("f") .succeeds() .stdout_contains("d41d8cd98f00b204e9800998ecf8427e *"); @@ -1711,6 +1715,10 @@ fn test_check_untagged_flag_without_file_name() { #[test] #[cfg(all(not(windows), feature = "b2sum"))] +#[cfg_attr( + wasi_runner, + ignore = "WASI sandbox: empty filename resolves to the preopened directory (EISDIR) instead of ENOENT, see #15357" +)] fn test_check_untagged_without_file_name() { let scene = TestScenario::new(util_name!()); let digest = "786a02f742015903c6c6fd852552d272912f4740e15847618a86e217f71f5419d25e1031afee585313896444934eb04b903a685b1448b755d56f701afe9be2ce"; @@ -1959,7 +1967,7 @@ fn test_check_directory_error() { #[cfg(windows)] let err_msg = "cksum: d: Permission denied\n"; ucmd.arg("--check") - .arg(at.subdir.join("f")) + .arg("f") .fails() .stderr_contains(err_msg); } @@ -1977,7 +1985,7 @@ fn test_check_base64_hashes() { scene .ucmd() .arg("--check") - .arg(at.subdir.join("check")) + .arg("check") .succeeds() .stdout_is("empty: OK\nempty: OK\nempty: OK\n"); } @@ -2180,6 +2188,10 @@ mod check_encoding { // This test should pass on linux and macos. #[cfg(not(windows))] #[test] + #[cfg_attr( + wasip2_runner, + ignore = "WASI preview2: OsString requires valid UTF-8, unlike unix/wasip1" + )] fn test_check_non_utf8_comment() { use super::*; let hashes = @@ -2195,7 +2207,7 @@ mod check_encoding { at.write_bytes("check", hashes); cmd.arg("--check") - .arg(at.subdir.join("check")) + .arg("check") .succeeds() .stdout_is("empty: OK\nempty: OK\nempty: OK\n") .no_stderr(); @@ -2205,6 +2217,10 @@ mod check_encoding { // create a file which name contains '\xff'. #[cfg(target_os = "linux")] #[test] + #[cfg_attr( + wasi_runner, + ignore = "WASI: preopened directories reject non-UTF-8 filenames" + )] fn test_check_non_utf8_filename() { use super::*; use std::{ffi::OsString, os::unix::ffi::OsStringExt}; @@ -2220,7 +2236,7 @@ mod check_encoding { scene .ucmd() .arg("--check") - .arg(at.subdir.join("check")) + .arg("check") .succeeds() .stdout_is_bytes(b"'funky'$'\\377''name': OK\n") .no_stderr(); @@ -2231,7 +2247,7 @@ mod check_encoding { scene .ucmd() .arg("--check") - .arg(at.subdir.join("check")) + .arg("check") .fails() .stdout_is_bytes(b"'funky'$'\\377''name': FAILED\n") .stderr_contains("1 computed checksum did NOT match"); @@ -2242,7 +2258,7 @@ mod check_encoding { scene .ucmd() .arg("--check") - .arg(at.subdir.join("check")) + .arg("check") .fails() .stdout_is_bytes(b"'flakey'$'\\377''name': FAILED open or read\n") .stderr_contains("1 listed file could not be read"); @@ -2250,6 +2266,10 @@ mod check_encoding { #[cfg(target_os = "linux")] #[test] + #[cfg_attr( + wasi_runner, + ignore = "WASI: preopened directories reject non-UTF-8 filenames" + )] fn test_quoting_in_stderr() { use super::*; use std::{ffi::OsStr, os::unix::ffi::OsStrExt}; @@ -2295,7 +2315,7 @@ fn test_check_blake_length_guess() { scene .ucmd() .arg("--check") - .arg(at.subdir.join("foo.sums")) + .arg("foo.sums") .succeeds() .stdout_is("foo.dat: OK\n"); } @@ -2309,7 +2329,7 @@ fn test_check_blake_length_guess() { scene .ucmd() .arg("--check") - .arg(at.subdir.join("foo.sums")) + .arg("foo.sums") .fails() .stderr_contains("foo.sums: no properly formatted checksum lines found"); @@ -2320,7 +2340,7 @@ fn test_check_blake_length_guess() { scene .ucmd() .arg("--check") - .arg(at.subdir.join("foo.sums")) + .arg("foo.sums") .fails() .stderr_contains("foo.sums: no properly formatted checksum lines found"); @@ -2331,7 +2351,7 @@ fn test_check_blake_length_guess() { scene .ucmd() .arg("--check") - .arg(at.subdir.join("foo.sums")) + .arg("foo.sums") .fails() .stderr_contains("foo.sums: no properly formatted checksum lines found"); } @@ -2349,7 +2369,7 @@ fn test_check_confusing_base64() { scene .ucmd() .arg("--check") - .arg(at.subdir.join("foo.sums")) + .arg("foo.sums") .succeeds() .stdout_is("foo.dat: OK\n"); } @@ -2373,14 +2393,14 @@ fn test_check_mix_hex_base64() { scene .ucmd() .arg("--check") - .arg(at.subdir.join("hex_b64")) + .arg("hex_b64") .succeeds() .stdout_only("foo2.dat: OK\nfoo1.dat: OK\n"); scene .ucmd() .arg("--check") - .arg(at.subdir.join("b64_hex")) + .arg("b64_hex") .succeeds() .stdout_only("foo1.dat: OK\nfoo2.dat: OK\n"); } @@ -2767,6 +2787,10 @@ mod cksum_check_mode { #[test] #[cfg_attr(not(unix), ignore = "/dev/null is only available on UNIX")] + #[cfg_attr( + wasi_runner, + ignore = "WASI sandbox: host paths (/dev/null) not visible" + )] fn test_untagged_base64_matching_tag() { let (at, mut ucmd) = at_and_ucmd!(); @@ -3302,6 +3326,10 @@ mod debug_flag { #[test] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg_attr( + wasi_runner, + ignore = "WASI: wasm32 guest has no x86 hardware path, so host-CPU debug output differs" + )] fn test_debug_flag() { // Test with default CRC algorithm - should output CPU feature detection new_ucmd!() @@ -3359,6 +3387,10 @@ mod debug_flag { #[test] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg_attr( + wasi_runner, + ignore = "WASI: wasm32 guest has no x86 hardware path, so host-CPU debug output differs" + )] fn test_debug_with_algorithms() { // Test with SHA256 - CPU detection should be same regardless of algorithm new_ucmd!() @@ -3409,6 +3441,10 @@ mod debug_flag { #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] #[test] + #[cfg_attr( + wasi_runner, + ignore = "WASI: wasm32 guest has no x86 hardware path, so host-CPU debug output differs" + )] fn test_debug_with_glibc_tunables() { if is_x86_feature_detected!("avx2") { for (tunables, expected) in [ @@ -3438,6 +3474,10 @@ mod debug_flag { #[test] #[cfg(target_arch = "aarch64")] + #[cfg_attr( + wasi_runner, + ignore = "WASI: wasm32 guest has no aarch64 hardware path, so host-CPU debug output differs" + )] fn test_debug_flag_aarch64() { // The vmull path needs PMULL. ASIMD alone is not enough. let expected = if std::arch::is_aarch64_feature_detected!("pmull") { @@ -3467,6 +3507,7 @@ mod debug_flag { #[test] #[cfg(all(target_os = "linux", not(target_env = "musl")))] +#[cfg_attr(wasi_runner, ignore = "WASI sandbox: host paths not visible")] fn test_check_file_with_io_error() { // /proc/self/mem causes EIO when read without proper seeking new_ucmd!() @@ -3481,6 +3522,7 @@ fn test_check_file_with_io_error() { #[test] #[cfg(all(target_os = "linux", not(target_env = "musl")))] +#[cfg_attr(wasi_runner, ignore = "WASI sandbox: host paths not visible")] fn test_check_checkfile_with_io_error() { // /proc/self/mem causes EIO when read without proper seeking new_ucmd!()