(check-x-vs-1): Use @PATH_SEPARATOR@, not `:'.
[coreutils.git] / tests / help-version
blobceb7603598fe4d990f145d68f4c4a92653c1c9f3
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_date=2
8 expected_failure_status_printenv=2
9 expected_failure_status_tty=3
10 expected_failure_status_sort=2
12 case "$all_programs" in
13 *nohup*)
14 if test -w /dev/full && test -c /dev/full && echo > /dev/full; then
15 cat 1>&2 <<\EOF
16 ************************************************
17 WARNING: On this system, the built-in echo function of /bin/sh
18 does not report failure when writing to a full device.
19 To demonstrate, run this command:
21 /bin/sh -c 'echo hello > /dev/full; echo status=$?'
23 Notice that the failing echo leaves its exit status set to zero
24 and does not produce a diagnostic.
26 That bug in /bin/sh would cause the tests of the nohup and groups
27 scripts to fail, so those two are being removed from the list of
28 programs checked by this test.
29 ************************************************
30 EOF
31 all_programs=`echo $all_programs|sed 's/\<nohup\> *//;s/\<groups\> *//'`
34 esac
36 fail=0
38 for lang in C fr da; do
39 for i in $all_programs; do
41 # false fails even when invoked with --help or --version.
42 if test $i = false; then
43 env LC_MESSAGES=$lang ./$i --help >/dev/null && fail=1
44 env LC_MESSAGES=$lang ./$i --version >/dev/null && fail=1
45 continue
48 # The just-built install executable is always named `ginstall'.
49 test $i = install && i=ginstall
51 # Make sure they exit successfully, under normal conditions.
52 ./$i --help >/dev/null || fail=1
53 ./$i --version >/dev/null || fail=1
55 # Make sure they fail upon `disk full' error.
56 if test -w /dev/full && test -c /dev/full; then
57 ./$i --help >/dev/full 2>/dev/null && fail=1
58 ./$i --version >/dev/full 2>/dev/null && fail=1
59 status=$?
60 eval "expected=\$expected_failure_status_$i"
61 test x$expected = x && expected=1
62 if test $status = $expected; then
63 : # ok
64 else
65 fail=1
66 echo "$i with --help and/or --version didn't fail with output" \
67 "redirected to /dev/full" 1>&2
70 done
71 done
73 tmp=tmp-$$
74 tmp_in=in-$$
75 tmp_in2=in2-$$
76 tmp_dir=dir-$$
77 tmp_out=out-$$
78 mkdir $tmp || fail=1
79 cd $tmp || fail=1
81 comm_args="$tmp_in $tmp_in"
82 csplit_args="$tmp_in //"
83 cut_args='-f 1'
84 join_args="$tmp_in $tmp_in"
85 tr_args='a a'
87 chmod_args="a+x $tmp_in"
88 # Punt on these.
89 chgrp_args=--version
90 chown_args=--version
91 mkfifo_args=--version
92 mknod_args=--version
94 cmp_args="$tmp_in $tmp_in2"
95 diff_args="$tmp_in $tmp_in2"
96 sdiff_args="$tmp_in $tmp_in2"
97 diff3_args="$tmp_in $tmp_in2 $tmp_in2"
98 cp_args="$tmp_in $tmp_in2"
99 ln_args="$tmp_in $tmp_in2"
100 ginstall_args="$tmp_in $tmp_in2"
101 mv_args="$tmp_in $tmp_in2"
102 mkdir_args=$tmp_in2
103 rmdir_args=$tmp_dir
104 rm_args=$tmp_in
105 shred_args=$tmp_in
106 touch_args=$tmp_in2
108 basename_args=$tmp_in
109 dirname_args=$tmp_in
110 expr_args=foo
112 # Punt, in case GNU `id' hasn't been installed yet.
113 groups_args=--version
115 pathchk_args=$tmp_in
116 yes_args=--version
117 logname_args=--version
118 nohup_args=--version
119 printf_args=foo
120 seq_args=10
121 sleep_args=0
122 su_args=--version
123 test_args=foo
124 # skip chroot, stty, tty, false
126 for i in $all_programs; do
127 # Skip these.
128 case $i in chroot|stty|tty|false) continue;; esac
130 rm -rf $tmp_in $tmp_in2 $tmp_dir $tmp_out
131 echo > $tmp_in
132 echo > $tmp_in2
133 mkdir $tmp_dir
134 # echo ================== $i
135 eval "args=\$${i}_args"
136 if ../$i $args < $tmp_in > $tmp_out; then
137 : # ok
138 else
139 echo FAIL: $i
140 fail=1
142 rm -rf $tmp_in $tmp_in2 $tmp_out $tmp_dir
143 done
145 # FIXME: trap
146 cd ..
147 rm -rf $tmp
149 exit $fail