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