summaryrefslogtreecommitdiff
path: root/posix/globtest.sh
blob: c51655b9b37d5411a90e2815f43aab7f12144f7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#! /bin/sh

common_objpfx=$1; shift

# Create the arena
: ${TMPDIR=/tmp}
testdir=$TMPDIR/globtest-dir
testout=$TMPDIR/globtest-out

trap 'rm -fr $testdir $testout' 1 2 3 15

rm -fr $testdir
mkdir $testdir
echo 1 > $testdir/file1
echo 2 > $testdir/file2
mkdir $testdir/dir1
mkdir $testdir/dir2
echo 1_1 > $testdir/dir1/file1_1
echo 1_2 > $testdir/dir1/file1_2

# Run some tests.
result=0
here=`pwd`

(cd $testdir &&
 LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*") |
sort > $testout
cat <<"EOF" | cmp - $testout || result=1
`dir1'
`dir2'
`file1'
`file2'
not NULL
EOF

(cd $testdir &&
 LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*/*") |
sort > $testout
cat <<"EOF" | cmp - $testout || result=1
`dir1/file1_1'
`dir1/file1_2'
not NULL
EOF

(cd $testdir &&
 LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*/1") |
sort > $testout
cat <<"EOF" | cmp - $testout || result=1
GLOB_NOMATCH
NULL
EOF

(cd $testdir &&
 LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*/*1_1") |
sort > $testout
cat <<"EOF" | cmp - $testout || result=1
`dir1/file1_1'
not NULL
EOF

(cd $testdir &&
 LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*/file1_1") |
sort > $testout
cat <<"EOF" | cmp - $testout || result=1
`dir1/file1_1'
not NULL
EOF

(cd $testdir &&
 LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*-/*") |
sort > $testout
cat <<"EOF" | cmp - $testout || result=1
GLOB_NOMATCH
NULL
EOF

(cd $testdir &&
 LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*-") |
sort > $testout
cat <<"EOF" | cmp - $testout || result=1
GLOB_NOMATCH
NULL
EOF

if test $result -eq 0; then
  rm -fr $testdir $testout
fi

exit $result

# Preserve executable bits for this shell script.
Local Variables:
eval:(defun frobme () (set-file-modes buffer-file-name file-mode))
eval:(make-local-variable 'file-mode)
eval:(setq file-mode (file-modes (buffer-file-name)))
eval:(make-local-variable 'after-save-hook)
eval:(add-hook 'after-save-hook 'frobme)
End: