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