FYI we've just pushed a new test in the attached that uses
strace to inject errors for testing, like:
$ strace -o /dev/null -P /dev/null -e fault=read:error=EIO \
cat /dev/null
cat: /dev/null: Input/output error
cheers,
PadraigFrom 3a9777bdb018ef09f65cf88e1e193911dc3afccf Mon Sep 17 00:00:00 2001
From: oech3 <[email protected]>
Date: Sun, 11 Jan 2026 18:14:44 +0000
Subject: [PATCH] tests: cksum: ensure --check handles I/O errors
* tests/cksum/cksum-c.sh: Use strace to inject EIO upon read(),
and verify it's handled appropriately.
From https://github.com/coreutils/coreutils/pull/167
---
tests/cksum/cksum-c.sh | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tests/cksum/cksum-c.sh b/tests/cksum/cksum-c.sh
index a355bdd63..2e93ad6e1 100755
--- a/tests/cksum/cksum-c.sh
+++ b/tests/cksum/cksum-c.sh
@@ -201,4 +201,22 @@ grep 'the --tag option is meaningless when verifying checksums' err || fail=1
# an emulation wrapper for legacy *sum utils.
cksum -a md5 /dev/null | cksum --untagged --check || fail=1
+# Ensure I/O errors handled appropriately
+if strace -o /dev/null -P path -e fault=read:error=EIO true; then
+ touch ok eio || framework_failure_
+ cksum -a md5 eio ok > check.md5 || fail=1
+ # Test one of the files being checked returns EIO
+ returns_ 1 strace -o /dev/null -P eio -e fault=read:error=EIO \
+ cksum --check check.md5 2>err >out || fail=1
+
+ printf '%s\n' 'eio: FAILED open or read' 'ok: OK' >exp || framework_failure_
+ compare exp out || fail=1
+
+ # Generate the expected error using cat:
+ strace -o /dev/null -P eio -e fault=read:error=EIO cat eio 2> exp.t
+ sed 's/cat/cksum/' < exp.t > exp && grep eio: exp && echo \
+ 'cksum: WARNING: 1 listed file could not be read' >>exp || framework_failure_
+ compare exp err || fail=1
+fi
+
Exit $fail
--
2.52.0