Revision: 689
http://vcs.pcre.org/viewvc?view=rev&revision=689
Author: ph10
Date: 2011-09-09 11:34:57 +0100 (Fri, 09 Sep 2011)
Log Message:
-----------
Patch to RunTest for use with simulations; further JIT code/test tidies.
Modified Paths:
--------------
code/trunk/RunTest
code/trunk/pcre_study.c
code/trunk/pcretest.c
code/trunk/testdata/testinput13
code/trunk/testdata/testinput14
code/trunk/testdata/testinput15
code/trunk/testdata/testoutput13
code/trunk/testdata/testoutput14
code/trunk/testdata/testoutput15
Modified: code/trunk/RunTest
===================================================================
--- code/trunk/RunTest 2011-09-09 09:35:48 UTC (rev 688)
+++ code/trunk/RunTest 2011-09-09 10:34:57 UTC (rev 689)
@@ -18,48 +18,15 @@
# two tests for JIT-specific features, one to be run when JIT support is
# available, and one when it is not.
+# The arguments for this script can be individual test numbers, or the word
+# "valgrind", or "sim" followed by an argument to run cross-compiled
+# executables under a simulator, for example:
+#
+# RunTest 3 sim "qemu-arm -s 8388608"
+
valgrind=
+sim=
-# Set up a suitable "diff" command for comparison. Some systems
-# have a diff that lacks a -u option. Try to deal with this.
-
-if diff -u /dev/null /dev/null; then cf="diff -u"; else cf="diff"; fi
-
-# Find the test data
-
-testdata=testdata
-if [ -n "$srcdir" -a -d "$srcdir" ] ; then
- testdata="$srcdir/testdata"
-fi
-
-# Find which optional facilities are available
-
-case `./pcretest -C | ./pcregrep 'Internal link size'` in
- *2) link_size=2;;
- *3) link_size=3;;
- *4) link_size=4;;
- *) echo "Failed to find internal link size"; exit 1;;
-esac
-
-./pcretest -C | ./pcregrep 'No UTF-8 support' >/dev/null
-utf8=$?
-
-./pcretest -C | ./pcregrep 'No Unicode properties support' >/dev/null
-ucp=$?
-
-jitopt=
-./pcretest -C | ./pcregrep \
- 'No Just-in-time compiler support|this architecture is unsupported' \
- >/dev/null
-jit=$?
-if [ $jit -ne 0 ] ; then
- jitopt=-s+
-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.
@@ -97,11 +64,47 @@
14) do14=yes;;
15) do15=yes;;
valgrind) valgrind="valgrind -q --smc-check=all";;
+ sim) shift; sim=$1;;
*) echo "Unknown test number $1"; exit 1;;
esac
shift
done
+# Set up a suitable "diff" command for comparison. Some systems
+# have a diff that lacks a -u option. Try to deal with this.
+
+if diff -u /dev/null /dev/null; then cf="diff -u"; else cf="diff"; fi
+
+# Find the test data
+
+testdata=testdata
+if [ -n "$srcdir" -a -d "$srcdir" ] ; then
+ testdata="$srcdir/testdata"
+fi
+
+# Find which optional facilities are available
+
+case `$sim ./pcretest -C | $sim ./pcregrep 'Internal link size'` in
+ *2) link_size=2;;
+ *3) link_size=3;;
+ *4) link_size=4;;
+ *) echo "Failed to find internal link size"; exit 1;;
+esac
+
+$sim ./pcretest -C | $sim ./pcregrep 'No UTF-8 support' >/dev/null
+utf8=$?
+
+$sim ./pcretest -C | $sim ./pcregrep 'No Unicode properties support' >/dev/null
+ucp=$?
+
+jitopt=
+$sim ./pcretest -C | $sim ./pcregrep 'No just-in-time compiler support' \
+ >/dev/null
+jit=$?
+if [ $jit -ne 0 ] ; then
+ jitopt=-s+
+fi
+
if [ $utf8 -eq 0 ] ; then
if [ $do4 = yes ] ; then
echo "Can't run test 4 because UTF-8 support is not configured"
@@ -194,7 +197,7 @@
if [ $do1 = yes ] ; then
echo "Test 1: main functionality (Compatible with Perl >= 5.8)"
for opt in "" "-s" $jitopt; do
- $valgrind ./pcretest -q $opt $testdata/testinput1 testtry
+ $sim $valgrind ./pcretest -q $opt $testdata/testinput1 testtry
if [ $? = 0 ] ; then
$cf $testdata/testoutput1 testtry
if [ $? != 0 ] ; then exit 1; fi
@@ -212,7 +215,7 @@
if [ $do2 = yes ] ; then
echo "Test 2: API, errors, internals, and non-Perl stuff"
for opt in "" "-s" $jitopt; do
- $valgrind ./pcretest -q $opt $testdata/testinput2 testtry
+ $sim $valgrind ./pcretest -q $opt $testdata/testinput2 testtry
if [ $? = 0 ] ; then
$cf $testdata/testoutput2 testtry
if [ $? != 0 ] ; then exit 1; fi
@@ -258,7 +261,7 @@
if [ "$locale" != "" ] ; then
echo "Test 3: locale-specific features (using '$locale' locale)"
for opt in "" "-s" $jitopt; do
- $valgrind ./pcretest -q $opt $infile testtry
+ $sim $valgrind ./pcretest -q $opt $infile testtry
if [ $? = 0 ] ; then
$cf $outfile testtry
if [ $? != 0 ] ; then
@@ -292,7 +295,7 @@
echo " Skipped because UTF-8 support is not available"
else
for opt in "" "-s" $jitopt; do
- $valgrind ./pcretest -q $opt $testdata/testinput4 testtry
+ $sim $valgrind ./pcretest -q $opt $testdata/testinput4 testtry
if [ $? = 0 ] ; then
$cf $testdata/testoutput4 testtry
if [ $? != 0 ] ; then exit 1; fi
@@ -312,7 +315,7 @@
echo " Skipped because UTF-8 support is not available"
else
for opt in "" "-s" $jitopt; do
- $valgrind ./pcretest -q $opt $testdata/testinput5 testtry
+ $sim $valgrind ./pcretest -q $opt $testdata/testinput5 testtry
if [ $? = 0 ] ; then
$cf $testdata/testoutput5 testtry
if [ $? != 0 ] ; then exit 1; fi
@@ -332,7 +335,7 @@
echo " Skipped because Unicode property support is not available"
else
for opt in "" "-s" $jitopt; do
- $valgrind ./pcretest -q $opt $testdata/testinput6 testtry
+ $sim $valgrind ./pcretest -q $opt $testdata/testinput6 testtry
if [ $? = 0 ] ; then
$cf $testdata/testoutput6 testtry
if [ $? != 0 ] ; then exit 1; fi
@@ -351,7 +354,7 @@
if [ $do7 = yes ] ; then
echo "Test 7: DFA matching"
for opt in "" "-s"; do
- $valgrind ./pcretest -q $opt -dfa $testdata/testinput7 testtry
+ $sim $valgrind ./pcretest -q $opt -dfa $testdata/testinput7 testtry
if [ $? = 0 ] ; then
$cf $testdata/testoutput7 testtry
if [ $? != 0 ] ; then exit 1; fi
@@ -367,7 +370,7 @@
echo " Skipped because UTF-8 support is not available"
else
for opt in "" "-s"; do
- $valgrind ./pcretest -q $opt -dfa $testdata/testinput8 testtry
+ $sim $valgrind ./pcretest -q $opt -dfa $testdata/testinput8 testtry
if [ $? = 0 ] ; then
$cf $testdata/testoutput8 testtry
if [ $? != 0 ] ; then exit 1; fi
@@ -384,7 +387,7 @@
echo " Skipped because Unicode property support is not available"
else
for opt in "" "-s"; do
- $valgrind ./pcretest -q $opt -dfa $testdata/testinput9 testtry
+ $sim $valgrind ./pcretest -q $opt -dfa $testdata/testinput9 testtry
if [ $? = 0 ] ; then
$cf $testdata/testoutput9 testtry
if [ $? != 0 ] ; then exit 1; fi
@@ -409,7 +412,7 @@
echo " Skipped because Unicode property support is not available"
else
for opt in "" "-s"; do
- $valgrind ./pcretest -q $opt $testdata/testinput10 testtry
+ $sim $valgrind ./pcretest -q $opt $testdata/testinput10 testtry
if [ $? = 0 ] ; then
$cf $testdata/testoutput10 testtry
if [ $? != 0 ] ; then exit 1; fi
@@ -425,7 +428,7 @@
if [ $do11 = yes ] ; then
echo "Test 11: Features from Perl >= 5.10 without UTF8 support"
for opt in "" "-s" $jitopt; do
- $valgrind ./pcretest -q $opt $testdata/testinput11 testtry
+ $sim $valgrind ./pcretest -q $opt $testdata/testinput11 testtry
if [ $? = 0 ] ; then
$cf $testdata/testoutput11 testtry
if [ $? != 0 ] ; then exit 1; fi
@@ -446,7 +449,7 @@
echo " Skipped because UTF-8 support is not available"
else
for opt in "" "-s" $jitopt; do
- $valgrind ./pcretest -q $opt $testdata/testinput12 testtry
+ $sim $valgrind ./pcretest -q $opt $testdata/testinput12 testtry
if [ $? = 0 ] ; then
$cf $testdata/testoutput12 testtry
if [ $? != 0 ] ; then exit 1; fi
@@ -468,7 +471,7 @@
echo " Skipped because Unicode property support is not available"
else
for opt in "" "-s" $jitopt; do
- $valgrind ./pcretest -q $opt $testdata/testinput13 testtry
+ $sim $valgrind ./pcretest -q $opt $testdata/testinput13 testtry
if [ $? = 0 ] ; then
$cf $testdata/testoutput13 testtry
if [ $? != 0 ] ; then exit 1; fi
@@ -485,11 +488,11 @@
# Test JIT-specific features when JIT is available
if [ $do14 = yes ] ; then
- echo "Test 14: JIT-specific features (JIT available and usable)"
+ echo "Test 14: JIT-specific features (JIT available)"
if [ $jit -eq 0 ] ; then
echo " Skipped because JIT is not available or not usable"
else
- $valgrind ./pcretest -q $testdata/testinput14 testtry
+ $sim $valgrind ./pcretest -q $testdata/testinput14 testtry
if [ $? = 0 ] ; then
$cf $testdata/testoutput14 testtry
if [ $? != 0 ] ; then exit 1; fi
@@ -502,13 +505,11 @@
# Test JIT-specific features when JIT is not available
if [ $do15 = yes ] ; then
- echo "Test 15: JIT-specific features (JIT not available or not usable)"
+ echo "Test 15: JIT-specific features (JIT not available)"
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
+ $sim $valgrind ./pcretest -q $testdata/testinput15 testtry
if [ $? = 0 ] ; then
$cf $testdata/testoutput15 testtry
if [ $? != 0 ] ; then exit 1; fi
Modified: code/trunk/pcre_study.c
===================================================================
--- code/trunk/pcre_study.c 2011-09-09 09:35:48 UTC (rev 688)
+++ code/trunk/pcre_study.c 2011-09-09 10:34:57 UTC (rev 689)
@@ -1332,22 +1332,23 @@
study->flags |= PCRE_STUDY_MAPPED;
memcpy(study->start_bits, start_bits, sizeof(start_bits));
}
+
+ /* Always set the minlength value in the block, because the JIT compiler
+ makes use of it. However, don't set the bit unless the length is greater than
+ zero - the interpretive pcre_exec() and pcre_dfa_exec() needn't waste time
+ checking this case. */
+
+ study->minlength = min;
+ if (min > 0) study->flags |= PCRE_STUDY_MINLEN;
- if (min > 0)
- {
- study->flags |= PCRE_STUDY_MINLEN;
- study->minlength = min;
- }
-
/* If JIT support was compiled and requested, attempt the JIT compilation.
If no starting bytes were found, and the minimum length is zero, and JIT
- compilation fails, no flags will be set, so abandon the extra block and
- return NULL. */
+ compilation fails, abandon the extra block and return NULL. */
#ifdef SUPPORT_JIT
extra->executable_jit = NULL;
if ((options & PCRE_STUDY_JIT_COMPILE) != 0) _pcre_jit_compile(re, extra);
- if (study->flags == 0)
+ if (study->flags == 0 && (extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) == 0)
{
pcre_free_study(extra);
extra = NULL;
Modified: code/trunk/pcretest.c
===================================================================
--- code/trunk/pcretest.c 2011-09-09 09:35:48 UTC (rev 688)
+++ code/trunk/pcretest.c 2011-09-09 10:34:57 UTC (rev 689)
@@ -1051,26 +1051,6 @@
/*************************************************
-* 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 *
*************************************************/
@@ -1380,8 +1360,7 @@
printf(" %sUnicode properties support\n", rc? "" : "No ");
(void)pcre_config(PCRE_CONFIG_JIT, &rc);
if (rc)
- printf(" Just-in-time compiler support%s\n", check_jit_arch()?
- "" : " (but this architecture is unsupported)");
+ printf(" Just-in-time compiler support\n");
else
printf(" No just-in-time compiler support\n");
(void)pcre_config(PCRE_CONFIG_NEWLINE, &rc);
Modified: code/trunk/testdata/testinput13
===================================================================
--- code/trunk/testdata/testinput13 2011-09-09 09:35:48 UTC (rev 688)
+++ code/trunk/testdata/testinput13 2011-09-09 10:34:57 UTC (rev 689)
@@ -483,8 +483,6 @@
\x{401}\x{420}\x{421}\x{422}\x{423}\x{424}\x{425}\x{426}\x{427}\x{428}\x{429}\x{42a}\x{42b}\x{42c}\x{42d}\x{42e}\x{42f}
\x{451}\x{440}\x{441}\x{442}\x{443}\x{444}\x{445}\x{446}\x{447}\x{448}\x{449}\x{44a}\x{44b}\x{44c}\x{44d}\x{44e}\x{44f}
-/\p{Xps}*/SI
-
/\p{Lu}+9\p{Lu}+B\p{Lu}+b/BZ
/\p{^Lu}+9\p{^Lu}+B\p{^Lu}+b/BZ
Modified: code/trunk/testdata/testinput14
===================================================================
--- code/trunk/testdata/testinput14 2011-09-09 09:35:48 UTC (rev 688)
+++ code/trunk/testdata/testinput14 2011-09-09 10:34:57 UTC (rev 689)
@@ -1,5 +1,6 @@
-/-- This test is run only when JIT support is available. It checks for a
- successful and an unsuccessful JIT compile and save/restore behaviour. --/
+/-- This test is run only when JIT support is available. It checks for a
+successful and an unsuccessful JIT compile and save and restore behaviour,
+and a couple of things that are different with JIT. --/
/abc/S+I
@@ -10,4 +11,6 @@
<testsavedregex
abc
+/\p{Xps}*/SI
+
/-- End of testinput14 --/
Modified: code/trunk/testdata/testinput15
===================================================================
--- code/trunk/testdata/testinput15 2011-09-09 09:35:48 UTC (rev 688)
+++ code/trunk/testdata/testinput15 2011-09-09 10:34:57 UTC (rev 689)
@@ -1,6 +1,9 @@
/-- This test is run only when JIT support is not available. It checks that an
- attempt to use it has the expected behaviour. --/
+attempt to use it has the expected behaviour. It also tests things that
+are different without JIT. --/
/abc/S+I
+/\p{Xps}*/SI
+
/-- End of testinput15 --/
Modified: code/trunk/testdata/testoutput13
===================================================================
--- code/trunk/testdata/testoutput13 2011-09-09 09:35:48 UTC (rev 688)
+++ code/trunk/testdata/testoutput13 2011-09-09 10:34:57 UTC (rev 689)
@@ -1059,13 +1059,6 @@
\x{451}\x{440}\x{441}\x{442}\x{443}\x{444}\x{445}\x{446}\x{447}\x{448}\x{449}\x{44a}\x{44b}\x{44c}\x{44d}\x{44e}\x{44f}
0: \x{451}\x{440}\x{441}\x{442}\x{443}\x{444}\x{445}\x{446}\x{447}\x{448}\x{449}\x{44a}\x{44b}\x{44c}\x{44d}\x{44e}\x{44f}
-/\p{Xps}*/SI
-Capturing subpattern count = 0
-No options
-No first char
-No need char
-Study returned NULL
-
/\p{Lu}+9\p{Lu}+B\p{Lu}+b/BZ
------------------------------------------------------------------
Bra
Modified: code/trunk/testdata/testoutput14
===================================================================
--- code/trunk/testdata/testoutput14 2011-09-09 09:35:48 UTC (rev 688)
+++ code/trunk/testdata/testoutput14 2011-09-09 10:34:57 UTC (rev 689)
@@ -1,6 +1,6 @@
-/-- This test is run only when JIT support is available. It checks for a
- successful and an unsuccessful JIT compile and save/restore behaviour. --/
-** Unknown option 'r'
+/-- This test is run only when JIT support is available. It checks for a
+successful and an unsuccessful JIT compile and save and restore behaviour,
+and a couple of things that are different with JIT. --/
/abc/S+I
Capturing subpattern count = 0
@@ -37,4 +37,13 @@
abc
0: abc
+/\p{Xps}*/SI
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Subject length lower bound = -1
+No set of starting bytes
+JIT study was successful
+
/-- End of testinput14 --/
Modified: code/trunk/testdata/testoutput15
===================================================================
--- code/trunk/testdata/testoutput15 2011-09-09 09:35:48 UTC (rev 688)
+++ code/trunk/testdata/testoutput15 2011-09-09 10:34:57 UTC (rev 689)
@@ -1,5 +1,6 @@
/-- This test is run only when JIT support is not available. It checks that an
- attempt to use it has the expected behaviour. --/
+attempt to use it has the expected behaviour. It also tests things that
+are different without JIT. --/
/abc/S+I
Capturing subpattern count = 0
@@ -10,4 +11,12 @@
No set of starting bytes
JIT support is not available in this version of PCRE
+/\p{Xps}*/SI
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Study returned NULL
+JIT support is not available in this version of PCRE
+
/-- End of testinput15 --/