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

Diff of /code/trunk/RunTest

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

revision 158 by ph10, Tue May 1 10:30:14 2007 UTC revision 671 by ph10, Tue Aug 23 11:17:49 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 'No Just-in-time compiler support' >/dev/null
52    jit=$?
53    if [ $jit -ne 0 ] ; then
54      jitopt=-s+
55    fi
56    
57  # Select which tests to run; for those that are explicitly requested, check  # Select which tests to run; for those that are explicitly requested, check
58  # that the necessary optional facilities are available.  # that the necessary optional facilities are available.
59    
# Line 37  do6=no Line 66  do6=no
66  do7=no  do7=no
67  do8=no  do8=no
68  do9=no  do9=no
69    do10=no
70    do11=no
71    do12=no
72    do13=no
73    do14=no
74    do15=no
75    
76  while [ $# -gt 0 ] ; do  while [ $# -gt 0 ] ; do
77    case $1 in    case $1 in
# Line 49  while [ $# -gt 0 ] ; do Line 84  while [ $# -gt 0 ] ; do
84      7) do7=yes;;      7) do7=yes;;
85      8) do8=yes;;      8) do8=yes;;
86      9) do9=yes;;      9) do9=yes;;
87      valgrind) valgrind="valgrind -q";;     10) do10=yes;;
88       11) do11=yes;;
89       12) do12=yes;;
90       13) do13=yes;;
91       14) do14=yes;;
92       15) do15=yes;;
93       valgrind) valgrind="valgrind -q --smc-check=all";;
94      *) echo "Unknown test number $1"; exit 1;;      *) echo "Unknown test number $1"; exit 1;;
95    esac    esac
96    shift    shift
97  done  done
98    
 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  
   
99  if [ $utf8 -eq 0 ] ; then  if [ $utf8 -eq 0 ] ; then
100    if [ $do4 = yes ] ; then    if [ $do4 = yes ] ; then
101      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 105  if [ $utf8 -eq 0 ] ; then
105      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"
106      exit 1      exit 1
107    fi    fi
   if [ $do6 = yes ] ; then  
     echo "Can't run test 6 because UTF-8 support is not configured"  
     exit 1  
   fi  
