[Pcre-svn] [671] code/trunk: Refactor RunTest and add JIT-sp…

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [671] code/trunk: Refactor RunTest and add JIT-specific tests.
Revision: 671
          http://vcs.pcre.org/viewvc?view=rev&revision=671
Author:   ph10
Date:     2011-08-23 12:17:49 +0100 (Tue, 23 Aug 2011)


Log Message:
-----------
Refactor RunTest and add JIT-specific tests.

Modified Paths:
--------------
    code/trunk/Makefile.am
    code/trunk/RunTest


Added Paths:
-----------
    code/trunk/testdata/testinput14
    code/trunk/testdata/testinput15
    code/trunk/testdata/testoutput14
    code/trunk/testdata/testoutput15


Modified: code/trunk/Makefile.am
===================================================================
--- code/trunk/Makefile.am    2011-08-23 11:16:56 UTC (rev 670)
+++ code/trunk/Makefile.am    2011-08-23 11:17:49 UTC (rev 671)
@@ -306,6 +306,8 @@
   testdata/testinput11 \
   testdata/testinput12 \
   testdata/testinput13 \
+  testdata/testinput14 \
+  testdata/testinput15 \
   testdata/testoutput1 \
   testdata/testoutput2 \
   testdata/testoutput3 \
@@ -319,6 +321,8 @@
   testdata/testoutput11 \
   testdata/testoutput12 \
   testdata/testoutput13 \
+  testdata/testoutput14 \
+  testdata/testoutput15 \
   testdata/wintestinput3 \
   testdata/wintestoutput3 \
   perltest.pl


Modified: code/trunk/RunTest
===================================================================
--- code/trunk/RunTest    2011-08-23 11:16:56 UTC (rev 670)
+++ code/trunk/RunTest    2011-08-23 11:17:49 UTC (rev 671)
@@ -1,15 +1,23 @@
 #! /bin/sh


-# Run the PCRE tests using the pcretest program. All tests are now run both
-# with and without -s, to ensure that everything is tested with and without
-# studying. However, there are some tests that produce different output after
-# studying, typically when we are tracing the actual matching process (for
-# example, using auto-callouts). In these few cases, the tests are duplicated
-# in the files, one with /S to force studying always, and one with /SS to force
-# *not* studying always. The use of -s doesn't then make any difference to
-# their output. There is also one test which compiles invalid UTF-8 with the
-# UTF-8 check turned off for which studying is disabled with /SS.
+# Run the PCRE tests using the pcretest program. The appropriate tests are
+# selected, depending on which build-time options were used.

+# All tests are now run both with and without -s, to ensure that everything is
+# tested with and without studying. However, there are some tests that produce
+# different output after studying, typically when we are tracing the actual
+# matching process (for example, using auto-callouts). In these few cases, the
+# tests are duplicated in the files, one with /S to force studying always, and
+# one with /SS to force *not* studying always. The use of -s doesn't then make
+# any difference to their output. There is also one test which compiles invalid
+# UTF-8 with the UTF-8 check turned off; for this, studying must also be
+# disabled with /SS.
+
+# 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
+# available, and one when it is not.
+
valgrind=

# Set up a suitable "diff" command for comparison. Some systems
@@ -62,6 +70,8 @@
do11=no
do12=no
do13=no
+do14=no
+do15=no

 while [ $# -gt 0 ] ; do
   case $1 in
@@ -78,6 +88,8 @@
    11) do11=yes;;
    12) do12=yes;;
    13) do13=yes;;
+   14) do14=yes;;
+   15) do15=yes;;
    valgrind) valgrind="valgrind -q --smc-check=all";;
     *) echo "Unknown test number $1"; exit 1;;
   esac
@@ -129,25 +141,40 @@
   fi
 fi


-# If no specific tests were requested, select all that are relevant.
+if [ $jit -eq 0 ] ; then
+  if [ $do14 = "yes" ] ; then
+    echo "Can't run test 14 because JIT support is not configured"
+    exit 1
+  fi
+else
+  if [ $do15 = "yes" ] ; then
+    echo "Can't run test 15 because JIT support is configured"
+    exit 1
+  fi
+fi                


