coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] tests: ensure all utilities that read input diagnose errors


From: Pádraig Brady
Subject: [PATCH 2/2] tests: ensure all utilities that read input diagnose errors
Date: Sun, 23 Apr 2023 23:51:18 +0100

* 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.
---
 tests/local.mk            |  3 +-
 tests/misc/date-f.sh      | 29 --------------
 tests/misc/dircolors.sh   | 28 --------------
 tests/misc/read-errors.sh | 79 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 80 insertions(+), 59 deletions(-)
 delete mode 100755 tests/misc/date-f.sh
 delete mode 100755 tests/misc/dircolors.sh
 create mode 100755 tests/misc/read-errors.sh

diff --git a/tests/local.mk b/tests/local.mk
index a0c024905..fb5c9c4a5 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -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                          \
diff --git a/tests/misc/date-f.sh b/tests/misc/date-f.sh
deleted file mode 100755
index ebbb95652..000000000
--- a/tests/misc/date-f.sh
+++ /dev/null
@@ -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
diff --git a/tests/misc/dircolors.sh b/tests/misc/dircolors.sh
deleted file mode 100755
index 9e2ae2890..000000000
--- a/tests/misc/dircolors.sh
+++ /dev/null
@@ -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
diff --git a/tests/misc/read-errors.sh b/tests/misc/read-errors.sh
new file mode 100755
index 000000000..288c3ecc2
--- /dev/null
+++ b/tests/misc/read-errors.sh
@@ -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
-- 
2.26.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]