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
151 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
152 ${common_objpfx}posix/globtest -c "$testdir" "abc" |
154 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
157 if test $failed -ne 0; then
158 echo "No check test failed" >> $logfile
162 # Test NOMAGIC without magic characters
164 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
165 ${common_objpfx}posix/globtest -g "$testdir" "abc" |
167 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
170 if test $failed -ne 0; then
171 echo "No magic test failed" >> $logfile
175 # Test NOMAGIC with magic characters
177 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
178 ${common_objpfx}posix/globtest -g "$testdir" "abc*" |
180 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
183 if test $failed -ne 0; then
184 echo "No magic w/ magic chars test failed" >> $logfile
188 # Test subdirs correctly
190 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
191 ${common_objpfx}posix/globtest "$testdir" "*/*" |
193 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
197 if test $failed -ne 0; then
198 echo "Subdirs test failed" >> $logfile
202 # Test subdirs for invalid names
204 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
205 ${common_objpfx}posix/globtest "$testdir" "*/1" |
207 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
210 if test $failed -ne 0; then
211 echo "Invalid subdir test failed" >> $logfile
215 # Test subdirs with wildcard
217 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
218 ${common_objpfx}posix/globtest "$testdir" "*/*1_1" |
220 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
223 if test $failed -ne 0; then
224 echo "Wildcard subdir test failed" >> $logfile
228 # Test subdirs with ?
230 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
231 ${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
233 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
237 if test $failed -ne 0; then
238 echo "Wildcard2 subdir test failed" >> $logfile
243 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
244 ${common_objpfx}posix/globtest "$testdir" "*/file1_1" |
246 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
249 if test $failed -ne 0; then
250 echo "Wildcard3 subdir test failed" >> $logfile
255 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
256 ${common_objpfx}posix/globtest "$testdir" "*-/*" |
258 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
261 if test $failed -ne 0; then
262 echo "Wildcard4 subdir test failed" >> $logfile
267 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
268 ${common_objpfx}posix/globtest "$testdir" "*-" |
270 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
273 if test $failed -ne 0; then
274 echo "Wildcard5 subdir test failed" >> $logfile
278 # Test subdirs with ?
280 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
281 ${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
283 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
287 if test $failed -ne 0; then
288 echo "Wildcard6 subdir test failed" >> $logfile
292 # Test subdirs with [ .. ]
294 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
295 ${common_objpfx}posix/globtest "$testdir" "*/file1_[12]" |
297 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
301 if test $failed -ne 0; then
302 echo "Brackets test failed" >> $logfile
306 # Test ']' inside bracket expression
308 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
309 ${common_objpfx}posix
/globtest
"$testdir" "dir1/file1_[]12]" |
311 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
315 if test $failed -ne 0; then
316 echo "Brackets2 test failed" >> $logfile
320 # Test tilde expansion
322 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
323 ${common_objpfx}posix/globtest -q -t "$testdir" "~" |
325 echo ~ | cmp - $testout >> $logfile || failed=1
326 if test $failed -ne 0; then
327 echo "Tilde test failed" >> $logfile
331 # Test tilde expansion with trailing slash
333 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
334 ${common_objpfx}posix/globtest -q -t "$testdir" "~/" |
336 # Some shell incorrectly(?) convert ~/ into // if ~ expands to /.
337 if test ~/ = //; then
338 echo / | cmp - $testout >> $logfile || failed=1
340 echo ~/ | cmp - $testout >> $logfile || failed=1
342 if test $failed -ne 0; then
343 echo "Tilde2 test failed" >> $logfile
347 # Test tilde expansion with username
349 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
350 ${common_objpfx}posix/globtest -q -t "$testdir" "~"$USER |
352 eval echo ~$USER | cmp - $testout >> $logfile || failed=1
353 if test $failed -ne 0; then
354 echo "Tilde3 test failed" >> $logfile
358 # Tilde expansion shouldn't match a file
360 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
361 ${common_objpfx}posix/globtest -T "$testdir" "~file4" |
363 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
366 if test $failed -ne 0; then
367 echo "Tilde4 test failed" >> $logfile
371 # Matching \** should only find *file6
373 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
374 ${common_objpfx}posix
/globtest
"$testdir" "\**" |
376 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
379 if test $failed -ne 0; then
380 echo "Star test failed" >> $logfile
384 # ... unless NOESCAPE is used, in which case it shouldn't match anything.
386 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
387 ${common_objpfx}posix/globtest -e "$testdir" "\**" |
389 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
392 if test $failed -ne 0; then
393 echo "Star2 test failed" >> $logfile
397 # Matching \*file6 should find *file6
399 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
400 ${common_objpfx}posix
/globtest
"$testdir" "\*file6" |
402 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
405 if test $failed -ne 0; then
406 echo "Star3 test failed" >> $logfile
410 # Try a recursive failed search
412 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
413 ${common_objpfx}posix/globtest -e "$testdir" "a*/*" |
415 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
418 if test $failed -ne 0; then
419 echo "Star4 test failed" >> $logfile
425 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
426 ${common_objpfx}posix
/globtest
-E "$testdir" "a*/*" |
428 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
431 if test $failed -ne 0; then
432 echo "Star5 test failed" >> $logfile
436 # Try a recursive search in unreadable directory
438 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
439 ${common_objpfx}posix/globtest "$testdir" "noread/*" |
441 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
444 if test $failed -ne 0; then
445 echo "Star6 test failed" >> $logfile
450 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
451 ${common_objpfx}posix
/globtest
"$testdir" "noread*/*" |
453 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
456 if test $failed -ne 0; then
457 echo "Star6 test failed" >> $logfile
461 # The following tests will fail if run as root.
462 user=`id -un 2> /dev/null`
463 if test -z "$user"; then
466 if test "$user" != root; then
468 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
469 ${common_objpfx}posix/globtest -E "$testdir" "noread/*" |
471 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
475 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
476 ${common_objpfx}posix
/globtest
-E "$testdir" "noread*/*" |
478 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
481 if test $failed -ne 0; then
482 echo "GLOB_ERR test failed" >> $logfile
487 # Try multiple patterns (GLOB_APPEND)
489 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
490 ${common_objpfx}posix/globtest "$testdir" "file1" "*/*" |
492 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
497 if test $failed -ne 0; then
498 echo "GLOB_APPEND test failed" >> $logfile
502 # Try multiple patterns (GLOB_APPEND) with offset (GLOB_DOOFFS)
504 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
505 ${common_objpfx}posix
/globtest
-o "$testdir" "file1" "*/*" |
507 cat <<"EOF" | cmp - $testout >> $logfile || failed=1
513 if test $failed -ne 0; then
514 echo "GLOB_APPEND2 test failed" >> $logfile
518 # Test NOCHECK with non-existing file in subdir.
520 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
521 ${common_objpfx}posix/globtest -c "$testdir" "*/blahblah" |
523 cat <<"EOF" |
cmp - $testout >> $logfile || failed
=1
528 if test $failed -ne 0; then
529 echo "No check2 test failed" >> $logfile
533 if test $result -eq 0; then
534 chmod 777 $testdir/noread
535 rm -fr $testdir $testout
536 echo "All OK." > $logfile
541 # Preserve executable bits for this shell script.
543 eval:(defun frobme
() (set-file-modes buffer-file-name file-mode
))
544 eval:(make-local-variable
'file-mode)
545 eval:(setq file-mode (file-modes (buffer-file-name)))
546 eval:(make-local-variable 'after-save-hook
)
547 eval:(add-hook
'after-save-hook 'frobme
)