]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | ||
3 | #- | |
4 | # Copyright (c) June 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. | |
5 | # All rights reserved. | |
6 | # | |
7 | # Redistribution and use in source and binary forms, with or without | |
8 | # modification, are permitted provided that the following conditions | |
9 | # are met: | |
10 | # 1. Redistributions of source code must retain the above copyright | |
11 | # notice, this list of conditions and the following disclaimer. | |
12 | # 2. Redistributions in binary form must reproduce the above copyright | |
13 | # notice, this list of conditions and the following disclaimer in the | |
14 | # documentation and/or other materials provided with the distribution. | |
15 | # | |
16 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |
17 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
20 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
21 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | # SUCH DAMAGE. | |
27 | ||
28 | # | |
29 | # TEST.sh - check if test(1) or builtin test works | |
30 | # | |
31 | # $FreeBSD$ | |
32 | ||
33 | # force a specified test program, e.g. `env test=/bin/test sh regress.sh' | |
34 | : ${test=test} | |
35 | ||
36 | t () | |
37 | { | |
38 | # $1 -> exit code | |
39 | # $2 -> $test expression | |
40 | ||
41 | count=$((count+1)) | |
42 | # check for syntax errors | |
43 | syntax="`eval $test $2 2>&1`" | |
44 | ret=$? | |
45 | if test -n "$syntax"; then | |
46 | printf "not ok %s - (syntax error)\n" "$count $2" | |
47 | elif [ "$ret" != "$1" ]; then | |
48 | printf "not ok %s - (got $ret, expected $1)\n" "$count $2" | |
49 | else | |
50 | printf "ok %s\n" "$count $2" | |
51 | fi | |
52 | } | |
53 | ||
54 | count=0 | |
55 | echo "1..130" | |
56 | ||
57 | t 0 'b = b' | |
58 | t 0 'b == b' | |
59 | t 1 'b != b' | |
60 | t 0 '\( b = b \)' | |
61 | t 0 '\( b == b \)' | |
62 | t 1 '! \( b = b \)' | |
63 | t 1 '! \( b == b \)' | |
64 | t 1 '! -f /etc/passwd' | |
65 | ||
66 | t 0 '-h = -h' | |
67 | t 0 '-o = -o' | |
68 | t 1 '-f = h' | |
69 | t 1 '-h = f' | |
70 | t 1 '-o = f' | |
71 | t 1 'f = -o' | |
72 | t 0 '\( -h = -h \)' | |
73 | t 1 '\( a = -h \)' | |
74 | t 1 '\( -f = h \)' | |
75 | t 0 '-h = -h -o a' | |
76 | t 0 '\( -h = -h \) -o 1' | |
77 | t 0 '-h = -h -o -h = -h' | |
78 | t 0 '\( -h = -h \) -o \( -h = -h \)' | |
79 | t 0 'roedelheim = roedelheim' | |
80 | t 1 'potsdam = berlin-dahlem' | |
81 | ||
82 | t 0 '-d /' | |
83 | t 0 '-d / -a a != b' | |
84 | t 1 '-z "-z"' | |
85 | t 0 '-n -n' | |
86 | ||
87 | t 0 '0' | |
88 | t 0 '\( 0 \)' | |
89 | t 0 '-E' | |
90 | t 0 '-X -a -X' | |
91 | t 0 '-XXX' | |
92 | t 0 '\( -E \)' | |
93 | t 0 'true -o X' | |
94 | t 0 'true -o -X' | |
95 | t 0 '\( \( \( a = a \) -o 1 \) -a 1 \) -a true' | |
96 | t 1 '-h /' | |
97 | t 0 '-r /' | |
98 | t 1 '-w /' | |
99 | t 0 '-x /bin/sh' | |
100 | t 0 '-c /dev/null' | |
101 | t 0 '-f /etc/passwd' | |
102 | t 0 '-s /etc/passwd' | |
103 | ||
104 | t 1 '! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)' | |
105 | t 0 '100 -eq 100' | |
106 | t 0 '100 -lt 200' | |
107 | t 1 '1000 -lt 200' | |
108 | t 0 '1000 -gt 200' | |
109 | t 0 '1000 -ge 200' | |
110 | t 0 '1000 -ge 1000' | |
111 | t 1 '2 -ne 2' | |
112 | t 0 '0 -eq 0' | |
113 | t 1 '-5 -eq 5' | |
114 | t 0 '\( 0 -eq 0 \)' | |
115 | t 1 '1 -eq 0 -o a = a -a 1 -eq 0 -o a = aa' | |
116 | ||
117 | t 1 '"" -o ""' | |
118 | t 1 '"" -a ""' | |
119 | t 1 '"a" -a ""' | |
120 | t 0 '"a" -a ! ""' | |
121 | t 1 '""' | |
122 | t 0 '! ""' | |
123 | ||
124 | t 0 '!' | |
125 | t 0 '\(' | |
126 | t 0 '\)' | |
127 | ||
128 | t 1 '\( = \)' | |
129 | t 0 '\( != \)' | |
130 | t 0 '\( ! \)' | |
131 | t 0 '\( \( \)' | |
132 | t 0 '\( \) \)' | |
133 | t 0 '! = !' | |
134 | t 1 '! != !' | |
135 | t 1 '-n = \)' | |
136 | t 0 '! != \)' | |
137 | t 1 '! = a' | |
138 | t 0 '! != -n' | |
139 | t 0 '! -c /etc/passwd' | |
140 | ||
141 | t 1 '! = = =' | |
142 | t 0 '! = = \)' | |
143 | t 0 '! "" -o ""' | |
144 | t 1 '! "x" -o ""' | |
145 | t 1 '! "" -o "x"' | |
146 | t 1 '! "x" -o "x"' | |
147 | t 0 '\( -f /etc/passwd \)' | |
148 | t 0 '\( ! "" \)' | |
149 | t 1 '\( ! -e \)' | |
150 | ||
151 | t 0 '0 -eq 0 -a -d /' | |
152 | t 0 '-s = "" -o "" = ""' | |
153 | t 0 '"" = "" -o -s = ""' | |
154 | t 1 '-s = "" -o -s = ""' | |
155 | t 0 '-z x -o x = "#" -o x = x' | |
156 | t 1 '-z y -o y = "#" -o y = x' | |
157 | t 0 '0 -ne 0 -o ! -f /' | |
158 | t 0 '1 -ne 0 -o ! -f /etc/passwd' | |
159 | t 1 '0 -ne 0 -o ! -f /etc/passwd' | |
160 | ||
161 | t 0 '-n =' | |
162 | t 1 '-z =' | |
163 | t 1 '! =' | |
164 | t 0 '-n -eq' | |
165 | t 1 '-z -eq' | |
166 | t 1 '! -eq' | |
167 | t 0 '-n -a' | |
168 | t 1 '-z -a' | |
169 | t 1 '! -a' | |
170 | t 0 '-n -o' | |
171 | t 1 '-z -o' | |
172 | t 1 '! -o' | |
173 | t 1 '! -n =' | |
174 | t 0 '! -z =' | |
175 | t 0 '! ! =' | |
176 | t 1 '! -n -eq' | |
177 | t 0 '! -z -eq' | |
178 | t 0 '! ! -eq' | |
179 | t 1 '! -n -a' | |
180 | t 0 '! -z -a' | |
181 | t 0 '! ! -a' | |
182 | t 1 '! -n -o' | |
183 | t 0 '! -z -o' | |
184 | t 0 '! ! -o' | |
185 | t 0 '\( -n = \)' | |
186 | t 1 '\( -z = \)' | |
187 | t 1 '\( ! = \)' | |
188 | t 0 '\( -n -eq \)' | |
189 | t 1 '\( -z -eq \)' | |
190 | t 1 '\( ! -eq \)' | |
191 | t 0 '\( -n -a \)' | |
192 | t 1 '\( -z -a \)' | |
193 | t 1 '\( ! -a \)' | |
194 | t 0 '\( -n -o \)' | |
195 | t 1 '\( -z -o \)' | |
196 | t 1 '\( ! -o \)' |