/[pcre]/code/trunk/RunTest
ViewVC logotype

Contents of /code/trunk/RunTest

Parent Directory Parent Directory | Revision Log Revision Log


Revision 559 - (hide annotations) (download)
Wed Oct 27 09:45:20 2010 UTC (4 years ago) by ph10
File size: 8383 byte(s)
Tidy up test comments, now that Perl >= 5.10 is generally around.

1 nigel 49 #! /bin/sh
2    
3 ph10 345 # Run PCRE tests.
4 nigel 49
5 nigel 87 valgrind=
6 ph10 339
7     # Set up a suitable "diff" command for comparison. Some systems
8     # have a diff that lacks a -u option. Try to deal with this.
9    
10     if diff -u /dev/null /dev/null; then cf="diff -u"; else cf="diff"; fi
11    
12     # Find the test data
13    
14 ph10 137 testdata=testdata
15     if [ -n "$srcdir" -a -d "$srcdir" ] ; then
16     testdata="$srcdir/testdata"
17 nigel 81 fi
18 nigel 49
19 ph10 116 # Find which optional facilities are available
20 nigel 87
21 ph10 116 case `./pcretest -C | ./pcregrep 'Internal link size'` in
22     *2) link_size=2;;
23     *3) link_size=3;;
24     *4) link_size=4;;
25     *) echo "Failed to find internal link size"; exit 1;;
26     esac
27 nigel 49
28 ph10 116 ./pcretest -C | ./pcregrep 'No UTF-8 support' >/dev/null
29     utf8=$?
30    
31     ./pcretest -C | ./pcregrep 'No Unicode properties support' >/dev/null
32     ucp=$?
33    
34     # Select which tests to run; for those that are explicitly requested, check
35     # that the necessary optional facilities are available.
36    
37 nigel 49 do1=no
38     do2=no
39     do3=no
40     do4=no
41     do5=no
42 nigel 75 do6=no
43 nigel 77 do7=no
44     do8=no
45     do9=no
46 ph10 164 do10=no
47 ph10 448 do11=no
48     do12=no
49 nigel 49
50     while [ $# -gt 0 ] ; do
51     case $1 in
52     1) do1=yes;;
53     2) do2=yes;;
54     3) do3=yes;;
55     4) do4=yes;;
56 nigel 77 5) do5=yes;;
57     6) do6=yes;;
58     7) do7=yes;;
59     8) do8=yes;;
60     9) do9=yes;;
61 ph10 165 10) do10=yes;;
62 ph10 448 11) do11=yes;;
63 ph10 461 12) do12=yes;;
64 ph10 164 valgrind) valgrind="valgrind -q";;
65 nigel 49 *) echo "Unknown test number $1"; exit 1;;
66     esac
67     shift
68     done
69    
70 ph10 116 if [ $utf8 -eq 0 ] ; then
71 nigel 63 if [ $do4 = yes ] ; then
72 nigel 75 echo "Can't run test 4 because UTF-8 support is not configured"
73 nigel 63 exit 1
74 nigel 77 fi
75 nigel 49 if [ $do5 = yes ] ; then
76 nigel 75 echo "Can't run test 5 because UTF-8 support is not configured"
77 nigel 49 exit 1
78 nigel 77 fi
79     if [ $do8 = yes ] ; then
80     echo "Can't run test 8 because UTF-8 support is not configured"
81     exit 1
82     fi
83     fi
84 nigel 49
85 ph10 116 if [ $ucp -eq 0 ] ; then
86 nigel 75 if [ $do6 = yes ] ; then
87     echo "Can't run test 6 because Unicode property support is not configured"
88     exit 1
89     fi
90 nigel 77 if [ $do9 = yes ] ; then
91     echo "Can't run test 9 because Unicode property support is not configured"
92     exit 1
93     fi
94 ph10 164 if [ $do10 = yes ] ; then
95     echo "Can't run test 10 because Unicode property support is not configured"
96     exit 1
97     fi
98 ph10 448 if [ $do12 = yes ] ; then
99     echo "Can't run test 12 because Unicode property support is not configured"
100     exit 1
101     fi
102 nigel 77 fi
103 nigel 75
104 ph10 164 if [ $link_size -ne 2 ] ; then
105     if [ $do10 = yes ] ; then
106     echo "Can't run test 10 because the link size ($link_size) is not 2"
107     exit 1
108     fi
109 ph10 165 fi
110 ph10 164
111 ph10 116 # If no specific tests were requested, select all that are relevant.
112    
113 nigel 75 if [ $do1 = no -a $do2 = no -a $do3 = no -a $do4 = no -a \
114 nigel 77 $do5 = no -a $do6 = no -a $do7 = no -a $do8 = no -a \
115 ph10 448 $do9 = no -a $do10 = no -a $do11 = no -a $do12 = no ] ; then
116 nigel 49 do1=yes
117 ph10 247 do2=yes
118 nigel 49 do3=yes
119 ph10 116 if [ $utf8 -ne 0 ] ; then do4=yes; fi
120 ph10 247 if [ $utf8 -ne 0 ] ; then do5=yes; fi
121 ph10 116 if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do6=yes; fi
122 ph10 247 do7=yes
123     if [ $utf8 -ne 0 ] ; then do8=yes; fi
124 ph10 116 if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do9=yes; fi
125 ph10 173 if [ $link_size -eq 2 -a $ucp -ne 0 ] ; then do10=yes; fi
126 ph10 448 do11=yes
127 ph10 461 if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do12=yes; fi
128 nigel 49 fi
129    
130 nigel 73 # Show which release
131    
132 ph10 128 echo ""
133     echo PCRE C library tests
134 nigel 73 ./pcretest /dev/null
135    
136 ph10 559 # Primary test, compatible with all versions of Perl >= 5.8
137 nigel 49
138     if [ $do1 = yes ] ; then
139 ph10 559 echo "Test 1: main functionality (Compatible with Perl >= 5.8)"
140 nigel 87 $valgrind ./pcretest -q $testdata/testinput1 testtry
141 nigel 49 if [ $? = 0 ] ; then
142 ph10 158 $cf $testdata/testoutput1 testtry
143 nigel 49 if [ $? != 0 ] ; then exit 1; fi
144     else exit 1
145     fi
146 nigel 77 echo "OK"
147 nigel 49 fi
148    
149 ph10 449 # PCRE tests that are not Perl-compatible - API, errors, internals
150 nigel 49
151     if [ $do2 = yes ] ; then
152 ph10 449 echo "Test 2: API, errors, internals, and non-Perl stuff"
153 ph10 162 $valgrind ./pcretest -q $testdata/testinput2 testtry
154     if [ $? = 0 ] ; then
155     $cf $testdata/testoutput2 testtry
156     if [ $? != 0 ] ; then exit 1; fi
157 ph10 371 else
158 ph10 358 echo " "
159     echo "** Test 2 requires a lot of stack. If it has crashed with a"
160     echo "** segmentation fault, it may be that you do not have enough"
161     echo "** stack available by default. Please see the 'pcrestack' man"
162 ph10 371 echo "** page for a discussion of PCRE's stack usage."
163     echo " "
164 ph10 358 exit 1
165 nigel 77 fi
166 ph10 162 echo "OK"
167 nigel 49 fi
168    
169 ph10 157 # Locale-specific tests, provided that either the "fr_FR" or the "french"
170     # locale is available. The former is the Unix-like standard; the latter is
171     # for Windows.
172 nigel 49
173 nigel 63 if [ $do3 = yes ] ; then
174 nigel 73 locale -a | grep '^fr_FR$' >/dev/null
175 nigel 49 if [ $? -eq 0 ] ; then
176 ph10 157 locale=fr_FR
177     infile=$testdata/testinput3
178     outfile=$testdata/testoutput3
179     else
180     locale -a | grep '^french$' >/dev/null
181     if [ $? -eq 0 ] ; then
182     locale=french
183     sed 's/fr_FR/french/' $testdata/testinput3 >test3input
184     sed 's/fr_FR/french/' $testdata/testoutput3 >test3output
185     infile=test3input
186 ph10 159 outfile=test3output
187 ph10 157 else
188 ph10 159 locale=
189 ph10 157 fi
190 ph10 159 fi
191 ph10 157
192     if [ "$locale" != "" ] ; then
193     echo "Test 3: locale-specific features (using '$locale' locale)"
194     $valgrind ./pcretest -q $infile testtry
195 nigel 49 if [ $? = 0 ] ; then
196 ph10 158 $cf $outfile testtry
197 nigel 77 if [ $? != 0 ] ; then
198 nigel 49 echo " "
199     echo "Locale test did not run entirely successfully."
200     echo "This usually means that there is a problem with the locale"
201 nigel 77 echo "settings rather than a bug in PCRE."
202 nigel 49 else
203 nigel 77 echo "OK"
204     fi
205 nigel 49 else exit 1
206     fi
207     else
208 ph10 157 echo "Cannot test locale-specific features - neither the 'fr_FR' nor the"
209     echo "'french' locale exists, or the \"locale\" command is not available"
210     echo "to check for them."
211 nigel 77 echo " "
212 nigel 49 fi
213     fi
214    
215     # Additional tests for UTF8 support
216    
217 nigel 63 if [ $do4 = yes ] ; then
218 ph10 559 echo "Test 4: UTF-8 support (Compatible with Perl >= 5.8)"
219 nigel 87 $valgrind ./pcretest -q $testdata/testinput4 testtry
220 nigel 49 if [ $? = 0 ] ; then
221 ph10 158 $cf $testdata/testoutput4 testtry
222 nigel 49 if [ $? != 0 ] ; then exit 1; fi
223     else exit 1
224     fi
225 nigel 77 echo "OK"
226 nigel 49 fi
227    
228 nigel 63 if [ $do5 = yes ] ; then
229 ph10 426 echo "Test 5: API, internals, and non-Perl stuff for UTF-8 support"
230 ph10 162 $valgrind ./pcretest -q $testdata/testinput5 testtry
231     if [ $? = 0 ] ; then
232     $cf $testdata/testoutput5 testtry
233     if [ $? != 0 ] ; then exit 1; fi
234     else exit 1
235 nigel 77 fi
236 ph10 162 echo "OK"
237 nigel 49 fi
238    
239 nigel 75 if [ $do6 = yes ] ; then
240 ph10 559 echo "Test 6: Unicode property support (Compatible with Perl >= 5.10)"
241 ph10 162 $valgrind ./pcretest -q $testdata/testinput6 testtry
242     if [ $? = 0 ] ; then
243     $cf $testdata/testoutput6 testtry
244     if [ $? != 0 ] ; then exit 1; fi
245     else exit 1
246 nigel 77 fi
247 ph10 162 echo "OK"
248 nigel 75 fi
249    
250 nigel 77 # Tests for DFA matching support
251    
252     if [ $do7 = yes ] ; then
253     echo "Test 7: DFA matching"
254 nigel 87 $valgrind ./pcretest -q -dfa $testdata/testinput7 testtry
255 nigel 77 if [ $? = 0 ] ; then
256 ph10 158 $cf $testdata/testoutput7 testtry
257 nigel 77 if [ $? != 0 ] ; then exit 1; fi
258     else exit 1
259     fi
260     echo "OK"
261     fi
262    
263     if [ $do8 = yes ] ; then
264     echo "Test 8: DFA matching with UTF-8"
265 nigel 87 $valgrind ./pcretest -q -dfa $testdata/testinput8 testtry
266 nigel 77 if [ $? = 0 ] ; then
267 ph10 158 $cf $testdata/testoutput8 testtry
268 nigel 77 if [ $? != 0 ] ; then exit 1; fi
269     else exit 1
270     fi
271     echo "OK"
272     fi
273    
274     if [ $do9 = yes ] ; then
275     echo "Test 9: DFA matching with Unicode properties"
276 nigel 87 $valgrind ./pcretest -q -dfa $testdata/testinput9 testtry
277 nigel 77 if [ $? = 0 ] ; then
278 ph10 158 $cf $testdata/testoutput9 testtry
279 nigel 77 if [ $? != 0 ] ; then exit 1; fi
280     else exit 1
281     fi
282     echo "OK"
283     fi
284    
285 ph10 164 # Test of internal offsets and code sizes. This test is run only when there
286     # is Unicode property support and the link size is 2. The actual tests are
287     # mostly the same as in some of the above, but in this test we inspect some
288     # offsets and sizes that require a known link size. This is a doublecheck for
289     # the maintainer, just in case something changes unexpectely.
290    
291     if [ $do10 = yes ] ; then
292     echo "Test 10: Internal offsets and code size tests"
293     $valgrind ./pcretest -q $testdata/testinput10 testtry
294     if [ $? = 0 ] ; then
295     $cf $testdata/testoutput10 testtry
296     if [ $? != 0 ] ; then exit 1; fi
297     else exit 1
298     fi
299     echo "OK"
300     fi
301    
302 ph10 559 # Test of Perl >= 5.10 features
303 ph10 448
304     if [ $do11 = yes ] ; then
305 ph10 559 echo "Test 11: Features from Perl >= 5.10"
306 ph10 448 $valgrind ./pcretest -q $testdata/testinput11 testtry
307     if [ $? = 0 ] ; then
308     $cf $testdata/testoutput11 testtry
309     if [ $? != 0 ] ; then exit 1; fi
310     else exit 1
311     fi
312     echo "OK"
313     fi
314    
315     # Test non-Perl-compatible Unicode property support
316    
317     if [ $do12 = yes ] ; then
318     echo "Test 12: API, internals, and non-Perl stuff for Unicode property support"
319     $valgrind ./pcretest -q $testdata/testinput12 testtry
320     if [ $? = 0 ] ; then
321     $cf $testdata/testoutput12 testtry
322     if [ $? != 0 ] ; then exit 1; fi
323     else exit 1
324     fi
325     echo "OK"
326     fi
327    
328 nigel 49 # End

Properties

Name Value
svn:executable *
svn:keywords "Author Date Id Revision Url"

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12