summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2021-08-30 20:24:39 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2021-08-31 02:11:04 -0700
commit6c8ef2ae8e8f0ce22b6b8f4b163959a3b5ef06f2 (patch)
tree42b06d3466590898e478fbf337440a88b8ad0328 /tests
parentdc6ccb0e798b7bbcd439e6f83fdc51b78b0e47ab (diff)
downloadgzip-6c8ef2ae8e8f0ce22b6b8f4b163959a3b5ef06f2.tar.gz
tests: update help-version from coreutils
This merges coreutils/tests/misc/help-version.sh into gzip/tests/help-version; they're now identical except for the initial init.sh configuration line. This should port better to NetBSD.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/help-version120
1 files changed, 61 insertions, 59 deletions
diff --git a/tests/help-version b/tests/help-version
index 3ad0d8d..07a5ec9 100755
--- a/tests/help-version
+++ b/tests/help-version
@@ -1,5 +1,5 @@
-#! /bin/sh
-# Make sure all these programs work properly
+#!/bin/sh
+# Make sure all of these programs work properly
# when invoked with --help or --version.
# Copyright (C) 2000-2021 Free Software Foundation, Inc.
@@ -17,20 +17,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
-# Ensure that $SHELL is set to *some* value and exported.
-# This is required for dircolors, which would fail e.g., when
-# invoked via debuild (which removes SHELL from the environment).
-test "x$SHELL" = x && SHELL=/bin/sh
-export SHELL
-
. "${srcdir=.}/init.sh"; path_prepend_ ..
+# Terminate any background processes
+cleanup_() { kill $pid 2>/dev/null && wait $pid; }
+
expected_failure_status_chroot=125
expected_failure_status_env=125
expected_failure_status_nice=125
expected_failure_status_nohup=125
expected_failure_status_stdbuf=125
-expected_failure_status_su=125
expected_failure_status_timeout=125
expected_failure_status_printenv=2
expected_failure_status_tty=3
@@ -71,49 +67,39 @@ done
test "x$v" = "x$VERSION" \
|| fail_ "--version-\$VERSION mismatch"
-for lang in C fr da; do
- for i in $built_programs; do
-
- # Skip `test'; it doesn't accept --help or --version.
- test $i = test && continue;
+for i in $built_programs; do
- # false fails even when invoked with --help or --version.
- if test $i = false; then
- env LC_MESSAGES=$lang $i --help >/dev/null && fail=1
- env LC_MESSAGES=$lang $i --version >/dev/null && fail=1
- continue
- fi
+ # Skip 'test'; it doesn't accept --help or --version.
+ test $i = test && continue
- args=
+ # false fails even when invoked with --help or --version.
+ # true and false are tested with these options separately.
+ test $i = false || test $i = true && continue
- # The just-built install executable is always named `ginstall'.
- test $i = install && i=ginstall
+ # The just-built install executable is always named 'ginstall'.
+ test $i = install && i=ginstall
- # Make sure they exit successfully, under normal conditions.
- eval "env \$i $args --help > h-\$i " || fail=1
- eval "env \$i $args --version >/dev/null" || fail=1
+ # Make sure they exit successfully, under normal conditions.
+ env $i --help >/dev/null || fail=1
+ env $i --version >/dev/null || fail=1
- # Make sure they mention the bug-reporting address in --help output.
- grep "$PACKAGE_BUGREPORT" h-$i > /dev/null || fail=1
- rm -f h-$i
+ # Make sure they fail upon 'file system full' error.
+ if test -w /dev/full && test -c /dev/full &&
+ ! printf x >/dev/full 2>/dev/null; then
+ test $i = [ && prog=lbracket || prog=$(echo $i|sed "s/$EXEEXT$//")
+ eval "expected=\$expected_failure_status_$prog"
+ test x$expected = x && expected=1
- # Make sure they fail upon `disk full' error.
- if test -w /dev/full && test -c /dev/full; then
- eval "env \$i $args --help >/dev/full 2>/dev/null" && fail=1
- eval "env \$i $args --version >/dev/full 2>/dev/null" && fail=1
+ returns_ $expected env $i --help >/dev/full 2>/dev/null &&
+ returns_ $expected env $i --version >/dev/full 2>/dev/null ||
+ {
+ fail=1
+ env $i --help >/dev/full 2>/dev/null
status=$?
- test $i = [ && prog=lbracket || prog=$i
- eval "expected=\$expected_failure_status_$prog"
- test x$expected = x && expected=1
- if test $status = $expected; then
- : # ok
- else
- fail=1
- echo "*** $i: bad exit status \`$status' (expected $expected)," 1>&2
- echo " with --help or --version output redirected to /dev/full" 1>&2
- fi
- fi
- done
+ echo "*** $i: bad exit status '$status' (expected $expected)," 1>&2
+ echo " with --help or --version output redirected to /dev/full" 1>&2
+ }
+ fi
done
bigZ_in=bigZ-in.Z
@@ -141,7 +127,7 @@ chown_setup () { args=--version; }
mkfifo_setup () { args=--version; }
mknod_setup () { args=--version; }
# Punt on uptime, since it fails (e.g., failing to get boot time)
-# on some systems, and we shouldn't let that stop `make check'.
+# on some systems, and we shouldn't let that stop 'make check'.
uptime_setup () { args=--version; }
# Create a file in the current directory, not in $TMPDIR.
@@ -153,18 +139,18 @@ cmp_setup () { args="$tmp_in $tmp_in2"; }
# The transfer rate would vary between runs.
dd_setup () { args=status=noxfer; }
-zdiff_setup () { args="$args $zin $zin2"; }
+zdiff_setup () { args="$zin $zin2"; }
zcmp_setup () { zdiff_setup; }
-zcat_setup () { TERM=dumb; export TERM; args="$args $zin"; }
+zcat_setup () { TERM=dumb; export TERM; args=$zin; }
gunzip_setup () { zcat_setup; }
zmore_setup () { zcat_setup; }
zless_setup () { zcat_setup; }
-znew_setup () { args="$args $bigZ_in"; }
+znew_setup () { args=$bigZ_in; }
zforce_setup () { zcat_setup; }
-zgrep_setup () { args="$args z $zin"; }
+zgrep_setup () { args="z $zin"; }
zegrep_setup () { zgrep_setup; }
zfgrep_setup () { zgrep_setup; }
-gzexe_setup () { args="$args $tmp_in"; }
+gzexe_setup () { args=$tmp_in; }
# We know that $tmp_in contains a "0"
grep_setup () { args="0 $tmp_in"; }
@@ -179,17 +165,29 @@ ln_setup () { args="$tmp_in ln-target"; }
ginstall_setup () { args="$tmp_in $tmp_in2"; }
mv_setup () { args="$tmp_in $tmp_in2"; }
mkdir_setup () { args=$tmp_dir/subdir; }
+realpath_setup () { args=$tmp_in; }
rmdir_setup () { args=$tmp_dir; }
rm_setup () { args=$tmp_in; }
shred_setup () { args=$tmp_in; }
touch_setup () { args=$tmp_in2; }
truncate_setup () { args="--reference=$tmp_in $tmp_in2"; }
+mkid_setup () { printf 'f(){}\ntypedef int t;\n' > f.c; args=. ; }
+lid_setup () { args=; }
+fid_setup () { args=f.c; }
+fnid_setup () { args=; }
+xtokid_setup () { args=; }
+aid_setup () { args=f; }
+eid_setup () { args=--version; }
+gid_setup () { args=f; }
+defid_setup () { args=t; }
+
basename_setup () { args=$tmp_in; }
dirname_setup () { args=$tmp_in; }
expr_setup () { args=foo; }
+basenc_setup () { args=--version; }
-# Punt, in case GNU `id' hasn't been installed yet.
+# Punt, in case GNU 'id' hasn't been installed yet.
groups_setup () { args=--version; }
pathchk_setup () { args=$tmp_in; }
@@ -199,7 +197,6 @@ nohup_setup () { args=--version; }
printf_setup () { args=foo; }
seq_setup () { args=10; }
sleep_setup () { args=0; }
-su_setup () { args=--version; }
stdbuf_setup () { args="-oL true"; }
timeout_setup () { args=--version; }
@@ -218,8 +215,9 @@ id_setup () { args=-u; }
# Use env to avoid invoking built-in sleep of Solaris 11's /bin/sh.
kill_setup () {
- env sleep 10m &
- args=$!
+ external=env
+ $external sleep 10m & pid=$!
+ args=$pid
}
link_setup () { args="$tmp_in link-target"; }
@@ -234,11 +232,14 @@ stat_setup () { args=$tmp_in; }
unlink_setup () { args=$tmp_in; }
lbracket_setup () { args=": ]"; }
+parted_setup () { args="-s $tmp_in mklabel gpt"
+ dd if=/dev/null of=$tmp_in seek=2000; }
+
# Ensure that each program "works" (exits successfully) when doing
# something more than --help or --version.
for i in $built_programs; do
# Skip these.
- case $i in chroot|stty|tty|false|chcon|runcon) continue;; esac
+ case $i in chroot|stty|tty|false|chcon|runcon|coreutils) continue;; esac
rm -rf $tmp_in $tmp_in2 $tmp_dir $tmp_out $bigZ_in $zin $zin2
echo z |gzip > $zin
@@ -253,12 +254,13 @@ for i in $built_programs; do
cp $tmp_in $tmp_in2
mkdir $tmp_dir
# echo ================== $i
- test $i = [ && prog=lbracket || prog=$i
- args=
+ test $i = [ && prog=lbracket || prog=$(echo $i|sed "s/$EXEEXT$//")
if type ${prog}_setup > /dev/null 2>&1; then
${prog}_setup
+ else
+ args=
fi
- if eval "env \$i $args < \$tmp_in > \$tmp_out"; then
+ if env $i $args < $tmp_in > $tmp_out; then
: # ok
else
echo FAIL: $i