108    if [ $do8 = yes ] ; then    if [ $do8 = yes ] ; then
109      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"
110      exit 1      exit 1
111    fi    fi
112    if [ $do9 = yes ] ; then    if [ $do12 = yes ] ; then
113      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"
114      exit 1      exit 1
115    fi    fi
116  fi  fi
# Line 102  if [ $ucp -eq 0 ] ; then Line 124  if [ $ucp -eq 0 ] ; then
124      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"
125      exit 1      exit 1
126    fi    fi
127      if [ $do10 = yes ] ; then
128        echo "Can't run test 10 because Unicode property support is not configured"
129        exit 1
130      fi
131      if [ $do13 = yes ] ; then
132        echo "Can't run test 12 because Unicode property support is not configured"
133        exit 1
134      fi
135  fi  fi
136    
137  # If no specific tests were requested, select all that are relevant.  if [ $link_size -ne 2 ] ; then
138      if [ $do10 = yes ] ; then
139        echo "Can't run test 10 because the link size ($link_size) is not 2"
140        exit 1
141      fi
142    fi
143    
144  if [ $do1 = no -a $do2 = no -a $do3 = no -a $do4 = no -a \  if [ $jit -eq 0 ] ; then
145       $do5 = no -a $do6 = no -a $do7 = no -a $do8 = no -a \    if [ $do14 = "yes" ] ; then
146       $do9 = no ] ; then      echo "Can't run test 14 because JIT support is not configured"
147        exit 1
148      fi
149    else
150      if [ $do15 = "yes" ] ; then
151        echo "Can't run test 15 because JIT support is configured"
152        exit 1
153      fi
154    fi
155    
156    # If no specific tests were requested, select all. Those that are not
157    # relevant will be skipped.
158    
159    if [ $do1  = no -a $do2  = no -a $do3  = no -a $do4  = no -a \
160         $do5  = no -a $do6  = no -a $do7  = no -a $do8  = no -a \
161         $do9  = no -a $do10 = no -a $do11 = no -a $do12 = no -a \
162         $do13 = no -a $do14 = no -a $do15 = no ] ; then
163    do1=yes    do1=yes
164    do2=yes    do2=yes
165    do3=yes    do3=yes
166    if [ $utf8 -ne 0 ] ; then do4=yes; fi    do4=yes
167    if [ $utf8 -ne 0 ] ; then do5=yes; fi    do5=yes
168    if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do6=yes; fi    do6=yes
169    do7=yes    do7=yes
170    if [ $utf8 -ne 0 ] ; then do8=yes; fi    do8=yes
171    if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do9=yes; fi    do9=yes
172      do10=yes
173      do11=yes
174      do12=yes
175      do13=yes
176      do14=yes
177      do15=yes
178  fi  fi
179    
180  # Show which release  # Show which release
# Line 126  echo "" Line 183  echo ""
183  echo PCRE C library tests  echo PCRE C library tests
184  ./pcretest /dev/null  ./pcretest /dev/null
185    
186  # Primary test, Perl-compatible  # Primary test, compatible with JIT and all versions of Perl >= 5.8
187    
188  if [ $do1 = yes ] ; then  if [ $do1 = yes ] ; then
189    echo "Test 1: main functionality (Perl compatible)"    echo "Test 1: main functionality (Compatible with Perl >= 5.8)"
190    $valgrind ./pcretest -q $testdata/testinput1 testtry    for opt in "" "-s" $jitopt; do
191    if [ $? = 0 ] ; then      $valgrind ./pcretest -q $opt $testdata/testinput1 testtry
192      $cf $testdata/testoutput1 testtry      if [ $? = 0 ] ; then
193      if [ $? != 0 ] ; then exit 1; fi        $cf $testdata/testoutput1 testtry
194    else exit 1        if [ $? != 0 ] ; then exit 1; fi
195    fi      else exit 1
196    echo "OK"      fi
197        if [ "$opt" = "-s" ] ; then echo "  OK with study"
198        elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
199        else echo "  OK"
200        fi
201      done
202  fi  fi
203    
204  # PCRE tests that are not Perl-compatible - API & error tests, mostly  # PCRE tests that are not JIT or Perl-compatible: API, errors, internals
205    
206  if [ $do2 = yes ] ; then  if [ $do2 = yes ] ; then
207    if [ "$link_size" = "2" ] ; then    echo "Test 2: API, errors, internals, and non-Perl stuff"
208      echo "Test 2: API and error handling (not Perl compatible)"    for opt in "" "-s" $jitopt; do
209      $valgrind ./pcretest -q $testdata/testinput2 testtry      $valgrind ./pcretest -q $opt $testdata/testinput2 testtry
210      if [ $? = 0 ] ; then      if [ $? = 0 ] ; then
211        $cf $testdata/testoutput2 testtry        $cf $testdata/testoutput2 testtry
212        if [ $? != 0 ] ; then exit 1; fi        if [ $? != 0 ] ; then exit 1; fi
213      else exit 1      else
214          echo " "
215          echo "** Test 2 requires a lot of stack. If it has crashed with a"
216          echo "** segmentation fault, it may be that you do not have enough"
217          echo "** stack available by default. Please see the 'pcrestack' man"
218          echo "** page for a discussion of PCRE's stack usage."
219          echo " "
220          exit 1
221      fi      fi
222      echo "OK"      if [ "$opt" = "-s" ] ; then echo "  OK with study"
223    else      elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
224      echo Test 2 skipped for link size other than 2 \($link_size\)      else echo "  OK"
225      echo " "      fi
226    fi    done
227  fi  fi
228    
229  # 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 174  if [ $do3 = yes ] ; then Line 243  if [ $do3 = yes ] ; then
243        sed 's/fr_FR/french/' $testdata/testinput3 >test3input        sed 's/fr_FR/french/' $testdata/testinput3 >test3input
244        sed 's/fr_FR/french/' $testdata/testoutput3 >test3output        sed 's/fr_FR/french/' $testdata/testoutput3 >test3output
245        infile=test3input        infile=test3input
246        outfile=test3output        outfile=test3output
247      else      else
248        locale=        locale=
249      fi      fi
250    fi    fi
251    
252    if [ "$locale" != "" ] ; then    if [ "$locale" != "" ] ; then
253      echo "Test 3: locale-specific features (using '$locale' locale)"      echo "Test 3: locale-specific features (using '$locale' locale)"
254      $valgrind ./pcretest -q $infile testtry      for opt in "" "-s" $jitopt; do
255      if [ $? = 0 ] ; then        $valgrind ./pcretest -q $opt $infile testtry
256        $cf $outfile testtry        if [ $? = 0 ] ; then
257        if [ $? != 0 ] ; then          $cf $outfile testtry
258          echo " "          if [ $? != 0 ] ; then
259          echo "Locale test did not run entirely successfully."            echo " "
260          echo "This usually means that there is a problem with the locale"            echo "Locale test did not run entirely successfully."
261          echo "settings rather than a bug in PCRE."            echo "This usually means that there is a problem with the locale"
262        else            echo "settings rather than a bug in PCRE."
263        echo "OK"            break;
264            else
265              if [ "$opt" = "-s" ] ; then echo "  OK with study"
266              elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
267              else echo "  OK"
268              fi
269            fi
270          else exit 1
271        fi        fi
272      else exit 1      done
     fi  
