/[pcre]/code/trunk/RunTest
ViewVC logotype

Diff of /code/trunk/RunTest

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 159 by ph10, Wed May 2 10:27:18 2007 UTC revision 674 by ph10, Fri Aug 26 18:17:51 2011 UTC
# Line 1  Line 1 
1  #! /bin/sh  #! /bin/sh
2    
3  # Run PCRE tests  # Run the PCRE tests using the pcretest program. The appropriate tests are
4    # selected, depending on which build-time options were used.
5    
6    # All tests are now run both with and without -s, to ensure that everything is
7    # tested with and without studying. However, there are some tests that produce
8    # different output after studying, typically when we are tracing the actual
9    # matching process (for example, using auto-callouts). In these few cases, the
10    # tests are duplicated in the files, one with /S to force studying always, and
11    # one with /SS to force *not* studying always. The use of -s doesn't then make
12    # any difference to their output. There is also one test which compiles invalid
13    # UTF-8 with the UTF-8 check turned off; for this, studying must also be
14    # disabled with /SS.
15    
16    # When JIT support is available, all the tests are also run with -s+ to test
17    # (again, almost) everything with studying and the JIT option. There are also
18    # two tests for JIT-specific features, one to be run when JIT support is
19    # available, and one when it is not.
20    
 cf="diff -u"  
21  valgrind=  valgrind=
 testdata=testdata  
22    
23    # Set up a suitable "diff" command for comparison. Some systems
24    # have a diff that lacks a -u option. Try to deal with this.
25    
26    if diff -u /dev/null /dev/null; then cf="diff -u"; else cf="diff"; fi
27    
28    # Find the test data
29    
30    testdata=testdata
31  if [ -n "$srcdir" -a -d "$srcdir" ] ; then  if [ -n "$srcdir" -a -d "$srcdir" ] ; then
32    testdata="$srcdir/testdata"    testdata="$srcdir/testdata"
33  fi  fi
# Line 25  utf8=$? Line 47  utf8=$?
47  ./pcretest -C | ./pcregrep 'No Unicode properties support' >/dev/null  ./pcretest -C | ./pcregrep 'No Unicode properties support' >/dev/null
48  ucp=$?  ucp=$?
49    
50    jitopt=
51    ./pcretest -C | ./pcregrep \
52      'No Just-in-time compiler support|this architecture is unsupported' \
53      >/dev/null
54    jit=$?
55    if [ $jit -ne 0 ] ; then
56      jitopt=-s+
57    else
58      ./pcretest -C | ./pcregrep 'this architecture is unsupported' >/dev/null
59      jitnotcompiled=$?
60    fi
61    
62    
63  # Select which tests to run; for those that are explicitly requested, check  # Select which tests to run; for those that are explicitly requested, check
64  # that the necessary optional facilities are available.  # that the necessary optional facilities are available.
65    
# Line 37  do6=no Line 72  do6=no
72  do7=no  do7=no
73  do8=no  do8=no
74  do9=no  do9=no
75    do10=no
76    do11=no
77    do12=no
78    do13=no
79    do14=no
80    do15=no
81    
82  while [ $# -gt 0 ] ; do  while [ $# -gt 0 ] ; do
83    case $1 in    case $1 in
# Line 49  while [ $# -gt 0 ] ; do Line 90  while [ $# -gt 0 ] ; do
90      7) do7=yes;;      7) do7=yes;;
91      8) do8=yes;;      8) do8=yes;;
92      9) do9=yes;;      9) do9=yes;;
93      valgrind) valgrind="valgrind -q";;     10) do10=yes;;
94       11) do11=yes;;
95       12) do12=yes;;
96       13) do13=yes;;
97       14) do14=yes;;
98       15) do15=yes;;
99       valgrind) valgrind="valgrind -q --smc-check=all";;
100      *) echo "Unknown test number $1"; exit 1;;      *) echo "Unknown test number $1"; exit 1;;
101    esac    esac
102    shift    shift
103  done  done
104    
 if [ "$link_size" != "2" ] ; then  
   if [ $do2 = yes ] ; then  
     echo "Can't run test 2 with an internal link size other than 2"  
     exit 1  
   fi  
   if [ $do5 = yes ] ; then  
     echo "Can't run test 5 with an internal link size other than 2"  
     exit 1  
   fi  
   if [ $do6 = yes ] ; then  
     echo "Can't run test 6 with an internal link size other than 2"  
     exit 1  
   fi  
 fi  
   
