2 # Make sure all these programs work properly
3 # when invoked with --help or --version.
5 # Copyright (C) 2000-2009 Free Software Foundation, Inc.
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 test "$VERBOSE" = yes && set -x
22 # Ensure that $SHELL is set to *some* value and exported.
23 # This is required for dircolors, which would fail e.g., when
24 # invoked via debuild (which removes SHELL from the environment).
25 test "x$SHELL" = x
&& SHELL
=/bin
/sh
30 expected_failure_status_nohup
=127
31 expected_failure_status_stdbuf
=125
32 expected_failure_status_timeout
=125
33 expected_failure_status_printenv
=2
34 expected_failure_status_tty
=3
35 expected_failure_status_sort
=2
36 expected_failure_status_expr
=3
37 expected_failure_status_lbracket
=2
38 expected_failure_status_dir
=2
39 expected_failure_status_ls
=2
40 expected_failure_status_vdir
=2
44 test "$built_programs" \
45 ||
{ echo "$this_test: no programs built!?!" 1>&2; Exit
$fail; }
47 for lang
in C fr da
; do
48 for i
in $built_programs; do
50 # Skip `test'; it doesn't accept --help or --version.
51 test $i = test && continue;
53 # false fails even when invoked with --help or --version.
54 if test $i = false
; then
55 env LC_MESSAGES
=$lang $i --help >/dev
/null
&& fail
=1
56 env LC_MESSAGES
=$lang $i --version >/dev
/null
&& fail
=1
60 # The just-built install executable is always named `ginstall'.
61 test $i = install && i
=ginstall
63 # Make sure they exit successfully, under normal conditions.
64 env
$i --help > h-
$i || fail
=1
65 env
$i --version >/dev
/null || fail
=1
67 # Make sure they mention the bug-reporting address in --help output.
68 grep "$PACKAGE_BUGREPORT" h-
$i > /dev
/null || fail
=1
71 # Make sure they fail upon `disk full' error.
72 if test -w /dev
/full
&& test -c /dev
/full
; then
73 env
$i --help >/dev
/full
2>/dev
/null
&& fail
=1
74 env
$i --version >/dev
/full
2>/dev
/null
&& fail
=1
76 test $i = [ && prog
=lbracket || prog
=$i
77 eval "expected=\$expected_failure_status_$prog"
78 test x
$expected = x
&& expected
=1
79 if test $status = $expected; then
83 echo "*** $i: bad exit status \`$status' (expected $expected)," 1>&2
84 echo " with --help or --version output redirected to /dev/full" 1>&2
98 comm_args
="$tmp_in $tmp_in"
99 csplit_args
="$tmp_in //"
101 join_args
="$tmp_in $tmp_in"
104 chmod_args
="a+x $tmp_in"
108 mkfifo_args
=--version
110 # Punt on uptime, since it fails (e.g., failing to get boot time)
111 # on some systems, and we shouldn't let that stop `make check'.
112 uptime_args
=--version
114 # Create a file in the current directory, not in $TMPDIR.
115 mktemp_args
=mktemp.XXXX
117 cmp_args
="$tmp_in $tmp_in2"
119 # Tell dd not to print the line with transfer rate and total.
120 # The transfer rate would vary between runs.
121 dd_args
=status
=noxfer
123 diff_args
="$tmp_in $tmp_in2"
124 sdiff_args
="$tmp_in $tmp_in2"
125 diff3_args
="$tmp_in $tmp_in2 $tmp_in2"
126 cp_args
="$tmp_in $tmp_in2"
127 ln_args
="$tmp_in ln-target"
128 ginstall_args
="$tmp_in $tmp_in2"
129 mv_args
="$tmp_in $tmp_in2"
130 mkdir_args
=$tmp_dir/subdir
135 truncate_args
="--reference=$tmp_in $tmp_in2"
137 basename_args
=$tmp_in
141 # Punt, in case GNU `id' hasn't been installed yet.
142 groups_args
=--version
146 logname_args
=--version
152 stdbuf_args
="-oL true"
153 timeout_args
=--version
155 # I'd rather not run sync, since it spins up disks that I've
156 # deliberately caused to spin down (but not unmounted).
161 # This is necessary in the unusual event that there is
162 # no valid entry in /etc/mtab.
165 # This is necessary in the unusual event that getpwuid (getuid ()) fails.
168 # Use env to avoid invoking built-in sleep of Solaris 11's /bin/sh.
172 link_args
="$tmp_in link-target"
182 # Ensure that each program "works" (exits successfully) when doing
183 # something more than --help or --version.
184 for i
in $built_programs; do
186 case $i in chroot|stty|tty|false|chcon|runcon
) continue;; esac
188 rm -rf $tmp_in $tmp_in2 $tmp_dir $tmp_out
192 # echo ================== $i
193 test $i = [ && prog
=lbracket || prog
=$i
194 eval "args=\$${prog}_args"
195 if env
$i $args < $tmp_in > $tmp_out; then
201 rm -rf $tmp_in $tmp_in2 $tmp_out $tmp_dir