-if [ $do1 = no -a $do2 = no -a $do3 = no -a $do4 = no -a \
-     $do5 = no -a $do6 = no -a $do7 = no -a $do8 = no -a \
-     $do9 = no -a $do10 = no -a $do11 = no -a $do12 = no -a \
-     $do13 = no ] ; then
+# If no specific tests were requested, select all. Those that are not
+# relevant will be skipped.
+
+if [ $do1  = no -a $do2  = no -a $do3  = no -a $do4  = no -a \
+     $do5  = no -a $do6  = no -a $do7  = no -a $do8  = no -a \
+     $do9  = no -a $do10 = no -a $do11 = no -a $do12 = no -a \
+     $do13 = no -a $do14 = no -a $do15 = no ] ; then
   do1=yes
   do2=yes
   do3=yes
-  if [ $utf8 -ne 0 ] ; then do4=yes; fi
-  if [ $utf8 -ne 0 ] ; then do5=yes; fi
-  if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do6=yes; fi
+  do4=yes
+  do5=yes
+  do6=yes
   do7=yes
-  if [ $utf8 -ne 0 ] ; then do8=yes; fi
-  if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do9=yes; fi
-  if [ $link_size -eq 2 -a $ucp -ne 0 ] ; then do10=yes; fi
+  do8=yes
+  do9=yes
+  do10=yes
   do11=yes
-  if [ $utf8 -ne 0 ] ; then do12=yes; fi
-  if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do13=yes; fi
+  do12=yes
+  do13=yes
+  do14=yes
+  do15=yes
 fi


 # Show which release
@@ -167,9 +194,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
@@ -192,9 +219,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
@@ -235,9 +262,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
@@ -255,50 +282,62 @@


 if [ $do4 = yes ] ; then
   echo "Test 4: UTF-8 support (Compatible with Perl >= 5.8)"
-  for opt in "" "-s" $jitopt; do
-    $valgrind ./pcretest -q $opt $testdata/testinput4 testtry
-    if [ $? = 0 ] ; then
-      $cf $testdata/testoutput4 testtry
-      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" 
-    fi
-  done
+  if [ $utf8 -eq 0 ] ; then
+    echo "  Skipped because UTF-8 support is not available"
+  else    
+    for opt in "" "-s" $jitopt; do
+      $valgrind ./pcretest -q $opt $testdata/testinput4 testtry
+      if [ $? = 0 ] ; then
+        $cf $testdata/testoutput4 testtry
+        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" 
+      fi
+    done
+  fi   
 fi


 if [ $do5 = yes ] ; then
   echo "Test 5: API, internals, and non-Perl stuff for UTF-8 support"
-  for opt in "" "-s" $jitopt; do
-    $valgrind ./pcretest -q $opt $testdata/testinput5 testtry
-    if [ $? = 0 ] ; then
-      $cf $testdata/testoutput5 testtry
-      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" 
-    fi
-  done
+  if [ $utf8 -eq 0 ] ; then
+    echo "  Skipped because UTF-8 support is not available"
+  else    
+    for opt in "" "-s" $jitopt; do
+      $valgrind ./pcretest -q $opt $testdata/testinput5 testtry
+      if [ $? = 0 ] ; then
+        $cf $testdata/testoutput5 testtry
+        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" 
+      fi
+    done
+  fi   
 fi


 if [ $do6 = yes ] ; then
   echo "Test 6: Unicode property support (Compatible with Perl >= 5.10)"
-  for opt in "" "-s" $jitopt; do
-    $valgrind ./pcretest -q $opt $testdata/testinput6 testtry
-    if [ $? = 0 ] ; then
-      $cf $testdata/testoutput6 testtry
-      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" 
-    fi
-  done
+  if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
+    echo "  Skipped because Unicode property support is not available"
+  else    
+    for opt in "" "-s" $jitopt; do
+      $valgrind ./pcretest -q $opt $testdata/testinput6 testtry
+      if [ $? = 0 ] ; then
+        $cf $testdata/testoutput6 testtry
+        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" 
+      fi
+    done
+  fi   
 fi


 # Tests for DFA matching support