105  if [ $utf8 -eq 0 ] ; then  if [ $utf8 -eq 0 ] ; then
106    if [ $do4 = yes ] ; then    if [ $do4 = yes ] ; then
107      echo "Can't run test 4 because UTF-8 support is not configured"      echo "Can't run test 4 because UTF-8 support is not configured"
# Line 79  if [ $utf8 -eq 0 ] ; then Line 111  if [ $utf8 -eq 0 ] ; then
111      echo "Can't run test 5 because UTF-8 support is not configured"      echo "Can't run test 5 because UTF-8 support is not configured"
112      exit 1      exit 1
113    fi    fi
   if [ $do6 = yes ] ; then  
     echo "Can't run test 6 because UTF-8 support is not configured"  
     exit 1  
   fi  
114    if [ $do8 = yes ] ; then    if [ $do8 = yes ] ; then
115      echo "Can't run test 8 because UTF-8 support is not configured"      echo "Can't run test 8 because UTF-8 support is not configured"
116      exit 1      exit 1
117    fi    fi
118    if [ $do9 = yes ] ; then    if [ $do12 = yes ] ; then
119      echo "Can't run test 9 because UTF-8 support is not configured"      echo "Can't run test 12 because UTF-8 support is not configured"
120      exit 1      exit 1
121    fi    fi
122  fi  fi
# Line 102  if [ $ucp -eq 0 ] ; then Line 130  if [ $ucp -eq 0 ] ; then
130      echo "Can't run test 9 because Unicode property support is not configured"      echo "Can't run test 9 because Unicode property support is not configured"
131      exit 1      exit 1
132    fi    fi
133      if [ $do10 = yes ] ; then
134        echo "Can't run test 10 because Unicode property support is not configured"
135        exit 1
136      fi
137      if [ $do13 = yes ] ; then
138        echo "Can't run test 12 because Unicode property support is not configured"
139        exit 1
140      fi
141  fi  fi
142    
143  # If no specific tests were requested, select all that are relevant.  if [ $link_size -ne 2 ] ; then
144      if [ $do10 = yes ] ; then
145        echo "Can't run test 10 because the link size ($link_size) is not 2"
146        exit 1
147      fi
148    fi
149    
150  if [ $do1 = no -a $do2 = no -a $do3 = no -a $do4 = no -a \  if [ $jit -eq 0 ] ; then
151       $do5 = no -a $do6 = no -a $do7 = no -a $do8 = no -a \    if [ $do14 = "yes" ] ; then
152       $do9 = no ] ; then      echo "Can't run test 14 because JIT support is not configured"
153        exit 1
154      fi
155    else
156      if [ $do15 = "yes" ] ; then
157        echo "Can't run test 15 because JIT support is configured"
158        exit 1
159      fi
160    fi
161    
162    # If no specific tests were requested, select all. Those that are not
163    # relevant will be skipped.
164    
165    if [ $do1  = no -a $do2  = no -a $do3  = no -a $do4  = no -a \
166         $do5  = no -a $do6  = no -a $do7  = no -a $do8  = no -a \
167         $do9  = no -a $do10 = no -a $do11 = no -a $do12 = no -a \
168         $do13 = no -a $do14 = no -a $do15 = no ] ; then
169    do1=yes    do1=yes
170    do2=yes    do2=yes
171    do3=yes    do3=yes
172    if [ $utf8 -ne 0 ] ; then do4=yes; fi    do4=yes
173    if [ $utf8 -ne 0 ] ; then do5=yes; fi    do5=yes
174    if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do6=yes; fi    do6=yes
175    do7=yes    do7=yes
176    if [ $utf8 -ne 0 ] ; then do8=yes; fi    do8=yes
177    if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do9=yes; fi    do9=yes
178      do10=yes
179      do11=yes
180      do12=yes
181      do13=yes
182      do14=yes
183      do15=yes
184  fi  fi
185    
186  # Show which release  # Show which release
# Line 126  echo "" Line 189  echo ""
189  echo PCRE C library tests  echo PCRE C library tests
190  ./pcretest /dev/null  ./pcretest /dev/null
191    
192  # Primary test, Perl-compatible  # Primary test, compatible with JIT and all versions of Perl >= 5.8
193    
194  if [ $do1 = yes ] ; then  if [ $do1 = yes ] ; then
195    echo "Test 1: main functionality (Perl compatible)"    echo "Test 1: main functionality (Compatible with Perl >= 5.8)"
196    $valgrind ./pcretest -q $testdata/testinput1 testtry    for opt in "" "-s" $jitopt; do
197    if [ $? = 0 ] ; then      $valgrind ./pcretest -q $opt $testdata/testinput1 testtry
198      $cf $testdata/testoutput1 testtry      if [ $? = 0 ] ; then
199      if [ $? != 0 ] ; then exit 1; fi        $cf $testdata/testoutput1 testtry
200    else exit 1        if [ $? != 0 ] ; then exit 1; fi
201    fi      else exit 1
202    echo "OK"      fi
203        if [ "$opt" = "-s" ] ; then echo "  OK with study"
204        elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
205        else echo "  OK"
206        fi
207      done
208  fi  fi
209    
210  # PCRE tests that are not Perl-compatible - API & error tests, mostly  # PCRE tests that are not JIT or Perl-compatible: API, errors, internals
211    
212  if [ $do2 = yes ] ; then  if [ $do2 = yes ] ; then
213    if [ "$link_size" = "2" ] ; then    echo "Test 2: API, errors, internals, and non-Perl stuff"
214      echo "Test 2: API and error handling (not Perl compatible)"    for opt in "" "-s" $jitopt; do
215      $valgrind ./pcretest -q $testdata/testinput2 testtry      $valgrind ./pcretest -q $opt $testdata/testinput2 testtry
216      if [ $? = 0 ] ; then      if [ $? = 0 ] ; then
217        $cf $testdata/testoutput2 testtry        $cf $testdata/testoutput2 testtry
218        if [ $? != 0 ] ; then exit 1; fi        if [ $? != 0 ] ; then exit 1; fi
219      else exit 1      else
220          echo " "
221          echo "** Test 2 requires a lot of stack. If it has crashed with a"
222          echo "** segmentation fault, it may be that you do not have enough"
223          echo "** stack available by default. Please see the 'pcrestack' man"
224          echo "** page for a discussion of PCRE's stack usage."
225          echo " "
226          exit 1
227      fi      fi
228      echo "OK"      if [ "$opt" = "-s" ] ; then echo "  OK with study"
229    else      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
230      echo Test 2 skipped for link size other than 2 \($link_size\)      else echo "  OK"
231      echo " "      fi
232    fi    done
233  fi  fi
234    
235  # Locale-specific tests, provided that either the "fr_FR" or the "french"  # Locale-specific tests, provided that either the "fr_FR" or the "french"
# Line 182  if [ $do3 = yes ] ; then Line 257  if [ $do3 = yes ] ; then
257    
258    if [ "$locale" != "" ] ; then    if [ "$locale" != "" ] ; then
259      echo "Test 3: locale-specific features (using '$locale' locale)"      echo "Test 3: locale-specific features (using '$locale' locale)"
260      $valgrind ./pcretest -q $infile testtry      for opt in "" "-s" $jitopt; do
261      if [ $? = 0 ] ; then        $valgrind ./pcretest -q $opt $infile testtry
262        $cf $outfile testtry        if [ $? = 0 ] ; then
263        if [ $? != 0 ] ; then          $cf $outfile testtry
264          echo " "          if [ $? != 0 ] ; then
265          echo "Locale test did not run entirely successfully."            echo " "
266          echo "This usually means that there is a problem with the locale"            echo "Locale test did not run entirely successfully."
267          echo "settings rather than a bug in PCRE."            echo "This usually means that there is a problem with the locale"
268        else            echo "settings rather than a bug in PCRE."
269        echo "OK"            break;
270            else
271              if [ "$opt" = "-s" ] ; then echo "  OK with study"
272              elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
273              else echo "  OK"
274              fi
275            fi
276          else exit 1
277        fi        fi
278      else exit 1      done
     fi  
