tests: ensure all utilities that read input diagnose errors

* 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.
This commit is contained in:
Pádraig Brady 2023-04-22 21:35:23 +01:00
parent 82e1750daa
commit 7ea7c020e8
4 changed files with 80 additions and 59 deletions

View File

@ -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 \
@ -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 \

View File

@ -1,29 +0,0 @@
#!/bin/sh
# Verify -f processing
# 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
print_ver_ date
# Make sure date fails when it can't read input
# (the current directory in this case)
if ! cat . >/dev/null; then
# can't read() directories
returns_ 1 date -f . || fail=1
fi
Exit $fail

View File

@ -1,28 +0,0 @@
#!/bin/sh
# 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
print_ver_ dircolors
# Make sure dircolors fails when it can't read input
# (the current directory in this case)
if ! cat . >/dev/null; then
# can't read() directories
returns_ 1 dircolors . || fail=1
fi
Exit $fail

79
tests/misc/read-errors.sh Executable file
View File

@ -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