3 common_objpfx
=$1; shift
5 rtld_installed_name
=$1; shift
7 # We have to find the libc and the NSS modules.
8 library_path
=${common_objpfx}:${common_objpfx}nss:${common_objpfx}nis
10 # Since we use `sort' we must make sure to use the same locale everywhere.
18 testdir
=$TMPDIR/globtest-dir
19 testout
=$TMPDIR/globtest-out
21 trap 'rm -fr $testdir $testout' 1 2 3 15
25 echo 1 > $testdir/file1
26 echo 2 > $testdir/file2
27 echo 3 > $testdir/-file3
28 echo 4 > $testdir/~file4
29 echo 5 > $testdir/.file5
30 echo 6 > $testdir/'*file6'
33 echo 1_1
> $testdir/dir
1/file1_1
34 echo 1_2
> $testdir/dir
1/file1_2
40 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
41 ${common_objpfx}posix
/globtest
"$testdir" "*" |
43 cat <<"EOF" | cmp - $testout || result=1
53 # Don't let glob sort it
54 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
55 ${common_objpfx}posix/globtest -s "$testdir" "*" |
57 cat <<"EOF" |
cmp - $testout || result
=1
68 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
69 ${common_objpfx}posix/globtest -m "$testdir" "*" |
71 cat <<"EOF" | cmp - $testout || result=1
81 # Find files starting with .
82 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
83 ${common_objpfx}posix/globtest -p "$testdir" "*" |
85 cat <<"EOF" | cmp - $testout || result=1
99 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
100 ${common_objpfx}posix
/globtest
-b "$testdir" "file{1,2}" |
102 cat <<"EOF" | cmp - $testout || result=1
108 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
109 ${common_objpfx}posix/globtest -c "$testdir" "abc" |
111 cat <<"EOF" |
cmp - $testout || result
=1
115 # Test NOMAGIC without magic characters
116 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
117 ${common_objpfx}posix/globtest -g "$testdir" "abc" |
119 cat <<"EOF" | cmp - $testout || result=1
123 # Test NOMAGIC with magic characters
124 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
125 ${common_objpfx}posix/globtest -g "$testdir" "abc*" |
127 cat <<"EOF" | cmp - $testout || result=1
131 # Test subdirs correctly
132 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
133 ${common_objpfx}posix/globtest "$testdir" "*/*" |
135 cat <<"EOF" | cmp - $testout || result=1
140 # Test subdirs for invalid names
141 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
142 ${common_objpfx}posix/globtest "$testdir" "*/1" |
144 cat <<"EOF" | cmp - $testout || result=1
148 # Test subdirs with wildcard
149 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
150 ${common_objpfx}posix/globtest "$testdir" "*/*1_1" |
152 cat <<"EOF" | cmp - $testout || result=1
156 # Test subdirs with ?
157 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
158 ${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
160 cat <<"EOF" | cmp - $testout || result=1
165 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
166 ${common_objpfx}posix/globtest "$testdir" "*/file1_1" |
168 cat <<"EOF" | cmp - $testout || result=1
172 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
173 ${common_objpfx}posix/globtest "$testdir" "*-/*" |
175 cat <<"EOF" | cmp - $testout || result=1
179 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
180 ${common_objpfx}posix/globtest "$testdir" "*-" |
182 cat <<"EOF" | cmp - $testout || result=1
186 # Test subdirs with ?
187 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
188 ${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
190 cat <<"EOF" | cmp - $testout || result=1
195 # Test tilde expansion
196 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
197 ${common_objpfx}posix/globtest -q -t "$testdir" "~" |
199 echo ~ | cmp - $testout || result=1
201 # Test tilde expansion with trailing slash
202 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
203 ${common_objpfx}posix/globtest -q -t "$testdir" "~/" |
205 echo ~/ | cmp - $testout || result=1
207 # Test tilde expansion with username
208 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
209 ${common_objpfx}posix/globtest -q -t "$testdir" "~"$USER |
211 eval echo ~$USER | cmp - $testout || result=1
213 # Tilde expansion shouldn't match a file
214 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
215 ${common_objpfx}posix/globtest -T "$testdir" "~file4" |
217 cat <<"EOF" | cmp - $testout || result=1
221 # Matching \** should only find *file6
222 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
223 ${common_objpfx}posix/globtest "$testdir" "\**" |
225 cat <<"EOF" | cmp - $testout || result=1
229 # ... unless NOESCAPE is used, in which case it shouldn't match anything.
230 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
231 ${common_objpfx}posix
/globtest
-e "$testdir" "\**" |
233 cat <<"EOF" | cmp - $testout || result=1
237 # Try a recursive failed search
238 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
239 ${common_objpfx}posix/globtest -e "$testdir" "a*/*" |
241 cat <<"EOF" |
cmp - $testout || result
=1
245 # Try multiple patterns (GLOB_APPEND)
246 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
247 ${common_objpfx}posix
/globtest
"$testdir" "file1" "*/*" |
249 cat <<"EOF" | cmp - $testout || result=1
255 # Try multiple patterns (GLOB_APPEND) with offset (GLOB_DOOFFS)
256 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
257 ${common_objpfx}posix/globtest -o "$testdir" "file1" "*/*" |
259 cat <<"EOF" |
cmp - $testout || result
=1
266 # Test NOCHECK with non-existing file in subdir.
267 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
268 ${common_objpfx}posix/globtest -c "$testdir" "*/blahblah" |
270 cat <<"EOF" | cmp - $testout || result=1
275 if test $result -eq 0; then
276 rm -fr $testdir $testout
281 # Preserve executable bits for this shell script.
283 eval:(defun frobme
() (set-file-modes buffer-file-name file-mode
))
284 eval:(make-local-variable
'file-mode)
285 eval:(setq file-mode (file-modes (buffer-file-name)))
286 eval:(make-local-variable 'after-save-hook
)
287 eval:(add-hook
'after-save-hook 'frobme
)