279    else    else
280      echo "Cannot test locale-specific features - neither the 'fr_FR' nor the"      echo "Cannot test locale-specific features - neither the 'fr_FR' nor the"
281      echo "'french' locale exists, or the \"locale\" command is not available"      echo "'french' locale exists, or the \"locale\" command is not available"
# Line 206  fi Line 287  fi
287  # Additional tests for UTF8 support  # Additional tests for UTF8 support
288    
289  if [ $do4 = yes ] ; then  if [ $do4 = yes ] ; then
290    echo "Test 4: UTF-8 support (Perl compatible)"    echo "Test 4: UTF-8 support (Compatible with Perl >= 5.8)"
291    $valgrind ./pcretest -q $testdata/testinput4 testtry    if [ $utf8 -eq 0 ] ; then
292    if [ $? = 0 ] ; then      echo "  Skipped because UTF-8 support is not available"
293      $cf $testdata/testoutput4 testtry    else
294      if [ $? != 0 ] ; then exit 1; fi      for opt in "" "-s" $jitopt; do
295    else exit 1        $valgrind ./pcretest -q $opt $testdata/testinput4 testtry
296          if [ $? = 0 ] ; then
297            $cf $testdata/testoutput4 testtry
298            if [ $? != 0 ] ; then exit 1; fi
299          else exit 1
300          fi
301          if [ "$opt" = "-s" ] ; then echo "  OK with study"
302          elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
303          else echo "  OK"
304          fi
305        done
306    fi    fi
   echo "OK"  
