1fb0dc8fbaa8ae8e7912df1116d59561009bc567
[platform/upstream/bash.git] / tests / test-tests
1 t()
2 {
3         test "$@"
4         echo $?
5 }
6
7 echo 't -a noexist'
8 t -a noexist
9 echo 't -a run-all'
10 t -a run-all
11
12 echo 't -b run-all'
13 t -b run-all
14 echo 't -b /dev/jb1a'
15 t -b /dev/jb1a
16
17 echo 't -c run-all'
18 t -c run-all
19 echo 't -c /dev/tty'
20 t -c /dev/tty
21
22 echo 't -d run-all'
23 t -d run-all
24 echo 't -d /etc'
25 t -d /etc
26
27 echo 't -e noexist'
28 t -e noexist
29 echo 't -e run-all'
30 t -e run-all
31
32 echo 't -f noexist'
33 t -f noexist
34 echo 't -f /dev/tty'
35 t -f /dev/tty
36 echo 't -f run-all'
37 t -f run-all
38
39 echo 't -g run-all'
40 t -g run-all
41
42 touch /tmp/test.setgid
43 chmod ug+x /tmp/test.setgid
44 chmod g+s /tmp/test.setgid
45 echo 't -g /tmp/test.setgid'
46 t -g /tmp/test.setgid
47 rm -f /tmp/test.setgid
48
49 echo 't -k run-all'
50 t -k run-all
51
52 echo 't -n ""'
53 t -n ""
54 echo 't -n "hello"'
55 t -n "hello"
56
57 echo 't -p run-all'
58 t -p run-all
59
60 echo 't -r noexist'
61 t -r noexist
62
63 touch /tmp/test.noread
64 chmod a-r /tmp/test.noread
65 echo 't -r /tmp/test.noread'
66 t -r /tmp/test.noread
67 rm -f /tmp/test.noread
68
69 echo 't -r run-all'
70 t -r run-all
71
72 echo 't -s noexist'
73 t -s noexist
74 echo 't -s /dev/null'
75 t -s /dev/null
76 echo 't -s run-all'
77 t -s run-all
78
79 echo 't -t 20'
80 t -t 20
81 echo 't -t 0'
82 t -t 0
83
84 echo 't -u noexist'
85 t -u noexist
86
87 echo 't -u run-all'
88 t -u run-all
89
90 touch /tmp/test.setuid
91 chmod u+x /tmp/test.setuid      # some systems require this to turn on setuid bit
92 chmod u+s /tmp/test.setuid
93 echo 't -u /tmp/test.setuid'
94 t -u /tmp/test.setuid
95 rm -f /tmp/test.setuid
96
97 echo 't -w noexist'
98 t -w noexist
99
100 touch /tmp/test.nowrite
101 chmod a-w /tmp/test.nowrite
102 echo 't -w /tmp/test.nowrite'
103 t -w /tmp/test.nowrite
104 rm -f /tmp/test.nowrite
105
106 echo 't -w /dev/null'
107 t -w /dev/null
108
109 echo 't -x noexist'
110 t -x noexist
111
112 touch /tmp/test.exec
113 chmod u+x /tmp/test.exec
114 echo 't -x /tmp/test.exec'
115 t -x /tmp/test.exec
116 rm -f /tmp/test.exec
117
118 touch /tmp/test.noexec
119 chmod u-x /tmp/test.noexec
120 echo 't -x /tmp/test.noexec'
121 t -x /tmp/test.noexec
122 rm -f /tmp/test.noexec
123
124 echo 't -z ""'
125 t -z ""
126 echo 't -z "foo"'
127 t -z "foo"
128
129 echo 't "foo"'
130 t "foo"
131 echo 't ""'
132 t ""
133
134 touch /tmp/test.owner
135 echo 't -O /tmp/test.owner'
136 t -O /tmp/test.owner
137 rm -f /tmp/test.owner
138
139 echo 't "hello" = "hello"'
140 t "hello" = "hello"
141 echo 't "hello" = "goodbye"'
142 t "hello" = "goodbye"
143
144 echo 't "hello" == "hello"'
145 t "hello" == "hello"
146 echo 't "hello" == "goodbye"'
147 t "hello" == "goodbye"
148
149 echo 't "hello" != "hello"'
150 t "hello" != "hello"
151 echo 't "hello" != "goodbye"'
152 t "hello" != "goodbye"
153
154 echo 't "hello" < "goodbye"'
155 t "hello" \< "goodbye"
156 echo 't "hello" > "goodbye"'
157 t "hello" \> "goodbye"
158
159 echo 't ! "hello" > "goodbye"'
160 t "! hello" \> "goodbye"
161
162 echo 't 200 -eq 200'
163 t 200 -eq 200
164 echo 't 34 -eq 222'
165 t 34 -eq 222
166
167 echo 't 200 -ne 200'
168 t 200 -ne 200
169 echo 't 34 -ne 222'
170 t 34 -ne 222
171
172 echo 't 200 -gt 200'
173 t 200 -gt 200
174 echo 't 340 -gt 222'
175 t 340 -gt 222
176
177 echo 't 200 -ge 200'
178 t 200 -ge 200
179 echo 't 34 -ge 222'
180 t 34 -ge 222
181
182 echo 't 200 -lt 200'
183 t 200 -lt 200
184 echo 't 34 -lt 222'
185 t 34 -lt 222
186
187 echo 't 200 -le 200'
188 t 200 -le 200
189 echo 't 340 -le 222'
190 t 340 -le 222
191
192 echo 't 700 -le 1000 -a -n "1" -a "20" = "20"'
193 t 700 -le 1000 -a -n "1" -a "20" = "20"
194 echo 't ! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)'
195 t ! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)
196
197 touch /tmp/abc
198 sleep 2
199 touch /tmp/def
200
201 echo 't /tmp/abc -nt /tmp/def'
202 t /tmp/abc -nt /tmp/def
203 echo 't /tmp/abc -ot /tmp/def'
204 t /tmp/abc -ot /tmp/def
205 echo 't /tmp/def -nt /tmp/abc'
206 t /tmp/def -nt /tmp/abc
207 echo 't /tmp/def -ot /tmp/abc'
208 t /tmp/def -ot /tmp/abc
209
210 echo 't /tmp/abc -ef /tmp/def'
211 t /tmp/abc -ef /tmp/def
212 ln /tmp/abc /tmp/ghi
213 echo 't /tmp/abc -ef /tmp/ghi'
214 t /tmp/abc -ef /tmp/ghi
215
216 rm /tmp/abc /tmp/def /tmp/ghi
217
218 echo 't -r /dev/fd/0'
219 t -r /dev/fd/0
220 echo 't -w /dev/fd/1'
221 t -w /dev/fd/1
222 echo 't -w /dev/fd/2'
223 t -w /dev/fd/2
224 echo 't'
225 t
226
227 echo 't 12 -eq 34'
228 t 12 -eq 34
229 echo 't ! 12 -eq 34'
230 t ! 12 -eq 34
231
232 echo 't -n abcd -o aaa'
233 t -n abcd -o aaa
234 echo 't -n abcd -o -z aaa'
235 t -n abcd -o -z aaa
236
237 echo 't -n abcd -a aaa'
238 t -n abcd -a aaa
239 echo 't -n abcd -a -z aaa'
240 t -n abcd -a -z aaa
241
242 set +o allexport
243 echo 't -o allexport'
244 t -o allexport
245 echo 't ! -o allexport'
246 t ! -o allexport
247
248 echo 't xx -a yy'
249 t xx -a yy
250 echo 't xx -o ""'
251 t xx -o ""
252 echo 't xx -a ""'
253 t xx -a ""
254
255 echo 't -X -a -X'
256 t -X -a -X
257 echo 't -X -o -X'
258 t -X -o -X
259 echo 't -X -o ""'
260 t -X -o ""
261 echo 't -X -a ""'
262 t -X -a ""
263 echo 't "" -a -X'
264 t "" -a -X
265 echo 't "" -o -X'
266 t "" -o -X
267 echo 't "" -a ""'
268 t "" -a ""
269 echo 't "" -o ""'
270 t "" -o ""
271 echo 't true -o -X'
272 t true -o -X
273 echo 't true -a -X'
274 t true -a -X
275
276 echo 't ( -E )'
277 t \( -E \)
278 echo 't ( "" )'
279 t \( "" \)