*** empty log message ***
[coreutils.git] / tests / help-version
blobaa8fb73a0c4f1bd07bd9950ec2cf0df147b8a5dc
1 #! /bin/sh
2 # Make sure all these programs work properly
3 # when invoked with --help or --version.
5 test "$VERBOSE" = yes && set -x
7 expected_failure_status_nohup=127
8 expected_failure_status_printenv=2
9 expected_failure_status_tty=3
10 expected_failure_status_sort=2
11 expected_failure_status_expr=3
12 expected_failure_status_lbracket=2
14 case "$all_programs" in
15 *groups*)
16 if test -w /dev/full && test -c /dev/full && echo > /dev/full; then
17 cat 1>&2 <<\EOF
18 ************************************************
19 WARNING: On this system, the built-in echo function of /bin/sh
20 does not report failure when writing to a full device.
21 To demonstrate, run this command:
23 /bin/sh -c 'echo hello > /dev/full; echo status=$?'
25 Notice that the failing echo leaves its exit status set to zero
26 and does not produce a diagnostic.
28 That bug in /bin/sh would cause the test of the groups
29 scripts to fail, so it is being removed from the list of
30 programs checked by this test.
31 ************************************************
32 EOF
33 all_programs=`echo $all_programs|sed 's/\<groups\> *//'`
36 esac
38 fail=0
40 for lang in C fr da; do
41 for i in $all_programs; do
43 # Skip `test'; it doesn't accept --help or --version.
44 test $i = test && continue;
46 # false fails even when invoked with --help or --version.
47 if test $i = false; then
48 env LC_MESSAGES=$lang ../src/$i --help >/dev/null && fail=1
49 env LC_MESSAGES=$lang ../src/$i --version >/dev/null && fail=1
50 continue
53 # The just-built install executable is always named `ginstall'.
54 test $i = install && i=ginstall
56 # Make sure they exit successfully, under normal conditions.
57 ../src/$i --help > h-$i || fail=1
58 ../src/$i --version >/dev/null || fail=1
60 # Make sure they mention the bug-reporting address in --help output.
61 grep "$PACKAGE_BUGREPORT" h-$i > /dev/null || fail=1
62 rm -f h-$i
64 # Make sure they fail upon `disk full' error.
65 if test -w /dev/full && test -c /dev/full; then
66 ../src/$i --help >/dev/full 2>/dev/null && fail=1
67 ../src/$i --version >/dev/full 2>/dev/null && fail=1
68 status=$?
69 test $i = [ && prog=lbracket || prog=$i
70 eval "expected=\$expected_failure_status_$prog"
71 test x$expected = x && expected=1
72 if test $status = $expected; then
73 : # ok
74 else
75 fail=1
76 echo "*** $i: bad exit status \`$status' (expected $expected)," 1>&2
77 echo " with --help or --version output redirected to /dev/full" 1>&2
80 done
81 done
83 tmp=tmp-$$
84 tmp_in=in-$$
85 tmp_in2=in2-$$
86 tmp_dir=dir-$$
87 tmp_out=out-$$
88 mkdir $tmp || fail=1
89 cd $tmp || fail=1
91 comm_args="$tmp_in $tmp_in"
92 csplit_args="$tmp_in //"
93 cut_args='-f 1'
94 join_args="$tmp_in $tmp_in"
95 tr_args='a a'
97 chmod_args="a+x $tmp_in"
98 # Punt on these.
99 chgrp_args=--version
100 chown_args=--version
101 mkfifo_args=--version
102 mknod_args=--version
104 cmp_args="$tmp_in $tmp_in2"
105 diff_args="$tmp_in $tmp_in2"
106 sdiff_args="$tmp_in $tmp_in2"
107 diff3_args="$tmp_in $tmp_in2 $tmp_in2"
108 cp_args="$tmp_in $tmp_in2"
109 ln_args="$tmp_in ln-target"
110 ginstall_args="$tmp_in $tmp_in2"
111 mv_args="$tmp_in $tmp_in2"
112 mkdir_args=$tmp_dir/subdir
113 rmdir_args=$tmp_dir
114 rm_args=$tmp_in
115 shred_args=$tmp_in
116 touch_args=$tmp_in2
118 basename_args=$tmp_in
119 dirname_args=$tmp_in
120 expr_args=foo
122 # Punt, in case GNU `id' hasn't been installed yet.
123 groups_args=--version
125 pathchk_args=$tmp_in
126 yes_args=--version
127 logname_args=--version
128 nohup_args=--version
129 printf_args=foo
130 seq_args=10
131 sleep_args=0
132 su_args=--version
133 test_args=foo
135 # This is necessary in the unusual event that there is
136 # no valid entry in /etc/mtab.
137 df_args=/
139 # This is necessary in the unusual event that getpwuid (getuid ()) fails.
140 id_args=-u
142 sleep 10m &
143 kill_args=$!
145 link_args="$tmp_in link-target"
146 unlink_args=$tmp_in
148 ln -s . slink
149 readlink_args=slink
151 stat_args=$tmp_in
152 unlink_args=$tmp_in
153 lbracket_args=": ]"
155 for i in $all_programs; do
156 # Skip these.
157 case $i in chroot|stty|tty|false) continue;; esac
159 rm -rf $tmp_in $tmp_in2 $tmp_dir $tmp_out
160 echo > $tmp_in
161 echo > $tmp_in2
162 mkdir $tmp_dir
163 # echo ================== $i
164 test $i = [ && prog=lbracket || prog=$i
165 eval "args=\$${prog}_args"
166 if ../../src/$i $args < $tmp_in > $tmp_out; then
167 : # ok
168 else
169 echo FAIL: $i
170 fail=1
172 rm -rf $tmp_in $tmp_in2 $tmp_out $tmp_dir
173 done
175 # FIXME: trap
176 cd ..
177 rm -rf $tmp
179 exit $fail