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

Diff of /code/trunk/RunTest

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

code/trunk/RunTest.in revision 53 by nigel, Sat Feb 24 21:39:42 2007 UTC code/trunk/RunTest revision 671 by ph10, Tue Aug 23 11:17:49 2011 UTC
# Line 1  Line 1 
1  #! /bin/sh  #! /bin/sh
2    
3  # This file is generated by configure from RunTest.in. Make any changes  # Run the PCRE tests using the pcretest program. The appropriate tests are
4  # to that file.  # selected, depending on which build-time options were used.
5    
6  # Run PCRE tests  # 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    
21    valgrind=
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
32      testdata="$srcdir/testdata"
33    fi
34    
35    # Find which optional facilities are available
36    
37  cf=diff  case `./pcretest -C | ./pcregrep 'Internal link size'` in
38  testdata=@top_srcdir@/testdata    *2) link_size=2;;
39      *3) link_size=3;;
40      *4) link_size=4;;
41       *) echo "Failed to find internal link size"; exit 1;;
42    esac
43    
44    ./pcretest -C | ./pcregrep 'No UTF-8 support' >/dev/null
45    utf8=$?
46    
47    ./pcretest -C | ./pcregrep 'No Unicode properties support' >/dev/null
48    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; if no selection, run all  # Select which tests to run; for those that are explicitly requested, check
58    # that the necessary optional facilities are available.
59    
60  do1=no  do1=no
61  do2=no  do2=no
# Line 16  do3=no Line 63  do3=no
63  do4=no  do4=no
64  do5=no  do5=no
65  do6=no  do6=no
66    do7=no
67    do8=no
68    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 23  while [ $# -gt 0 ] ; do Line 79  while [ $# -gt 0 ] ; do
79      2) do2=yes;;      2) do2=yes;;
80      3) do3=yes;;      3) do3=yes;;
81      4) do4=yes;;      4) do4=yes;;
82      5) do5=yes;;      5) do5=yes;;
83      6) do6=yes;;      6) do6=yes;;
84        7) do7=yes;;
85        8) do8=yes;;
86        9) do9=yes;;
87       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    
99  if [ "@UTF8@" = "" ] ; then  if [ $utf8 -eq 0 ] ; then
100      if [ $do4 = yes ] ; then
101        echo "Can't run test 4 because UTF-8 support is not configured"
102        exit 1
103      fi
104    if [ $do5 = yes ] ; then    if [ $do5 = yes ] ; then
105      echo "Can't run test 5 because UFT8 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
108      if [ $do8 = yes ] ; then
109        echo "Can't run test 8 because UTF-8 support is not configured"
110        exit 1
111      fi
112      if [ $do12 = yes ] ; then
113        echo "Can't run test 12 because UTF-8 support is not configured"
114        exit 1
115      fi
116    fi
117    
118    if [ $ucp -eq 0 ] ; then
119    if [ $do6 = yes ] ; then    if [ $do6 = yes ] ; then
120      echo "Can't run test 6 because UFT8 support is not configured"      echo "Can't run test 6 because Unicode property support is not configured"
121      exit 1      exit 1
122    fi    fi
123  fi    if [ $do9 = yes ] ; then
124        echo "Can't run test 9 because Unicode property support is not configured"
125        exit 1
126      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
136    
137    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 [ $jit -eq 0 ] ; then
145      if [ $do14 = "yes" ] ; then
146        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 [ $do1 = no -a $do2 = no -a $do3 = no -a $do4 = no -a\  # If no specific tests were requested, select all. Those that are not
157       $do5 = no -a $do6 = no ] ; then  # 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    do4=yes    do4=yes
167    if [ "@UTF8@" != "" ] ; then do5=yes; fi    do5=yes
168    if [ "@UTF8@" != "" ] ; then do6=yes; fi    do6=yes
169      do7=yes
170      do8=yes
171      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  # Primary test, Perl-compatible  # Show which release
181    
182    echo ""
183    echo PCRE C library tests
184    ./pcretest /dev/null
185    
186    # Primary test, compatible with JIT and all versions of Perl >= 5.8
187    
188  if [ $do1 = yes ] ; then  if [ $do1 = yes ] ; then
189    echo "Testing main functionality (Perl compatible)"    echo "Test 1: main functionality (Compatible with Perl >= 5.8)"
190    ./pcretest $testdata/testinput1 testtry    for opt in "" "-s" $jitopt; do
191    if [ $? = 0 ] ; then      $valgrind ./pcretest -q $opt $testdata/testinput1 testtry
192      $cf testtry $testdata/testoutput1      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        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    echo "Testing API and error handling (not Perl compatible)"    echo "Test 2: API, errors, internals, and non-Perl stuff"
208    ./pcretest -i $testdata/testinput2 testtry    for opt in "" "-s" $jitopt; do
209    if [ $? = 0 ] ; then      $valgrind ./pcretest -q $opt $testdata/testinput2 testtry
210      $cf testtry $testdata/testoutput2      if [ $? = 0 ] ; then
211      if [ $? != 0 ] ; then exit 1; fi        $cf $testdata/testoutput2 testtry
212    else exit 1        if [ $? != 0 ] ; then exit 1; fi
213    fi      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
222        if [ "$opt" = "-s" ] ; then echo "  OK with study"
223        elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
224        else echo "  OK"
225        fi
226      done
227  fi  fi
228    
229  # Additional Perl-compatible tests for Perl 5.005's new features  # Locale-specific tests, provided that either the "fr_FR" or the "french"
230    # locale is available. The former is the Unix-like standard; the latter is
231    # for Windows.
232    
233  if [ $do3 = yes ] ; then  if [ $do3 = yes ] ; then
234    echo "Testing Perl 5.005 features (Perl 5.005 compatible)"    locale -a | grep '^fr_FR$' >/dev/null
235    ./pcretest $testdata/testinput3 testtry    if [ $? -eq 0 ] ; then
236    if [ $? = 0 ] ; then      locale=fr_FR
237      $cf testtry $testdata/testoutput3      infile=$testdata/testinput3
238      if [ $? != 0 ] ; then exit 1; fi      outfile=$testdata/testoutput3
239    else exit 1    else
240        locale -a | grep '^french$' >/dev/null
241        if [ $? -eq 0 ] ; then
242          locale=french
243          sed 's/fr_FR/french/' $testdata/testinput3 >test3input
244          sed 's/fr_FR/french/' $testdata/testoutput3 >test3output
245          infile=test3input
246          outfile=test3output
247        else
248          locale=
249        fi
250    fi    fi
 fi  