@@ -312,34 +351,42 @@
       if [ $? != 0 ] ; then exit 1; fi
     else exit 1
     fi
-    if [ "$opt" = "-s" ] ; then echo "OK with study" ; else echo "OK"; fi
+    if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
   done
 fi


 if [ $do8 = yes ] ; then
   echo "Test 8: DFA matching with UTF-8"
-  for opt in "" "-s"; do
-    $valgrind ./pcretest -q $opt -dfa $testdata/testinput8 testtry
-    if [ $? = 0 ] ; then
-      $cf $testdata/testoutput8 testtry
-      if [ $? != 0 ] ; then exit 1; fi
-    else exit 1
-    fi
-    if [ "$opt" = "-s" ] ; then echo "OK with study" ; else echo "OK"; fi
-  done
+  if [ $utf8 -eq 0 ] ; then
+    echo "  Skipped because UTF-8 support is not available"
+  else    
+    for opt in "" "-s"; do
+      $valgrind ./pcretest -q $opt -dfa $testdata/testinput8 testtry
+      if [ $? = 0 ] ; then
+        $cf $testdata/testoutput8 testtry
+        if [ $? != 0 ] ; then exit 1; fi
+      else exit 1
+      fi
+      if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
+    done
+  fi   
 fi


 if [ $do9 = yes ] ; then
   echo "Test 9: DFA matching with Unicode properties"
-  for opt in "" "-s"; do
-    $valgrind ./pcretest -q $opt -dfa $testdata/testinput9 testtry
-    if [ $? = 0 ] ; then
-      $cf $testdata/testoutput9 testtry
-      if [ $? != 0 ] ; then exit 1; fi
-    else exit 1
-    fi
-    if [ "$opt" = "-s" ] ; then echo "OK with study" ; else echo "OK"; fi
-  done
+  if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
+    echo "  Skipped because Unicode property support is not available"
+  else    
+    for opt in "" "-s"; do
+      $valgrind ./pcretest -q $opt -dfa $testdata/testinput9 testtry
+      if [ $? = 0 ] ; then
+        $cf $testdata/testoutput9 testtry
+        if [ $? != 0 ] ; then exit 1; fi
+      else exit 1
+      fi
+      if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
+    done
+  fi   
 fi


# Test of internal offsets and code sizes. This test is run only when there
@@ -350,15 +397,21 @@

 if [ $do10 = yes ] ; then
   echo "Test 10: Internal offsets and code size tests"
-  for opt in "" "-s"; do
-    $valgrind ./pcretest -q $opt $testdata/testinput10 testtry
-    if [ $? = 0 ] ; then
-      $cf $testdata/testoutput10 testtry
-      if [ $? != 0 ] ; then exit 1; fi
-    else exit 1
-    fi
-    if [ "$opt" = "-s" ] ; then echo "OK with study" ; else echo "OK"; fi
-  done
+  if [ $link_size -ne 2 ] ; then 
+    echo "  Skipped because link size is not 2"
+  elif [ $ucp -eq 0 ] ; then 
+    echo "  Skipped because Unicode property support is not available"
+  else   
+    for opt in "" "-s"; do
+      $valgrind ./pcretest -q $opt $testdata/testinput10 testtry
+      if [ $? = 0 ] ; then
+        $cf $testdata/testoutput10 testtry
+        if [ $? != 0 ] ; then exit 1; fi
+      else exit 1
+      fi
+      if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
+    done
+  fi   
 fi


 # Test of Perl >= 5.10 features without UTF8 support
@@ -372,9 +425,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
@@ -383,36 +436,78 @@


 if [ $do12 = yes ] ; then
   echo "Test 12: Features from Perl >= 5.10 with UTF8 support"
