From 19d4af015c8c86c30789c43e6447ef468c5748aa Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 13 Jan 2026 15:45:03 +0100 Subject: [PATCH 1/4] uucore: fix test_pid_entry test failing in CI environments The test assumed that the process always has exactly one TTY in its file descriptors. In CI environments or when running tests without a terminal attached, there is no controlling TTY, causing the test to fail with `assert_eq!(result.len(), 1)` when `result.len()` is 0. --- src/uucore/src/lib/features/proc_info.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/uucore/src/lib/features/proc_info.rs b/src/uucore/src/lib/features/proc_info.rs index 8345e7e0921..d36f5d0100b 100644 --- a/src/uucore/src/lib/features/proc_info.rs +++ b/src/uucore/src/lib/features/proc_info.rs @@ -465,11 +465,16 @@ mod tests { .flat_map(Teletype::try_from) .collect::>(); - assert_eq!(result.len(), 1); - assert_eq!( - pid_entry.tty(), - Vec::from_iter(result.into_iter()).first().unwrap().clone() - ); + // In CI environments or when running without a terminal, there may be no TTY + if result.is_empty() { + assert_eq!(pid_entry.tty(), Teletype::Unknown); + } else { + assert_eq!(result.len(), 1); + assert_eq!( + pid_entry.tty(), + Vec::from_iter(result.into_iter()).first().unwrap().clone() + ); + } } #[test] From 1a9fdfdb785b51f389cfb8978ff6181942828044 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 13 Jan 2026 17:13:34 +0100 Subject: [PATCH 2/4] ci: fix coverage script to catch test failures and find llvm-profdata - Add `set -o pipefail` to ensure test failures from cargo nextest are detected even when output is piped through grep - Look for llvm-profdata in the nightly toolchain (nightly-gnu) since that's what the script uses for coverage builds - Add helpful error message if llvm-profdata is not found --- util/build-run-test-coverage-linux.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/util/build-run-test-coverage-linux.sh b/util/build-run-test-coverage-linux.sh index 9dcfefed25c..8aba215304c 100755 --- a/util/build-run-test-coverage-linux.sh +++ b/util/build-run-test-coverage-linux.sh @@ -28,6 +28,8 @@ set -e # Treat unset variables as errors set -u +# Ensure pipeline failures are caught (not just the last command's exit code) +set -o pipefail # Print expanded commands to stdout before running them set -x @@ -39,7 +41,12 @@ REPO_main_dir="$(dirname -- "${ME_dir}")" FEATURES_OPTION=${FEATURES_OPTION:-"--features=feat_os_unix"} COVERAGE_DIR=${COVERAGE_DIR:-"${REPO_main_dir}/coverage"} -LLVM_PROFDATA="$(find "$(rustc --print sysroot)" -name llvm-profdata)" +# Find llvm-profdata in the nightly toolchain (which is used for coverage builds) +LLVM_PROFDATA="$(find "$(RUSTUP_TOOLCHAIN=nightly-gnu rustc --print sysroot)" -name llvm-profdata)" +if [ -z "${LLVM_PROFDATA}" ]; then + echo "Error: llvm-profdata not found. Install it with: rustup +nightly-gnu component add llvm-tools" + exit 1 +fi PROFRAW_DIR="${COVERAGE_DIR}/traces" PROFDATA_DIR="${COVERAGE_DIR}/data" From 4f4fa0839a190258f8723aa6ae9fff5e234eac93 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 13 Jan 2026 17:21:29 +0100 Subject: [PATCH 3/4] tests/dd: fix locale-dependent test failures Add LANG=C environment variable to the FIFO tests alongside LC_ALL=C and LANGUAGE=C. The Fluent localization system checks multiple locale environment variables, and all three are needed to ensure English output in the test assertions. --- tests/by-util/test_dd.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/by-util/test_dd.rs b/tests/by-util/test_dd.rs index 3e53f9a59e5..03c5bceebd6 100644 --- a/tests/by-util/test_dd.rs +++ b/tests/by-util/test_dd.rs @@ -1655,6 +1655,8 @@ fn test_reading_partial_blocks_from_fifo() { .stdout(Stdio::piped()) .stderr(Stdio::piped()) .env("LC_ALL", "C") + .env("LANG", "C") + .env("LANGUAGE", "C") .spawn() .unwrap(); @@ -1700,6 +1702,8 @@ fn test_reading_partial_blocks_from_fifo_unbuffered() { .stdout(Stdio::piped()) .stderr(Stdio::piped()) .env("LC_ALL", "C") + .env("LANG", "C") + .env("LANGUAGE", "C") .spawn() .unwrap(); From cf2806f22a76f7a0589bbb237b0ffef81ca52c85 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 13 Jan 2026 17:26:52 +0100 Subject: [PATCH 4/4] uucore: fix getsid error handling The previous implementation checked if Errno::last() was UnknownErrno to determine success, but this is incorrect because errno is not cleared on success. A previous syscall could have set errno to a value like ENOENT, causing getsid to incorrectly report an error. The correct pattern is to check if the result is -1, which is what getsid returns on error per POSIX. --- src/uucore/src/lib/features/process.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/uucore/src/lib/features/process.rs b/src/uucore/src/lib/features/process.rs index 55e8c36482b..043d4850d9b 100644 --- a/src/uucore/src/lib/features/process.rs +++ b/src/uucore/src/lib/features/process.rs @@ -67,13 +67,11 @@ pub fn getpid() -> pid_t { /// so some system such as redox doesn't supported. #[cfg(not(target_os = "redox"))] pub fn getsid(pid: i32) -> Result { - unsafe { - let result = libc::getsid(pid); - if Errno::last() == Errno::UnknownErrno { - Ok(result) - } else { - Err(Errno::last()) - } + let result = unsafe { libc::getsid(pid) }; + if result == -1 { + Err(Errno::last()) + } else { + Ok(result) } }