251    
252  if [ $do1 = yes -a $do2 = yes -a $do3 = yes ] ; then    if [ "$locale" != "" ] ; then
253    echo " "      echo "Test 3: locale-specific features (using '$locale' locale)"
254    echo "The three main tests all ran OK"      for opt in "" "-s" $jitopt; do
255    echo " "        $valgrind ./pcretest -q $opt $infile testtry
256          if [ $? = 0 ] ; then
257            $cf $outfile testtry
258            if [ $? != 0 ] ; then
259              echo " "
260              echo "Locale test did not run entirely successfully."
261              echo "This usually means that there is a problem with the locale"
262              echo "settings rather than a bug in PCRE."
263              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
272        done
273      else
274        echo "Cannot test locale-specific features - neither the 'fr_FR' nor the"
275        echo "'french' locale exists, or the \"locale\" command is not available"
276        echo "to check for them."
277        echo " "
278      fi
279  fi  fi
280    
281  # Locale-specific tests, provided the "fr" locale is available  # Additional tests for UTF8 support
282    
283  if [ $do4 = yes ] ; then  if [ $do4 = yes ] ; then
284    locale -a | grep '^fr$' >/dev/null    echo "Test 4: UTF-8 support (Compatible with Perl >= 5.8)"
285    if [ $? -eq 0 ] ; then    if [ $utf8 -eq 0 ] ; then
286      echo "Testing locale-specific features (using 'fr' locale)"      echo "  Skipped because UTF-8 support is not available"
287      ./pcretest $testdata/testinput4 testtry    else
288        for opt in "" "-s" $jitopt; do
289          $valgrind ./pcretest -q $opt $testdata/testinput4 testtry
290          if [ $? = 0 ] ; then
291            $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
302    
303    if [ $do5 = yes ] ; then
304      echo "Test 5: API, internals, and non-Perl stuff for UTF-8 support"
305      if [ $utf8 -eq 0 ] ; then
306        echo "  Skipped because UTF-8 support is not available"
307      else
308        for opt in "" "-s" $jitopt; do
309          $valgrind ./pcretest -q $opt $testdata/testinput5 testtry
310          if [ $? = 0 ] ; then
311            $cf $testdata/testoutput5 testtry
312            if [ $? != 0 ] ; then exit 1; fi
313          else exit 1
314          fi
315          if [ "$opt" = "-s" ] ; then echo "  OK with study"
316          elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
317          else echo "  OK"
318          fi
319        done
320      fi
321    fi
322    
323    if [ $do6 = yes ] ; then
324      echo "Test 6: Unicode property support (Compatible with Perl >= 5.10)"
325      if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
326        echo "  Skipped because Unicode property support is not available"
327      else
328        for opt in "" "-s" $jitopt; do
329          $valgrind ./pcretest -q $opt $testdata/testinput6 testtry
330          if [ $? = 0 ] ; then
331            $cf $testdata/testoutput6 testtry
332            if [ $? != 0 ] ; then exit 1; fi
333          else exit 1
334          fi
335          if [ "$opt" = "-s" ] ; then echo "  OK with study"
336          elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
337          else echo "  OK"
338          fi
339        done
340      fi
341    fi
342    
343    # Tests for DFA matching support
344    
345    if [ $do7 = yes ] ; then
346      echo "Test 7: DFA matching"
347      for opt in "" "-s"; do
348        $valgrind ./pcretest -q $opt -dfa $testdata/testinput7 testtry
349      if [ $? = 0 ] ; then      if [ $? = 0 ] ; then
350        $cf testtry $testdata/testoutput4        $cf $testdata/testoutput7 testtry
351        if [ $? != 0 ] ; then        if [ $? != 0 ] ; then exit 1; fi
         echo " "  
         echo "Locale test did not run entirely successfully."  
         echo "This usually means that there is a problem with the locale"  
         echo "settings rather than a bug in PCRE."  
       else  
       echo "Locale test ran OK"  
       fi  
       echo " "  
