/[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 81 by nigel, Sat Feb 24 21:40:59 2007 UTC code/trunk/RunTest revision 371 by ph10, Mon Aug 25 18:28:05 2008 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 PCRE tests.
 # to that file.  
4    
5  # Run PCRE tests  valgrind=
6    
7  cf=diff  # Set up a suitable "diff" command for comparison. Some systems
8  if [ ! -d testdata ] ; then  # have a diff that lacks a -u option. Try to deal with this.
9    ln -s @top_srcdir@/testdata testdata  
10    if diff -u /dev/null /dev/null; then cf="diff -u"; else cf="diff"; fi
11    
12    # Find the test data
13    
14    testdata=testdata
15    if [ -n "$srcdir" -a -d "$srcdir" ] ; then
16      testdata="$srcdir/testdata"
17  fi  fi
 testdata=./testdata  
18    
19  # Select which tests to run; if no selection, run all  # Find which optional facilities are available
20    
21    case `./pcretest -C | ./pcregrep 'Internal link size'` in
22      *2) link_size=2;;
23      *3) link_size=3;;
24      *4) link_size=4;;
25       *) echo "Failed to find internal link size"; exit 1;;
26    esac
27    
28    ./pcretest -C | ./pcregrep 'No UTF-8 support' >/dev/null
29    utf8=$?
30    
31    ./pcretest -C | ./pcregrep 'No Unicode properties support' >/dev/null
32    ucp=$?
33    
34    # Select which tests to run; for those that are explicitly requested, check
35    # that the necessary optional facilities are available.
36    
37  do1=no  do1=no
38  do2=no  do2=no
# Line 22  do6=no Line 43  do6=no
43  do7=no  do7=no
44  do8=no  do8=no
45  do9=no  do9=no
46    do10=no
47    
48  while [ $# -gt 0 ] ; do  while [ $# -gt 0 ] ; do
49    case $1 in    case $1 in
# Line 34  while [ $# -gt 0 ] ; do Line 56  while [ $# -gt 0 ] ; do
56      7) do7=yes;;      7) do7=yes;;
57      8) do8=yes;;      8) do8=yes;;
58      9) do9=yes;;      9) do9=yes;;
59       10) do10=yes;;
60       valgrind) valgrind="valgrind -q";;
61      *) echo "Unknown test number $1"; exit 1;;      *) echo "Unknown test number $1"; exit 1;;
62    esac    esac
63    shift    shift
64  done  done
65    
66  if [ "@LINK_SIZE@" != "" -a "@LINK_SIZE@" != "-DLINK_SIZE=2" ] ; then  if [ $utf8 -eq 0 ] ; 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  
   
 if [ "@UTF8@" = "" ] ; then  
67    if [ $do4 = yes ] ; then    if [ $do4 = yes ] ; then
68      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"
69      exit 1      exit 1
# Line 63  if [ "@UTF8@" = "" ] ; then Line 72  if [ "@UTF8@" = "" ] ; then
72      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"
73      exit 1      exit 1
74    fi    fi
   if [ $do6 = yes ] ; then  
     echo "Can't run test 6 because UTF-8 support is not configured"  
     exit 1  
   fi  
75    if [ $do8 = yes ] ; then    if [ $do8 = yes ] ; then
76      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"
77      exit 1      exit 1
78    fi    fi
   if [ $do9 = yes ] ; then  
     echo "Can't run test 9 because UTF-8 support is not configured"  
     exit 1  
   fi  
