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