* tests/misc/read-errors.sh: Validate that commands which read multiple
files, read all files on error, and exit with appropriate status.
---
tests/misc/read-errors.sh | 94 ++++++++++++++++++++++-----------------
1 file changed, 53 insertions(+), 41 deletions(-)
diff --git a/tests/misc/read-errors.sh b/tests/misc/read-errors.sh
index 834440959..81fa5b9dd 100755
--- a/tests/misc/read-errors.sh
+++ b/tests/misc/read-errors.sh
@@ -22,47 +22,49 @@ getlimits_
! cat . >/dev/null 2>&1 || skip_ "Need unreadable directories"
-printf '%s' "\
+# commands tagged with $count are checked that they output
+# the correct number of errors
+printf '%s' '\
basenc --base32 .
basenc -d --base64 .
-cat .
-cksum -a blake2b .
-cksum -a bsd .
-cksum -a crc .
-cksum -a crc32b .
-cksum -a md5 .
-cksum -a sha1 .
-cksum -a sha2 -l 224 .
-cksum -a sha2 -l 256 .
-cksum -a sha2 -l 384 .
-cksum -a sha2 -l 512 .
-cksum -a sha3 -l 224 .
-cksum -a sha3 -l 256 .
-cksum -a sha3 -l 384 .
-cksum -a sha3 -l 512 .
-cksum -a sm3 .
-cksum -a sysv .
-cksum -a md5 /dev/null | sed 's|/dev/null|.|' | cksum --check
+cat . $count
+cksum -a blake2b . $count
+cksum -a bsd . $count
+cksum -a crc . $count
+cksum -a crc32b . $count
+cksum -a md5 . $count
+cksum -a sha1 . $count
+cksum -a sha2 -l 224 . $count
+cksum -a sha2 -l 256 . $count
+cksum -a sha2 -l 384 . $count
+cksum -a sha2 -l 512 . $count
+cksum -a sha3 -l 224 . $count
+cksum -a sha3 -l 256 . $count
+cksum -a sha3 -l 384 . $count
+cksum -a sha3 -l 512 . $count
+cksum -a sm3 . $count
+cksum -a sysv . $count
+cksum -a md5 /dev/null | sed "s|/dev/null|.|" | cksum --check
comm . .
csplit . 1
-cut -b1 .
-cut -f1 .
+cut -b1 . $count
+cut -f1 . $count
date -f .
dd if=.
dircolors .
-expand .
+expand . $count
factor < .
-fmt .
-fold .
-head -n1 .
-head -n-1 .
-head -c1 .
-head -c-1 .
+fmt . $count
+fold . $count
+head -n1 . $count
+head -n-1 . $count
+head -c1 . $count
+head -c-1 . $count
join . .
-nl .
+nl . $count
numfmt < .
-od .
-paste .
+od . $count
+paste . $count
pr .
ptx .
shuf -r .
@@ -74,21 +76,21 @@ split -C1 .
split -n1 .
split -nl/1 .
split -nr/1 .
-tac .
-tail -n1 .
-tail -c1 .
-tail -n+1 .
-tail -c+1 .
+tac . $count
+tail -n1 . $count
+tail -c1 . $FIXME_count
+tail -n+1 . $FIXME_count
+tail -c+1 . $FIXME_count
tee < .
tr 1 1 < .
tsort .
-unexpand .
+unexpand . $count
uniq .
uniq -c .
-wc .
-wc -c .
-wc -l .
-" |
+wc . $count
+wc -c . $count
+wc -l . $count
+' |
sort -k 1b,1 > all_readers || framework_failure_
printf '%s\n' $built_programs |
@@ -96,10 +98,20 @@ sort -k 1b,1 > built_programs || framework_failure_
join all_readers built_programs > built_readers || framework_failure_
+count=''
while read reader; do
eval $reader >/dev/null && { fail=1; echo "$reader: exited with 0" >&2; }
done < built_readers
+count='.' # read '.' twice
+while read reader; do
+ printf '%s' "$reader" | grep -F '$count' >/dev/null || continue
+ eval $reader 2>errs >/dev/null
+ test "$?" = 1 ||
+ { fail=1; echo "$reader: did not exit with 1" >&2; }
+ test "$(grep -F : errs | wc -l)" = 2 ||
+ { fail=1; echo "$reader: did not produce 2 errors" >&2; cat errs; }
+done < built_readers
expected_failure_status_sort=2
--
2.53.0