Revision: 674
http://vcs.pcre.org/viewvc?view=rev&revision=674
Author: ph10
Date: 2011-08-26 19:17:51 +0100 (Fri, 26 Aug 2011)
Log Message:
-----------
More JIT testing.
Modified Paths:
--------------
code/trunk/RunTest
code/trunk/pcretest.c
code/trunk/testdata/testinput14
code/trunk/testdata/testoutput14
Modified: code/trunk/RunTest
===================================================================
--- code/trunk/RunTest 2011-08-25 16:06:03 UTC (rev 673)
+++ code/trunk/RunTest 2011-08-26 18:17:51 UTC (rev 674)
@@ -15,7 +15,7 @@
# When JIT support is available, all the tests are also run with -s+ to test
# (again, almost) everything with studying and the JIT option. There are also
-# two tests for JIT-specific features, one to be run when JIT support is
+# two tests for JIT-specific features, one to be run when JIT support is
# available, and one when it is not.
valgrind=
@@ -48,12 +48,18 @@
ucp=$?
jitopt=
-./pcretest -C | ./pcregrep 'No Just-in-time compiler support' >/dev/null
+./pcretest -C | ./pcregrep \
+ 'No Just-in-time compiler support|this architecture is unsupported' \
+ >/dev/null
jit=$?
if [ $jit -ne 0 ] ; then
jitopt=-s+
-fi
+else
+ ./pcretest -C | ./pcregrep 'this architecture is unsupported' >/dev/null
+ jitnotcompiled=$?
+fi
+
# Select which tests to run; for those that are explicitly requested, check
# that the necessary optional facilities are available.
@@ -151,7 +157,7 @@
echo "Can't run test 15 because JIT support is configured"
exit 1
fi
-fi
+fi
# If no specific tests were requested, select all. Those that are not
# relevant will be skipped.
@@ -194,9 +200,9 @@
if [ $? != 0 ] ; then exit 1; fi
else exit 1
fi
- if [ "$opt" = "-s" ] ; then echo " OK with study"
- elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
- else echo " OK"
+ if [ "$opt" = "-s" ] ; then echo " OK with study"
+ elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
+ else echo " OK"
fi
done
fi
@@ -219,9 +225,9 @@
echo " "
exit 1
fi
- if [ "$opt" = "-s" ] ; then echo " OK with study"
- elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
- else echo " OK"
+ if [ "$opt" = "-s" ] ; then echo " OK with study"
+ elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
+ else echo " OK"
fi
done
fi
@@ -262,9 +268,9 @@
echo "settings rather than a bug in PCRE."
break;
else
- if [ "$opt" = "-s" ] ; then echo " OK with study"
- elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
- else echo " OK"
+ if [ "$opt" = "-s" ] ; then echo " OK with study"
+ elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
+ else echo " OK"
fi
fi
else exit 1
@@ -284,7 +290,7 @@
echo "Test 4: UTF-8 support (Compatible with Perl >= 5.8)"
if [ $utf8 -eq 0 ] ; then
echo " Skipped because UTF-8 support is not available"
- else
+ else
for opt in "" "-s" $jitopt; do
$valgrind ./pcretest -q $opt $testdata/testinput4 testtry
if [ $? = 0 ] ; then
@@ -292,19 +298,19 @@
if [ $? != 0 ] ; then exit 1; fi
else exit 1
fi
- if [ "$opt" = "-s" ] ; then echo " OK with study"
- elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
- else echo " OK"
+ if [ "$opt" = "-s" ] ; then echo " OK with study"
+ elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
+ else echo " OK"
fi
done
- fi
+ fi
fi
if [ $do5 = yes ] ; then
echo "Test 5: API, internals, and non-Perl stuff for UTF-8 support"
if [ $utf8 -eq 0 ] ; then
echo " Skipped because UTF-8 support is not available"
- else
+ else
for opt in "" "-s" $jitopt; do
$valgrind ./pcretest -q $opt $testdata/testinput5 testtry
if [ $? = 0 ] ; then
@@ -312,19 +318,19 @@
if [ $? != 0 ] ; then exit 1; fi
else exit 1
fi
- if [ "$opt" = "-s" ] ; then echo " OK with study"
- elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
- else echo " OK"
+ if [ "$opt" = "-s" ] ; then echo " OK with study"
+ elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
+ else echo " OK"
fi
done
- fi
+ fi
fi
if [ $do6 = yes ] ; then
echo "Test 6: Unicode property support (Compatible with Perl >= 5.10)"
if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
echo " Skipped because Unicode property support is not available"
- else
+ else
for opt in "" "-s" $jitopt; do
$valgrind ./pcretest -q $opt $testdata/testinput6 testtry
if [ $? = 0 ] ; then
@@ -332,12 +338,12 @@
if [ $? != 0 ] ; then exit 1; fi
else exit 1
fi
- if [ "$opt" = "-s" ] ; then echo " OK with study"
- elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
- else echo " OK"
+ if [ "$opt" = "-s" ] ; then echo " OK with study"
+ elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
+ else echo " OK"
fi
done
- fi
+ fi
fi
# Tests for DFA matching support
@@ -359,7 +365,7 @@
echo "Test 8: DFA matching with UTF-8"
if [ $utf8 -eq 0 ] ; then
echo " Skipped because UTF-8 support is not available"
- else
+ else
for opt in "" "-s"; do
$valgrind ./pcretest -q $opt -dfa $testdata/testinput8 testtry
if [ $? = 0 ] ; then
@@ -369,14 +375,14 @@
fi
if [ "$opt" = "-s" ] ; then echo " OK with study" ; else echo " OK"; fi
done
- fi
+ fi
fi
if [ $do9 = yes ] ; then
echo "Test 9: DFA matching with Unicode properties"
if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
echo " Skipped because Unicode property support is not available"
- else
+ else
for opt in "" "-s"; do
$valgrind ./pcretest -q $opt -dfa $testdata/testinput9 testtry
if [ $? = 0 ] ; then
@@ -386,7 +392,7 @@
fi
if [ "$opt" = "-s" ] ; then echo " OK with study" ; else echo " OK"; fi
done
- fi
+ fi
fi
# Test of internal offsets and code sizes. This test is run only when there
@@ -397,11 +403,11 @@
if [ $do10 = yes ] ; then
echo "Test 10: Internal offsets and code size tests"
- if [ $link_size -ne 2 ] ; then
+ if [ $link_size -ne 2 ] ; then
echo " Skipped because link size is not 2"
- elif [ $ucp -eq 0 ] ; then
+ elif [ $ucp -eq 0 ] ; then
echo " Skipped because Unicode property support is not available"
- else
+ else
for opt in "" "-s"; do
$valgrind ./pcretest -q $opt $testdata/testinput10 testtry
if [ $? = 0 ] ; then
@@ -411,7 +417,7 @@
fi
if [ "$opt" = "-s" ] ; then echo " OK with study" ; else echo " OK"; fi
done
- fi
+ fi
fi
# Test of Perl >= 5.10 features without UTF8 support
@@ -425,9 +431,9 @@
if [ $? != 0 ] ; then exit 1; fi
else exit 1
fi
- if [ "$opt" = "-s" ] ; then echo " OK with study"
- elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
- else echo " OK"
+ if [ "$opt" = "-s" ] ; then echo " OK with study"
+ elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
+ else echo " OK"
fi
done
fi
@@ -438,7 +444,7 @@
echo "Test 12: Features from Perl >= 5.10 with UTF8 support"
if [ $utf8 -eq 0 ] ; then
echo " Skipped because UTF-8 support is not available"
- else
+ else
for opt in "" "-s" $jitopt; do
$valgrind ./pcretest -q $opt $testdata/testinput12 testtry
if [ $? = 0 ] ; then
@@ -446,12 +452,12 @@
if [ $? != 0 ] ; then exit 1; fi
else exit 1
fi
- if [ "$opt" = "-s" ] ; then echo " OK with study"
- elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
- else echo " OK"
+ if [ "$opt" = "-s" ] ; then echo " OK with study"
+ elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
+ else echo " OK"
fi
done
- fi
+ fi
fi
# Test non-Perl-compatible Unicode property support
@@ -460,7 +466,7 @@
echo "Test 13: API, internals, and non-Perl stuff for Unicode property support"
if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
echo " Skipped because Unicode property support is not available"
- else
+ else
for opt in "" "-s" $jitopt; do
$valgrind ./pcretest -q $opt $testdata/testinput13 testtry
if [ $? = 0 ] ; then
@@ -468,20 +474,20 @@
if [ $? != 0 ] ; then exit 1; fi
else exit 1
fi
- if [ "$opt" = "-s" ] ; then echo " OK with study"
- elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
- else echo " OK"
+ if [ "$opt" = "-s" ] ; then echo " OK with study"
+ elif [ "$opt" = "-s+" ] ; then echo " OK with JIT study"
+ else echo " OK"
fi
done
- fi
+ fi
fi
# Test JIT-specific features when JIT is available
if [ $do14 = yes ] ; then
- echo "Test 14: JIT-specific features (JIT available)"
+ echo "Test 14: JIT-specific features (JIT available and usable)"
if [ $jit -eq 0 ] ; then
- echo " Skipped because JIT is not available"
+ echo " Skipped because JIT is not available or not usable"
else
$valgrind ./pcretest -q $testdata/testinput14 testtry
if [ $? = 0 ] ; then
@@ -489,16 +495,18 @@
if [ $? != 0 ] ; then exit 1; fi
else exit 1
fi
- echo " OK"
- fi
+ echo " OK"
+ fi
fi
-
+
# Test JIT-specific features when JIT is not available
if [ $do15 = yes ] ; then
- echo "Test 15: JIT-specific features (JIT not available)"
+ echo "Test 15: JIT-specific features (JIT not available or not usable)"
if [ $jit -ne 0 ] ; then
echo " Skipped because JIT is available"
+ elif [ $jitnotcompiled -eq 0 ] ; then
+ echo " Skipped because JIT does not support this architecture"
else
$valgrind ./pcretest -q $testdata/testinput15 testtry
if [ $? = 0 ] ; then
@@ -506,8 +514,8 @@
if [ $? != 0 ] ; then exit 1; fi
else exit 1
fi
- echo " OK"
- fi
+ echo " OK"
+ fi
fi
# End
Modified: code/trunk/pcretest.c
===================================================================
--- code/trunk/pcretest.c 2011-08-25 16:06:03 UTC (rev 673)
+++ code/trunk/pcretest.c 2011-08-26 18:17:51 UTC (rev 674)
@@ -1050,6 +1050,26 @@
/*************************************************
+* Check for supported JIT architecture *
+*************************************************/
+
+/* If it won't JIT-compile a very simple regex, return FALSE. */
+
+static int check_jit_arch(void)
+{
+const char *error;
+int erroffset, rc;
+pcre *re = pcre_compile("abc", 0, &error, &erroffset, NULL);
+pcre_extra *extra = pcre_study(re, PCRE_STUDY_JIT_COMPILE, &error);
+rc = extra != NULL && (extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 &&
+ extra->executable_jit != NULL;
+pcre_free_study(extra);
+free(re);
+return rc;
+}
+
+
+/*************************************************
* Byte flipping function *
*************************************************/
@@ -1358,7 +1378,11 @@
(void)pcre_config(PCRE_CONFIG_UNICODE_PROPERTIES, &rc);
printf(" %sUnicode properties support\n", rc? "" : "No ");
(void)pcre_config(PCRE_CONFIG_JIT, &rc);
- printf(" %sJust-in-time compiler support\n", rc? "" : "No ");
+ if (rc)
+ printf(" Just-in-time compiler support%s\n", check_jit_arch()?
+ "" : " (but this architecture is unsupported)");
+ else
+ printf(" No just-in-time compiler support\n");
(void)pcre_config(PCRE_CONFIG_NEWLINE, &rc);
/* Note that these values are always the ASCII values, even
in EBCDIC environments. CR is 13 and NL is 10. */
Modified: code/trunk/testdata/testinput14
===================================================================
--- code/trunk/testdata/testinput14 2011-08-25 16:06:03 UTC (rev 673)
+++ code/trunk/testdata/testinput14 2011-08-26 18:17:51 UTC (rev 674)
@@ -1,8 +1,13 @@
/-- This test is run only when JIT support is available. It checks for a
- successful and an unsuccessful JIT compile. --/
+ successful and an unsuccessful JIT compile and save/restore behaviour. --/
/abc/S+I
-/ab\C/S+I
+/ab(*COMMIT)/S+I
+/abc/S+I>testsavedregex
+
+<testsavedregex
+ abc
+
/-- End of testinput14 --/
Modified: code/trunk/testdata/testoutput14
===================================================================
--- code/trunk/testdata/testoutput14 2011-08-25 16:06:03 UTC (rev 673)
+++ code/trunk/testdata/testoutput14 2011-08-26 18:17:51 UTC (rev 674)
@@ -1,5 +1,6 @@
/-- This test is run only when JIT support is available. It checks for a
- successful and an unsuccessful JIT compile. --/
+ successful and an unsuccessful JIT compile and save/restore behaviour. --/
+** Unknown option 'r'
/abc/S+I
Capturing subpattern count = 0
@@ -10,13 +11,30 @@
No set of starting bytes
JIT study was successful
-/ab\C/S+I
+/ab(*COMMIT)/S+I
Capturing subpattern count = 0
No options
First char = 'a'
Need char = 'b'
-Subject length lower bound = 3
+Subject length lower bound = 2
No set of starting bytes
JIT study was not successful
+/abc/S+I>testsavedregex
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'c'
+Subject length lower bound = 3
+No set of starting bytes
+JIT study was successful
+Compiled pattern written to testsavedregex
+Study data written to testsavedregex
+
+<testsavedregex
+Compiled pattern loaded from testsavedregex
+Study data loaded from testsavedregex
+ abc
+ 0: abc
+
/-- End of testinput14 --/