1 | if (( $UID == 0 )); then
|
---|
2 | echo "test-tests: the test suite should not be run as root" >&2
|
---|
3 | fi
|
---|
4 |
|
---|
5 | b()
|
---|
6 | {
|
---|
7 | [ "$@" ]
|
---|
8 | echo $?
|
---|
9 | }
|
---|
10 |
|
---|
11 | t()
|
---|
12 | {
|
---|
13 | test "$@"
|
---|
14 | echo $?
|
---|
15 | }
|
---|
16 |
|
---|
17 | echo 't -a noexist'
|
---|
18 | t -a noexist
|
---|
19 | echo 't -a run-all'
|
---|
20 | t -a run-all
|
---|
21 |
|
---|
22 | echo 't -b run-all'
|
---|
23 | t -b run-all
|
---|
24 | echo 't -b /dev/jb1a'
|
---|
25 | t -b /dev/jb1a
|
---|
26 |
|
---|
27 | echo 't -c run-all'
|
---|
28 | t -c run-all
|
---|
29 | echo 't -c /dev/tty'
|
---|
30 | t -c /dev/tty
|
---|
31 |
|
---|
32 | echo 't -d run-all'
|
---|
33 | t -d run-all
|
---|
34 | echo 't -d /etc'
|
---|
35 | t -d /etc
|
---|
36 | echo 't -d ""'
|
---|
37 | t -d ""
|
---|
38 | echo 'b -d ""'
|
---|
39 | b -d ""
|
---|
40 |
|
---|
41 | echo 't -e noexist'
|
---|
42 | t -e noexist
|
---|
43 | echo 't -e run-all'
|
---|
44 | t -e run-all
|
---|
45 |
|
---|
46 | echo 't -f noexist'
|
---|
47 | t -f noexist
|
---|
48 | echo 't -f /dev/tty'
|
---|
49 | t -f /dev/tty
|
---|
50 | echo 't -f run-all'
|
---|
51 | t -f run-all
|
---|
52 |
|
---|
53 | echo 't -g run-all'
|
---|
54 | t -g run-all
|
---|
55 |
|
---|
56 | touch /tmp/test.setgid
|
---|
57 | chgrp ${GROUPS[0]} /tmp/test.setgid
|
---|
58 | chmod ug+x /tmp/test.setgid
|
---|
59 | chmod g+s /tmp/test.setgid
|
---|
60 | echo 't -g /tmp/test.setgid'
|
---|
61 | t -g /tmp/test.setgid
|
---|
62 | rm -f /tmp/test.setgid
|
---|
63 |
|
---|
64 | echo 't -k run-all'
|
---|
65 | t -k run-all
|
---|
66 |
|
---|
67 | echo 't -n ""'
|
---|
68 | t -n ""
|
---|
69 | echo 't -n "hello"'
|
---|
70 | t -n "hello"
|
---|
71 |
|
---|
72 | echo 't -p run-all'
|
---|
73 | t -p run-all
|
---|
74 |
|
---|
75 | echo 't -r noexist'
|
---|
76 | t -r noexist
|
---|
77 |
|
---|
78 | if (( $UID != 0 )); then
|
---|
79 | touch /tmp/test.noread
|
---|
80 | chmod a-r /tmp/test.noread
|
---|
81 | echo 't -r /tmp/test.noread'
|
---|
82 | t -r /tmp/test.noread
|
---|
83 | rm -f /tmp/test.noread
|
---|
84 | else
|
---|
85 | echo 't -r /tmp/test.noread'
|
---|
86 | echo 1
|
---|
87 | fi
|
---|
88 |
|
---|
89 | echo 't -r run-all'
|
---|
90 | t -r run-all
|
---|
91 |
|
---|
92 | echo 't -s noexist'
|
---|
93 | t -s noexist
|
---|
94 | echo 't -s /dev/null'
|
---|
95 | t -s /dev/null
|
---|
96 | echo 't -s run-all'
|
---|
97 | t -s run-all
|
---|
98 |
|
---|
99 | echo 't -t 20'
|
---|
100 | t -t 20
|
---|
101 | echo 't -t 0'
|
---|
102 | t -t 0 < /dev/tty
|
---|
103 |
|
---|
104 | echo 't -u noexist'
|
---|
105 | t -u noexist
|
---|
106 |
|
---|
107 | echo 't -u run-all'
|
---|
108 | t -u run-all
|
---|
109 |
|
---|
110 | touch /tmp/test.setuid
|
---|
111 | chmod u+x /tmp/test.setuid # some systems require this to turn on setuid bit
|
---|
112 | chmod u+s /tmp/test.setuid
|
---|
113 | echo 't -u /tmp/test.setuid'
|
---|
114 | t -u /tmp/test.setuid
|
---|
115 | rm -f /tmp/test.setuid
|
---|
116 |
|
---|
117 | echo 't -w noexist'
|
---|
118 | t -w noexist
|
---|
119 |
|
---|
120 | if (( $UID != 0 )); then
|
---|
121 | touch /tmp/test.nowrite
|
---|
122 | chmod a-w /tmp/test.nowrite
|
---|
123 | echo 't -w /tmp/test.nowrite'
|
---|
124 | t -w /tmp/test.nowrite
|
---|
125 | rm -f /tmp/test.nowrite
|
---|
126 | else
|
---|
127 | echo 't -w /tmp/test.nowrite'
|
---|
128 | echo 1
|
---|
129 | fi
|
---|
130 |
|
---|
131 | echo 't -w /dev/null'
|
---|
132 | t -w /dev/null
|
---|
133 |
|
---|
134 | echo 't -x noexist'
|
---|
135 | t -x noexist
|
---|
136 |
|
---|
137 | touch /tmp/test.exec
|
---|
138 | chmod u+x /tmp/test.exec
|
---|
139 | echo 't -x /tmp/test.exec'
|
---|
140 | t -x /tmp/test.exec
|
---|
141 | rm -f /tmp/test.exec
|
---|
142 |
|
---|
143 | touch /tmp/test.noexec
|
---|
144 | chmod u-x /tmp/test.noexec
|
---|
145 | echo 't -x /tmp/test.noexec'
|
---|
146 | t -x /tmp/test.noexec
|
---|
147 | rm -f /tmp/test.noexec
|
---|
148 |
|
---|
149 | echo 't -z ""'
|
---|
150 | t -z ""
|
---|
151 | echo 't -z "foo"'
|
---|
152 | t -z "foo"
|
---|
153 |
|
---|
154 | echo 't "foo"'
|
---|
155 | t "foo"
|
---|
156 | echo 't ""'
|
---|
157 | t ""
|
---|
158 |
|
---|
159 | touch /tmp/test.owner
|
---|
160 | echo 't -O /tmp/test.owner'
|
---|
161 | t -O /tmp/test.owner
|
---|
162 | rm -f /tmp/test.owner
|
---|
163 |
|
---|
164 | touch /tmp/test.socket
|
---|
165 | echo 't -S /tmp/test.socket'
|
---|
166 | t -S /tmp/test.socket # false
|
---|
167 | rm -f /tmp/test.socket
|
---|
168 |
|
---|
169 | touch /tmp/test.newer
|
---|
170 | echo 't -N /tmp/test.newer'
|
---|
171 | t -N /tmp/test.newer
|
---|
172 | rm -f /tmp/test.newer
|
---|
173 |
|
---|
174 | echo 't "hello" = "hello"'
|
---|
175 | t "hello" = "hello"
|
---|
176 | echo 't "hello" = "goodbye"'
|
---|
177 | t "hello" = "goodbye"
|
---|
178 |
|
---|
179 | echo 't "hello" == "hello"'
|
---|
180 | t "hello" == "hello"
|
---|
181 | echo 't "hello" == "goodbye"'
|
---|
182 | t "hello" == "goodbye"
|
---|
183 |
|
---|
184 | echo 't "hello" != "hello"'
|
---|
185 | t "hello" != "hello"
|
---|
186 | echo 't "hello" != "goodbye"'
|
---|
187 | t "hello" != "goodbye"
|
---|
188 |
|
---|
189 | echo 't "hello" < "goodbye"'
|
---|
190 | t "hello" \< "goodbye"
|
---|
191 | echo 't "hello" > "goodbye"'
|
---|
192 | t "hello" \> "goodbye"
|
---|
193 |
|
---|
194 | echo 't ! "hello" > "goodbye"'
|
---|
195 | t "! hello" \> "goodbye"
|
---|
196 |
|
---|
197 | echo 't 200 -eq 200'
|
---|
198 | t 200 -eq 200
|
---|
199 | echo 't 34 -eq 222'
|
---|
200 | t 34 -eq 222
|
---|
201 | echo 't -32 -eq 32'
|
---|
202 | t -32 -eq 32
|
---|
203 |
|
---|
204 | echo 't 200 -ne 200'
|
---|
205 | t 200 -ne 200
|
---|
206 | echo 't 34 -ne 222'
|
---|
207 | t 34 -ne 222
|
---|
208 |
|
---|
209 | echo 't 200 -gt 200'
|
---|
210 | t 200 -gt 200
|
---|
211 | echo 't 340 -gt 222'
|
---|
212 | t 340 -gt 222
|
---|
213 |
|
---|
214 | echo 't 200 -ge 200'
|
---|
215 | t 200 -ge 200
|
---|
216 | echo 't 34 -ge 222'
|
---|
217 | t 34 -ge 222
|
---|
218 |
|
---|
219 | echo 't 200 -lt 200'
|
---|
220 | t 200 -lt 200
|
---|
221 | echo 't 34 -lt 222'
|
---|
222 | t 34 -lt 222
|
---|
223 |
|
---|
224 | echo 't 200 -le 200'
|
---|
225 | t 200 -le 200
|
---|
226 | echo 't 340 -le 222'
|
---|
227 | t 340 -le 222
|
---|
228 |
|
---|
229 | echo 't 700 -le 1000 -a -n "1" -a "20" = "20"'
|
---|
230 | t 700 -le 1000 -a -n "1" -a "20" = "20"
|
---|
231 | echo 't ! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)'
|
---|
232 | t ! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)
|
---|
233 |
|
---|
234 | touch /tmp/abc
|
---|
235 | sleep 2
|
---|
236 | touch /tmp/def
|
---|
237 |
|
---|
238 | echo 't /tmp/abc -nt /tmp/def'
|
---|
239 | t /tmp/abc -nt /tmp/def
|
---|
240 | echo 't /tmp/abc -ot /tmp/def'
|
---|
241 | t /tmp/abc -ot /tmp/def
|
---|
242 | echo 't /tmp/def -nt /tmp/abc'
|
---|
243 | t /tmp/def -nt /tmp/abc
|
---|
244 | echo 't /tmp/def -ot /tmp/abc'
|
---|
245 | t /tmp/def -ot /tmp/abc
|
---|
246 |
|
---|
247 | echo 't /tmp/abc -ef /tmp/def'
|
---|
248 | t /tmp/abc -ef /tmp/def
|
---|
249 | ln /tmp/abc /tmp/ghi
|
---|
250 | echo 't /tmp/abc -ef /tmp/ghi'
|
---|
251 | t /tmp/abc -ef /tmp/ghi
|
---|
252 |
|
---|
253 | rm /tmp/abc /tmp/def /tmp/ghi
|
---|
254 |
|
---|
255 | echo 't -r /dev/fd/0'
|
---|
256 | t -r /dev/fd/0
|
---|
257 | echo 't -w /dev/fd/1'
|
---|
258 | t -w /dev/fd/1
|
---|
259 | echo 't -w /dev/fd/2'
|
---|
260 | t -w /dev/fd/2
|
---|
261 |
|
---|
262 | echo 't -r /dev/stdin'
|
---|
263 | t -r /dev/stdin
|
---|
264 | echo 't -w /dev/stdout'
|
---|
265 | t -w /dev/stdout
|
---|
266 | echo 't -w /dev/stderr'
|
---|
267 | t -w /dev/stderr
|
---|
268 |
|
---|
269 | echo 't'
|
---|
270 | t
|
---|
271 | echo 'b'
|
---|
272 | b
|
---|
273 |
|
---|
274 | echo 't 12 -eq 34'
|
---|
275 | t 12 -eq 34
|
---|
276 | echo 't ! 12 -eq 34'
|
---|
277 | t ! 12 -eq 34
|
---|
278 |
|
---|
279 | echo 't -n abcd -o aaa'
|
---|
280 | t -n abcd -o aaa
|
---|
281 | echo 't -n abcd -o -z aaa'
|
---|
282 | t -n abcd -o -z aaa
|
---|
283 |
|
---|
284 | echo 't -n abcd -a aaa'
|
---|
285 | t -n abcd -a aaa
|
---|
286 | echo 't -n abcd -a -z aaa'
|
---|
287 | t -n abcd -a -z aaa
|
---|
288 |
|
---|
289 | set +o allexport
|
---|
290 | echo 't -o allexport'
|
---|
291 | t -o allexport
|
---|
292 | echo 't ! -o allexport'
|
---|
293 | t ! -o allexport
|
---|
294 |
|
---|
295 | echo 't xx -a yy'
|
---|
296 | t xx -a yy
|
---|
297 | echo 't xx -o ""'
|
---|
298 | t xx -o ""
|
---|
299 | echo 't xx -a ""'
|
---|
300 | t xx -a ""
|
---|
301 |
|
---|
302 | echo 't -X -a -X'
|
---|
303 | t -X -a -X
|
---|
304 | echo 't -X -o -X'
|
---|
305 | t -X -o -X
|
---|
306 | echo 't -X -o ""'
|
---|
307 | t -X -o ""
|
---|
308 | echo 't -X -a ""'
|
---|
309 | t -X -a ""
|
---|
310 | echo 't "" -a -X'
|
---|
311 | t "" -a -X
|
---|
312 | echo 't "" -o -X'
|
---|
313 | t "" -o -X
|
---|
314 | echo 't "" -a ""'
|
---|
315 | t "" -a ""
|
---|
316 | echo 't "" -o ""'
|
---|
317 | t "" -o ""
|
---|
318 | echo 't true -o -X'
|
---|
319 | t true -o -X
|
---|
320 | echo 't true -a -X'
|
---|
321 | t true -a -X
|
---|
322 |
|
---|
323 | echo 't ( -E )'
|
---|
324 | t \( -E \)
|
---|
325 | echo 't ( "" )'
|
---|
326 | t \( "" \)
|
---|
327 |
|
---|
328 | z=42
|
---|
329 |
|
---|
330 | echo 't ! -z "$z"'
|
---|
331 | t ! -z "$z"
|
---|
332 |
|
---|
333 | echo 't ! -n "$z"'
|
---|
334 | t ! -n "$z"
|
---|
335 |
|
---|
336 | zero=
|
---|
337 | echo 't "$zero"'
|
---|
338 | t "$zero"
|
---|
339 | echo 't ! "$zero"'
|
---|
340 | t ! "$zero"
|
---|
341 | echo 'b "$zero"'
|
---|
342 | b "$zero"
|
---|
343 | echo 'b ! "$zero"'
|
---|
344 | b ! "$zero"
|
---|
345 |
|
---|
346 | touch /tmp/test.group
|
---|
347 | chgrp ${GROUPS[0]} /tmp/test.group
|
---|
348 | echo 't -G /tmp/test.group'
|
---|
349 | t -G /tmp/test.group
|
---|
350 | rm /tmp/test.group
|
---|
351 |
|
---|
352 | case "${THIS_SH}" in
|
---|
353 | /*) SHNAME=${THIS_SH} ;;
|
---|
354 | *) SHNAME=${PWD}/${THIS_SH} ;;
|
---|
355 | esac
|
---|
356 |
|
---|
357 | if ln -s ${SHNAME} /tmp/test.symlink 2>/dev/null; then
|
---|
358 | chgrp ${GROUPS[0]} /tmp/test.symlink 2>/dev/null
|
---|
359 | echo 't -h /tmp/test.symlink'
|
---|
360 | t -h /tmp/test.symlink
|
---|
361 | # some systems don't let you remove this
|
---|
362 | rm -f /tmp/test.symlink 2>/dev/null
|
---|
363 | else
|
---|
364 | echo 't -h /tmp/test.symlink'
|
---|
365 | echo 0
|
---|
366 | fi
|
---|
367 |
|
---|
368 | # arithmetic constant errors
|
---|
369 | echo "t 4+3 -eq 7"
|
---|
370 | t 4+3 -eq 7
|
---|
371 | echo "b 4-5 -eq 7"
|
---|
372 | b 4+3 -eq 7
|
---|
373 |
|
---|
374 | echo "t 9 -eq 4+5"
|
---|
375 | t 9 -eq 4+5
|
---|
376 | echo "b 9 -eq 4+5"
|
---|
377 | b 9 -eq 4+5
|
---|
378 |
|
---|
379 | A=7
|
---|
380 | echo "t A -eq 7"
|
---|
381 | t A -eq 7
|
---|
382 | echo "b A -eq 7"
|
---|
383 | b A -eq 7
|
---|
384 |
|
---|
385 | B=9
|
---|
386 | echo "t 9 -eq B"
|
---|
387 | t 9 -eq B
|
---|
388 | echo "b 9 -eq B"
|
---|
389 | b 9 -eq B
|
---|
390 |
|
---|
391 | # badly formed expressions
|
---|
392 | echo 't ( 1 = 2'
|
---|
393 | t \( 1 = 2
|
---|
394 | echo 'b ( 1 = 2'
|
---|
395 | b \( 1 = 2
|
---|
396 |
|
---|
397 | # more errors
|
---|
398 | t a b
|
---|
399 | t a b c
|
---|
400 | t -A v
|
---|
401 | # too many arguments -- argument expected is also reasonable
|
---|
402 | t 4 -eq 4 -a 2 -ne 5 -a 4 -ne
|
---|
403 | # too many arguments
|
---|
404 | t 4 -eq 4 -a 3 4
|
---|
405 |
|
---|
406 | [
|
---|
407 | echo $?
|
---|
408 |
|
---|
409 | t \( \)
|
---|
410 |
|
---|
411 | # non-numeric arguments to `test -t' should return failure -- fix in 2.05
|
---|
412 | echo 't -t a'
|
---|
413 | t -t a
|
---|
414 | echo 't -t addsds'
|
---|
415 | t -t addsds
|
---|
416 | echo 't -t 42'
|
---|
417 | t -t 42
|
---|
418 | echo 't -t /dev/tty'
|
---|
419 | t -t /dev/tty
|
---|
420 | echo 't -t /dev/tty4'
|
---|
421 | t -t /dev/tty4
|
---|
422 | echo 't -t /dev/tty4444444...'
|
---|
423 | t -t /dev/tty4444444...
|
---|