3 common_objpfx
=$1; shift
5 rtld_installed_name
=$1; shift
6 logfile
=$common_objpfx/posix
/globtest.out
8 # We have to make the paths `common_objpfx' absolute.
9 case "$common_objpfx" in
11 common_objpfx
="`pwd`/$common_objpfx"
17 # We have to find the libc and the NSS modules.
18 library_path
=${common_objpfx}:${common_objpfx}nss:${common_objpfx}nis:${common_objpfx}db2:${common_objpfx}hesiod
20 # Since we use `sort' we must make sure to use the same locale everywhere.
28 testdir
=$TMPDIR/globtest-dir
29 testout
=$TMPDIR/globtest-out
31 trap 'chmod 777 $testdir/noread; rm -fr $testdir $testout' 1 2 3 15
33 rm -fr $testdir 2>/dev
/null
35 echo 1 > $testdir/file1
36 echo 2 > $testdir/file2
37 echo 3 > $testdir/-file3
38 echo 4 > $testdir/~file4
39 echo 5 > $testdir/.file5
40 echo 6 > $testdir/'*file6'
43 test -d $testdir/noread || mkdir
$testdir/noread
44 chmod a-r
$testdir/noread
45 echo 1_1
> $testdir/dir
1/file1_1
46 echo 1_2
> $testdir/dir
1/file1_2
54 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
55 ${common_objpfx}posix
/globtest
"$testdir" "*" |
57 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
67 if test $failed -ne 0; then
68 echo "Normal test failed" >> $logfile
72 # Don't let glob sort it
74 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
75 ${common_objpfx}posix/globtest -s "$testdir" "*" |
77 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
87 if test $failed -ne 0; then
88 echo "No sort test failed" >> $logfile
94 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
95 ${common_objpfx}posix/globtest -m "$testdir" "*" |
97 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
107 if test $failed -ne 0; then
108 echo "Mark directories test failed" >> $logfile
112 # Find files starting with .
114 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
115 ${common_objpfx}posix/globtest -p "$testdir" "*" |
117 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
130 if test $failed -ne 0; then
131 echo "Leading period test failed" >> $logfile
137 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
138 ${common_objpfx}posix
/globtest
-b "$testdir" "file{1,2}" |
140 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
144 if test $failed -ne 0; then
145 echo "Braces test failed" >> $logfile
150 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
151 ${common_objpfx}posix/globtest -b "$testdir" "{file{1,2},-file3}" |
153 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
158 if test $failed -ne 0; then
159 echo "Braces test 2 failed" >> $logfile
164 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
165 ${common_objpfx}posix
/globtest
-b "$testdir" "{" |
167 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
170 if test $failed -ne 0; then
171 echo "Braces test 3 failed" >> $logfile
177 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
178 ${common_objpfx}posix/globtest -c "$testdir" "abc" |
180 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
183 if test $failed -ne 0; then
184 echo "No check test failed" >> $logfile
188 # Test NOMAGIC without magic characters
190 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
191 ${common_objpfx}posix/globtest -g "$testdir" "abc" |
193 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
196 if test $failed -ne 0; then
197 echo "No magic test failed" >> $logfile
201 # Test NOMAGIC with magic characters
203 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
204 ${common_objpfx}posix/globtest -g "$testdir" "abc*" |
206 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
209 if test $failed -ne 0; then
210 echo "No magic w/ magic chars test failed" >> $logfile
214 # Test subdirs correctly
216 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
217 ${common_objpfx}posix/globtest "$testdir" "*/*" |
219 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
223 if test $failed -ne 0; then
224 echo "Subdirs test failed" >> $logfile
228 # Test subdirs for invalid names
230 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
231 ${common_objpfx}posix/globtest "$testdir" "*/1" |
233 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
236 if test $failed -ne 0; then
237 echo "Invalid subdir test failed" >> $logfile
241 # Test subdirs with wildcard
243 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
244 ${common_objpfx}posix/globtest "$testdir" "*/*1_1" |
246 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
249 if test $failed -ne 0; then
250 echo "Wildcard subdir test failed" >> $logfile
254 # Test subdirs with ?
256 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
257 ${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
259 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
263 if test $failed -ne 0; then
264 echo "Wildcard2 subdir test failed" >> $logfile
269 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
270 ${common_objpfx}posix/globtest "$testdir" "*/file1_1" |
272 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
275 if test $failed -ne 0; then
276 echo "Wildcard3 subdir test failed" >> $logfile
281 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
282 ${common_objpfx}posix/globtest "$testdir" "*-/*" |
284 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
287 if test $failed -ne 0; then
288 echo "Wildcard4 subdir test failed" >> $logfile
293 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
294 ${common_objpfx}posix/globtest "$testdir" "*-" |
296 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
299 if test $failed -ne 0; then
300 echo "Wildcard5 subdir test failed" >> $logfile
304 # Test subdirs with ?
306 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
307 ${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
309 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
313 if test $failed -ne 0; then
314 echo "Wildcard6 subdir test failed" >> $logfile
318 # Test subdirs with [ .. ]
320 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
321 ${common_objpfx}posix/globtest "$testdir" "*/file1_[12]" |
323 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
327 if test $failed -ne 0; then
328 echo "Brackets test failed" >> $logfile
332 # Test ']' inside bracket expression
334 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
335 ${common_objpfx}posix
/globtest
"$testdir" "dir1/file1_[]12]" |
337 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
341 if test $failed -ne 0; then
342 echo "Brackets2 test failed" >> $logfile
346 # Test tilde expansion
348 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
349 ${common_objpfx}posix/globtest -q -t "$testdir" "~" |
351 echo ~ | cmp - $testout >> $logfile || failed=1
352 if test $failed -ne 0; then
354 echo "Tilde test failed" >> $logfile
357 echo "Tilde test could not be run" >> $logfile
361 # Test tilde expansion with trailing slash
363 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
364 ${common_objpfx}posix/globtest -q -t "$testdir" "~/" |
366 # Some shell incorrectly(?) convert ~/ into // if ~ expands to /.
367 if test ~/ = //; then
368 echo / | cmp - $testout >> $logfile || failed=1
370 echo ~/ | cmp - $testout >> $logfile || failed=1
372 if test $failed -ne 0; then
374 echo "Tilde2 test failed" >> $logfile
377 echo "Tilde2 test could not be run" >> $logfile
381 # Test tilde expansion with username
383 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
384 ${common_objpfx}posix/globtest -q -t "$testdir" "~"$USER |
386 eval echo ~$USER | cmp - $testout >> $logfile || failed=1
387 if test $failed -ne 0; then
388 if eval test -d ~$USER; then
389 echo "Tilde3 test failed" >> $logfile
392 echo "Tilde3 test could not be run" >> $logfile
396 # Tilde expansion shouldn't match a file
398 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
399 ${common_objpfx}posix/globtest -T "$testdir" "~file4" |
401 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
404 if test $failed -ne 0; then
405 echo "Tilde4 test failed" >> $logfile
409 # Matching \** should only find *file6
411 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
412 ${common_objpfx}posix
/globtest
"$testdir" "\**" |
414 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
417 if test $failed -ne 0; then
418 echo "Star test failed" >> $logfile
422 # ... unless NOESCAPE is used, in which case it shouldn't match anything.
424 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
425 ${common_objpfx}posix/globtest -e "$testdir" "\**" |
427 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
430 if test $failed -ne 0; then
431 echo "Star2 test failed" >> $logfile
435 # Matching \*file6 should find *file6
437 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
438 ${common_objpfx}posix
/globtest
"$testdir" "\*file6" |
440 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
443 if test $failed -ne 0; then
444 echo "Star3 test failed" >> $logfile
448 # Try a recursive failed search
450 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
451 ${common_objpfx}posix/globtest -e "$testdir" "a*/*" |
453 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
456 if test $failed -ne 0; then
457 echo "Star4 test failed" >> $logfile
463 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
464 ${common_objpfx}posix
/globtest
-E "$testdir" "a*/*" |
466 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
469 if test $failed -ne 0; then
470 echo "Star5 test failed" >> $logfile
474 # Try a recursive search in unreadable directory
476 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
477 ${common_objpfx}posix/globtest "$testdir" "noread/*" |
479 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
482 if test $failed -ne 0; then
483 echo "Star6 test failed" >> $logfile
488 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
489 ${common_objpfx}posix
/globtest
"$testdir" "noread*/*" |
491 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
494 if test $failed -ne 0; then
495 echo "Star6 test failed" >> $logfile
499 # The following tests will fail if run as root.
500 user=`id -un 2> /dev/null`
501 if test -z "$user"; then
504 if test "$user" != root; then
506 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
507 ${common_objpfx}posix/globtest -E "$testdir" "noread/*" |
509 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
513 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
514 ${common_objpfx}posix
/globtest
-E "$testdir" "noread*/*" |
516 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
519 if test $failed -ne 0; then
520 echo "GLOB_ERR test failed" >> $logfile
525 # Try multiple patterns (GLOB_APPEND)
527 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
528 ${common_objpfx}posix/globtest "$testdir" "file1" "*/*" |
530 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
535 if test $failed -ne 0; then
536 echo "GLOB_APPEND test failed" >> $logfile
540 # Try multiple patterns (GLOB_APPEND) with offset (GLOB_DOOFFS)
542 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
543 ${common_objpfx}posix
/globtest
-o "$testdir" "file1" "*/*" |
545 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
551 if test $failed -ne 0; then
552 echo "GLOB_APPEND2 test failed" >> $logfile
556 # Test NOCHECK with non-existing file in subdir.
558 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
559 ${common_objpfx}posix/globtest -c "$testdir" "*/blahblah" |
561 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
566 if test $failed -ne 0; then
567 echo "No check2 test failed" >> $logfile
571 if test $result -eq 0; then
572 chmod 777 $testdir/noread
573 rm -fr $testdir $testout
574 echo "All OK." > $logfile
579 # Preserve executable bits for this shell script.
581 eval:(defun frobme
() (set-file-modes buffer-file-name file-mode
))
582 eval:(make-local-variable
'file-mode)
583 eval:(setq file-mode (file-modes (buffer-file-name)))
584 eval:(make-local-variable 'after-save-hook
)
585 eval:(add-hook
'after-save-hook 'frobme
)