79  fi  fi
80    
81  if [ "@UCP@" = "" ] ; then  if [ $ucp -eq 0 ] ; then
82    if [ $do6 = yes ] ; then    if [ $do6 = yes ] ; then
83      echo "Can't run test 6 because Unicode property support is not configured"      echo "Can't run test 6 because Unicode property support is not configured"
84      exit 1      exit 1
# Line 86  if [ "@UCP@" = "" ] ; then Line 87  if [ "@UCP@" = "" ] ; then
87      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"
88      exit 1      exit 1
89    fi    fi
90      if [ $do10 = yes ] ; then
91        echo "Can't run test 10 because Unicode property support is not configured"
92        exit 1
93      fi
94  fi  fi
95    
96    if [ $link_size -ne 2 ] ; then
97      if [ $do10 = yes ] ; then
98        echo "Can't run test 10 because the link size ($link_size) is not 2"
99        exit 1
100      fi
101    fi
102    
103    # If no specific tests were requested, select all that are relevant.
104    
105  if [ $do1 = no -a $do2 = no -a $do3 = no -a $do4 = no -a \  if [ $do1 = no -a $do2 = no -a $do3 = no -a $do4 = no -a \
106       $do5 = no -a $do6 = no -a $do7 = no -a $do8 = no -a \       $do5 = no -a $do6 = no -a $do7 = no -a $do8 = no -a \
107       $do9 = no ] ; then       $do9 = no -a $do10 = no ] ; then
108    do1=yes    do1=yes
109    do2=yes    do2=yes
110    do3=yes    do3=yes
111    if [ "@UTF8@" != "" ] ; then do4=yes; fi    if [ $utf8 -ne 0 ] ; then do4=yes; fi
112    if [ "@UTF8@" != "" ] ; then do5=yes; fi    if [ $utf8 -ne 0 ] ; then do5=yes; fi
113    if [ "@UTF8@" != "" -a "@UCP@" != "" ] ; then do6=yes; fi    if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do6=yes; fi
114    do7=yes    do7=yes
115    if [ "@UTF8@" != "" ] ; then do8=yes; fi    if [ $utf8 -ne 0 ] ; then do8=yes; fi
116    if [ "@UTF8@" != "" -a "@UCP@" != "" ] ; then do9=yes; fi    if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do9=yes; fi
117      if [ $link_size -eq 2 -a $ucp -ne 0 ] ; then do10=yes; fi
118  fi  fi
119    
120  # Show which release  # Show which release
121    
122    echo ""
123    echo PCRE C library tests
124  ./pcretest /dev/null  ./pcretest /dev/null
125    
126  # Primary test, Perl-compatible  # Primary test, Perl-compatible
127    
128  if [ $do1 = yes ] ; then  if [ $do1 = yes ] ; then
129    echo "Test 1: main functionality (Perl compatible)"    echo "Test 1: main functionality (Perl compatible)"
130    ./pcretest $testdata/testinput1 testtry    $valgrind ./pcretest -q $testdata/testinput1 testtry
131    if [ $? = 0 ] ; then    if [ $? = 0 ] ; then
132      $cf testtry $testdata/testoutput1      $cf $testdata/testoutput1 testtry
133      if [ $? != 0 ] ; then exit 1; fi      if [ $? != 0 ] ; then exit 1; fi
134    else exit 1    else exit 1
135    fi    fi
136    echo "OK"    echo "OK"
   echo " "  
137  fi  fi
138    
139  # PCRE tests that are not Perl-compatible - API & error tests, mostly  # PCRE tests that are not Perl-compatible - API & error tests, mostly
140    
141  if [ $do2 = yes ] ; then  if [ $do2 = yes ] ; then
142    if [ "@LINK_SIZE@" = "" -o "@LINK_SIZE@" = "-DLINK_SIZE=2" ] ; then    echo "Test 2: API and error handling (not Perl compatible)"
143      echo "Test 2: API and error handling (not Perl compatible)"    $valgrind ./pcretest -q $testdata/testinput2 testtry
144      ./pcretest -i $testdata/testinput2 testtry    if [ $? = 0 ] ; then
145      if [ $? = 0 ] ; then      $cf $testdata/testoutput2 testtry
146        $cf testtry $testdata/testoutput2      if [ $? != 0 ] ; then exit 1; fi
       if [ $? != 0 ] ; then exit 1; fi  
     else exit 1  
     fi  
     echo "OK"  
     echo " "  