273    else    else
274      echo "Cannot test locale-specific features - neither the 'fr_FR' nor the"      echo "Cannot test locale-specific features - neither the 'fr_FR' nor the"
275      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 281  fi
281  # Additional tests for UTF8 support  # Additional tests for UTF8 support
282    
283  if [ $do4 = yes ] ; then  if [ $do4 = yes ] ; then
284    echo "Test 4: UTF-8 support (Perl compatible)"    echo "Test 4: UTF-8 support (Compatible with Perl >= 5.8)"
285    $valgrind ./pcretest -q $testdata/testinput4 testtry    if [ $utf8 -eq 0 ] ; then
286    if [ $? = 0 ] ; then      echo "  Skipped because UTF-8 support is not available"
287      $cf $testdata/testoutput4 testtry    else
288      if [ $? != 0 ] ; then exit 1; fi      for opt in "" "-s" $jitopt; do
289    else exit 1        $valgrind ./pcretest -q $opt $testdata/testinput4 testtry
290    fi        if [ $? = 0 ] ; then
291    echo "OK"          $cf $testdata/testoutput4 testtry
292            if [ $? != 0 ] ; then exit 1; fi
293          else exit 1
294          fi
295          if [ "$opt" = "-s" ] ; then echo "  OK with study"
296          elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
297          else echo "  OK"
298          fi
299        done
300      fi
301  fi  fi
302    
303  if [ $do5 = yes ] ; then  if [ $do5 = yes ] ; then
304    if [ "$link_size" = "2" ] ; then    echo "Test 5: API, internals, and non-Perl stuff for UTF-8 support"
305      echo "Test 5: API and internals for UTF-8 support (not Perl compatible)"    if [ $utf8 -eq 0 ] ; then
306      $valgrind ./pcretest -q $testdata/testinput5 testtry      echo "  Skipped because UTF-8 support is not available"
307      if [ $? = 0 ] ; then    else
308        $cf $testdata/testoutput5 testtry      for opt in "" "-s" $jitopt; do
309        if [ $? != 0 ] ; then exit 1; fi        $valgrind ./pcretest -q $opt $testdata/testinput5 testtry
310      else exit 1        if [ $? = 0 ] ; then
311      fi          $cf $testdata/testoutput5 testtry
312      echo "OK"          if [ $? != 0 ] ; then exit 1; fi
313    else        else exit 1
314      echo Test 5 skipped for link size other than 2 \($link_size\)        fi
315      echo " "        if [ "$opt" = "-s" ] ; then echo "  OK with study"
316    fi        elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
317          else echo "  OK"
318          fi
319        done
320      fi
321  fi  fi
322    
323  if [ $do6 = yes ] ; then  if [ $do6 = yes ] ; then
324    if [ "$link_size" = "2" ] ; then    echo "Test 6: Unicode property support (Compatible with Perl >= 5.10)"
325      echo "Test 6: Unicode property support"    if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
326      $valgrind ./pcretest -q $testdata/testinput6 testtry      echo "  Skipped because Unicode property support is not available"
327      if [ $? = 0 ] ; then    else
328        $cf $testdata/testoutput6 testtry      for opt in "" "-s" $jitopt; do
329        if [ $? != 0 ] ; then exit 1; fi        $valgrind ./pcretest -q $opt $testdata/testinput6 testtry
330      else exit 1        if [ $? = 0 ] ; then
331      fi          $cf $testdata/testoutput6 testtry
332      echo "OK"          if [ $? != 0 ] ; then exit 1; fi
333    else        else exit 1
334      echo Test 6 skipped for link size other than 2 \($link_size\)        fi
335      echo " "        if [ "$opt" = "-s" ] ; then echo "  OK with study"
336    fi        elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
337          else echo "  OK"
338          fi
339        done
340      fi
341  fi  fi
342    
343  # Tests for DFA matching support  # Tests for DFA matching support
344    
345  if [ $do7 = yes ] ; then  if [ $do7 = yes ] ; then
346    echo "Test 7: DFA matching"    echo "Test 7: DFA matching"
347    $valgrind ./pcretest -q -dfa $testdata/testinput7 testtry    for opt in "" "-s"; do
348    if [ $? = 0 ] ; then      $valgrind ./pcretest -q $opt -dfa $testdata/testinput7 testtry
349      $cf $testdata/testoutput7 testtry      if [ $? = 0 ] ; then
350      if [ $? != 0 ] ; then exit 1; fi        $cf $testdata/testoutput7 testtry
351    else exit 1        if [ $? != 0 ] ; then exit 1; fi
352    fi      else exit 1
353    echo "OK"      fi
354        if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
355      done
356  fi  fi
357    
358  if [ $do8 = yes ] ; then  if [ $do8 = yes ] ; then
359    echo "Test 8: DFA matching with UTF-8"    echo "Test 8: DFA matching with UTF-8"
360    $valgrind ./pcretest -q -dfa $testdata/testinput8 testtry    if [ $utf8 -eq 0 ] ; then
361    if [ $? = 0 ] ; then      echo "  Skipped because UTF-8 support is not available"
362      $cf $testdata/testoutput8 testtry    else
363      if [ $? != 0 ] ; then exit 1; fi      for opt in "" "-s"; do
364    else exit 1        $valgrind ./pcretest -q $opt -dfa $testdata/testinput8 testtry
365    fi        if [ $? = 0 ] ; then
366    echo "OK"          $cf $testdata/testoutput8 testtry
367            if [ $? != 0 ] ; then exit 1; fi
368          else exit 1
369          fi
370          if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
371        done
372      fi
373  fi  fi
374    
375  if [ $do9 = yes ] ; then  if [ $do9 = yes ] ; then
376    echo "Test 9: DFA matching with Unicode properties"    echo "Test 9: DFA matching with Unicode properties"
377    $valgrind ./pcretest -q -dfa $testdata/testinput9 testtry    if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
378    if [ $? = 0 ] ; then      echo "  Skipped because Unicode property support is not available"
379      $cf $testdata/testoutput9 testtry    else
380      if [ $? != 0 ] ; then exit 1; fi      for opt in "" "-s"; do
381    else exit 1        $valgrind ./pcretest -q $opt -dfa $testdata/testinput9 testtry
382    fi        if [ $? = 0 ] ; then
383    echo "OK"          $cf $testdata/testoutput9 testtry
384            if [ $? != 0 ] ; then exit 1; fi
385          else exit 1
386          fi
387          if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
388        done
389      fi
390    fi
391    
392    # Test of internal offsets and code sizes. This test is run only when there
393    # is Unicode property support and the link size is 2. The actual tests are
394    # mostly the same as in some of the above, but in this test we inspect some
395    # offsets and sizes that require a known link size. This is a doublecheck for
396    # the maintainer, just in case something changes unexpectely.
397    
398    if [ $do10 = yes ] ; then
399      echo "Test 10: Internal offsets and code size tests"
400      if [ $link_size -ne 2 ] ; then
401        echo "  Skipped because link size is not 2"
402      elif [ $ucp -eq 0 ] ; then
403        echo "  Skipped because Unicode property support is not available"
404      else
405        for opt in "" "-s"; do
406          $valgrind ./pcretest -q $opt $testdata/testinput10 testtry
407          if [ $? = 0 ] ; then
408            $cf $testdata/testoutput10 testtry
409            if [ $? != 0 ] ; then exit 1; fi
410          else exit 1
411          fi
412          if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
413        done
414      fi
415    fi
416    
417    # Test of Perl >= 5.10 features without UTF8 support
418    
419    if [ $do11 = yes ] ; then
420      echo "Test 11: Features from Perl >= 5.10 without UTF8 support"
421      for opt in "" "-s" $jitopt; do
422        $valgrind ./pcretest -q $opt $testdata/testinput11 testtry
423        if [ $? = 0 ] ; then
424          $cf $testdata/testoutput11 testtry
425          if [ $? != 0 ] ; then exit 1; fi
426        else exit 1
427        fi
428        if [ "$opt" = "-s" ] ; then echo "  OK with study"
429        elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
430        else echo "  OK"
431        fi
432      done
433    fi
434    
435    # Test of Perl >= 5.10 features with UTF8 support
436    
437    if [ $do12 = yes ] ; then
438      echo "Test 12: Features from Perl >= 5.10 with UTF8 support"
439      if [ $utf8 -eq 0 ] ; then
440        echo "  Skipped because UTF-8 support is not available"
441      else
442        for opt in "" "-s" $jitopt; do
443          $valgrind ./pcretest -q $opt $testdata/testinput12 testtry
444          if [ $? = 0 ] ; then
445            $cf $testdata/testoutput12 testtry
446            if [ $? != 0 ] ; then exit 1; fi
447          else exit 1
448          fi
449          if [ "$opt" = "-s" ] ; then echo "  OK with study"
450          elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
451          else echo "  OK"
452          fi
453        done
454      fi
455    fi
456    
457    # Test non-Perl-compatible Unicode property support
458    
459    if [ $do13 = yes ] ; then
460      echo "Test 13: API, internals, and non-Perl stuff for Unicode property support"
461      if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
462        echo "  Skipped because Unicode property support is not available"
463      else
464        for opt in "" "-s" $jitopt; do
465          $valgrind ./pcretest -q $opt $testdata/testinput13 testtry
466          if [ $? = 0 ] ; then
467            $cf $testdata/testoutput13 testtry
468            if [ $? != 0 ] ; then exit 1; fi
469          else exit 1
470          fi
471          if [ "$opt" = "-s" ] ; then echo "  OK with study"
472          elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
473          else echo "  OK"
474          fi
475        done
476      fi
477    fi
478    
479    # Test JIT-specific features when JIT is available
480    
481    if [ $do14 = yes ] ; then
482      echo "Test 14: JIT-specific features (JIT available)"
483      if [ $jit -eq 0 ] ; then
484        echo "  Skipped because JIT is not available"
485      else
486        $valgrind ./pcretest -q $testdata/testinput14 testtry
487        if [ $? = 0 ] ; then
488          $cf $testdata/testoutput14 testtry
489          if [ $? != 0 ] ; then exit 1; fi
490        else exit 1
491        fi
492        echo "  OK"
493      fi
494    fi
495    
496    # Test JIT-specific features when JIT is not available
497    
498    if [ $do15 = yes ] ; then
499      echo "Test 15: JIT-specific features (JIT not available)"
500      if [ $jit -ne 0 ] ; then
501        echo "  Skipped because JIT is available"
502      else
503        $valgrind ./pcretest -q $testdata/testinput15 testtry
504        if [ $? = 0 ] ; then
505          $cf $testdata/testoutput15 testtry
506          if [ $? != 0 ] ; then exit 1; fi
507        else exit 1
508        fi
509        echo "  OK"
510      fi
511  fi  fi
512    
513  # End  # End

Legend:
Removed from v.158  
changed lines
  Added in v.671

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12