source: trunk/coreutils/tests/help-version@ 2612

Last change on this file since 2612 was 2604, checked in by bird, 19 years ago

Made it work on OS/2. (access denied errors mostly, caused by messing with $tmp_in which is opened read only by the shell for input redirection.)

File size: 5.6 KB
Line 
1#! /bin/sh
2# Make sure all these programs work properly
3# when invoked with --help or --version.
4
5test "$VERBOSE" = yes && set -x
6
7expected_failure_status_nohup=127
8expected_failure_status_printenv=2
9expected_failure_status_tty=3
10expected_failure_status_sort=2
11expected_failure_status_expr=3
12expected_failure_status_lbracket=2
13expected_failure_status_dir=2
14expected_failure_status_ls=2
15expected_failure_status_vdir=2
16
17case "$all_programs" in
18 *groups*)
19 if test -w /dev/full && test -c /dev/full \
20 && echo > /dev/full 2>/dev/null; then
21 cat 1>&2 <<\EOF
22************************************************
23WARNING: On this system, the built-in echo function of /bin/sh
24does not report failure when writing to a full device.
25To demonstrate, run this command:
26
27 /bin/sh -c 'echo hello > /dev/full; echo status=$?'
28
29Notice that the failing echo leaves its exit status set to zero
30and does not produce a diagnostic.
31
32That bug in /bin/sh would cause the test of the groups
33scripts to fail, so it is being removed from the list of
34programs checked by this test.
35************************************************
36EOF
37 all_programs=`echo $all_programs|sed 's/\<groups\> *//'`
38 fi
39 ;;
40esac
41
42fail=0
43
44for lang in C fr da; do
45 for i in $all_programs; do
46
47 # Skip `test'; it doesn't accept --help or --version.
48 test $i = test && continue;
49
50 # false fails even when invoked with --help or --version.
51 if test $i = false; then
52 env LC_MESSAGES=$lang ../src/$i --help >/dev/null && fail=1
53 env LC_MESSAGES=$lang ../src/$i --version >/dev/null && fail=1
54 continue
55 fi
56
57 # The just-built install executable is always named `ginstall'.
58 test $i = install && i=ginstall
59
60 # Make sure they exit successfully, under normal conditions.
61 ../src/$i --help > h-$i || fail=1
62 ../src/$i --version >/dev/null || fail=1
63
64 # Make sure they mention the bug-reporting address in --help output.
65 grep "$PACKAGE_BUGREPORT" h-$i > /dev/null || fail=1
66 rm -f h-$i
67
68 # Make sure they fail upon `disk full' error.
69 if test -w /dev/full && test -c /dev/full; then
70 ../src/$i --help >/dev/full 2>/dev/null && fail=1
71 ../src/$i --version >/dev/full 2>/dev/null && fail=1
72 status=$?
73 test $i = [ && prog=lbracket || prog=$i
74 eval "expected=\$expected_failure_status_$prog"
75 test x$expected = x && expected=1
76 if test $status = $expected; then
77 : # ok
78 else
79 fail=1
80 echo "*** $i: bad exit status \`$status' (expected $expected)," 1>&2
81 echo " with --help or --version output redirected to /dev/full" 1>&2
82 fi
83 fi
84 done
85done
86
87tmp=tmp-$$
88tmp_in=in-$$
89tmp_in2=in2-$$
90tmp_in3=in3-$$ #bird
91tmp_dir=dir-$$
92tmp_out=out-$$
93mkdir $tmp || fail=1
94cd $tmp || fail=1
95
96comm_args="$tmp_in $tmp_in"
97csplit_args="$tmp_in //"
98cut_args='-f 1'
99join_args="$tmp_in $tmp_in"
100tr_args='a a'
101
102#chmod_args="a+x $tmp_in" # bird
103chmod_args="a+x $tmp_in2" # bird - access denied
104# Punt on these.
105chgrp_args=--version
106chown_args=--version
107mkfifo_args=--version
108mknod_args=--version
109# Punt on uptime, since it fails (e.g., failing to get boot time)
110# on some systems, and we shouldn't let that stop `make check'.
111uptime_args=--version
112
113cmp_args="$tmp_in $tmp_in2"
114diff_args="$tmp_in $tmp_in2"
115sdiff_args="$tmp_in $tmp_in2"
116diff3_args="$tmp_in $tmp_in2 $tmp_in2"
117cp_args="$tmp_in $tmp_in2"
118#ln_args="$tmp_in ln-target" # bird
119if $srcdir/is-hardlink-supported; then # bird
120ln_args="$tmp_in ln-target" # bird
121else # bird
122ln_args="-s $tmp_in ln-target" # bird
123fi # bird
124ginstall_args="$tmp_in $tmp_in2"
125#mv_args="$tmp_in $tmp_in2" # bird
126mv_args="$tmp_in2 $tmp_in3" # bird - access denied
127mkdir_args=$tmp_dir/subdir
128rmdir_args=$tmp_dir
129#rm_args=$tmp_in # bird
130rm_args=$tmp_in2 # bird - access denied
131#shred_args=$tmp_in # bird
132shred_args=$tmp_in2 # bird - access denied
133touch_args=$tmp_in2
134
135basename_args=$tmp_in
136dirname_args=$tmp_in
137expr_args=foo
138
139# Punt, in case GNU `id' hasn't been installed yet.
140groups_args=--version
141
142pathchk_args=$tmp_in
143yes_args=--version
144logname_args=--version
145nohup_args=--version
146printf_args=foo
147seq_args=10
148sleep_args=0
149su_args=--version
150test_args=foo
151
152# This is necessary in the unusual event that there is
153# no valid entry in /etc/mtab.
154df_args=/
155
156# This is necessary in the unusual event that getpwuid (getuid ()) fails.
157id_args=-u
158
159sleep 10m &
160kill_args=$!
161
162link_args="$tmp_in link-target"
163unlink_args=$tmp_in
164
165ln -s . slink
166readlink_args=slink
167
168stat_args=$tmp_in
169#unlink_args=$tmp_in # bird
170unlink_args=$tmp_in2 # bird - access denied
171lbracket_args=": ]"
172
173for i in $all_programs; do
174 # Skip these.
175 case $i in chroot|stty|tty|false) continue;; esac
176
177 rm -rf $tmp_in $tmp_in2 $tmp_dir $tmp_out
178 echo > $tmp_in
179 echo > $tmp_in2
180 mkdir $tmp_dir
181 # echo ================== $i
182 test $i = [ && prog=lbracket || prog=$i
183 eval "args=\$${prog}_args"
184 if ../../src/$i $args < $tmp_in > $tmp_out; then
185 : # ok
186 else
187 case $i in # bird
188 link|pinky|whoami|who|users) # bird
189 echo "IGNORED: $i";; # bird
190 *) # bird
191 echo "FAIL: $i" # bird
192 fail=1;; # bird
193 esac # bird
194
195 fi
196 rm -rf $tmp_in $tmp_in2 $tmp_out $tmp_dir $tmp_in3 # bird (in3)
197done
198
199# FIXME: trap
200cd ..
201rm -rf $tmp
202
203exit $fail
Note: See TracBrowser for help on using the repository browser.