]>
Commit | Line | Data |
---|---|---|
f3721ab2 | 1 | #! /bin/bash |
9a9028b1 | 2 | # Test for glob(3). |
568035b7 | 3 | # Copyright (C) 1997-2013 Free Software Foundation, Inc. |
9a9028b1 DL |
4 | # This file is part of the GNU C Library. |
5 | ||
6 | # The GNU C Library is free software; you can redistribute it and/or | |
7 | # modify it under the terms of the GNU Lesser General Public | |
8 | # License as published by the Free Software Foundation; either | |
9 | # version 2.1 of the License, or (at your option) any later version. | |
10 | ||
11 | # The GNU C Library is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | # Lesser General Public License for more details. | |
15 | ||
16 | # You should have received a copy of the GNU Lesser General Public | |
17 | # License along with the GNU C Library; if not, see | |
18 | # <http://www.gnu.org/licenses/>. | |
61eb22d3 | 19 | |
57c69bef DL |
20 | set -e |
21 | ||
61eb22d3 | 22 | common_objpfx=$1; shift |
740b3dbe L |
23 | test_via_rtld_prefix=$1; shift |
24 | test_program_prefix=$1; shift | |
cc1290d0 | 25 | test_wrapper_env=$1; shift |
3f36c563 | 26 | logfile=$common_objpfx/posix/globtest.out |
61eb22d3 | 27 | |
98d2ca3d UD |
28 | #CMP=cmp |
29 | CMP="diff -u" | |
30 | ||
c277d2e5 UD |
31 | # We have to make the paths `common_objpfx' absolute. |
32 | case "$common_objpfx" in | |
33 | .*) | |
34 | common_objpfx="`pwd`/$common_objpfx" | |
35 | ;; | |
36 | *) | |
37 | ;; | |
38 | esac | |
39 | ||
7ce241a0 | 40 | # Since we use `sort' we must make sure to use the same locale everywhere. |
3f62b69a UD |
41 | LC_ALL=C |
42 | export LC_ALL | |
43 | LANG=C | |
44 | export LANG | |
45 | ||
61eb22d3 | 46 | # Create the arena |
0708a7d1 JM |
47 | testdir=${common_objpfx}posix/globtest-dir |
48 | testout=${common_objpfx}posix/globtest-out | |
49 | rm -rf $testdir $testout | |
50 | mkdir $testdir | |
61eb22d3 | 51 | |
460adbb8 | 52 | trap 'chmod 777 $testdir/noread; rm -fr $testdir $testout' 1 2 3 15 |
61eb22d3 | 53 | |
61eb22d3 UD |
54 | echo 1 > $testdir/file1 |
55 | echo 2 > $testdir/file2 | |
3f62b69a UD |
56 | echo 3 > $testdir/-file3 |
57 | echo 4 > $testdir/~file4 | |
58 | echo 5 > $testdir/.file5 | |
59 | echo 6 > $testdir/'*file6' | |
98d2ca3d UD |
60 | echo 7 > $testdir/'{file7,}' |
61 | echo 8 > $testdir/'\{file8\}' | |
62 | echo 9 > $testdir/'\{file9\,file9b\}' | |
63 | echo 9 > $testdir/'\file9b\' #' | |
64 | echo a > $testdir/'filea,' | |
65 | echo a > $testdir/'fileb}c' | |
61eb22d3 UD |
66 | mkdir $testdir/dir1 |
67 | mkdir $testdir/dir2 | |
460adbb8 UD |
68 | test -d $testdir/noread || mkdir $testdir/noread |
69 | chmod a-r $testdir/noread | |
61eb22d3 UD |
70 | echo 1_1 > $testdir/dir1/file1_1 |
71 | echo 1_2 > $testdir/dir1/file1_2 | |
1fb2614a | 72 | ln -fs dir1 $testdir/link1 |
61eb22d3 UD |
73 | |
74 | # Run some tests. | |
75 | result=0 | |
3f36c563 | 76 | rm -f $logfile |
61eb22d3 | 77 | |
3f62b69a | 78 | # Normal test |
3f36c563 | 79 | failed=0 |
740b3dbe | 80 | ${test_program_prefix} \ |
14e9dd67 | 81 | ${common_objpfx}posix/globtest "$testdir" "*" | |
61eb22d3 | 82 | sort > $testout |
98d2ca3d | 83 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
3f62b69a UD |
84 | `*file6' |
85 | `-file3' | |
98d2ca3d UD |
86 | `\file9b\' |
87 | `\{file8\}' | |
88 | `\{file9\,file9b\}' | |
3f62b69a UD |
89 | `dir1' |
90 | `dir2' | |
91 | `file1' | |
92 | `file2' | |
98d2ca3d UD |
93 | `filea,' |
94 | `fileb}c' | |
1fb2614a | 95 | `link1' |
460adbb8 | 96 | `noread' |
98d2ca3d | 97 | `{file7,}' |
3f62b69a UD |
98 | `~file4' |
99 | EOF | |
3f36c563 UD |
100 | if test $failed -ne 0; then |
101 | echo "Normal test failed" >> $logfile | |
102 | result=1 | |
103 | fi | |
3f62b69a UD |
104 | |
105 | # Don't let glob sort it | |
3f36c563 | 106 | failed=0 |
740b3dbe | 107 | ${test_program_prefix} \ |
3f62b69a UD |
108 | ${common_objpfx}posix/globtest -s "$testdir" "*" | |
109 | sort > $testout | |
98d2ca3d | 110 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
3f62b69a UD |
111 | `*file6' |
112 | `-file3' | |
98d2ca3d UD |
113 | `\file9b\' |
114 | `\{file8\}' | |
115 | `\{file9\,file9b\}' | |
3f62b69a UD |
116 | `dir1' |
117 | `dir2' | |
118 | `file1' | |
119 | `file2' | |
98d2ca3d UD |
120 | `filea,' |
121 | `fileb}c' | |
1fb2614a | 122 | `link1' |
460adbb8 | 123 | `noread' |
98d2ca3d | 124 | `{file7,}' |
3f62b69a UD |
125 | `~file4' |
126 | EOF | |
3f36c563 UD |
127 | if test $failed -ne 0; then |
128 | echo "No sort test failed" >> $logfile | |
129 | result=1 | |
130 | fi | |
3f62b69a UD |
131 | |
132 | # Mark directories | |
3f36c563 | 133 | failed=0 |
740b3dbe | 134 | ${test_program_prefix} \ |
3f62b69a UD |
135 | ${common_objpfx}posix/globtest -m "$testdir" "*" | |
136 | sort > $testout | |
98d2ca3d | 137 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
3f62b69a UD |
138 | `*file6' |
139 | `-file3' | |
98d2ca3d UD |
140 | `\file9b\' |
141 | `\{file8\}' | |
142 | `\{file9\,file9b\}' | |
3f62b69a UD |
143 | `dir1/' |
144 | `dir2/' | |
145 | `file1' | |
146 | `file2' | |
98d2ca3d UD |
147 | `filea,' |
148 | `fileb}c' | |
1fb2614a | 149 | `link1/' |
460adbb8 | 150 | `noread/' |
98d2ca3d | 151 | `{file7,}' |
3f62b69a UD |
152 | `~file4' |
153 | EOF | |
3f36c563 UD |
154 | if test $failed -ne 0; then |
155 | echo "Mark directories test failed" >> $logfile | |
156 | result=1 | |
157 | fi | |
3f62b69a UD |
158 | |
159 | # Find files starting with . | |
3f36c563 | 160 | failed=0 |
740b3dbe | 161 | ${test_program_prefix} \ |
3f62b69a UD |
162 | ${common_objpfx}posix/globtest -p "$testdir" "*" | |
163 | sort > $testout | |
98d2ca3d | 164 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
3f62b69a UD |
165 | `*file6' |
166 | `-file3' | |
167 | `.' | |
168 | `..' | |
169 | `.file5' | |
98d2ca3d UD |
170 | `\file9b\' |
171 | `\{file8\}' | |
172 | `\{file9\,file9b\}' | |
61eb22d3 UD |
173 | `dir1' |
174 | `dir2' | |
175 | `file1' | |
176 | `file2' | |
98d2ca3d UD |
177 | `filea,' |
178 | `fileb}c' | |
1fb2614a | 179 | `link1' |
460adbb8 | 180 | `noread' |
98d2ca3d | 181 | `{file7,}' |
3f62b69a UD |
182 | `~file4' |
183 | EOF | |
3f36c563 UD |
184 | if test $failed -ne 0; then |
185 | echo "Leading period test failed" >> $logfile | |
186 | result=1 | |
187 | fi | |
3f62b69a UD |
188 | |
189 | # Test braces | |
3f36c563 | 190 | failed=0 |
740b3dbe | 191 | ${test_program_prefix} \ |
3f62b69a UD |
192 | ${common_objpfx}posix/globtest -b "$testdir" "file{1,2}" | |
193 | sort > $testout | |
98d2ca3d | 194 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
3f62b69a UD |
195 | `file1' |
196 | `file2' | |
197 | EOF | |
3f36c563 UD |
198 | if test $failed -ne 0; then |
199 | echo "Braces test failed" >> $logfile | |
200 | result=1 | |
201 | fi | |
3f62b69a | 202 | |
096f1151 | 203 | failed=0 |
740b3dbe | 204 | ${test_program_prefix} \ |
096f1151 UD |
205 | ${common_objpfx}posix/globtest -b "$testdir" "{file{1,2},-file3}" | |
206 | sort > $testout | |
98d2ca3d | 207 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
096f1151 UD |
208 | `-file3' |
209 | `file1' | |
210 | `file2' | |
211 | EOF | |
212 | if test $failed -ne 0; then | |
213 | echo "Braces test 2 failed" >> $logfile | |
214 | result=1 | |
215 | fi | |
216 | ||
217 | failed=0 | |
740b3dbe | 218 | ${test_program_prefix} \ |
096f1151 UD |
219 | ${common_objpfx}posix/globtest -b "$testdir" "{" | |
220 | sort > $testout | |
98d2ca3d | 221 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
096f1151 UD |
222 | GLOB_NOMATCH |
223 | EOF | |
224 | if test $failed -ne 0; then | |
225 | echo "Braces test 3 failed" >> $logfile | |
226 | result=1 | |
227 | fi | |
228 | ||
3f62b69a | 229 | # Test NOCHECK |
3f36c563 | 230 | failed=0 |
740b3dbe | 231 | ${test_program_prefix} \ |
3f62b69a UD |
232 | ${common_objpfx}posix/globtest -c "$testdir" "abc" | |
233 | sort > $testout | |
98d2ca3d | 234 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
3f62b69a | 235 | `abc' |
61eb22d3 | 236 | EOF |
3f36c563 UD |
237 | if test $failed -ne 0; then |
238 | echo "No check test failed" >> $logfile | |
239 | result=1 | |
240 | fi | |
61eb22d3 | 241 | |
3f62b69a | 242 | # Test NOMAGIC without magic characters |
3f36c563 | 243 | failed=0 |
740b3dbe | 244 | ${test_program_prefix} \ |
3f62b69a UD |
245 | ${common_objpfx}posix/globtest -g "$testdir" "abc" | |
246 | sort > $testout | |
98d2ca3d | 247 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
3f62b69a UD |
248 | `abc' |
249 | EOF | |
3f36c563 UD |
250 | if test $failed -ne 0; then |
251 | echo "No magic test failed" >> $logfile | |
252 | result=1 | |
253 | fi | |
3f62b69a UD |
254 | |
255 | # Test NOMAGIC with magic characters | |
3f36c563 | 256 | failed=0 |
740b3dbe | 257 | ${test_program_prefix} \ |
3f62b69a UD |
258 | ${common_objpfx}posix/globtest -g "$testdir" "abc*" | |
259 | sort > $testout | |
98d2ca3d | 260 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
3f62b69a UD |
261 | GLOB_NOMATCH |
262 | EOF | |
3f36c563 UD |
263 | if test $failed -ne 0; then |
264 | echo "No magic w/ magic chars test failed" >> $logfile | |
265 | result=1 | |
266 | fi | |
3f62b69a | 267 | |
add09583 UD |
268 | # Test NOMAGIC for subdirs |
269 | failed=0 | |
740b3dbe | 270 | ${test_program_prefix} \ |
add09583 UD |
271 | ${common_objpfx}posix/globtest -g "$testdir" "*/does-not-exist" | |
272 | sort > $testout | |
98d2ca3d | 273 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
add09583 UD |
274 | GLOB_NOMATCH |
275 | EOF | |
276 | if test $failed -ne 0; then | |
277 | echo "No magic in subdir test failed" >> $logfile | |
278 | result=1 | |
279 | fi | |
280 | ||
3f62b69a | 281 | # Test subdirs correctly |
3f36c563 | 282 | failed=0 |
740b3dbe | 283 | ${test_program_prefix} \ |
14e9dd67 | 284 | ${common_objpfx}posix/globtest "$testdir" "*/*" | |
61eb22d3 | 285 | sort > $testout |
98d2ca3d | 286 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
61eb22d3 UD |
287 | `dir1/file1_1' |
288 | `dir1/file1_2' | |
1fb2614a UD |
289 | `link1/file1_1' |
290 | `link1/file1_2' | |
61eb22d3 | 291 | EOF |
3f36c563 UD |
292 | if test $failed -ne 0; then |
293 | echo "Subdirs test failed" >> $logfile | |
294 | result=1 | |
295 | fi | |
61eb22d3 | 296 | |
3f62b69a | 297 | # Test subdirs for invalid names |
3f36c563 | 298 | failed=0 |
740b3dbe | 299 | ${test_program_prefix} \ |
14e9dd67 | 300 | ${common_objpfx}posix/globtest "$testdir" "*/1" | |
61eb22d3 | 301 | sort > $testout |
98d2ca3d | 302 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
61eb22d3 | 303 | GLOB_NOMATCH |
61eb22d3 | 304 | EOF |
3f36c563 UD |
305 | if test $failed -ne 0; then |
306 | echo "Invalid subdir test failed" >> $logfile | |
307 | result=1 | |
308 | fi | |
61eb22d3 | 309 | |
3f62b69a | 310 | # Test subdirs with wildcard |
3f36c563 | 311 | failed=0 |
740b3dbe | 312 | ${test_program_prefix} \ |
14e9dd67 | 313 | ${common_objpfx}posix/globtest "$testdir" "*/*1_1" | |
61eb22d3 | 314 | sort > $testout |
98d2ca3d | 315 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
61eb22d3 | 316 | `dir1/file1_1' |
1fb2614a | 317 | `link1/file1_1' |
3f62b69a | 318 | EOF |
3f36c563 UD |
319 | if test $failed -ne 0; then |
320 | echo "Wildcard subdir test failed" >> $logfile | |
321 | result=1 | |
322 | fi | |
3f62b69a UD |
323 | |
324 | # Test subdirs with ? | |
3f36c563 | 325 | failed=0 |
740b3dbe | 326 | ${test_program_prefix} \ |
3f62b69a UD |
327 | ${common_objpfx}posix/globtest "$testdir" "*/*?_?" | |
328 | sort > $testout | |
98d2ca3d | 329 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
3f62b69a UD |
330 | `dir1/file1_1' |
331 | `dir1/file1_2' | |
1fb2614a UD |
332 | `link1/file1_1' |
333 | `link1/file1_2' | |
61eb22d3 | 334 | EOF |
3f36c563 UD |
335 | if test $failed -ne 0; then |
336 | echo "Wildcard2 subdir test failed" >> $logfile | |
337 | result=1 | |
338 | fi | |
61eb22d3 | 339 | |
3f36c563 | 340 | failed=0 |
740b3dbe | 341 | ${test_program_prefix} \ |
14e9dd67 | 342 | ${common_objpfx}posix/globtest "$testdir" "*/file1_1" | |
61eb22d3 | 343 | sort > $testout |
98d2ca3d | 344 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
61eb22d3 | 345 | `dir1/file1_1' |
1fb2614a | 346 | `link1/file1_1' |
61eb22d3 | 347 | EOF |
3f36c563 UD |
348 | if test $failed -ne 0; then |
349 | echo "Wildcard3 subdir test failed" >> $logfile | |
350 | result=1 | |
351 | fi | |
61eb22d3 | 352 | |
3f36c563 | 353 | failed=0 |
740b3dbe | 354 | ${test_program_prefix} \ |
14e9dd67 | 355 | ${common_objpfx}posix/globtest "$testdir" "*-/*" | |
61eb22d3 | 356 | sort > $testout |
98d2ca3d | 357 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
61eb22d3 | 358 | GLOB_NOMATCH |
61eb22d3 | 359 | EOF |
3f36c563 UD |
360 | if test $failed -ne 0; then |
361 | echo "Wildcard4 subdir test failed" >> $logfile | |
362 | result=1 | |
363 | fi | |
61eb22d3 | 364 | |
3f36c563 | 365 | failed=0 |
740b3dbe | 366 | ${test_program_prefix} \ |
14e9dd67 | 367 | ${common_objpfx}posix/globtest "$testdir" "*-" | |
61eb22d3 | 368 | sort > $testout |
98d2ca3d | 369 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
61eb22d3 | 370 | GLOB_NOMATCH |
3f62b69a | 371 | EOF |
3f36c563 UD |
372 | if test $failed -ne 0; then |
373 | echo "Wildcard5 subdir test failed" >> $logfile | |
374 | result=1 | |
375 | fi | |
3f62b69a UD |
376 | |
377 | # Test subdirs with ? | |
3f36c563 | 378 | failed=0 |
740b3dbe | 379 | ${test_program_prefix} \ |
3f62b69a UD |
380 | ${common_objpfx}posix/globtest "$testdir" "*/*?_?" | |
381 | sort > $testout | |
98d2ca3d | 382 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
3f62b69a UD |
383 | `dir1/file1_1' |
384 | `dir1/file1_2' | |
1fb2614a UD |
385 | `link1/file1_1' |
386 | `link1/file1_2' | |
3f62b69a | 387 | EOF |
3f36c563 UD |
388 | if test $failed -ne 0; then |
389 | echo "Wildcard6 subdir test failed" >> $logfile | |
390 | result=1 | |
391 | fi | |
3f62b69a | 392 | |
460adbb8 | 393 | # Test subdirs with [ .. ] |
3f36c563 | 394 | failed=0 |
740b3dbe | 395 | ${test_program_prefix} \ |
460adbb8 UD |
396 | ${common_objpfx}posix/globtest "$testdir" "*/file1_[12]" | |
397 | sort > $testout | |
98d2ca3d | 398 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
460adbb8 UD |
399 | `dir1/file1_1' |
400 | `dir1/file1_2' | |
1fb2614a UD |
401 | `link1/file1_1' |
402 | `link1/file1_2' | |
460adbb8 | 403 | EOF |
3f36c563 UD |
404 | if test $failed -ne 0; then |
405 | echo "Brackets test failed" >> $logfile | |
406 | result=1 | |
407 | fi | |
460adbb8 UD |
408 | |
409 | # Test ']' inside bracket expression | |
3f36c563 | 410 | failed=0 |
740b3dbe | 411 | ${test_program_prefix} \ |
460adbb8 UD |
412 | ${common_objpfx}posix/globtest "$testdir" "dir1/file1_[]12]" | |
413 | sort > $testout | |
98d2ca3d | 414 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
460adbb8 UD |
415 | `dir1/file1_1' |
416 | `dir1/file1_2' | |
417 | EOF | |
3f36c563 UD |
418 | if test $failed -ne 0; then |
419 | echo "Brackets2 test failed" >> $logfile | |
420 | result=1 | |
421 | fi | |
460adbb8 | 422 | |
3f62b69a | 423 | # Test tilde expansion |
3f36c563 | 424 | failed=0 |
740b3dbe | 425 | ${test_program_prefix} \ |
c9243dac UD |
426 | ${common_objpfx}posix/globtest -q -t "$testdir" "~" | |
427 | sort >$testout | |
98d2ca3d | 428 | echo ~ | $CMP - $testout >> $logfile || failed=1 |
3f36c563 | 429 | if test $failed -ne 0; then |
748945b3 UD |
430 | if test -d ~; then |
431 | echo "Tilde test failed" >> $logfile | |
432 | result=1 | |
433 | else | |
434 | echo "Tilde test could not be run" >> $logfile | |
435 | fi | |
3f36c563 | 436 | fi |
3f62b69a UD |
437 | |
438 | # Test tilde expansion with trailing slash | |
3f36c563 | 439 | failed=0 |
740b3dbe | 440 | ${test_program_prefix} \ |
c9243dac UD |
441 | ${common_objpfx}posix/globtest -q -t "$testdir" "~/" | |
442 | sort > $testout | |
3737ff12 UD |
443 | # Some shell incorrectly(?) convert ~/ into // if ~ expands to /. |
444 | if test ~/ = //; then | |
98d2ca3d | 445 | echo / | $CMP - $testout >> $logfile || failed=1 |
3737ff12 | 446 | else |
98d2ca3d | 447 | echo ~/ | $CMP - $testout >> $logfile || failed=1 |
3f36c563 UD |
448 | fi |
449 | if test $failed -ne 0; then | |
748945b3 UD |
450 | if test -d ~/; then |
451 | echo "Tilde2 test failed" >> $logfile | |
452 | result=1 | |
453 | else | |
454 | echo "Tilde2 test could not be run" >> $logfile | |
455 | fi | |
547ff462 | 456 | fi |
3f62b69a | 457 | |
548f51f6 | 458 | # Test tilde expansion with username |
3f36c563 | 459 | failed=0 |
740b3dbe | 460 | ${test_program_prefix} \ |
548f51f6 AJ |
461 | ${common_objpfx}posix/globtest -q -t "$testdir" "~"$USER | |
462 | sort > $testout | |
98d2ca3d | 463 | eval echo ~$USER | $CMP - $testout >> $logfile || failed=1 |
3f36c563 | 464 | if test $failed -ne 0; then |
748945b3 UD |
465 | if eval test -d ~$USER; then |
466 | echo "Tilde3 test failed" >> $logfile | |
467 | result=1 | |
468 | else | |
469 | echo "Tilde3 test could not be run" >> $logfile | |
470 | fi | |
3f36c563 | 471 | fi |
548f51f6 | 472 | |
3f62b69a | 473 | # Tilde expansion shouldn't match a file |
3f36c563 | 474 | failed=0 |
740b3dbe | 475 | ${test_program_prefix} \ |
1bc21e7a UD |
476 | ${common_objpfx}posix/globtest -T "$testdir" "~file4" | |
477 | sort > $testout | |
98d2ca3d | 478 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
1bc21e7a UD |
479 | GLOB_NOMATCH |
480 | EOF | |
3f36c563 UD |
481 | if test $failed -ne 0; then |
482 | echo "Tilde4 test failed" >> $logfile | |
483 | result=1 | |
484 | fi | |
3f62b69a UD |
485 | |
486 | # Matching \** should only find *file6 | |
3f36c563 | 487 | failed=0 |
740b3dbe | 488 | ${test_program_prefix} \ |
3f62b69a UD |
489 | ${common_objpfx}posix/globtest "$testdir" "\**" | |
490 | sort > $testout | |
98d2ca3d | 491 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
3f62b69a UD |
492 | `*file6' |
493 | EOF | |
3f36c563 UD |
494 | if test $failed -ne 0; then |
495 | echo "Star test failed" >> $logfile | |
496 | result=1 | |
497 | fi | |
3f62b69a | 498 | |
98d2ca3d UD |
499 | # ... unless NOESCAPE is used, in which case it should entries with a |
500 | # leading \. | |
3f36c563 | 501 | failed=0 |
740b3dbe | 502 | ${test_program_prefix} \ |
3f62b69a UD |
503 | ${common_objpfx}posix/globtest -e "$testdir" "\**" | |
504 | sort > $testout | |
98d2ca3d UD |
505 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
506 | `\file9b\' | |
507 | `\{file8\}' | |
508 | `\{file9\,file9b\}' | |
3f62b69a | 509 | EOF |
3f36c563 UD |
510 | if test $failed -ne 0; then |
511 | echo "Star2 test failed" >> $logfile | |
512 | result=1 | |
513 | fi | |
3f62b69a | 514 | |
460adbb8 | 515 | # Matching \*file6 should find *file6 |
3f36c563 | 516 | failed=0 |
740b3dbe | 517 | ${test_program_prefix} \ |
460adbb8 UD |
518 | ${common_objpfx}posix/globtest "$testdir" "\*file6" | |
519 | sort > $testout | |
98d2ca3d | 520 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
460adbb8 UD |
521 | `*file6' |
522 | EOF | |
3f36c563 UD |
523 | if test $failed -ne 0; then |
524 | echo "Star3 test failed" >> $logfile | |
525 | result=1 | |
526 | fi | |
460adbb8 | 527 | |
98d2ca3d UD |
528 | # GLOB_BRACE alone |
529 | failed=0 | |
740b3dbe | 530 | ${test_program_prefix} \ |
98d2ca3d UD |
531 | ${common_objpfx}posix/globtest -b "$testdir" '\{file7\,\}' | |
532 | sort > $testout | |
533 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 | |
534 | `{file7,}' | |
535 | EOF | |
536 | if test $failed -ne 0; then | |
537 | echo "Brace4 test failed" >> $logfile | |
538 | result=1 | |
539 | fi | |
540 | ||
541 | # GLOB_BRACE and GLOB_NOESCAPE | |
542 | failed=0 | |
740b3dbe | 543 | ${test_program_prefix} \ |
98d2ca3d UD |
544 | ${common_objpfx}posix/globtest -b -e "$testdir" '\{file9\,file9b\}' | |
545 | sort > $testout | |
546 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 | |
547 | `\file9b\' | |
548 | EOF | |
549 | if test $failed -ne 0; then | |
550 | echo "Brace5 test failed" >> $logfile | |
551 | result=1 | |
552 | fi | |
553 | ||
554 | # Escaped comma | |
555 | failed=0 | |
740b3dbe | 556 | ${test_program_prefix} \ |
98d2ca3d UD |
557 | ${common_objpfx}posix/globtest -b "$testdir" '{filea\,}' | |
558 | sort > $testout | |
559 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 | |
560 | `filea,' | |
561 | EOF | |
562 | if test $failed -ne 0; then | |
563 | echo "Brace6 test failed" >> $logfile | |
564 | result=1 | |
565 | fi | |
566 | ||
567 | # Escaped closing brace | |
568 | failed=0 | |
740b3dbe | 569 | ${test_program_prefix} \ |
98d2ca3d UD |
570 | ${common_objpfx}posix/globtest -b "$testdir" '{fileb\}c}' | |
571 | sort > $testout | |
572 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 | |
573 | `fileb}c' | |
574 | EOF | |
575 | if test $failed -ne 0; then | |
576 | echo "Brace7 test failed" >> $logfile | |
577 | result=1 | |
578 | fi | |
579 | ||
3f62b69a | 580 | # Try a recursive failed search |
3f36c563 | 581 | failed=0 |
740b3dbe | 582 | ${test_program_prefix} \ |
3f62b69a UD |
583 | ${common_objpfx}posix/globtest -e "$testdir" "a*/*" | |
584 | sort > $testout | |
98d2ca3d | 585 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
3f62b69a UD |
586 | GLOB_NOMATCH |
587 | EOF | |
3f36c563 UD |
588 | if test $failed -ne 0; then |
589 | echo "Star4 test failed" >> $logfile | |
590 | result=1 | |
591 | fi | |
3f62b69a | 592 | |
460adbb8 | 593 | # ... with GLOB_ERR |
3f36c563 | 594 | failed=0 |
740b3dbe | 595 | ${test_program_prefix} \ |
460adbb8 UD |
596 | ${common_objpfx}posix/globtest -E "$testdir" "a*/*" | |
597 | sort > $testout | |
98d2ca3d | 598 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
460adbb8 UD |
599 | GLOB_NOMATCH |
600 | EOF | |
3f36c563 UD |
601 | if test $failed -ne 0; then |
602 | echo "Star5 test failed" >> $logfile | |
603 | result=1 | |
604 | fi | |
460adbb8 UD |
605 | |
606 | # Try a recursive search in unreadable directory | |
3f36c563 | 607 | failed=0 |
740b3dbe | 608 | ${test_program_prefix} \ |
460adbb8 UD |
609 | ${common_objpfx}posix/globtest "$testdir" "noread/*" | |
610 | sort > $testout | |
98d2ca3d | 611 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
460adbb8 UD |
612 | GLOB_NOMATCH |
613 | EOF | |
3f36c563 UD |
614 | if test $failed -ne 0; then |
615 | echo "Star6 test failed" >> $logfile | |
616 | result=1 | |
617 | fi | |
460adbb8 | 618 | |
3f36c563 | 619 | failed=0 |
740b3dbe | 620 | ${test_program_prefix} \ |
460adbb8 UD |
621 | ${common_objpfx}posix/globtest "$testdir" "noread*/*" | |
622 | sort > $testout | |
98d2ca3d | 623 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
460adbb8 UD |
624 | GLOB_NOMATCH |
625 | EOF | |
3f36c563 UD |
626 | if test $failed -ne 0; then |
627 | echo "Star6 test failed" >> $logfile | |
628 | result=1 | |
629 | fi | |
460adbb8 | 630 | |
3b690639 UD |
631 | # The following tests will fail if run as root. |
632 | user=`id -un 2> /dev/null` | |
633 | if test -z "$user"; then | |
634 | uid="$USER" | |
635 | fi | |
636 | if test "$user" != root; then | |
637 | # ... with GLOB_ERR | |
740b3dbe | 638 | ${test_program_prefix} \ |
3b690639 UD |
639 | ${common_objpfx}posix/globtest -E "$testdir" "noread/*" | |
640 | sort > $testout | |
98d2ca3d | 641 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
460adbb8 UD |
642 | GLOB_ABORTED |
643 | EOF | |
644 | ||
740b3dbe | 645 | ${test_program_prefix} \ |
e7c036b3 UD |
646 | ${common_objpfx}posix/globtest -E "$testdir" "noread*/*" | |
647 | sort > $testout | |
98d2ca3d | 648 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
460adbb8 UD |
649 | GLOB_ABORTED |
650 | EOF | |
3f36c563 UD |
651 | if test $failed -ne 0; then |
652 | echo "GLOB_ERR test failed" >> $logfile | |
653 | result=1 | |
654 | fi | |
e7c036b3 | 655 | fi # not run as root |
460adbb8 | 656 | |
3f62b69a | 657 | # Try multiple patterns (GLOB_APPEND) |
3f36c563 | 658 | failed=0 |
740b3dbe | 659 | ${test_program_prefix} \ |
3f62b69a UD |
660 | ${common_objpfx}posix/globtest "$testdir" "file1" "*/*" | |
661 | sort > $testout | |
98d2ca3d | 662 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
3f62b69a UD |
663 | `dir1/file1_1' |
664 | `dir1/file1_2' | |
665 | `file1' | |
1fb2614a UD |
666 | `link1/file1_1' |
667 | `link1/file1_2' | |
3f62b69a | 668 | EOF |
3f36c563 UD |
669 | if test $failed -ne 0; then |
670 | echo "GLOB_APPEND test failed" >> $logfile | |
671 | result=1 | |
672 | fi | |
3f62b69a UD |
673 | |
674 | # Try multiple patterns (GLOB_APPEND) with offset (GLOB_DOOFFS) | |
3f36c563 | 675 | failed=0 |
740b3dbe | 676 | ${test_program_prefix} \ |
3f62b69a UD |
677 | ${common_objpfx}posix/globtest -o "$testdir" "file1" "*/*" | |
678 | sort > $testout | |
98d2ca3d | 679 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
3f62b69a UD |
680 | `abc' |
681 | `dir1/file1_1' | |
682 | `dir1/file1_2' | |
683 | `file1' | |
1fb2614a UD |
684 | `link1/file1_1' |
685 | `link1/file1_2' | |
61eb22d3 | 686 | EOF |
3f36c563 UD |
687 | if test $failed -ne 0; then |
688 | echo "GLOB_APPEND2 test failed" >> $logfile | |
689 | result=1 | |
690 | fi | |
61eb22d3 | 691 | |
e852e889 | 692 | # Test NOCHECK with non-existing file in subdir. |
3f36c563 | 693 | failed=0 |
740b3dbe | 694 | ${test_program_prefix} \ |
e852e889 UD |
695 | ${common_objpfx}posix/globtest -c "$testdir" "*/blahblah" | |
696 | sort > $testout | |
98d2ca3d | 697 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 |
870a4e12 | 698 | `*/blahblah' |
e852e889 | 699 | EOF |
3f36c563 UD |
700 | if test $failed -ne 0; then |
701 | echo "No check2 test failed" >> $logfile | |
702 | result=1 | |
703 | fi | |
e852e889 | 704 | |
5a4b5076 UD |
705 | # Test [[:punct:]] not matching leading period. |
706 | failed=0 | |
740b3dbe | 707 | ${test_program_prefix} \ |
5a4b5076 UD |
708 | ${common_objpfx}posix/globtest -c "$testdir" "[[:punct:]]*" | |
709 | sort > $testout | |
710 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 | |
711 | `*file6' | |
712 | `-file3' | |
713 | `\file9b\' | |
714 | `\{file8\}' | |
715 | `\{file9\,file9b\}' | |
716 | `{file7,}' | |
717 | `~file4' | |
718 | EOF | |
719 | if test $failed -ne 0; then | |
720 | echo "Punct test failed" >> $logfile | |
721 | result=1 | |
722 | fi | |
723 | ||
05f135ba UD |
724 | mkdir $testdir/'dir3*' |
725 | echo 1 > $testdir/'dir3*'/file1 | |
726 | mkdir $testdir/'dir4[a' | |
727 | echo 2 > $testdir/'dir4[a'/file1 | |
728 | echo 3 > $testdir/'dir4[a'/file2 | |
729 | mkdir $testdir/'dir5[ab]' | |
730 | echo 4 > $testdir/'dir5[ab]'/file1 | |
731 | echo 5 > $testdir/'dir5[ab]'/file2 | |
732 | mkdir $testdir/dir6 | |
733 | echo 6 > $testdir/dir6/'file1[a' | |
734 | echo 7 > $testdir/dir6/'file1[ab]' | |
735 | failed=0 | |
740b3dbe | 736 | v=`${test_program_prefix} \ |
05f135ba UD |
737 | ${common_objpfx}posix/globtest "$testdir" 'dir3\*/file2'` |
738 | test "$v" != 'GLOB_NOMATCH' && echo "$v" >> $logfile && failed=1 | |
740b3dbe | 739 | ${test_program_prefix} \ |
05f135ba UD |
740 | ${common_objpfx}posix/globtest -c "$testdir" \ |
741 | 'dir3\*/file1' 'dir3\*/file2' 'dir1/file\1_1' 'dir1/file\1_9' \ | |
742 | 'dir2\/' 'nondir\/' 'dir4[a/fil*1' 'di*r4[a/file2' 'dir5[ab]/file[12]' \ | |
794c3ad3 UD |
743 | 'dir6/fil*[a' 'dir*6/file1[a' 'dir6/fi*l[ab]' 'dir*6/file1[ab]' \ |
744 | 'dir6/file1[[.a.]*' | | |
05f135ba UD |
745 | sort > $testout |
746 | cat <<"EOF" | $CMP - $testout >> $logfile || failed=1 | |
05f135ba UD |
747 | `dir*6/file1[ab]' |
748 | `dir1/file1_1' | |
749 | `dir1/file\1_9' | |
750 | `dir2/' | |
751 | `dir3*/file1' | |
752 | `dir3\*/file2' | |
794c3ad3 UD |
753 | `dir4[a/file1' |
754 | `dir4[a/file2' | |
05f135ba UD |
755 | `dir5[ab]/file[12]' |
756 | `dir6/fi*l[ab]' | |
794c3ad3 UD |
757 | `dir6/file1[a' |
758 | `dir6/file1[a' | |
759 | `dir6/file1[a' | |
760 | `dir6/file1[ab]' | |
05f135ba UD |
761 | `nondir\/' |
762 | EOF | |
cc1290d0 | 763 | ${test_wrapper_env} \ |
05f135ba | 764 | HOME="$testdir" \ |
740b3dbe | 765 | ${test_via_rtld_prefix} \ |
05f135ba UD |
766 | ${common_objpfx}posix/globtest -ct "$testdir" \ |
767 | '~/dir1/file1_1' '~/dir1/file1_9' '~/dir3\*/file1' '~/dir3\*/file2' \ | |
768 | '~\/dir1/file1_2' | | |
769 | sort > $testout | |
770 | cat <<EOF | $CMP - $testout >> $logfile || failed=1 | |
771 | \`$testdir/dir1/file1_1' | |
772 | \`$testdir/dir1/file1_2' | |
773 | \`$testdir/dir3*/file1' | |
774 | \`~/dir1/file1_9' | |
775 | \`~/dir3\\*/file2' | |
776 | EOF | |
777 | if eval test -d ~"$USER"/; then | |
778 | user=`echo "$USER" | sed -n -e 's/^\([^\\]\)\([^\\][^\\]*\)$/~\1\\\\\2/p'` | |
779 | if test -n "$user"; then | |
740b3dbe | 780 | ${test_program_prefix} \ |
05f135ba UD |
781 | ${common_objpfx}posix/globtest -ctq "$testdir" "$user/" | |
782 | sort > $testout | |
783 | eval echo ~$USER/ | $CMP - $testout >> $logfile || failed=1 | |
740b3dbe | 784 | ${test_program_prefix} \ |
05f135ba UD |
785 | ${common_objpfx}posix/globtest -ctq "$testdir" "$user\\/" | |
786 | sort > $testout | |
787 | eval echo ~$USER/ | $CMP - $testout >> $logfile || failed=1 | |
740b3dbe | 788 | ${test_program_prefix} \ |
05f135ba UD |
789 | ${common_objpfx}posix/globtest -ctq "$testdir" "$user" | |
790 | sort > $testout | |
791 | eval echo ~$USER | $CMP - $testout >> $logfile || failed=1 | |
792 | fi | |
793 | fi | |
794 | if test $failed -ne 0; then | |
795 | echo "Escape tests failed" >> $logfile | |
796 | result=1 | |
797 | fi | |
798 | ||
61eb22d3 | 799 | if test $result -eq 0; then |
460adbb8 | 800 | chmod 777 $testdir/noread |
3f62b69a | 801 | rm -fr $testdir $testout |
3f36c563 | 802 | echo "All OK." > $logfile |
61eb22d3 UD |
803 | fi |
804 | ||
805 | exit $result | |
806 | ||
807 | # Preserve executable bits for this shell script. | |
808 | Local Variables: | |
809 | eval:(defun frobme () (set-file-modes buffer-file-name file-mode)) | |
810 | eval:(make-local-variable 'file-mode) | |
811 | eval:(setq file-mode (file-modes (buffer-file-name))) | |
812 | eval:(make-local-variable 'after-save-hook) | |
813 | eval:(add-hook 'after-save-hook 'frobme) | |
814 | End: |