307  fi  fi
308    
309  if [ $do5 = yes ] ; then  if [ $do5 = yes ] ; then
310    if [ "$link_size" = "2" ] ; then    echo "Test 5: API, internals, and non-Perl stuff for UTF-8 support"
311      echo "Test 5: API and internals for UTF-8 support (not Perl compatible)"    if [ $utf8 -eq 0 ] ; then
312      $valgrind ./pcretest -q $testdata/testinput5 testtry      echo "  Skipped because UTF-8 support is not available"
313      else
314        for opt in "" "-s" $jitopt; do
315          $valgrind ./pcretest -q $opt $testdata/testinput5 testtry
316          if [ $? = 0 ] ; then
317            $cf $testdata/testoutput5 testtry
318            if [ $? != 0 ] ; then exit 1; fi
319          else exit 1
320          fi
321          if [ "$opt" = "-s" ] ; then echo "  OK with study"
322          elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
323          else echo "  OK"
324          fi
325        done
326      fi
327    fi
328    
329    if [ $do6 = yes ] ; then
330      echo "Test 6: Unicode property support (Compatible with Perl >= 5.10)"
331      if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
332        echo "  Skipped because Unicode property support is not available"
333      else
334        for opt in "" "-s" $jitopt; do
335          $valgrind ./pcretest -q $opt $testdata/testinput6 testtry
336          if [ $? = 0 ] ; then
337            $cf $testdata/testoutput6 testtry
338            if [ $? != 0 ] ; then exit 1; fi
339          else exit 1
340          fi
341          if [ "$opt" = "-s" ] ; then echo "  OK with study"
342          elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
343          else echo "  OK"
344          fi
345        done
346      fi
347    fi
348    
349    # Tests for DFA matching support
350    
351    if [ $do7 = yes ] ; then
352      echo "Test 7: DFA matching"
353      for opt in "" "-s"; do
354        $valgrind ./pcretest -q $opt -dfa $testdata/testinput7 testtry
355      if [ $? = 0 ] ; then      if [ $? = 0 ] ; then
356        $cf $testdata/testoutput5 testtry        $cf $testdata/testoutput7 testtry
357        if [ $? != 0 ] ; then exit 1; fi        if [ $? != 0 ] ; then exit 1; fi
358      else exit 1      else exit 1
359      fi      fi
360      echo "OK"      if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
361      done
362    fi
363    
364    if [ $do8 = yes ] ; then
365      echo "Test 8: DFA matching with UTF-8"
366      if [ $utf8 -eq 0 ] ; then
367        echo "  Skipped because UTF-8 support is not available"
368    else    else
369      echo Test 5 skipped for link size other than 2 \($link_size\)      for opt in "" "-s"; do
370      echo " "        $valgrind ./pcretest -q $opt -dfa $testdata/testinput8 testtry
371          if [ $? = 0 ] ; then
372            $cf $testdata/testoutput8 testtry
373            if [ $? != 0 ] ; then exit 1; fi
374          else exit 1
375          fi
376          if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
377        done
378    fi    fi
379  fi  fi
380    
381  if [ $do6 = yes ] ; then  if [ $do9 = yes ] ; then
382    if [ "$link_size" = "2" ] ; then    echo "Test 9: DFA matching with Unicode properties"
383      echo "Test 6: Unicode property support"    if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
384      $valgrind ./pcretest -q $testdata/testinput6 testtry      echo "  Skipped because Unicode property support is not available"
385      else
386        for opt in "" "-s"; do
387          $valgrind ./pcretest -q $opt -dfa $testdata/testinput9 testtry
388          if [ $? = 0 ] ; then
389            $cf $testdata/testoutput9 testtry
390            if [ $? != 0 ] ; then exit 1; fi
391          else exit 1
392          fi
393          if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
394        done
395      fi
396    fi
397    
398    # Test of internal offsets and code sizes. This test is run only when there
399    # is Unicode property support and the link size is 2. The actual tests are
400    # mostly the same as in some of the above, but in this test we inspect some
401    # offsets and sizes that require a known link size. This is a doublecheck for
402    # the maintainer, just in case something changes unexpectely.
403    
404    if [ $do10 = yes ] ; then
405      echo "Test 10: Internal offsets and code size tests"
406      if [ $link_size -ne 2 ] ; then
407        echo "  Skipped because link size is not 2"
408      elif [ $ucp -eq 0 ] ; then
409        echo "  Skipped because Unicode property support is not available"
410      else
411        for opt in "" "-s"; do
412          $valgrind ./pcretest -q $opt $testdata/testinput10 testtry
413          if [ $? = 0 ] ; then
414            $cf $testdata/testoutput10 testtry
415            if [ $? != 0 ] ; then exit 1; fi
416          else exit 1
417          fi
418          if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
419        done
420      fi
421    fi
422    
423    # Test of Perl >= 5.10 features without UTF8 support
424    
425    if [ $do11 = yes ] ; then
426      echo "Test 11: Features from Perl >= 5.10 without UTF8 support"
427      for opt in "" "-s" $jitopt; do
428        $valgrind ./pcretest -q $opt $testdata/testinput11 testtry
429      if [ $? = 0 ] ; then      if [ $? = 0 ] ; then
430        $cf $testdata/testoutput6 testtry        $cf $testdata/testoutput11 testtry
431        if [ $? != 0 ] ; then exit 1; fi        if [ $? != 0 ] ; then exit 1; fi
432      else exit 1      else exit 1
433      fi      fi
434      echo "OK"      if [ "$opt" = "-s" ] ; then echo "  OK with study"
435        elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
436        else echo "  OK"
437        fi
438      done
439    fi
440    
441    # Test of Perl >= 5.10 features with UTF8 support
442    
443    if [ $do12 = yes ] ; then
444      echo "Test 12: Features from Perl >= 5.10 with UTF8 support"
445      if [ $utf8 -eq 0 ] ; then
446        echo "  Skipped because UTF-8 support is not available"
447    else    else
448      echo Test 6 skipped for link size other than 2 \($link_size\)      for opt in "" "-s" $jitopt; do
449      echo " "        $valgrind ./pcretest -q $opt $testdata/testinput12 testtry
450          if [ $? = 0 ] ; then
451            $cf $testdata/testoutput12 testtry
452            if [ $? != 0 ] ; then exit 1; fi
453          else exit 1
454          fi
455          if [ "$opt" = "-s" ] ; then echo "  OK with study"
456          elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
457          else echo "  OK"
458          fi
459        done
460    fi    fi
461  fi  fi
462    
463  # Tests for DFA matching support  # Test non-Perl-compatible Unicode property support
464    
465  if [ $do7 = yes ] ; then  if [ $do13 = yes ] ; then
466    echo "Test 7: DFA matching"    echo "Test 13: API, internals, and non-Perl stuff for Unicode property support"
467    $valgrind ./pcretest -q -dfa $testdata/testinput7 testtry    if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
468    if [ $? = 0 ] ; then      echo "  Skipped because Unicode property support is not available"
469      $cf $testdata/testoutput7 testtry    else
470      if [ $? != 0 ] ; then exit 1; fi      for opt in "" "-s" $jitopt; do
471    else exit 1        $valgrind ./pcretest -q $opt $testdata/testinput13 testtry
472          if [ $? = 0 ] ; then
473            $cf $testdata/testoutput13 testtry
474            if [ $? != 0 ] ; then exit 1; fi
475          else exit 1
476          fi
477          if [ "$opt" = "-s" ] ; then echo "  OK with study"
478          elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
479          else echo "  OK"
480          fi
481        done
482    fi    fi
   echo "OK"  
