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