147    else    else
148      echo Test 2 skipped for link size other than 2 \(@LINK_SIZE@\)      echo " "
149      echo " "      echo "** Test 2 requires a lot of stack. If it has crashed with a"
150        echo "** segmentation fault, it may be that you do not have enough"
151        echo "** stack available by default. Please see the 'pcrestack' man"
152        echo "** page for a discussion of PCRE's stack usage."
153        echo " "
154        exit 1
155    fi    fi
156      echo "OK"
157  fi  fi
158    
159  # Locale-specific tests, provided the "fr_FR" locale is available  # Locale-specific tests, provided that either the "fr_FR" or the "french"
160    # locale is available. The former is the Unix-like standard; the latter is
161    # for Windows.
162    
163  if [ $do3 = yes ] ; then  if [ $do3 = yes ] ; then
164    locale -a | grep '^fr_FR$' >/dev/null    locale -a | grep '^fr_FR$' >/dev/null
165    if [ $? -eq 0 ] ; then    if [ $? -eq 0 ] ; then
166      echo "Test 3: locale-specific features (using 'fr_FR' locale)"      locale=fr_FR
167      ./pcretest $testdata/testinput3 testtry      infile=$testdata/testinput3
168        outfile=$testdata/testoutput3
169      else
170        locale -a | grep '^french$' >/dev/null
171        if [ $? -eq 0 ] ; then
172          locale=french
173          sed 's/fr_FR/french/' $testdata/testinput3 >test3input
174          sed 's/fr_FR/french/' $testdata/testoutput3 >test3output
175          infile=test3input
176          outfile=test3output
177        else
178          locale=
179        fi
180      fi
181    
182      if [ "$locale" != "" ] ; then
183        echo "Test 3: locale-specific features (using '$locale' locale)"
184        $valgrind ./pcretest -q $infile testtry
185      if [ $? = 0 ] ; then      if [ $? = 0 ] ; then
186        $cf testtry $testdata/testoutput3        $cf $outfile testtry
187        if [ $? != 0 ] ; then        if [ $? != 0 ] ; then
188          echo " "          echo " "
189          echo "Locale test did not run entirely successfully."          echo "Locale test did not run entirely successfully."
# Line 156  if [ $do3 = yes ] ; then Line 192  if [ $do3 = yes ] ; then
192        else        else
193        echo "OK"        echo "OK"
194        fi        fi
       echo " "  
195      else exit 1      else exit 1
196      fi      fi
197    else    else
198      echo "Cannot test locale-specific features - 'fr_FR' locale not found,"      echo "Cannot test locale-specific features - neither the 'fr_FR' nor the"
199      echo "or the \"locale\" command is not available to check for it."      echo "'french' locale exists, or the \"locale\" command is not available"
200        echo "to check for them."
201      echo " "      echo " "
202    fi    fi
203  fi  fi
# Line 170  fi Line 206  fi
206    
207  if [ $do4 = yes ] ; then  if [ $do4 = yes ] ; then
208    echo "Test 4: UTF-8 support (Perl compatible)"    echo "Test 4: UTF-8 support (Perl compatible)"
209    ./pcretest $testdata/testinput4 testtry    $valgrind ./pcretest -q $testdata/testinput4 testtry
210    if [ $? = 0 ] ; then    if [ $? = 0 ] ; then
211      $cf testtry $testdata/testoutput4      $cf $testdata/testoutput4 testtry
212      if [ $? != 0 ] ; then exit 1; fi      if [ $? != 0 ] ; then exit 1; fi
213    else exit 1    else exit 1
214    fi    fi
215    echo "OK"    echo "OK"
   echo " "  
216  fi  fi
217    
218  if [ $do5 = yes ] ; then  if [ $do5 = yes ] ; then
219    if [ "@LINK_SIZE@" = "" -o "@LINK_SIZE@" = "-DLINK_SIZE=2" ] ; then    echo "Test 5: API and internals for UTF-8 support (not Perl compatible)"
220      echo "Test 5: API and internals for UTF-8 support (not Perl compatible)"    $valgrind ./pcretest -q $testdata/testinput5 testtry
221      ./pcretest $testdata/testinput5 testtry    if [ $? = 0 ] ; then
222      if [ $? = 0 ] ; then      $cf $testdata/testoutput5 testtry
223        $cf testtry $testdata/testoutput5      if [ $? != 0 ] ; then exit 1; fi
224        if [ $? != 0 ] ; then exit 1; fi    else exit 1
     else exit 1  
     fi  
     echo "OK"  
     echo " "  
   else  
     echo Test 5 skipped for link size other than 2 \(@LINK_SIZE@\)  
     echo " "  