483  fi  fi
484    
485  if [ $do8 = yes ] ; then  # Test JIT-specific features when JIT is available
486    echo "Test 8: DFA matching with UTF-8"  
487    $valgrind ./pcretest -q -dfa $testdata/testinput8 testtry  if [ $do14 = yes ] ; then
488    if [ $? = 0 ] ; then    echo "Test 14: JIT-specific features (JIT available and usable)"
489      $cf $testdata/testoutput8 testtry    if [ $jit -eq 0 ] ; then
490      if [ $? != 0 ] ; then exit 1; fi      echo "  Skipped because JIT is not available or not usable"
491    else exit 1    else
492        $valgrind ./pcretest -q $testdata/testinput14 testtry
493        if [ $? = 0 ] ; then
494          $cf $testdata/testoutput14 testtry
495          if [ $? != 0 ] ; then exit 1; fi
496        else exit 1
497        fi
498        echo "  OK"
499    fi    fi
   echo "OK"  
500  fi  fi
501    
502  if [ $do9 = yes ] ; then  # Test JIT-specific features when JIT is not available
503    echo "Test 9: DFA matching with Unicode properties"  
504    $valgrind ./pcretest -q -dfa $testdata/testinput9 testtry  if [ $do15 = yes ] ; then
505    if [ $? = 0 ] ; then    echo "Test 15: JIT-specific features (JIT not available or not usable)"
506      $cf $testdata/testoutput9 testtry    if [ $jit -ne 0 ] ; then
507      if [ $? != 0 ] ; then exit 1; fi      echo "  Skipped because JIT is available"
508    else exit 1    elif [ $jitnotcompiled -eq 0 ] ; then
509        echo "  Skipped because JIT does not support this architecture"
510      else
511        $valgrind ./pcretest -q $testdata/testinput15 testtry
512        if [ $? = 0 ] ; then
513          $cf $testdata/testoutput15 testtry
514          if [ $? != 0 ] ; then exit 1; fi
515        else exit 1
516        fi
517        echo "  OK"
518    fi    fi
   echo "OK"  
519  fi  fi
520    
521  # End  # End

Legend:
Removed from v.159  
changed lines
  Added in v.674

  ViewVC Help
Powered by ViewVC 1.1.5