2
# Make sure all of these programs work properly
3
# when invoked with --help or --version.
5
# Copyright (C) 2000-2012 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
# Ensure that $SHELL is set to *some* value and exported.
21
# This is required for dircolors, which would fail e.g., when
22
# invoked via debuild (which removes SHELL from the environment).
23
test "x$SHELL" = x && SHELL=/bin/sh
26
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
28
expected_failure_status_chroot=125
29
expected_failure_status_env=125
30
expected_failure_status_nice=125
31
expected_failure_status_nohup=125
32
expected_failure_status_stdbuf=125
33
expected_failure_status_timeout=125
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
expected_failure_status_cmp=2
44
expected_failure_status_zcmp=2
45
expected_failure_status_sdiff=2
46
expected_failure_status_diff3=2
47
expected_failure_status_diff=2
48
expected_failure_status_zdiff=2
49
expected_failure_status_zgrep=2
50
expected_failure_status_zegrep=2
51
expected_failure_status_zfgrep=2
53
expected_failure_status_grep=2
54
expected_failure_status_egrep=2
55
expected_failure_status_fgrep=2
57
test "$built_programs" \
58
|| fail_ "built_programs not specified!?!"
61
|| fail_ "set envvar VERSION; it is required for a PATH sanity-check"
63
# Extract version from --version output of the first program
64
for i in $built_programs; do
65
v=$(env $i --version | sed -n '1s/.* //p;q')
69
# Ensure that it matches $VERSION.
70
test "x$v" = "x$VERSION" \
71
|| fail_ "--version-\$VERSION mismatch"
73
for lang in C fr da; do
74
for i in $built_programs; do
76
# Skip 'test'; it doesn't accept --help or --version.
77
test $i = test && continue;
79
# false fails even when invoked with --help or --version.
80
if test $i = false; then
81
env LC_MESSAGES=$lang $i --help >/dev/null && fail=1
82
env LC_MESSAGES=$lang $i --version >/dev/null && fail=1
86
# The just-built install executable is always named 'ginstall'.
87
test $i = install && i=ginstall
89
# Make sure they exit successfully, under normal conditions.
90
env $i --help > h-$i || fail=1
91
env $i --version >/dev/null || fail=1
93
# Make sure they mention the bug-reporting address in --help output.
94
grep "$PACKAGE_BUGREPORT" h-$i > /dev/null || fail=1
97
# Make sure they fail upon 'disk full' error.
98
if test -w /dev/full && test -c /dev/full; then
99
env $i --help >/dev/full 2>/dev/null && fail=1
100
env $i --version >/dev/full 2>/dev/null && fail=1
102
test $i = [ && prog=lbracket || prog=$(echo $i|sed "s/$EXEEXT$//")
103
eval "expected=\$expected_failure_status_$prog"
104
test x$expected = x && expected=1
105
if test $status = $expected; then
109
echo "*** $i: bad exit status '$status' (expected $expected)," 1>&2
110
echo " with --help or --version output redirected to /dev/full" 1>&2
128
comm_setup () { args="$tmp_in $tmp_in"; }
129
csplit_setup () { args="$tmp_in //"; }
130
cut_setup () { args='-f 1'; }
131
join_setup () { args="$tmp_in $tmp_in"; }
132
tr_setup () { args='a a'; }
134
chmod_setup () { args="a+x $tmp_in"; }
136
chgrp_setup () { args=--version; }
137
chown_setup () { args=--version; }
138
mkfifo_setup () { args=--version; }
139
mknod_setup () { args=--version; }
140
# Punt on uptime, since it fails (e.g., failing to get boot time)
141
# on some systems, and we shouldn't let that stop 'make check'.
142
uptime_setup () { args=--version; }
144
# Create a file in the current directory, not in $TMPDIR.
145
mktemp_setup () { args=mktemp.XXXX; }
147
cmp_setup () { args="$tmp_in $tmp_in2"; }
149
# Tell dd not to print the line with transfer rate and total.
150
# The transfer rate would vary between runs.
151
dd_setup () { args=status=noxfer; }
153
zdiff_setup () { args="$zin $zin2"; }
154
zcmp_setup () { args="$zin $zin2"; }
155
zcat_setup () { args=$zin; }
156
gunzip_setup () { args=$zin; }
157
zmore_setup () { args=$zin; }
158
zless_setup () { args=$zin; }
159
znew_setup () { args=$bigZ_in; }
160
zforce_setup () { args=$zin; }
161
zgrep_setup () { args="z $zin"; }
162
zegrep_setup () { args="z $zin"; }
163
zfgrep_setup () { args="z $zin"; }
164
gzexe_setup () { args=$tmp_in; }
166
# We know that $tmp_in contains a "0"
167
grep_setup () { args="0 $tmp_in"; }
168
egrep_setup () { args="0 $tmp_in"; }
169
fgrep_setup () { args="0 $tmp_in"; }
171
diff_setup () { args="$tmp_in $tmp_in2"; }
172
sdiff_setup () { args="$tmp_in $tmp_in2"; }
173
diff3_setup () { args="$tmp_in $tmp_in2 $tmp_in2"; }
174
cp_setup () { args="$tmp_in $tmp_in2"; }
175
ln_setup () { args="$tmp_in ln-target"; }
176
ginstall_setup () { args="$tmp_in $tmp_in2"; }
177
mv_setup () { args="$tmp_in $tmp_in2"; }
178
mkdir_setup () { args=$tmp_dir/subdir; }
179
realpath_setup () { args=$tmp_in; }
180
rmdir_setup () { args=$tmp_dir; }
181
rm_setup () { args=$tmp_in; }
182
shred_setup () { args=$tmp_in; }
183
touch_setup () { args=$tmp_in2; }
184
truncate_setup () { args="--reference=$tmp_in $tmp_in2"; }
186
mkid_setup () { printf 'f(){}\ntypedef int t;\n' > f.c; args=. ; }
187
lid_setup () { args=; }
188
fid_setup () { args=f.c; }
189
fnid_setup () { args=; }
190
xtokid_setup () { args=; }
191
aid_setup () { args=f; }
192
eid_setup () { args=--version; }
193
gid_setup () { args=f; }
194
defid_setup () { args=t; }
196
basename_setup () { args=$tmp_in; }
197
dirname_setup () { args=$tmp_in; }
198
expr_setup () { args=foo; }
200
# Punt, in case GNU 'id' hasn't been installed yet.
201
groups_setup () { args=--version; }
203
pathchk_setup () { args=$tmp_in; }
204
yes_setup () { args=--version; }
205
logname_setup () { args=--version; }
206
nohup_setup () { args=--version; }
207
printf_setup () { args=foo; }
208
seq_setup () { args=10; }
209
sleep_setup () { args=0; }
210
stdbuf_setup () { args="-oL true"; }
211
timeout_setup () { args=--version; }
213
# I'd rather not run sync, since it spins up disks that I've
214
# deliberately caused to spin down (but not unmounted).
215
sync_setup () { args=--version; }
217
test_setup () { args=foo; }
219
# This is necessary in the unusual event that there is
220
# no valid entry in /etc/mtab.
221
df_setup () { args=/; }
223
# This is necessary in the unusual event that getpwuid (getuid ()) fails.
224
id_setup () { args=-u; }
226
# Use env to avoid invoking built-in sleep of Solaris 11's /bin/sh.
232
link_setup () { args="$tmp_in link-target"; }
233
unlink_setup () { args=$tmp_in; }
240
stat_setup () { args=$tmp_in; }
241
unlink_setup () { args=$tmp_in; }
242
lbracket_setup () { args=": ]"; }
244
parted_setup () { args="-s $tmp_in mklabel gpt"
245
dd if=/dev/null of=$tmp_in seek=2000; }
247
# Ensure that each program "works" (exits successfully) when doing
248
# something more than --help or --version.
249
for i in $built_programs; do
251
case $i in chroot|stty|tty|false|chcon|runcon) continue;; esac
253
rm -rf $tmp_in $tmp_in2 $tmp_dir $tmp_out $bigZ_in $zin $zin2
258
# This is sort of kludgey: use numbers so this is valid input for factor,
259
# and two tokens so it's valid input for tsort.
260
echo 2147483647 0 > $tmp_in
261
# Make $tmp_in2 identical. Then, using $tmp_in and $tmp_in2 as arguments
262
# to the likes of cmp and diff makes them exit successfully.
265
# echo ================== $i
266
test $i = [ && prog=lbracket || prog=$(echo $i|sed "s/$EXEEXT$//")
267
if type ${prog}_setup > /dev/null 2>&1; then
272
if env $i $args < $tmp_in > $tmp_out; then
278
rm -rf $tmp_in $tmp_in2 $tmp_out $tmp_dir