225    fi    fi
226      echo "OK"
227  fi  fi
228    
229  if [ $do6 = yes ] ; then  if [ $do6 = yes ] ; then
230    if [ "@LINK_SIZE@" = "" -o "@LINK_SIZE@" = "-DLINK_SIZE=2" ] ; then    echo "Test 6: Unicode property support"
231      echo "Test 6: Unicode property support"    $valgrind ./pcretest -q $testdata/testinput6 testtry
232      ./pcretest $testdata/testinput6 testtry    if [ $? = 0 ] ; then
233      if [ $? = 0 ] ; then      $cf $testdata/testoutput6 testtry
234        $cf testtry $testdata/testoutput6      if [ $? != 0 ] ; then exit 1; fi
235        if [ $? != 0 ] ; then exit 1; fi    else exit 1
     else exit 1  
     fi  
     echo "OK"  
     echo " "  
   else  
     echo Test 6 skipped for link size other than 2 \(@LINK_SIZE@\)  
     echo " "  
236    fi    fi
237      echo "OK"
238  fi  fi
239    
240  # Tests for DFA matching support  # Tests for DFA matching support
241    
242  if [ $do7 = yes ] ; then  if [ $do7 = yes ] ; then
243    echo "Test 7: DFA matching"    echo "Test 7: DFA matching"
244    ./pcretest -dfa $testdata/testinput7 testtry    $valgrind ./pcretest -q -dfa $testdata/testinput7 testtry
245    if [ $? = 0 ] ; then    if [ $? = 0 ] ; then
246      $cf testtry $testdata/testoutput7      $cf $testdata/testoutput7 testtry
247      if [ $? != 0 ] ; then exit 1; fi      if [ $? != 0 ] ; then exit 1; fi
248    else exit 1    else exit 1
249    fi    fi
250    echo "OK"    echo "OK"
   echo " "  
251  fi  fi
252    
253  if [ $do8 = yes ] ; then  if [ $do8 = yes ] ; then
254    echo "Test 8: DFA matching with UTF-8"    echo "Test 8: DFA matching with UTF-8"
255    ./pcretest -dfa $testdata/testinput8 testtry    $valgrind ./pcretest -q -dfa $testdata/testinput8 testtry
256    if [ $? = 0 ] ; then    if [ $? = 0 ] ; then
257      $cf testtry $testdata/testoutput8      $cf $testdata/testoutput8 testtry
258      if [ $? != 0 ] ; then exit 1; fi      if [ $? != 0 ] ; then exit 1; fi
259    else exit 1    else exit 1
260    fi    fi
261    echo "OK"    echo "OK"
   echo " "  
262  fi  fi
263    
264  if [ $do9 = yes ] ; then  if [ $do9 = yes ] ; then
265    echo "Test 9: DFA matching with Unicode properties"    echo "Test 9: DFA matching with Unicode properties"
266    ./pcretest -dfa $testdata/testinput9 testtry    $valgrind ./pcretest -q -dfa $testdata/testinput9 testtry
267      if [ $? = 0 ] ; then
268        $cf $testdata/testoutput9 testtry
269        if [ $? != 0 ] ; then exit 1; fi
270      else exit 1
271      fi
272      echo "OK"
273    fi
274    
275    # Test of internal offsets and code sizes. This test is run only when there
276    # is Unicode property support and the link size is 2. The actual tests are
277    # mostly the same as in some of the above, but in this test we inspect some
278    # offsets and sizes that require a known link size. This is a doublecheck for
279    # the maintainer, just in case something changes unexpectely.
280    
281    if [ $do10 = yes ] ; then
282      echo "Test 10: Internal offsets and code size tests"
283      $valgrind ./pcretest -q $testdata/testinput10 testtry
284    if [ $? = 0 ] ; then    if [ $? = 0 ] ; then
285      $cf testtry $testdata/testoutput9      $cf $testdata/testoutput10 testtry
286      if [ $? != 0 ] ; then exit 1; fi      if [ $? != 0 ] ; then exit 1; fi
287    else exit 1    else exit 1
288    fi    fi
289    echo "OK"    echo "OK"
   echo " "  
290  fi  fi
291    
292  # End  # End

Legend:
Removed from v.81  
changed lines
  Added in v.371

  ViewVC Help
Powered by ViewVC 1.1.5