summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xRunTest122
-rw-r--r--pcretest.c26
-rw-r--r--testdata/testinput149
-rw-r--r--testdata/testoutput1424
4 files changed, 118 insertions, 63 deletions
diff --git a/RunTest b/RunTest
index e3164b0..9ea9b50 100755
--- a/RunTest
+++ b/RunTest
@@ -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,11 +48,17 @@ utf8=$?
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 @@ else
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 [ $do1 = yes ] ; then
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 @@ if [ $do2 = yes ] ; then
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 @@ if [ $do3 = yes ] ; then
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 @@ if [ $do4 = yes ] ; then
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 [ $do4 = yes ] ; then
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 [ $do5 = yes ] ; then
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 [ $do6 = yes ] ; then
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 @@ if [ $do8 = yes ] ; then
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 @@ if [ $do8 = yes ] ; then
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 @@ if [ $do9 = yes ] ; then
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 @@ fi
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 @@ if [ $do10 = yes ] ; then
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 [ $do11 = yes ] ; then
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 @@ if [ $do12 = yes ] ; then
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 [ $do12 = yes ] ; then
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 @@ if [ $do13 = yes ] ; then
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 [ $do13 = yes ] ; then
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 [ $do14 = yes ] ; then
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 [ $do15 = yes ] ; then
if [ $? != 0 ] ; then exit 1; fi
else exit 1
fi
- echo " OK"
- fi
+ echo " OK"
+ fi
fi
# End
diff --git a/pcretest.c b/pcretest.c
index da6dfeb..bf5cf00 100644
--- a/pcretest.c
+++ b/pcretest.c
@@ -1050,6 +1050,26 @@ if ((rc = pcre_fullinfo(re, study, option, ptr)) < 0)
/*************************************************
+* 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 @@ while (argc > 1 && argv[op][0] == '-')
(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. */
diff --git a/testdata/testinput14 b/testdata/testinput14
index e4d1b24..b9e91b5 100644
--- a/testdata/testinput14
+++ b/testdata/testinput14
@@ -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 --/
diff --git a/testdata/testoutput14 b/testdata/testoutput14
index 2874272..9b2f21d 100644
--- a/testdata/testoutput14
+++ b/testdata/testoutput14
@@ -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 @@ Subject length lower bound = 3
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 --/