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