3 common_objpfx
=$1; shift
5 rtld_installed_name
=$1; shift
7 # We have to make the paths `common_objpfx' absolute.
8 case "$common_objpfx" in
10 common_objpfx
="`pwd`/$common_objpfx"
16 # We have to find the libc and the NSS modules.
17 library_path
=${common_objpfx}:${common_objpfx}nss:${common_objpfx}nis:${common_objpfx}db2:${common_objpfx}hesiod
19 # Since we use `sort' we must make sure to use the same locale everywhere.
27 testdir
=$TMPDIR/globtest-dir
28 testout
=$TMPDIR/globtest-out
30 trap 'chmod 777 $testdir/noread; rm -fr $testdir $testout' 1 2 3 15
32 rm -fr $testdir 2>/dev
/null
34 echo 1 > $testdir/file1
35 echo 2 > $testdir/file2
36 echo 3 > $testdir/-file3
37 echo 4 > $testdir/~file4
38 echo 5 > $testdir/.file5
39 echo 6 > $testdir/'*file6'
42 test -d $testdir/noread || mkdir
$testdir/noread
43 chmod a-r
$testdir/noread
44 echo 1_1
> $testdir/dir
1/file1_1
45 echo 1_2
> $testdir/dir
1/file1_2
51 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
52 ${common_objpfx}posix
/globtest
"$testdir" "*" |
54 cat <<"EOF" | cmp - $testout || result=1
65 # Don't let glob sort it
66 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
67 ${common_objpfx}posix/globtest -s "$testdir" "*" |
69 cat <<"EOF" |
cmp - $testout || result
=1
81 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
82 ${common_objpfx}posix/globtest -m "$testdir" "*" |
84 cat <<"EOF" | cmp - $testout || result=1
95 # Find files starting with .
96 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
97 ${common_objpfx}posix/globtest -p "$testdir" "*" |
99 cat <<"EOF" | cmp - $testout || result=1
114 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
115 ${common_objpfx}posix
/globtest
-b "$testdir" "file{1,2}" |
117 cat <<"EOF" | cmp - $testout || result=1
123 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
124 ${common_objpfx}posix/globtest -c "$testdir" "abc" |
126 cat <<"EOF" |
cmp - $testout || result
=1
130 # Test NOMAGIC without magic characters
131 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
132 ${common_objpfx}posix/globtest -g "$testdir" "abc" |
134 cat <<"EOF" | cmp - $testout || result=1
138 # Test NOMAGIC with magic characters
139 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
140 ${common_objpfx}posix/globtest -g "$testdir" "abc*" |
142 cat <<"EOF" | cmp - $testout || result=1
146 # Test subdirs correctly
147 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
148 ${common_objpfx}posix/globtest "$testdir" "*/*" |
150 cat <<"EOF" | cmp - $testout || result=1
155 # Test subdirs for invalid names
156 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
157 ${common_objpfx}posix/globtest "$testdir" "*/1" |
159 cat <<"EOF" | cmp - $testout || result=1
163 # Test subdirs with wildcard
164 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
165 ${common_objpfx}posix/globtest "$testdir" "*/*1_1" |
167 cat <<"EOF" | cmp - $testout || result=1
171 # Test subdirs with ?
172 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
173 ${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
175 cat <<"EOF" | cmp - $testout || result=1
180 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
181 ${common_objpfx}posix/globtest "$testdir" "*/file1_1" |
183 cat <<"EOF" | cmp - $testout || result=1
187 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
188 ${common_objpfx}posix/globtest "$testdir" "*-/*" |
190 cat <<"EOF" | cmp - $testout || result=1
194 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
195 ${common_objpfx}posix/globtest "$testdir" "*-" |
197 cat <<"EOF" | cmp - $testout || result=1
201 # Test subdirs with ?
202 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
203 ${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
205 cat <<"EOF" | cmp - $testout || result=1
210 # Test subdirs with [ .. ]
211 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
212 ${common_objpfx}posix/globtest "$testdir" "*/file1_[12]" |
214 cat <<"EOF" | cmp - $testout || result=1
219 # Test ']' inside bracket expression
220 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
221 ${common_objpfx}posix
/globtest
"$testdir" "dir1/file1_[]12]" |
223 cat <<"EOF" | cmp - $testout || result=1
228 # Test tilde expansion
229 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
230 ${common_objpfx}posix/globtest -q -t "$testdir" "~" |
232 echo ~ | cmp - $testout || result=1
234 # Test tilde expansion with trailing slash
235 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
236 ${common_objpfx}posix/globtest -q -t "$testdir" "~/" |
238 # Some shell incorrectly(?) convert ~/ into // if ~ expands to /.
239 if test ~/ = //; then
240 echo / | cmp - $testout || result=1
242 echo ~/ | cmp - $testout || result=1
245 # Test tilde expansion with username
246 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
247 ${common_objpfx}posix/globtest -q -t "$testdir" "~"$USER |
249 eval echo ~$USER | cmp - $testout || result=1
251 # Tilde expansion shouldn't match a file
252 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
253 ${common_objpfx}posix/globtest -T "$testdir" "~file4" |
255 cat <<"EOF" |
cmp - $testout || result
=1
259 # Matching \** should only find *file6
260 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
261 ${common_objpfx}posix
/globtest
"$testdir" "\**" |
263 cat <<"EOF" | cmp - $testout || result=1
267 # ... unless NOESCAPE is used, in which case it shouldn't match anything.
268 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
269 ${common_objpfx}posix/globtest -e "$testdir" "\**" |
271 cat <<"EOF" |
cmp - $testout || result
=1
275 # Matching \*file6 should find *file6
276 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
277 ${common_objpfx}posix
/globtest
"$testdir" "\*file6" |
279 cat <<"EOF" | cmp - $testout || result=1
283 # Try a recursive failed search
284 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
285 ${common_objpfx}posix/globtest -e "$testdir" "a*/*" |
287 cat <<"EOF" |
cmp - $testout || result
=1
292 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
293 ${common_objpfx}posix
/globtest
-E "$testdir" "a*/*" |
295 cat <<"EOF" | cmp - $testout || result=1
299 # Try a recursive search in unreadable directory
300 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
301 ${common_objpfx}posix/globtest "$testdir" "noread/*" |
303 cat <<"EOF" |
cmp - $testout || result
=1
307 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
308 ${common_objpfx}posix
/globtest
"$testdir" "noread*/*" |
310 cat <<"EOF" | cmp - $testout || result=1
314 # The following tests will fail if run as root.
315 user=`id -un 2> /dev/null`
316 if test -z "$user"; then
319 if test "$user" != root; then
321 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
322 ${common_objpfx}posix/globtest -E "$testdir" "noread/*" |
324 cat <<"EOF" |
cmp - $testout || result
=1
328 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
329 ${common_objpfx}posix
/globtest
-E "$testdir" "noread*/*" |
331 cat <<"EOF" | cmp - $testout || result=1
336 # Try multiple patterns (GLOB_APPEND)
337 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
338 ${common_objpfx}posix/globtest "$testdir" "file1" "*/*" |
340 cat <<"EOF" |
cmp - $testout || result
=1
346 # Try multiple patterns (GLOB_APPEND) with offset (GLOB_DOOFFS)
347 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
348 ${common_objpfx}posix
/globtest
-o "$testdir" "file1" "*/*" |
350 cat <<"EOF" | cmp - $testout || result=1
357 # Test NOCHECK with non-existing file in subdir.
358 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
359 ${common_objpfx}posix/globtest -c "$testdir" "*/blahblah" |
361 cat <<"EOF" |
cmp - $testout || result
=1
367 if test $result -eq 0; then
368 chmod 777 $testdir/noread
369 rm -fr $testdir $testout
374 # Preserve executable bits for this shell script.
376 eval:(defun frobme
() (set-file-modes buffer-file-name file-mode
))
377 eval:(make-local-variable
'file-mode)
378 eval:(setq file-mode (file-modes (buffer-file-name)))
379 eval:(make-local-variable 'after-save-hook
)
380 eval:(add-hook
'after-save-hook 'frobme
)