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