Skip to content

Commit

Permalink
tests: ensure all utilities that read input diagnose errors
Browse files Browse the repository at this point in the history
* tests/misc/read-errors.sh: Add a new test.
* tests/misc/date-f.sh: Remove unneeded test.
* tests/misc/dircolors.sh: Likewise.
* tests/local.mk: Reference new test, and dereference removed ones.
  • Loading branch information
pixelb committed Apr 24, 2023
1 parent 82e1750 commit 7ea7c02
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 59 deletions.
3 changes: 1 addition & 2 deletions tests/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ all_tests = \
tests/cp/link-heap.sh \
tests/cp/no-ctx.sh \
tests/misc/tty-eof.pl \
tests/misc/read-errors.sh \
tests/tail-2/inotify-hash-abuse.sh \
tests/tail-2/inotify-hash-abuse2.sh \
tests/tail-2/F-vs-missing.sh \
Expand Down Expand Up @@ -302,11 +303,9 @@ all_tests = \
tests/misc/csplit-io-err.sh \
tests/misc/csplit-suppress-matched.pl \
tests/misc/date-debug.sh \
tests/misc/date-f.sh \
tests/misc/date-sec.sh \
tests/misc/date-tz.sh \
tests/misc/dircolors.pl \
tests/misc/dircolors.sh \
tests/misc/dirname.pl \
tests/misc/env-null.sh \
tests/misc/env-S.pl \
Expand Down
29 changes: 0 additions & 29 deletions tests/misc/date-f.sh

This file was deleted.

28 changes: 0 additions & 28 deletions tests/misc/dircolors.sh

This file was deleted.

79 changes: 79 additions & 0 deletions tests/misc/read-errors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/sh
# Make sure all of these programs diagnose read errors

# Copyright (C) 2023 Free Software Foundation, Inc.

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src

! cat . >/dev/null 2>&1 || skip_ "Need unreadable directories"

echo "\
basenc --base32 .
basenc -d --base64 .
cat .
cksum -a blake2b .
cksum -a bsd .
cksum -a crc .
cksum -a md5 .
cksum -a sha1 .
cksum -a sha224 .
cksum -a sha256 .
cksum -a sha384 .
cksum -a sha512 .
cksum -a sm3 .
cksum -a sysv .
comm . .
csplit . 1
cut -b1 .
date -f .
dd if=.
dircolors .
expand .
factor < .
fmt .
fold .
head .
join . .
nl .
numfmt < .
od .
paste .
pr .
ptx .
shuf .
sort .
split .
tac .
tail .
tee < .
tr 1 1 < .
tsort .
unexpand .
uniq .
wc .
" |
sort -k 1b,1 > all_readers || framework_failure_

printf '%s\n' $built_programs |
sort -k 1b,1 > built_programs || framework_failure_

join all_readers built_programs > built_readers || framework_failure_

while read reader; do
eval $reader >/dev/null && { fail=1; echo "$reader: exited with 0" >&2; }
done < built_readers

Exit $fail

0 comments on commit 7ea7c02

Please sign in to comment.