2 # Make sure all these programs work properly
3 # when invoked with --help or --version.
5 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 test "$VERBOSE" = yes && set -x
25 # Ensure that $SHELL is set to *some* value and exported.
26 # This is required for dircolors, which would fail e.g., when
27 # invoked via debuild (which removes SHELL from the environment).
28 test "x$SHELL" = x
&& SHELL
=/bin
/sh
31 .
$srcdir/envvar-check
33 expected_failure_status_nohup
=127
34 expected_failure_status_printenv
=2
35 expected_failure_status_tty
=3
36 expected_failure_status_sort
=2
37 expected_failure_status_expr
=3
38 expected_failure_status_lbracket
=2
39 expected_failure_status_dir
=2
40 expected_failure_status_ls
=2
41 expected_failure_status_vdir
=2
43 case "$all_programs" in
45 if test -w /dev
/full
&& test -c /dev
/full \
46 && echo > /dev
/full
2>/dev
/null
; then
48 ************************************************
49 WARNING
: On this system
, the built-in
echo function of
/bin
/sh
50 does not report failure when writing to a full device.
51 To demonstrate
, run this
command:
53 /bin
/sh
-c 'echo hello > /dev/full; echo status=$?'
55 Notice that the failing
echo leaves its
exit status
set to zero
56 and does not produce a diagnostic.
58 That bug
in /bin
/sh would cause the
test of the groups
59 scripts to fail
, so it is being removed from the list of
60 programs checked by this
test.
61 ************************************************
63 all_programs
=`echo $all_programs | tr ' ' '\n' | grep -v '^groups$'`
70 for lang
in C fr da
; do
71 for i
in $all_programs; do
73 # Skip `test'; it doesn't accept --help or --version.
74 test $i = test && continue;
76 # false fails even when invoked with --help or --version.
77 if test $i = false
; then
78 env LC_MESSAGES
=$lang ..
/src
/$i --help >/dev
/null
&& fail
=1
79 env LC_MESSAGES
=$lang ..
/src
/$i --version >/dev
/null
&& fail
=1
83 # The just-built install executable is always named `ginstall'.
84 test $i = install && i
=ginstall
86 # Make sure they exit successfully, under normal conditions.
87 ..
/src
/$i --help > h-
$i || fail
=1
88 ..
/src
/$i --version >/dev
/null || fail
=1
90 # Make sure they mention the bug-reporting address in --help output.
91 grep "$PACKAGE_BUGREPORT" h-
$i > /dev
/null || fail
=1
94 # Make sure they fail upon `disk full' error.
95 if test -w /dev
/full
&& test -c /dev
/full
; then
96 ..
/src
/$i --help >/dev
/full
2>/dev
/null
&& fail
=1
97 ..
/src
/$i --version >/dev
/full
2>/dev
/null
&& fail
=1
99 test $i = [ && prog
=lbracket || prog
=$i
100 eval "expected=\$expected_failure_status_$prog"
101 test x
$expected = x
&& expected
=1
102 if test $status = $expected; then
106 echo "*** $i: bad exit status \`$status' (expected $expected)," 1>&2
107 echo " with --help or --version output redirected to /dev/full" 1>&2
121 comm_args
="$tmp_in $tmp_in"
122 csplit_args
="$tmp_in //"
124 join_args
="$tmp_in $tmp_in"
127 chmod_args
="a+x $tmp_in"
131 mkfifo_args
=--version
133 # Punt on uptime, since it fails (e.g., failing to get boot time)
134 # on some systems, and we shouldn't let that stop `make check'.
135 uptime_args
=--version
137 cmp_args
="$tmp_in $tmp_in2"
139 # Tell dd not to print the line with transfer rate and total.
140 # The transfer rate would vary between runs.
141 dd_args
=status
=noxfer
143 diff_args
="$tmp_in $tmp_in2"
144 sdiff_args
="$tmp_in $tmp_in2"
145 diff3_args
="$tmp_in $tmp_in2 $tmp_in2"
146 cp_args
="$tmp_in $tmp_in2"
147 ln_args
="$tmp_in ln-target"
148 ginstall_args
="$tmp_in $tmp_in2"
149 mv_args
="$tmp_in $tmp_in2"
150 mkdir_args
=$tmp_dir/subdir
156 basename_args
=$tmp_in
160 # Punt, in case GNU `id' hasn't been installed yet.
161 groups_args
=--version
165 logname_args
=--version
172 # I'd rather not run sync, since it spins up disks that I've
173 # deliberately caused to spin down (but not unmounted).
178 # This is necessary in the unusual event that there is
179 # no valid entry in /etc/mtab.
182 # This is necessary in the unusual event that getpwuid (getuid ()) fails.
188 link_args
="$tmp_in link-target"
198 for i
in $all_programs; do
200 case $i in chroot|stty|tty|false
) continue;; esac
202 rm -rf $tmp_in $tmp_in2 $tmp_dir $tmp_out
206 # echo ================== $i
207 test $i = [ && prog
=lbracket || prog
=$i
208 eval "args=\$${prog}_args"
209 if ..
/..
/src
/$i $args < $tmp_in > $tmp_out; then
215 rm -rf $tmp_in $tmp_in2 $tmp_out $tmp_dir