1:
2:
3: common_objpfx=$1; shift
4: elf_objpfx=$1; shift
5: rtld_installed_name=$1; shift
6: logfile=$common_objpfx/posix/globtest.out
7:
8:
9: CMP="diff -u"
10:
11:
12: case "$common_objpfx" in
13: .*)
14: common_objpfx="`pwd`/$common_objpfx"
15: ;;
16: *)
17: ;;
18: esac
19:
20:
21: library_path=${common_objpfx}:${common_objpfx}nss:${common_objpfx}nis:${common_objpfx}db2:${common_objpfx}hesiod
22:
23:
24: LC_ALL=C
25: export LC_ALL
26: LANG=C
27: export LANG
28:
29:
30: : ${TMPDIR=/tmp}
31: testdir=$TMPDIR/globtest-dir
32: testout=$TMPDIR/globtest-out
33:
34: trap 'chmod 777 $testdir/noread; rm -fr $testdir $testout' 1 2 3 15
35:
36: test -d $testdir/noread && chmod 777 $testdir/noread
37: rm -fr $testdir 2>/dev/null
38: mkdir $testdir
39: echo 1 > $testdir/file1
40: echo 2 > $testdir/file2
41: echo 3 > $testdir/-file3
42: echo 4 > $testdir/~file4
43: echo 5 > $testdir/.file5
44: echo 6 > $testdir/'*file6'
45: echo 7 > $testdir/'{file7,}'
46: echo 8 > $testdir/'\{file8\}'
47: echo 9 > $testdir/'\{file9\,file9b\}'
48: echo 9 > $testdir/'\file9b\'
49: echo a > $testdir/'filea,'
50: echo a > $testdir/'fileb}c'
51: mkdir $testdir/dir1
52: mkdir $testdir/dir2
53: test -d $testdir/noread || mkdir $testdir/noread
54: chmod a-r $testdir/noread
55: echo 1_1 > $testdir/dir1/file1_1
56: echo 1_2 > $testdir/dir1/file1_2
57: ln -fs dir1 $testdir/link1
58:
59:
60: result=0
61: rm -f $logfile
62:
63:
64: failed=0
65: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
66: ${common_objpfx}posix/globtest "$testdir" "*" |
67: sort > $testout
68: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
69: `*file6'
70: `-file3'
71: `\file9b\'
72: `\{file8\}'
73: `\{file9\,file9b\}'
74: `dir1'
75: `dir2'
76: `file1'
77: `file2'
78: `filea,'
79: `fileb}c'
80: `link1'
81: `noread'
82: `{file7,}'
83: `~file4'
84: EOF
85: if test $failed -ne 0; then
86: echo "Normal test failed" >> $logfile
87: result=1
88: fi
89:
90:
91: failed=0
92: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
93: ${common_objpfx}posix/globtest -s "$testdir" "*" |
94: sort > $testout
95: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
96: `*file6'
97: `-file3'
98: `\file9b\'
99: `\{file8\}'
100: `\{file9\,file9b\}'
101: `dir1'
102: `dir2'
103: `file1'
104: `file2'
105: `filea,'
106: `fileb}c'
107: `link1'
108: `noread'
109: `{file7,}'
110: `~file4'
111: EOF
112: if test $failed -ne 0; then
113: echo "No sort test failed" >> $logfile
114: result=1
115: fi
116:
117:
118: failed=0
119: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
120: ${common_objpfx}posix/globtest -m "$testdir" "*" |
121: sort > $testout
122: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
123: `*file6'
124: `-file3'
125: `\file9b\'
126: `\{file8\}'
127: `\{file9\,file9b\}'
128: `dir1/'
129: `dir2/'
130: `file1'
131: `file2'
132: `filea,'
133: `fileb}c'
134: `link1/'
135: `noread/'
136: `{file7,}'
137: `~file4'
138: EOF
139: if test $failed -ne 0; then
140: echo "Mark directories test failed" >> $logfile
141: result=1
142: fi
143:
144:
145: failed=0
146: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
147: ${common_objpfx}posix/globtest -p "$testdir" "*" |
148: sort > $testout
149: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
150: `*file6'
151: `-file3'
152: `.'
153: `..'
154: `.file5'
155: `\file9b\'
156: `\{file8\}'
157: `\{file9\,file9b\}'
158: `dir1'
159: `dir2'
160: `file1'
161: `file2'
162: `filea,'
163: `fileb}c'
164: `link1'
165: `noread'
166: `{file7,}'
167: `~file4'
168: EOF
169: if test $failed -ne 0; then
170: echo "Leading period test failed" >> $logfile
171: result=1
172: fi
173:
174:
175: failed=0
176: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
177: ${common_objpfx}posix/globtest -b "$testdir" "file{1,2}" |
178: sort > $testout
179: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
180: `file1'
181: `file2'
182: EOF
183: if test $failed -ne 0; then
184: echo "Braces test failed" >> $logfile
185: result=1
186: fi
187:
188: failed=0
189: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
190: ${common_objpfx}posix/globtest -b "$testdir" "{file{1,2},-file3}" |
191: sort > $testout
192: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
193: `-file3'
194: `file1'
195: `file2'
196: EOF
197: if test $failed -ne 0; then
198: echo "Braces test 2 failed" >> $logfile
199: result=1
200: fi
201:
202: failed=0
203: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
204: ${common_objpfx}posix/globtest -b "$testdir" "{" |
205: sort > $testout
206: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
207: GLOB_NOMATCH
208: EOF
209: if test $failed -ne 0; then
210: echo "Braces test 3 failed" >> $logfile
211: result=1
212: fi
213:
214:
215: failed=0
216: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
217: ${common_objpfx}posix/globtest -c "$testdir" "abc" |
218: sort > $testout
219: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
220: `abc'
221: EOF
222: if test $failed -ne 0; then
223: echo "No check test failed" >> $logfile
224: result=1
225: fi
226:
227:
228: failed=0
229: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
230: ${common_objpfx}posix/globtest -g "$testdir" "abc" |
231: sort > $testout
232: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
233: `abc'
234: EOF
235: if test $failed -ne 0; then
236: echo "No magic test failed" >> $logfile
237: result=1
238: fi
239:
240:
241: failed=0
242: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
243: ${common_objpfx}posix/globtest -g "$testdir" "abc*" |
244: sort > $testout
245: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
246: GLOB_NOMATCH
247: EOF
248: if test $failed -ne 0; then
249: echo "No magic w/ magic chars test failed" >> $logfile
250: result=1
251: fi
252:
253:
254: failed=0
255: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
256: ${common_objpfx}posix/globtest -g "$testdir" "*/does-not-exist" |
257: sort > $testout
258: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
259: GLOB_NOMATCH
260: EOF
261: if test $failed -ne 0; then
262: echo "No magic in subdir test failed" >> $logfile
263: result=1
264: fi
265:
266:
267: failed=0
268: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
269: ${common_objpfx}posix/globtest "$testdir" "*/*" |
270: sort > $testout
271: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
272: `dir1/file1_1'
273: `dir1/file1_2'
274: `link1/file1_1'
275: `link1/file1_2'
276: EOF
277: if test $failed -ne 0; then
278: echo "Subdirs test failed" >> $logfile
279: result=1
280: fi
281:
282:
283: failed=0
284: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
285: ${common_objpfx}posix/globtest "$testdir" "*/1" |
286: sort > $testout
287: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
288: GLOB_NOMATCH
289: EOF
290: if test $failed -ne 0; then
291: echo "Invalid subdir test failed" >> $logfile
292: result=1
293: fi
294:
295:
296: failed=0
297: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
298: ${common_objpfx}posix/globtest "$testdir" "*/*1_1" |
299: sort > $testout
300: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
301: `dir1/file1_1'
302: `link1/file1_1'
303: EOF
304: if test $failed -ne 0; then
305: echo "Wildcard subdir test failed" >> $logfile
306: result=1
307: fi
308:
309:
310: failed=0
311: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
312: ${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
313: sort > $testout
314: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
315: `dir1/file1_1'
316: `dir1/file1_2'
317: `link1/file1_1'
318: `link1/file1_2'
319: EOF
320: if test $failed -ne 0; then
321: echo "Wildcard2 subdir test failed" >> $logfile
322: result=1
323: fi
324:
325: failed=0
326: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
327: ${common_objpfx}posix/globtest "$testdir" "*/file1_1" |
328: sort > $testout
329: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
330: `dir1/file1_1'
331: `link1/file1_1'
332: EOF
333: if test $failed -ne 0; then
334: echo "Wildcard3 subdir test failed" >> $logfile
335: result=1
336: fi
337:
338: failed=0
339: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
340: ${common_objpfx}posix/globtest "$testdir" "*-/*" |
341: sort > $testout
342: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
343: GLOB_NOMATCH
344: EOF
345: if test $failed -ne 0; then
346: echo "Wildcard4 subdir test failed" >> $logfile
347: result=1
348: fi
349:
350: failed=0
351: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
352: ${common_objpfx}posix/globtest "$testdir" "*-" |
353: sort > $testout
354: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
355: GLOB_NOMATCH
356: EOF
357: if test $failed -ne 0; then
358: echo "Wildcard5 subdir test failed" >> $logfile
359: result=1
360: fi
361:
362:
363: failed=0
364: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
365: ${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
366: sort > $testout
367: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
368: `dir1/file1_1'
369: `dir1/file1_2'
370: `link1/file1_1'
371: `link1/file1_2'
372: EOF
373: if test $failed -ne 0; then
374: echo "Wildcard6 subdir test failed" >> $logfile
375: result=1
376: fi
377:
378:
379: failed=0
380: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
381: ${common_objpfx}posix/globtest "$testdir" "*/file1_[12]" |
382: sort > $testout
383: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
384: `dir1/file1_1'
385: `dir1/file1_2'
386: `link1/file1_1'
387: `link1/file1_2'
388: EOF
389: if test $failed -ne 0; then
390: echo "Brackets test failed" >> $logfile
391: result=1
392: fi
393:
394:
395: failed=0
396: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
397: ${common_objpfx}posix/globtest "$testdir" "dir1/file1_[]12]" |
398: sort > $testout
399: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
400: `dir1/file1_1'
401: `dir1/file1_2'
402: EOF
403: if test $failed -ne 0; then
404: echo "Brackets2 test failed" >> $logfile
405: result=1
406: fi
407:
408:
409: failed=0
410: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
411: ${common_objpfx}posix/globtest -q -t "$testdir" "~" |
412: sort >$testout
413: echo ~ | $CMP - $testout >> $logfile || failed=1
414: if test $failed -ne 0; then
415: if test -d ~; then
416: echo "Tilde test failed" >> $logfile
417: result=1
418: else
419: echo "Tilde test could not be run" >> $logfile
420: fi
421: fi
422:
423:
424: failed=0
425: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
426: ${common_objpfx}posix/globtest -q -t "$testdir" "~/" |
427: sort > $testout
428:
429: if test ~/ = //; then
430: echo / | $CMP - $testout >> $logfile || failed=1
431: else
432: echo ~/ | $CMP - $testout >> $logfile || failed=1
433: fi
434: if test $failed -ne 0; then
435: if test -d ~/; then
436: echo "Tilde2 test failed" >> $logfile
437: result=1
438: else
439: echo "Tilde2 test could not be run" >> $logfile
440: fi
441: fi
442:
443:
444: failed=0
445: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
446: ${common_objpfx}posix/globtest -q -t "$testdir" "~"$USER |
447: sort > $testout
448: eval echo ~$USER | $CMP - $testout >> $logfile || failed=1
449: if test $failed -ne 0; then
450: if eval test -d ~$USER; then
451: echo "Tilde3 test failed" >> $logfile
452: result=1
453: else
454: echo "Tilde3 test could not be run" >> $logfile
455: fi
456: fi
457:
458:
459: failed=0
460: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
461: ${common_objpfx}posix/globtest -T "$testdir" "~file4" |
462: sort > $testout
463: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
464: GLOB_NOMATCH
465: EOF
466: if test $failed -ne 0; then
467: echo "Tilde4 test failed" >> $logfile
468: result=1
469: fi
470:
471:
472: failed=0
473: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
474: ${common_objpfx}posix/globtest "$testdir" "\**" |
475: sort > $testout
476: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
477: `*file6'
478: EOF
479: if test $failed -ne 0; then
480: echo "Star test failed" >> $logfile
481: result=1
482: fi
483:
484:
485:
486: failed=0
487: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
488: ${common_objpfx}posix/globtest -e "$testdir" "\**" |
489: sort > $testout
490: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
491: `\file9b\'
492: `\{file8\}'
493: `\{file9\,file9b\}'
494: EOF
495: if test $failed -ne 0; then
496: echo "Star2 test failed" >> $logfile
497: result=1
498: fi
499:
500:
501: failed=0
502: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
503: ${common_objpfx}posix/globtest "$testdir" "\*file6" |
504: sort > $testout
505: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
506: `*file6'
507: EOF
508: if test $failed -ne 0; then
509: echo "Star3 test failed" >> $logfile
510: result=1
511: fi
512:
513:
514: failed=0
515: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
516: ${common_objpfx}posix/globtest -b "$testdir" '\{file7\,\}' |
517: sort > $testout
518: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
519: `{file7,}'
520: EOF
521: if test $failed -ne 0; then
522: echo "Brace4 test failed" >> $logfile
523: result=1
524: fi
525:
526:
527: failed=0
528: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
529: ${common_objpfx}posix/globtest -b -e "$testdir" '\{file9\,file9b\}' |
530: sort > $testout
531: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
532: `\file9b\'
533: EOF
534: if test $failed -ne 0; then
535: echo "Brace5 test failed" >> $logfile
536: result=1
537: fi
538:
539:
540: failed=0
541: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
542: ${common_objpfx}posix/globtest -b "$testdir" '{filea\,}' |
543: sort > $testout
544: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
545: `filea,'
546: EOF
547: if test $failed -ne 0; then
548: echo "Brace6 test failed" >> $logfile
549: result=1
550: fi
551:
552:
553: failed=0
554: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
555: ${common_objpfx}posix/globtest -b "$testdir" '{fileb\}c}' |
556: sort > $testout
557: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
558: `fileb}c'
559: EOF
560: if test $failed -ne 0; then
561: echo "Brace7 test failed" >> $logfile
562: result=1
563: fi
564:
565:
566: failed=0
567: ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
568: ${common_objpfx}posix/globtest -e "$testdir" "a*/*" |
569: sort > $testout
570: cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
571: GLOB_NOMATCH
572: