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.
10 if diff -u /dev/null /dev/null; then cf="diff -u"; else cf="diff"; fi
15 if [ -n "$srcdir" -a -d "$srcdir" ] ; then
16 testdata="$srcdir/testdata"
19 # Find which optional facilities are available
21 case `./pcretest -C | ./pcregrep 'Internal link size'` in
25 *) echo "Failed to find internal link size"; exit 1;;
28 ./pcretest -C | ./pcregrep 'No UTF-8 support' >/dev/null
31 ./pcretest -C | ./pcregrep 'No Unicode properties support' >/dev/null
34 # Select which tests to run; for those that are explicitly requested, check
35 # that the necessary optional facilities are available.
50 while [ $# -gt 0 ] ; do
64 valgrind) valgrind="valgrind -q";;
65 *) echo "Unknown test number $1"; exit 1;;
70 if [ $utf8 -eq 0 ] ; then
71 if [ $do4 = yes ] ; then
72 echo "Can't run test 4 because UTF-8 support is not configured"
75 if [ $do5 = yes ] ; then
76 echo "Can't run test 5 because UTF-8 support is not configured"
79 if [ $do8 = yes ] ; then
80 echo "Can't run test 8 because UTF-8 support is not configured"
85 if [ $ucp -eq 0 ] ; then
86 if [ $do6 = yes ] ; then
87 echo "Can't run test 6 because Unicode property support is not configured"
90 if [ $do9 = yes ] ; then
91 echo "Can't run test 9 because Unicode property support is not configured"
94 if [ $do10 = yes ] ; then
95 echo "Can't run test 10 because Unicode property support is not configured"
98 if [ $do12 = yes ] ; then
99 echo "Can't run test 12 because Unicode property support is not configured"
104 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"
111 # If no specific tests were requested, select all that are relevant.
113 if [ $do1 = no -a $do2 = no -a $do3 = no -a $do4 = no -a \
114 $do5 = no -a $do6 = no -a $do7 = no -a $do8 = no -a \
115 $do9 = no -a $do10 = no -a $do11 = no -a $do12 = no ] ; then
119 if [ $utf8 -ne 0 ] ; then do4=yes; fi
120 if [ $utf8 -ne 0 ] ; then do5=yes; fi
121 if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do6=yes; fi
123 if [ $utf8 -ne 0 ] ; then do8=yes; fi
124 if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do9=yes; fi
125 if [ $link_size -eq 2 -a $ucp -ne 0 ] ; then do10=yes; fi
127 if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do12=yes; fi
133 echo PCRE C library tests
136 # Primary test, compatible with all versions of Perl >= 5.8
138 if [ $do1 = yes ] ; then
139 echo "Test 1: main functionality (Compatible with Perl >= 5.8)"
140 $valgrind ./pcretest -q $testdata/testinput1 testtry
142 $cf $testdata/testoutput1 testtry
143 if [ $? != 0 ] ; then exit 1; fi
149 # PCRE tests that are not Perl-compatible - API, errors, internals
151 if [ $do2 = yes ] ; then
152 echo "Test 2: API, errors, internals, and non-Perl stuff"
153 $valgrind ./pcretest -q $testdata/testinput2 testtry
155 $cf $testdata/testoutput2 testtry
156 if [ $? != 0 ] ; then exit 1; fi
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 echo "** page for a discussion of PCRE's stack usage."
169 # 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
173 if [ $do3 = yes ] ; then
174 locale -a | grep '^fr_FR$' >/dev/null
175 if [ $? -eq 0 ] ; then
177 infile=$testdata/testinput3
178 outfile=$testdata/testoutput3
180 locale -a | grep '^french$' >/dev/null
181 if [ $? -eq 0 ] ; then
183 sed 's/fr_FR/french/' $testdata/testinput3 >test3input
184 sed 's/fr_FR/french/' $testdata/testoutput3 >test3output
192 if [ "$locale" != "" ] ; then
193 echo "Test 3: locale-specific features (using '$locale' locale)"
194 $valgrind ./pcretest -q $infile testtry
197 if [ $? != 0 ] ; then
199 echo "Locale test did not run entirely successfully."
200 echo "This usually means that there is a problem with the locale"
201 echo "settings rather than a bug in PCRE."
208 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."
215 # Additional tests for UTF8 support
217 if [ $do4 = yes ] ; then
218 echo "Test 4: UTF-8 support (Compatible with Perl >= 5.8)"
219 $valgrind ./pcretest -q $testdata/testinput4 testtry
221 $cf $testdata/testoutput4 testtry
222 if [ $? != 0 ] ; then exit 1; fi
228 if [ $do5 = yes ] ; then
229 echo "Test 5: API, internals, and non-Perl stuff for UTF-8 support"
230 $valgrind ./pcretest -q $testdata/testinput5 testtry
232 $cf $testdata/testoutput5 testtry
233 if [ $? != 0 ] ; then exit 1; fi
239 if [ $do6 = yes ] ; then
240 echo "Test 6: Unicode property support (Compatible with Perl >= 5.10)"
241 $valgrind ./pcretest -q $testdata/testinput6 testtry
243 $cf $testdata/testoutput6 testtry
244 if [ $? != 0 ] ; then exit 1; fi
250 # Tests for DFA matching support
252 if [ $do7 = yes ] ; then
253 echo "Test 7: DFA matching"
254 $valgrind ./pcretest -q -dfa $testdata/testinput7 testtry
256 $cf $testdata/testoutput7 testtry
257 if [ $? != 0 ] ; then exit 1; fi
263 if [ $do8 = yes ] ; then
264 echo "Test 8: DFA matching with UTF-8"
265 $valgrind ./pcretest -q -dfa $testdata/testinput8 testtry
267 $cf $testdata/testoutput8 testtry
268 if [ $? != 0 ] ; then exit 1; fi
274 if [ $do9 = yes ] ; then
275 echo "Test 9: DFA matching with Unicode properties"
276 $valgrind ./pcretest -q -dfa $testdata/testinput9 testtry
278 $cf $testdata/testoutput9 testtry
279 if [ $? != 0 ] ; then exit 1; fi
285 # 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.
291 if [ $do10 = yes ] ; then
292 echo "Test 10: Internal offsets and code size tests"
293 $valgrind ./pcretest -q $testdata/testinput10 testtry
295 $cf $testdata/testoutput10 testtry
296 if [ $? != 0 ] ; then exit 1; fi
302 # Test of Perl >= 5.10 features
304 if [ $do11 = yes ] ; then
305 echo "Test 11: Features from Perl >= 5.10"
306 $valgrind ./pcretest -q $testdata/testinput11 testtry
308 $cf $testdata/testoutput11 testtry
309 if [ $? != 0 ] ; then exit 1; fi
315 # Test non-Perl-compatible Unicode property support
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
321 $cf $testdata/testoutput12 testtry
322 if [ $? != 0 ] ; then exit 1; fi