# Make sure all these programs work properly
# when invoked with --help or --version.
-# Copyright (C) 2000-2010 Free Software Foundation, Inc.
+# Copyright (C) 2000-2017 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
# 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 <http://www.gnu.org/licenses/>.
+# 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
test "x$SHELL" = x && SHELL=/bin/sh
export SHELL
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ..
+. "${srcdir=.}/init.sh"; path_prepend_ ..
expected_failure_status_chroot=125
expected_failure_status_env=125
test "$built_programs" \
|| fail_ "built_programs not specified!?!"
+test "$VERSION" \
+ || fail_ "set envvar VERSION; it is required for a PATH sanity-check"
+
+# Extract version from --version output of the first program
+for i in $built_programs; do
+ v=$(env $i --version | sed -n '1s/.* //p;q')
+ break
+done
+
+# Ensure that it matches $VERSION.
+test "x$v" = "x$VERSION" \
+ || fail_ "--version-\$VERSION mismatch"
+
for lang in C fr da; do
for i in $built_programs; do
continue
fi
+ args=
+
# The just-built install executable is always named `ginstall'.
test $i = install && i=ginstall
# Make sure they exit successfully, under normal conditions.
- env $i --help > h-$i || fail=1
- env $i --version >/dev/null || fail=1
+ eval "env \$i $args --help > h-\$i " || fail=1
+ eval "env \$i $args --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
# Make sure they fail upon `disk full' error.
if test -w /dev/full && test -c /dev/full; then
- env $i --help >/dev/full 2>/dev/null && fail=1
- env $i --version >/dev/full 2>/dev/null && fail=1
+ eval "env \$i $args --help >/dev/full 2>/dev/null" && fail=1
+ eval "env \$i $args --version >/dev/full 2>/dev/null" && fail=1
status=$?
test $i = [ && prog=lbracket || prog=$i
eval "expected=\$expected_failure_status_$prog"
# The transfer rate would vary between runs.
dd_setup () { args=status=noxfer; }
-zdiff_setup () { args="$zin $zin2"; }
-zcmp_setup () { args="$zin $zin2"; }
-zcat_setup () { args=$zin; }
-gunzip_setup () { args=$zin; }
-zmore_setup () { args=$zin; }
-zless_setup () { args=$zin; }
-znew_setup () { args=$bigZ_in; }
-zforce_setup () { args=$zin; }
-zgrep_setup () { args="z $zin"; }
-zegrep_setup () { args="z $zin"; }
-zfgrep_setup () { args="z $zin"; }
-gzexe_setup () { args=$tmp_in; }
+zdiff_setup () { args="$args $zin $zin2"; }
+zcmp_setup () { zdiff_setup; }
+zcat_setup () { TERM=dumb; export TERM; args="$args $zin"; }
+gunzip_setup () { zcat_setup; }
+zmore_setup () { zcat_setup; }
+zless_setup () { zcat_setup; }
+znew_setup () { args="$args $bigZ_in"; }
+zforce_setup () { zcat_setup; }
+zgrep_setup () { args="$args z $zin"; }
+zegrep_setup () { zgrep_setup; }
+zfgrep_setup () { zgrep_setup; }
+gzexe_setup () { args="$args $tmp_in"; }
# We know that $tmp_in contains a "0"
grep_setup () { args="0 $tmp_in"; }
mkdir $tmp_dir
# echo ================== $i
test $i = [ && prog=lbracket || prog=$i
+ args=
if type ${prog}_setup > /dev/null 2>&1; then
${prog}_setup
- else
- args=
fi
- if env $i $args < $tmp_in > $tmp_out; then
+ if eval "env \$i $args < \$tmp_in > \$tmp_out"; then
: # ok
else
echo FAIL: $i