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