-  for opt in "" "-s" $jitopt; do
-    $valgrind ./pcretest -q $opt $testdata/testinput12 testtry
-    if [ $? = 0 ] ; then
-      $cf $testdata/testoutput12 testtry
-      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" 
-    fi
-  done
+  if [ $utf8 -eq 0 ] ; then
+    echo "  Skipped because UTF-8 support is not available"
+  else    
+    for opt in "" "-s" $jitopt; do
+      $valgrind ./pcretest -q $opt $testdata/testinput12 testtry
+      if [ $? = 0 ] ; then
+        $cf $testdata/testoutput12 testtry
+        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" 
+      fi
+    done
+  fi   
 fi


# Test non-Perl-compatible Unicode property support

 if [ $do13 = yes ] ; then
   echo "Test 13: API, internals, and non-Perl stuff for Unicode property support"
-  for opt in "" "-s" $jitopt; do
-    $valgrind ./pcretest -q $opt $testdata/testinput13 testtry
+  if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
+    echo "  Skipped because Unicode property support is not available"
+  else    
+    for opt in "" "-s" $jitopt; do
+      $valgrind ./pcretest -q $opt $testdata/testinput13 testtry
+      if [ $? = 0 ] ; then
+        $cf $testdata/testoutput13 testtry
+        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" 
+      fi
+    done
+  fi   
+fi
+
+# Test JIT-specific features when JIT is available
+
+if [ $do14 = yes ] ; then
+  echo "Test 14: JIT-specific features (JIT available)"
+  if [ $jit -eq 0 ] ; then
+    echo "  Skipped because JIT is not available"
+  else
+    $valgrind ./pcretest -q $testdata/testinput14 testtry
     if [ $? = 0 ] ; then
-      $cf $testdata/testoutput13 testtry
+      $cf $testdata/testoutput14 testtry
       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" 
+    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)"
+  if [ $jit -ne 0 ] ; then
+    echo "  Skipped because JIT is available"
+  else
+    $valgrind ./pcretest -q $testdata/testinput15 testtry
+    if [ $? = 0 ] ; then
+      $cf $testdata/testoutput15 testtry
+      if [ $? != 0 ] ; then exit 1; fi
+    else exit 1
     fi
-  done
+    echo "  OK" 
+  fi   
 fi


# End

Added: code/trunk/testdata/testinput14
===================================================================
--- code/trunk/testdata/testinput14                            (rev 0)
+++ code/trunk/testdata/testinput14    2011-08-23 11:17:49 UTC (rev 671)
@@ -0,0 +1,8 @@
+/-- This test is run only when JIT support is available. It checks for a 
+    successful and an unsuccessful JIT compile. --/
+
+/abc/S+I
+
+/ab\C/S+I
+
+/-- End of testinput14 --/


Added: code/trunk/testdata/testinput15
===================================================================
--- code/trunk/testdata/testinput15                            (rev 0)
+++ code/trunk/testdata/testinput15    2011-08-23 11:17:49 UTC (rev 671)
@@ -0,0 +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. --/
+   
+/abc/S+I
+
+/-- End of testinput15 --/


Added: code/trunk/testdata/testoutput14
===================================================================
--- code/trunk/testdata/testoutput14                            (rev 0)
+++ code/trunk/testdata/testoutput14    2011-08-23 11:17:49 UTC (rev 671)
@@ -0,0 +1,22 @@
+/-- This test is run only when JIT support is available. It checks for a 
+    successful and an unsuccessful JIT compile. --/
+
+/abc/S+I
+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
+
+/ab\C/S+I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'b'
+Subject length lower bound = 3
+No set of starting bytes
+JIT study was not successful
+
+/-- End of testinput14 --/


Added: code/trunk/testdata/testoutput15
===================================================================
--- code/trunk/testdata/testoutput15                            (rev 0)
+++ code/trunk/testdata/testoutput15    2011-08-23 11:17:49 UTC (rev 671)
@@ -0,0 +1,13 @@
+/-- This test is run only when JIT support is not available. It checks that an 
+    attempt to use it has the expected behaviour. --/
+   
+/abc/S+I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'c'
+Subject length lower bound = 3
+No set of starting bytes
+JIT support is not available in this version of PCRE
+
+/-- End of testinput15 --/