352      else exit 1      else exit 1
353      fi      fi
354    else      if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
355      echo "Cannot test locale-specific features - 'fr' locale not found,"    done
     echo "or the \"locale\" command is not available to check for it."  
     echo " "  
   fi  
356  fi  fi
357    
358  # Additional tests for UTF8 support  if [ $do8 = yes ] ; then
359      echo "Test 8: DFA matching with UTF-8"
360      if [ $utf8 -eq 0 ] ; then
361        echo "  Skipped because UTF-8 support is not available"
362      else
363        for opt in "" "-s"; do
364          $valgrind ./pcretest -q $opt -dfa $testdata/testinput8 testtry
365          if [ $? = 0 ] ; then
366            $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
374    
375  if [ $do5 = yes ] ; then  if [ $do9 = yes ] ; then
376    echo "Testing experimental, incomplete UTF8 support (Perl compatible)"    echo "Test 9: DFA matching with Unicode properties"
377    ./pcretest $testdata/testinput5 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 testtry $testdata/testoutput5    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 "UTF8 test ran OK"          $cf $testdata/testoutput9 testtry
384    echo " "          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  fi
391    
392  if [ $do6 = yes ] ; then  # Test of internal offsets and code sizes. This test is run only when there
393    echo "Testing API and internals for UTF8 support (not Perl compatible)"  # is Unicode property support and the link size is 2. The actual tests are
394    ./pcretest $testdata/testinput6 testtry  # mostly the same as in some of the above, but in this test we inspect some
395    if [ $? = 0 ] ; then  # offsets and sizes that require a known link size. This is a doublecheck for
396      $cf testtry $testdata/testoutput6  # the maintainer, just in case something changes unexpectely.
397      if [ $? != 0 ] ; then exit 1; fi  
398    else exit 1  if [ $do10 = yes ] ; then
399    fi    echo "Test 10: Internal offsets and code size tests"
400    echo "UTF8 internals test ran OK"    if [ $link_size -ne 2 ] ; then
401    echo " "      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.53  
changed lines
  Added in v.671

  ViewVC Help
Powered by ViewVC 1.1.5