mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
tests: add WASI integration test support via wasmtime
This commit is contained in:
@@ -32,7 +32,7 @@ jobs:
|
||||
run: |
|
||||
curl https://wasmtime.dev/install.sh -sSf | bash
|
||||
echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH
|
||||
- name: Run tests
|
||||
- name: Run unit tests
|
||||
env:
|
||||
CARGO_TARGET_WASM32_WASIP1_RUNNER: wasmtime
|
||||
run: |
|
||||
@@ -40,3 +40,28 @@ jobs:
|
||||
EXCLUDE="dd|df|du|env|expr|mktemp|more|tac|test"
|
||||
UTILS=$(./util/show-utils.sh | tr ' ' '\n' | grep -vE "^($EXCLUDE)$" | sed 's/^/-p uu_/' | tr '\n' ' ')
|
||||
cargo test --target wasm32-wasip1 --no-default-features $UTILS
|
||||
- name: Run integration tests via wasmtime
|
||||
env:
|
||||
RUSTFLAGS: --cfg wasi_runner
|
||||
run: |
|
||||
# Build the WASI binary
|
||||
cargo build --target wasm32-wasip1 --no-default-features --features feat_wasm
|
||||
# Run host-compiled integration tests against the WASI binary.
|
||||
# Tests incompatible with WASI are annotated with
|
||||
# #[cfg_attr(wasi_runner, ignore)] in the test source files.
|
||||
# TODO: add integration tests for these tools as WASI support is extended:
|
||||
# arch b2sum cat cksum cp csplit date dir dircolors fmt join ln
|
||||
# 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
|
||||
UUTESTS_BINARY_PATH="$(pwd)/target/wasm32-wasip1/debug/coreutils.wasm" \
|
||||
UUTESTS_WASM_RUNNER=wasmtime \
|
||||
cargo test --test tests -- \
|
||||
test_base32:: test_base64:: test_basenc:: test_basename:: \
|
||||
test_comm:: test_cut:: test_dirname:: test_echo:: \
|
||||
test_expand:: test_factor:: test_false:: test_fold:: \
|
||||
test_head:: test_link:: test_nl:: test_numfmt:: \
|
||||
test_od:: test_paste:: test_printf:: test_shuf:: test_sum:: \
|
||||
test_tee:: test_tr:: test_true:: test_truncate:: \
|
||||
test_unexpand:: test_unlink:: test_wc::
|
||||
|
||||
@@ -74,3 +74,4 @@ Yargs
|
||||
|
||||
# Product
|
||||
codspeed
|
||||
wasmtime
|
||||
|
||||
@@ -135,6 +135,7 @@ ROOTFS
|
||||
reparse
|
||||
rposition
|
||||
seedable
|
||||
seekable
|
||||
semver
|
||||
semiprime
|
||||
semiprimes
|
||||
@@ -158,6 +159,7 @@ SIGTTOU
|
||||
sigttou
|
||||
sigusr
|
||||
strcasecmp
|
||||
strcoll
|
||||
subcommand
|
||||
subexpression
|
||||
submodule
|
||||
|
||||
@@ -718,6 +718,7 @@ workspace = true
|
||||
unexpected_cfgs = { level = "warn", check-cfg = [
|
||||
'cfg(fuzzing)',
|
||||
'cfg(target_os, values("cygwin"))',
|
||||
'cfg(wasi_runner)',
|
||||
] }
|
||||
unused_qualifications = "warn"
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
# WASI integration test gaps
|
||||
|
||||
Tests annotated with `#[cfg_attr(wasi_runner, ignore = "...")]` are skipped when running integration tests against a WASI binary via wasmtime. This document tracks the reasons so that gaps in WASI support are visible in one place.
|
||||
|
||||
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, ln, 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
|
||||
|
||||
The WASI guest only sees directories explicitly mapped with `--dir`. Host paths like `/proc`, `/sys`, and `/dev` are not accessible. Affected tests include those that read `/proc/version`, `/proc/modules`, `/proc/cpuinfo`, `/proc/self/mem`, `/sys/kernel/profiling`, `/dev/null`, `/dev/zero`, `/dev/full`, and tests that rely on anonymous pipes or Linux-specific I/O error paths.
|
||||
|
||||
## WASI: argv/filenames must be valid UTF-8
|
||||
|
||||
The WASI specification requires that argv entries and filenames are valid UTF-8. Tests that pass non-UTF-8 bytes as arguments or create files with non-UTF-8 names cannot run under WASI.
|
||||
|
||||
## WASI: no FIFO/mkfifo support
|
||||
|
||||
WASI does not support creating or opening FIFOs (named pipes). Tests that use `mkfifo` are skipped.
|
||||
|
||||
## WASI: no pipe/signal support
|
||||
|
||||
WASI does not support Unix signals or pipe creation. Tests that rely on `SIGPIPE`, broken pipe detection, or pipe-based I/O are skipped.
|
||||
|
||||
## WASI: no subprocess spawning
|
||||
|
||||
WASI does not support spawning child processes. Tests that shell out to other commands or invoke a second binary are skipped.
|
||||
|
||||
## WASI: stdin file position not preserved through wasmtime
|
||||
|
||||
When stdin is a seekable file, wasmtime does not preserve the file position between the host and guest. Tests that validate stdin offset behavior after `head` reads are skipped.
|
||||
@@ -20,6 +20,7 @@ fn test_version() {
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn test_base64_non_utf8_paths() {
|
||||
use std::os::unix::ffi::OsStringExt;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
@@ -277,6 +278,7 @@ cyBvdmVyIHRoZSBsYXp5IGRvZy4=
|
||||
|
||||
#[test]
|
||||
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI sandbox: host paths not visible")]
|
||||
fn test_read_error() {
|
||||
new_ucmd!()
|
||||
.arg("/proc/self/mem")
|
||||
|
||||
@@ -138,6 +138,7 @@ fn test_too_many_args_output() {
|
||||
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
#[test]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn test_invalid_utf8_args() {
|
||||
let param = uucore::os_str_from_bytes(b"/tmp/some-\xc0-file.k\xf3")
|
||||
.expect("Only unix platforms can test non-unicode names");
|
||||
|
||||
@@ -39,15 +39,15 @@ fn test_z85_not_padded_encode() {
|
||||
|
||||
#[test]
|
||||
fn test_invalid_input() {
|
||||
let error_message = if cfg!(windows) {
|
||||
"basenc: .: Permission denied\n"
|
||||
let cmd = new_ucmd!().args(&["--base32", "."]).fails();
|
||||
if cfg!(windows) {
|
||||
cmd.stderr_only("basenc: .: Permission denied\n");
|
||||
} else if std::env::var("UUTESTS_WASM_RUNNER").is_ok() {
|
||||
// wasi-libc may report a different error string than the host libc
|
||||
cmd.stderr_contains("basenc: read error:");
|
||||
} else {
|
||||
"basenc: read error: Is a directory\n"
|
||||
};
|
||||
new_ucmd!()
|
||||
.args(&["--base32", "."])
|
||||
.fails()
|
||||
.stderr_only(error_message);
|
||||
cmd.stderr_only("basenc: read error: Is a directory\n");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -396,6 +396,7 @@ fn test_file() {
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn test_file_with_non_utf8_name() {
|
||||
use std::os::unix::ffi::OsStringExt;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
+40
-29
@@ -451,19 +451,21 @@ fn test_is_dir() {
|
||||
|
||||
#[test]
|
||||
fn test_sorted() {
|
||||
let expected_stderr =
|
||||
"comm: file 2 is not in sorted order\ncomm: input is not in sorted order\n";
|
||||
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
at.write("comm1", "1\n3");
|
||||
at.write("comm2", "3\n2");
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["comm1", "comm2"])
|
||||
.fails_with_code(1)
|
||||
.stdout_is("1\n\t\t3\n\t2\n")
|
||||
.stderr_is(expected_stderr);
|
||||
let cmd = scene.ucmd().args(&["comm1", "comm2"]).run();
|
||||
// WASI's strcoll (C locale only) may not detect unsorted input,
|
||||
// but the comparison output is still correct.
|
||||
if std::env::var("UUTESTS_WASM_RUNNER").is_ok() {
|
||||
cmd.success().stdout_is("1\n\t\t3\n\t2\n");
|
||||
} else {
|
||||
cmd.failure()
|
||||
.code_is(1)
|
||||
.stdout_is("1\n\t\t3\n\t2\n")
|
||||
.stderr_is("comm: file 2 is not in sorted order\ncomm: input is not in sorted order\n");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -490,16 +492,19 @@ fn test_both_inputs_out_of_order() {
|
||||
at.write("file_a", "3\n1\n0\n");
|
||||
at.write("file_b", "3\n2\n0\n");
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["file_a", "file_b"])
|
||||
.fails_with_code(1)
|
||||
.stdout_is("\t\t3\n1\n0\n\t2\n\t0\n")
|
||||
.stderr_is(
|
||||
"comm: file 1 is not in sorted order\n\
|
||||
comm: file 2 is not in sorted order\n\
|
||||
comm: input is not in sorted order\n",
|
||||
);
|
||||
let cmd = scene.ucmd().args(&["file_a", "file_b"]).run();
|
||||
if std::env::var("UUTESTS_WASM_RUNNER").is_ok() {
|
||||
cmd.success().stdout_is("\t\t3\n1\n0\n\t2\n\t0\n");
|
||||
} else {
|
||||
cmd.failure()
|
||||
.code_is(1)
|
||||
.stdout_is("\t\t3\n1\n0\n\t2\n\t0\n")
|
||||
.stderr_is(
|
||||
"comm: file 1 is not in sorted order\n\
|
||||
comm: file 2 is not in sorted order\n\
|
||||
comm: input is not in sorted order\n",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -509,16 +514,19 @@ fn test_both_inputs_out_of_order_last_pair() {
|
||||
at.write("file_a", "3\n1\n");
|
||||
at.write("file_b", "3\n2\n");
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["file_a", "file_b"])
|
||||
.fails_with_code(1)
|
||||
.stdout_is("\t\t3\n1\n\t2\n")
|
||||
.stderr_is(
|
||||
"comm: file 1 is not in sorted order\n\
|
||||
comm: file 2 is not in sorted order\n\
|
||||
comm: input is not in sorted order\n",
|
||||
);
|
||||
let cmd = scene.ucmd().args(&["file_a", "file_b"]).run();
|
||||
if std::env::var("UUTESTS_WASM_RUNNER").is_ok() {
|
||||
cmd.success().stdout_is("\t\t3\n1\n\t2\n");
|
||||
} else {
|
||||
cmd.failure()
|
||||
.code_is(1)
|
||||
.stdout_is("\t\t3\n1\n\t2\n")
|
||||
.stderr_is(
|
||||
"comm: file 1 is not in sorted order\n\
|
||||
comm: file 2 is not in sorted order\n\
|
||||
comm: input is not in sorted order\n",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -650,6 +658,7 @@ fn test_comm_eintr_handling() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn test_output_lossy_utf8() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
@@ -675,6 +684,7 @@ fn test_output_lossy_utf8() {
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI sandbox: host paths not visible")]
|
||||
fn test_comm_anonymous_pipes() {
|
||||
use std::{io::Write, os::fd::AsRawFd, process};
|
||||
use uucore::pipes::pipe;
|
||||
@@ -714,6 +724,7 @@ fn test_comm_anonymous_pipes() {
|
||||
|
||||
#[test]
|
||||
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI sandbox: host paths not visible")]
|
||||
fn test_read_error() {
|
||||
new_ucmd!()
|
||||
.arg("/proc/self/mem")
|
||||
|
||||
@@ -137,6 +137,7 @@ fn test_delimiter_with_byte_and_char() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI sandbox: host paths not visible")]
|
||||
fn test_too_large() {
|
||||
new_ucmd!()
|
||||
.args(&["-b1-18446744073709551615", "/dev/null"])
|
||||
@@ -569,6 +570,7 @@ fn test_multiple_mode_args() {
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn test_8bit_non_utf8_delimiter() {
|
||||
use std::ffi::OsStr;
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
@@ -635,6 +637,7 @@ fn test_failed_write_is_reported() {
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn test_cut_non_utf8_paths() {
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
|
||||
@@ -72,6 +72,7 @@ fn test_empty() {
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn test_dirname_non_utf8_paths() {
|
||||
use std::ffi::OsStr;
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
@@ -177,6 +178,7 @@ fn test_trailing_dot_emoji() {
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn test_trailing_dot_non_utf8() {
|
||||
use std::ffi::OsStr;
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
|
||||
@@ -586,6 +586,7 @@ fn multibyte_escape_unicode() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn non_utf_8_hex_round_trip() {
|
||||
new_ucmd!()
|
||||
.args(&["-e", r"\xFF"])
|
||||
@@ -610,6 +611,7 @@ fn nine_bit_octal() {
|
||||
|
||||
#[test]
|
||||
#[cfg(target_family = "unix")]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn non_utf_8() {
|
||||
use std::ffi::OsStr;
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
@@ -664,6 +666,7 @@ fn test_cmd_result_stdout_check_and_stdout_str_check() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: no subprocess spawning")]
|
||||
fn test_cmd_result_stderr_check_and_stderr_str_check() {
|
||||
let ts = TestScenario::new("echo");
|
||||
|
||||
|
||||
@@ -429,6 +429,7 @@ fn test_nonexisting_file() {
|
||||
|
||||
#[test]
|
||||
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI sandbox: host paths not visible")]
|
||||
fn test_read_error() {
|
||||
new_ucmd!()
|
||||
.arg("/proc/self/mem")
|
||||
@@ -438,6 +439,7 @@ fn test_read_error() {
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn test_expand_non_utf8_paths() {
|
||||
use std::os::unix::ffi::OsStringExt;
|
||||
use uutests::at_and_ucmd;
|
||||
|
||||
@@ -69,6 +69,7 @@ fn test_trim_null_chars() {
|
||||
#[test]
|
||||
#[cfg(feature = "sort")]
|
||||
#[cfg(not(target_os = "android"))]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI sandbox: host paths not visible")]
|
||||
fn test_parallel() {
|
||||
use hex_literal::hex;
|
||||
use sha1::{Digest, Sha1};
|
||||
|
||||
@@ -413,6 +413,7 @@ fn test_presume_input_pipe_5_chars() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: no subprocess spawning")]
|
||||
fn test_all_but_last_bytes_large_file_piped() {
|
||||
// Validate print-all-but-last-n-bytes with a large piped-in (i.e. non-seekable) file.
|
||||
let scene = TestScenario::new(util_name!());
|
||||
@@ -481,6 +482,7 @@ fn test_all_but_last_lines_large_file_presume_input_pipe() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: no subprocess spawning")]
|
||||
fn test_all_but_last_lines_large_file() {
|
||||
// Create our fixtures on the fly. We need the input file to be at least double
|
||||
// the size of BUF_SIZE as specified in head.rs. Go for something a bit bigger
|
||||
@@ -554,6 +556,10 @@ fn test_all_but_last_lines_large_file() {
|
||||
not(target_os = "openbsd")
|
||||
))]
|
||||
#[test]
|
||||
#[cfg_attr(
|
||||
wasi_runner,
|
||||
ignore = "WASI: stdin file position not preserved through wasmtime"
|
||||
)]
|
||||
fn test_validate_stdin_offset_lines() {
|
||||
// A handful of unix-only tests to validate behavior when reading from stdin on a seekable
|
||||
// file. GNU-compatibility requires that the stdin file be left such that if another
|
||||
@@ -654,6 +660,10 @@ fn test_validate_stdin_offset_lines() {
|
||||
not(target_os = "openbsd")
|
||||
))]
|
||||
#[test]
|
||||
#[cfg_attr(
|
||||
wasi_runner,
|
||||
ignore = "WASI: stdin file position not preserved through wasmtime"
|
||||
)]
|
||||
fn test_validate_stdin_offset_bytes() {
|
||||
// A handful of unix-only tests to validate behavior when reading from stdin on a seekable
|
||||
// file. GNU-compatibility requires that the stdin file be left such that if another
|
||||
@@ -779,6 +789,7 @@ fn test_validate_stdin_offset_bytes() {
|
||||
not(target_os = "openbsd")
|
||||
))]
|
||||
#[test]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI sandbox: host paths (/proc) not visible")]
|
||||
fn test_read_backwards_bytes_proc_fs_version() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
|
||||
@@ -795,6 +806,7 @@ fn test_read_backwards_bytes_proc_fs_version() {
|
||||
not(target_os = "openbsd")
|
||||
))]
|
||||
#[test]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI sandbox: host paths (/proc) not visible")]
|
||||
fn test_read_backwards_bytes_proc_fs_modules() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
|
||||
@@ -815,6 +827,7 @@ fn test_read_backwards_bytes_proc_fs_modules() {
|
||||
not(target_os = "openbsd")
|
||||
))]
|
||||
#[test]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI sandbox: host paths (/proc) not visible")]
|
||||
fn test_read_backwards_lines_proc_fs_modules() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
|
||||
@@ -835,6 +848,7 @@ fn test_read_backwards_lines_proc_fs_modules() {
|
||||
not(target_os = "openbsd")
|
||||
))]
|
||||
#[test]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI sandbox: host paths (/sys) not visible")]
|
||||
fn test_read_backwards_bytes_sys_kernel_profiling() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
// in case the kernel was not built with profiling support, e.g. WSL
|
||||
@@ -890,6 +904,7 @@ fn test_write_to_dev_full() {
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn test_head_non_utf8_paths() {
|
||||
use std::ffi::OsStr;
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
|
||||
@@ -8,6 +8,7 @@ use uutests::{at_and_ucmd, new_ucmd, util::TestScenario, util_name};
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn test_non_utf8_paths() {
|
||||
use std::os::unix::ffi::OsStringExt;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
@@ -208,6 +209,7 @@ fn test_number_separator() {
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn test_number_separator_non_utf8() {
|
||||
use std::{ffi::OsString, os::unix::ffi::OsStringExt};
|
||||
|
||||
@@ -629,6 +631,7 @@ fn test_section_delimiter() {
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn test_section_delimiter_non_utf8() {
|
||||
use std::{ffi::OsString, os::unix::ffi::OsStringExt};
|
||||
|
||||
@@ -695,6 +698,7 @@ fn test_one_char_section_delimiter() {
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn test_one_byte_section_delimiter() {
|
||||
use std::{ffi::OsString, os::unix::ffi::OsStringExt};
|
||||
|
||||
|
||||
@@ -1170,6 +1170,7 @@ fn test_zero_terminated_embedded_newline() {
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn test_non_utf8_delimiter() {
|
||||
use std::ffi::OsStr;
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
|
||||
@@ -764,31 +764,47 @@ fn test_invalid_traditional_offsets_are_filenames() {
|
||||
|
||||
#[test]
|
||||
fn test_traditional_offset_overflow_diagnosed() {
|
||||
// The ERANGE message differs across platforms (e.g. "Result too large"
|
||||
// on glibc vs "Result not representable" on wasi-libc), so when testing
|
||||
// via a WASM runner we just check that stderr mentions the input value.
|
||||
let wasm = std::env::var("UUTESTS_WASM_RUNNER").is_ok();
|
||||
let erange = erange_message();
|
||||
let long_octal = "7".repeat(255);
|
||||
let long_decimal = format!("{}.", "9".repeat(254));
|
||||
let long_hex = format!("0x{}", "f".repeat(253));
|
||||
|
||||
new_ucmd!()
|
||||
let cmd = new_ucmd!()
|
||||
.arg("-")
|
||||
.arg(&long_octal)
|
||||
.pipe_in(Vec::<u8>::new())
|
||||
.fails_with_code(1)
|
||||
.stderr_only(format!("od: {long_octal}: {erange}\n"));
|
||||
.fails_with_code(1);
|
||||
if wasm {
|
||||
cmd.stderr_contains(format!("od: {long_octal}:"));
|
||||
} else {
|
||||
cmd.stderr_only(format!("od: {long_octal}: {erange}\n"));
|
||||
}
|
||||
|
||||
new_ucmd!()
|
||||
let cmd = new_ucmd!()
|
||||
.arg("-")
|
||||
.arg(&long_decimal)
|
||||
.pipe_in(Vec::<u8>::new())
|
||||
.fails_with_code(1)
|
||||
.stderr_only(format!("od: {long_decimal}: {erange}\n"));
|
||||
.fails_with_code(1);
|
||||
if wasm {
|
||||
cmd.stderr_contains(format!("od: {long_decimal}:"));
|
||||
} else {
|
||||
cmd.stderr_only(format!("od: {long_decimal}: {erange}\n"));
|
||||
}
|
||||
|
||||
new_ucmd!()
|
||||
let cmd = new_ucmd!()
|
||||
.arg("-")
|
||||
.arg(&long_hex)
|
||||
.pipe_in(Vec::<u8>::new())
|
||||
.fails_with_code(1)
|
||||
.stderr_only(format!("od: {long_hex}: {erange}\n"));
|
||||
.fails_with_code(1);
|
||||
if wasm {
|
||||
cmd.stderr_contains(format!("od: {long_hex}:"));
|
||||
} else {
|
||||
cmd.stderr_only(format!("od: {long_hex}: {erange}\n"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -881,6 +897,7 @@ fn test_skip_bytes_prints_after_consuming_multiple_inputs() {
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI sandbox: host paths (/proc) not visible")]
|
||||
fn test_skip_bytes_proc_file_without_seeking() {
|
||||
let proc_path = Path::new("/proc/version");
|
||||
if !proc_path.exists() {
|
||||
@@ -918,6 +935,10 @@ fn test_skip_bytes_error() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(
|
||||
wasi_runner,
|
||||
ignore = "WASI: stdin file position not preserved through wasmtime"
|
||||
)]
|
||||
fn test_read_bytes() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let fixtures = &scene.fixtures;
|
||||
|
||||
@@ -417,6 +417,7 @@ fn test_data() {
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn test_non_utf8_delimiter() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.write("f1", "1\n2\n");
|
||||
@@ -432,6 +433,7 @@ fn test_non_utf8_delimiter() {
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn test_paste_non_utf8_paths() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
@@ -466,6 +468,7 @@ fn make_broken_pipe() -> std::fs::File {
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI sandbox: host paths (/dev) not visible")]
|
||||
fn test_dev_zero_write_error_dev_full() {
|
||||
use std::fs::File;
|
||||
|
||||
@@ -482,6 +485,7 @@ fn test_dev_zero_write_error_dev_full() {
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI sandbox: host paths (/dev) not visible")]
|
||||
fn test_dev_zero_closed_pipe() {
|
||||
new_ucmd!()
|
||||
.arg("/dev/zero")
|
||||
|
||||
@@ -1336,6 +1336,7 @@ fn mb_input() {
|
||||
|
||||
#[test]
|
||||
#[cfg(target_family = "unix")]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn mb_invalid_unicode() {
|
||||
use std::ffi::OsStr;
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
@@ -1424,6 +1425,7 @@ fn positional_format_specifiers() {
|
||||
|
||||
#[test]
|
||||
#[cfg(target_family = "unix")]
|
||||
#[cfg_attr(wasi_runner, ignore = "WASI: argv/filenames must be valid UTF-8")]
|
||||
fn non_utf_8_input() {
|
||||
use std::ffi::OsStr;
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user