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.
48 while [ $# -gt 0 ] ; do
60 valgrind) valgrind="valgrind -q";;
61 *) echo "Unknown test number $1"; exit 1;;
66 if [ $utf8 -eq 0 ] ; then
67 if [ $do4 = yes ] ; then
68 echo "Can't run test 4 because UTF-8 support is not configured"
71 if [ $do5 = yes ] ; then
72 echo "Can't run test 5 because UTF-8 support is not configured"
75 if [ $do8 = yes ] ; then
76 echo "Can't run test 8 because UTF-8 support is not configured"
81 if [ $ucp -eq 0 ] ; then
82 if [ $do6 = yes ] ; then
83 echo "Can't run test 6 because Unicode property support is not configured"
86 if [ $do9 = yes ] ; then
87 echo "Can't run test 9 because Unicode property support is not configured"
90 if [ $do10 = yes ] ; then
91 echo "Can't run test 10 because Unicode property support is not configured"
96 if [ $link_size -ne 2 ] ; then
97 if [ $do10 = yes ] ; then
98 echo "Can't run test 10 because the link size ($link_size) is not 2"
103 # If no specific tests were requested, select all that are relevant.
105 if [ $do1 = no -a $do2 = no -a $do3 = no -a $do4 = no -a \
106 $do5 = no -a $do6 = no -a $do7 = no -a $do8 = no -a \
107 $do9 = no -a $do10 = no ] ; then
111 if [ $utf8 -ne 0 ] ; then do4=yes; fi
112 if [ $utf8 -ne 0 ] ; then do5=yes; fi
113 if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do6=yes; fi
115 if [ $utf8 -ne 0 ] ; then do8=yes; fi
116 if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do9=yes; fi
117 if [ $link_size -eq 2 -a $ucp -ne 0 ] ; then do10=yes; fi
123 echo PCRE C library tests
126 # Primary test, Perl-compatible
128 if [ $do1 = yes ] ; then
129 echo "Test 1: main functionality (Perl compatible)"
130 $valgrind ./pcretest -q $testdata/testinput1 testtry
132 $cf $testdata/testoutput1 testtry
133 if [ $? != 0 ] ; then exit 1; fi
139 # PCRE tests that are not Perl-compatible - API & error tests, mostly
141 if [ $do2 = yes ] ; then
142 echo "Test 2: API and error handling (not Perl compatible)"
143 $valgrind ./pcretest -q $testdata/testinput2 testtry
145 $cf $testdata/testoutput2 testtry
146 if [ $? != 0 ] ; then exit 1; fi
149 echo "** Test 2 requires a lot of stack. If it has crashed with a"
150 echo "** segmentation fault, it may be that you do not have enough"
151 echo "** stack available by default. Please see the 'pcrestack' man"
152 echo "** page for a discussion of PCRE's stack usage."
159 # Locale-specific tests, provided that either the "fr_FR" or the "french"
160 # locale is available. The former is the Unix-like standard; the latter is
163 if [ $do3 = yes ] ; then
164 locale -a | grep '^fr_FR$' >/dev/null
165 if [ $? -eq 0 ] ; then
167 infile=$testdata/testinput3
168 outfile=$testdata/testoutput3
170 locale -a | grep '^french$' >/dev/null
171 if [ $? -eq 0 ] ; then
173 sed 's/fr_FR/french/' $testdata/testinput3 >test3input
174 sed 's/fr_FR/french/' $testdata/testoutput3 >test3output
182 if [ "$locale" != "" ] ; then
183 echo "Test 3: locale-specific features (using '$locale' locale)"
184 $valgrind ./pcretest -q $infile testtry
187 if [ $? != 0 ] ; then
189 echo "Locale test did not run entirely successfully."
190 echo "This usually means that there is a problem with the locale"
191 echo "settings rather than a bug in PCRE."
198 echo "Cannot test locale-specific features - neither the 'fr_FR' nor the"
199 echo "'french' locale exists, or the \"locale\" command is not available"
200 echo "to check for them."
205 # Additional tests for UTF8 support
207 if [ $do4 = yes ] ; then
208 echo "Test 4: UTF-8 support (Perl compatible)"
209 $valgrind ./pcretest -q $testdata/testinput4 testtry
211 $cf $testdata/testoutput4 testtry
212 if [ $? != 0 ] ; then exit 1; fi
218 if [ $do5 = yes ] ; then
219 echo "Test 5: API and internals for UTF-8 support (not Perl compatible)"
220 $valgrind ./pcretest -q $testdata/testinput5 testtry
222 $cf $testdata/testoutput5 testtry
223 if [ $? != 0 ] ; then exit 1; fi
229 if [ $do6 = yes ] ; then
230 echo "Test 6: Unicode property support"
231 $valgrind ./pcretest -q $testdata/testinput6 testtry
233 $cf $testdata/testoutput6 testtry
234 if [ $? != 0 ] ; then exit 1; fi
240 # Tests for DFA matching support
242 if [ $do7 = yes ] ; then
243 echo "Test 7: DFA matching"
244 $valgrind ./pcretest -q -dfa $testdata/testinput7 testtry
246 $cf $testdata/testoutput7 testtry
247 if [ $? != 0 ] ; then exit 1; fi
253 if [ $do8 = yes ] ; then
254 echo "Test 8: DFA matching with UTF-8"
255 $valgrind ./pcretest -q -dfa $testdata/testinput8 testtry
257 $cf $testdata/testoutput8 testtry
258 if [ $? != 0 ] ; then exit 1; fi
264 if [ $do9 = yes ] ; then
265 echo "Test 9: DFA matching with Unicode properties"
266 $valgrind ./pcretest -q -dfa $testdata/testinput9 testtry
268 $cf $testdata/testoutput9 testtry
269 if [ $? != 0 ] ; then exit 1; fi
275 # Test of internal offsets and code sizes. This test is run only when there
276 # is Unicode property support and the link size is 2. The actual tests are
277 # mostly the same as in some of the above, but in this test we inspect some
278 # offsets and sizes that require a known link size. This is a doublecheck for
279 # the maintainer, just in case something changes unexpectely.
281 if [ $do10 = yes ] ; then
282 echo "Test 10: Internal offsets and code size tests"
283 $valgrind ./pcretest -q $testdata/testinput10 testtry
285 $cf $testdata/testoutput10 testtry
286 if [ $? != 0 ] ; then exit 1; fi