Annotation of embedaddon/pcre/RunTest, revision 1.1.1.1

1.1       misho       1: #! /bin/sh
                      2: 
                      3: # 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: 
                     21: # The arguments for this script can be individual test numbers, or the word
                     22: # "valgrind", or "sim" followed by an argument to run cross-compiled
                     23: # executables under a simulator, for example:
                     24: #
                     25: # RunTest 3 sim "qemu-arm -s 8388608"
                     26: 
                     27: valgrind=
                     28: sim=
                     29: 
                     30: # Select which tests to run; for those that are explicitly requested, check
                     31: # that the necessary optional facilities are available.
                     32: 
                     33: do1=no
                     34: do2=no
                     35: do3=no
                     36: do4=no
                     37: do5=no
                     38: do6=no
                     39: do7=no
                     40: do8=no
                     41: do9=no
                     42: do10=no
                     43: do11=no
                     44: do12=no
                     45: do13=no
                     46: do14=no
                     47: do15=no
                     48: 
                     49: while [ $# -gt 0 ] ; do
                     50:   case $1 in
                     51:     1) do1=yes;;
                     52:     2) do2=yes;;
                     53:     3) do3=yes;;
                     54:     4) do4=yes;;
                     55:     5) do5=yes;;
                     56:     6) do6=yes;;
                     57:     7) do7=yes;;
                     58:     8) do8=yes;;
                     59:     9) do9=yes;;
                     60:    10) do10=yes;;
                     61:    11) do11=yes;;
                     62:    12) do12=yes;;
                     63:    13) do13=yes;;
                     64:    14) do14=yes;;
                     65:    15) do15=yes;;
                     66:    valgrind) valgrind="valgrind -q --smc-check=all";;
                     67:    sim) shift; sim=$1;;
                     68:     *) echo "Unknown test number $1"; exit 1;;
                     69:   esac
                     70:   shift
                     71: done
                     72: 
                     73: # Set up a suitable "diff" command for comparison. Some systems
                     74: # have a diff that lacks a -u option. Try to deal with this.
                     75: 
                     76: if diff -u /dev/null /dev/null; then cf="diff -u"; else cf="diff"; fi
                     77: 
                     78: # Find the test data
                     79: 
                     80: if [ -n "$srcdir" -a -d "$srcdir" ] ; then
                     81:   testdata="$srcdir/testdata"
                     82: elif [ -d "./testdata" ] ; then
                     83:   testdata=./testdata
                     84: elif [ -d "../testdata" ] ; then
                     85:   testdata=../testdata
                     86: else
                     87:   echo "Cannot find the testdata directory"
                     88:   exit 1
                     89: fi
                     90: 
                     91: # Find which optional facilities are available. In some Windows environments
                     92: # the output of pcretest -C has CRLF at the end of each line, but the shell
                     93: # strips only linefeeds from the output of a `backquoted` command. Hence the
                     94: # alternative patterns.
                     95: 
                     96: case `$sim ./pcretest -C | $sim ./pcregrep 'Internal link size'` in
                     97:   *2|*2[[:space:]]) link_size=2;;
                     98:   *3|*3[[:space:]]) link_size=3;;
                     99:   *4|*4[[:space:]]) link_size=4;;
                    100:    *) echo "Failed to find internal link size"; exit 1;;
                    101: esac
                    102: 
                    103: $sim ./pcretest -C | $sim ./pcregrep 'No UTF-8 support' >/dev/null
                    104: utf8=$?
                    105: 
                    106: $sim ./pcretest -C | $sim ./pcregrep 'No Unicode properties support' >/dev/null
                    107: ucp=$?
                    108: 
                    109: jitopt=
                    110: $sim ./pcretest -C | $sim ./pcregrep 'No just-in-time compiler support' \
                    111:   >/dev/null
                    112: jit=$?
                    113: if [ $jit -ne 0 ] ; then
                    114:   jitopt=-s+
                    115: fi
                    116: 
                    117: if [ $utf8 -eq 0 ] ; then
                    118:   if [ $do4 = yes ] ; then
                    119:     echo "Can't run test 4 because UTF-8 support is not configured"
                    120:     exit 1
                    121:   fi
                    122:   if [ $do5 = yes ] ; then
                    123:     echo "Can't run test 5 because UTF-8 support is not configured"
                    124:     exit 1
                    125:   fi
                    126:   if [ $do8 = yes ] ; then
                    127:     echo "Can't run test 8 because UTF-8 support is not configured"
                    128:     exit 1
                    129:   fi
                    130:   if [ $do12 = yes ] ; then
                    131:     echo "Can't run test 12 because UTF-8 support is not configured"
                    132:     exit 1
                    133:   fi
                    134: fi
                    135: 
                    136: if [ $ucp -eq 0 ] ; then
                    137:   if [ $do6 = yes ] ; then
                    138:     echo "Can't run test 6 because Unicode property support is not configured"
                    139:     exit 1
                    140:   fi
                    141:   if [ $do9 = yes ] ; then
                    142:     echo "Can't run test 9 because Unicode property support is not configured"
                    143:     exit 1
                    144:   fi
                    145:   if [ $do10 = yes ] ; then
                    146:     echo "Can't run test 10 because Unicode property support is not configured"
                    147:     exit 1
                    148:   fi
                    149:   if [ $do13 = yes ] ; then
                    150:     echo "Can't run test 12 because Unicode property support is not configured"
                    151:     exit 1
                    152:   fi
                    153: fi
                    154: 
                    155: if [ $link_size -ne 2 ] ; then
                    156:   if [ $do10 = yes ] ; then
                    157:     echo "Can't run test 10 because the link size ($link_size) is not 2"
                    158:     exit 1
                    159:   fi
                    160: fi
                    161: 
                    162: if [ $jit -eq 0 ] ; then
                    163:   if [ $do14 = "yes" ] ; then
                    164:     echo "Can't run test 14 because JIT support is not configured"
                    165:     exit 1
                    166:   fi
                    167: else
                    168:   if [ $do15 = "yes" ] ; then
                    169:     echo "Can't run test 15 because JIT support is configured"
                    170:     exit 1
                    171:   fi
                    172: fi
                    173: 
                    174: # If no specific tests were requested, select all. Those that are not
                    175: # relevant will be skipped.
                    176: 
                    177: if [ $do1  = no -a $do2  = no -a $do3  = no -a $do4  = no -a \
                    178:      $do5  = no -a $do6  = no -a $do7  = no -a $do8  = no -a \
                    179:      $do9  = no -a $do10 = no -a $do11 = no -a $do12 = no -a \
                    180:      $do13 = no -a $do14 = no -a $do15 = no ] ; then
                    181:   do1=yes
                    182:   do2=yes
                    183:   do3=yes
                    184:   do4=yes
                    185:   do5=yes
                    186:   do6=yes
                    187:   do7=yes
                    188:   do8=yes
                    189:   do9=yes
                    190:   do10=yes
                    191:   do11=yes
                    192:   do12=yes
                    193:   do13=yes
                    194:   do14=yes
                    195:   do15=yes
                    196: fi
                    197: 
                    198: # Show which release and which test data
                    199: 
                    200: echo ""
                    201: echo PCRE C library tests using test data from $testdata
                    202: $sim ./pcretest /dev/null
                    203: 
                    204: # Primary test, compatible with JIT and all versions of Perl >= 5.8
                    205: 
                    206: if [ $do1 = yes ] ; then
                    207:   echo "Test 1: main functionality (Compatible with Perl >= 5.8)"
                    208:   for opt in "" "-s" $jitopt; do
                    209:     $sim $valgrind ./pcretest -q $opt $testdata/testinput1 testtry
                    210:     if [ $? = 0 ] ; then
                    211:       $cf $testdata/testoutput1 testtry
                    212:       if [ $? != 0 ] ; then exit 1; fi
                    213:     else exit 1
                    214:     fi
                    215:     if [ "$opt" = "-s" ] ; then echo "  OK with study"
                    216:     elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
                    217:     else echo "  OK"
                    218:     fi
                    219:   done
                    220: fi
                    221: 
                    222: # PCRE tests that are not JIT or Perl-compatible: API, errors, internals
                    223: 
                    224: if [ $do2 = yes ] ; then
                    225:   echo "Test 2: API, errors, internals, and non-Perl stuff (not UTF-8)"
                    226:   for opt in "" "-s" $jitopt; do
                    227:     $sim $valgrind ./pcretest -q $opt $testdata/testinput2 testtry
                    228:     if [ $? = 0 ] ; then
                    229:       $cf $testdata/testoutput2 testtry
                    230:       if [ $? != 0 ] ; then exit 1; fi
                    231:     else
                    232:       echo " "
                    233:       echo "** Test 2 requires a lot of stack. If it has crashed with a"
                    234:       echo "** segmentation fault, it may be that you do not have enough"
                    235:       echo "** stack available by default. Please see the 'pcrestack' man"
                    236:       echo "** page for a discussion of PCRE's stack usage."
                    237:       echo " "
                    238:       exit 1
                    239:     fi
                    240:     if [ "$opt" = "-s" ] ; then echo "  OK with study"
                    241:     elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
                    242:     else echo "  OK"
                    243:     fi
                    244:   done
                    245: fi
                    246: 
                    247: # Locale-specific tests, provided that either the "fr_FR" or the "french"
                    248: # locale is available. The former is the Unix-like standard; the latter is
                    249: # for Windows. Another possibility is "fr", which needs to be run against
                    250: # the Windows-specific input and output files.
                    251: 
                    252: if [ $do3 = yes ] ; then
                    253:   locale -a | grep '^fr_FR$' >/dev/null
                    254:   if [ $? -eq 0 ] ; then
                    255:     locale=fr_FR
                    256:     infile=$testdata/testinput3
                    257:     outfile=$testdata/testoutput3
                    258:   else
                    259:     infile=test3input
                    260:     outfile=test3output
                    261:     locale -a | grep '^french$' >/dev/null
                    262:     if [ $? -eq 0 ] ; then
                    263:       locale=french
                    264:       sed 's/fr_FR/french/' $testdata/testinput3 >test3input
                    265:       sed 's/fr_FR/french/' $testdata/testoutput3 >test3output
                    266:     else
                    267:       locale -a | grep '^fr$' >/dev/null
                    268:       if [ $? -eq 0 ] ; then
                    269:         locale=fr
                    270:         sed 's/fr_FR/fr/' $testdata/wintestinput3 >test3input
                    271:         sed 's/fr_FR/fr/' $testdata/wintestoutput3 >test3output
                    272:       else
                    273:         locale=
                    274:       fi
                    275:     fi
                    276:   fi
                    277: 
                    278:   if [ "$locale" != "" ] ; then
                    279:     echo "Test 3: locale-specific features (using '$locale' locale)"
                    280:     for opt in "" "-s" $jitopt; do
                    281:       $sim $valgrind ./pcretest -q $opt $infile testtry
                    282:       if [ $? = 0 ] ; then
                    283:         $cf $outfile testtry
                    284:         if [ $? != 0 ] ; then
                    285:           echo " "
                    286:           echo "Locale test did not run entirely successfully."
                    287:           echo "This usually means that there is a problem with the locale"
                    288:           echo "settings rather than a bug in PCRE."
                    289:           break;
                    290:         else
                    291:           if [ "$opt" = "-s" ] ; then echo "  OK with study"
                    292:           elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
                    293:           else echo "  OK"
                    294:           fi
                    295:         fi
                    296:       else exit 1
                    297:       fi
                    298:     done
                    299:   else
                    300:     echo "Cannot test locale-specific features - none of the 'fr_FR', 'fr' or"
                    301:     echo "'french' locales exist, or the \"locale\" command is not available"
                    302:     echo "to check for them."
                    303:     echo " "
                    304:   fi
                    305: fi
                    306: 
                    307: # Additional tests for UTF8 support
                    308: 
                    309: if [ $do4 = yes ] ; then
                    310:   echo "Test 4: UTF-8 support (Compatible with Perl >= 5.8)"
                    311:   if [ $utf8 -eq 0 ] ; then
                    312:     echo "  Skipped because UTF-8 support is not available"
                    313:   else
                    314:     for opt in "" "-s" $jitopt; do
                    315:       $sim $valgrind ./pcretest -q $opt $testdata/testinput4 testtry
                    316:       if [ $? = 0 ] ; then
                    317:         $cf $testdata/testoutput4 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 [ $do5 = yes ] ; then
                    330:   echo "Test 5: API, internals, and non-Perl stuff for UTF-8 support"
                    331:   if [ $utf8 -eq 0 ] ; then
                    332:     echo "  Skipped because UTF-8 support is not available"
                    333:   else
                    334:     for opt in "" "-s" $jitopt; do
                    335:       $sim $valgrind ./pcretest -q $opt $testdata/testinput5 testtry
                    336:       if [ $? = 0 ] ; then
                    337:         $cf $testdata/testoutput5 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: if [ $do6 = yes ] ; then
                    350:   echo "Test 6: Unicode property support (Compatible with Perl >= 5.10)"
                    351:   if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
                    352:     echo "  Skipped because Unicode property support is not available"
                    353:   else
                    354:     for opt in "" "-s" $jitopt; do
                    355:       $sim $valgrind ./pcretest -q $opt $testdata/testinput6 testtry
                    356:       if [ $? = 0 ] ; then
                    357:         $cf $testdata/testoutput6 testtry
                    358:         if [ $? != 0 ] ; then exit 1; fi
                    359:       else exit 1
                    360:       fi
                    361:       if [ "$opt" = "-s" ] ; then echo "  OK with study"
                    362:       elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
                    363:       else echo "  OK"
                    364:       fi
                    365:     done
                    366:   fi
                    367: fi
                    368: 
                    369: # Tests for DFA matching support
                    370: 
                    371: if [ $do7 = yes ] ; then
                    372:   echo "Test 7: DFA matching"
                    373:   for opt in "" "-s"; do
                    374:     $sim $valgrind ./pcretest -q $opt -dfa $testdata/testinput7 testtry
                    375:     if [ $? = 0 ] ; then
                    376:       $cf $testdata/testoutput7 testtry
                    377:       if [ $? != 0 ] ; then exit 1; fi
                    378:     else exit 1
                    379:     fi
                    380:     if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
                    381:   done
                    382: fi
                    383: 
                    384: if [ $do8 = yes ] ; then
                    385:   echo "Test 8: DFA matching with UTF-8"
                    386:   if [ $utf8 -eq 0 ] ; then
                    387:     echo "  Skipped because UTF-8 support is not available"
                    388:   else
                    389:     for opt in "" "-s"; do
                    390:       $sim $valgrind ./pcretest -q $opt -dfa $testdata/testinput8 testtry
                    391:       if [ $? = 0 ] ; then
                    392:         $cf $testdata/testoutput8 testtry
                    393:         if [ $? != 0 ] ; then exit 1; fi
                    394:       else exit 1
                    395:       fi
                    396:       if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
                    397:     done
                    398:   fi
                    399: fi
                    400: 
                    401: if [ $do9 = yes ] ; then
                    402:   echo "Test 9: DFA matching with Unicode properties"
                    403:   if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
                    404:     echo "  Skipped because Unicode property support is not available"
                    405:   else
                    406:     for opt in "" "-s"; do
                    407:       $sim $valgrind ./pcretest -q $opt -dfa $testdata/testinput9 testtry
                    408:       if [ $? = 0 ] ; then
                    409:         $cf $testdata/testoutput9 testtry
                    410:         if [ $? != 0 ] ; then exit 1; fi
                    411:       else exit 1
                    412:       fi
                    413:       if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
                    414:     done
                    415:   fi
                    416: fi
                    417: 
                    418: # Test of internal offsets and code sizes. This test is run only when there
                    419: # is Unicode property support and the link size is 2. The actual tests are
                    420: # mostly the same as in some of the above, but in this test we inspect some
                    421: # offsets and sizes that require a known link size. This is a doublecheck for
                    422: # the maintainer, just in case something changes unexpectely.
                    423: 
                    424: if [ $do10 = yes ] ; then
                    425:   echo "Test 10: Internal offsets and code size tests"
                    426:   if [ $link_size -ne 2 ] ; then
                    427:     echo "  Skipped because link size is not 2"
                    428:   elif [ $ucp -eq 0 ] ; then
                    429:     echo "  Skipped because Unicode property support is not available"
                    430:   else
                    431:     for opt in "" "-s"; do
                    432:       $sim $valgrind ./pcretest -q $opt $testdata/testinput10 testtry
                    433:       if [ $? = 0 ] ; then
                    434:         $cf $testdata/testoutput10 testtry
                    435:         if [ $? != 0 ] ; then exit 1; fi
                    436:       else exit 1
                    437:       fi
                    438:       if [ "$opt" = "-s" ] ; then echo "  OK with study" ; else echo "  OK"; fi
                    439:     done
                    440:   fi
                    441: fi
                    442: 
                    443: # Test of Perl >= 5.10 features without UTF8 support
                    444: 
                    445: if [ $do11 = yes ] ; then
                    446:   echo "Test 11: Features from Perl >= 5.10 without UTF8 support"
                    447:   for opt in "" "-s" $jitopt; do
                    448:     $sim $valgrind ./pcretest -q $opt $testdata/testinput11 testtry
                    449:     if [ $? = 0 ] ; then
                    450:       $cf $testdata/testoutput11 testtry
                    451:       if [ $? != 0 ] ; then exit 1; fi
                    452:     else exit 1
                    453:     fi
                    454:     if [ "$opt" = "-s" ] ; then echo "  OK with study"
                    455:     elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
                    456:     else echo "  OK"
                    457:     fi
                    458:   done
                    459: fi
                    460: 
                    461: # Test of Perl >= 5.10 features with UTF8 support
                    462: 
                    463: if [ $do12 = yes ] ; then
                    464:   echo "Test 12: Features from Perl >= 5.10 with UTF8 support"
                    465:   if [ $utf8 -eq 0 ] ; then
                    466:     echo "  Skipped because UTF-8 support is not available"
                    467:   else
                    468:     for opt in "" "-s" $jitopt; do
                    469:       $sim $valgrind ./pcretest -q $opt $testdata/testinput12 testtry
                    470:       if [ $? = 0 ] ; then
                    471:         $cf $testdata/testoutput12 testtry
                    472:         if [ $? != 0 ] ; then exit 1; fi
                    473:       else exit 1
                    474:       fi
                    475:       if [ "$opt" = "-s" ] ; then echo "  OK with study"
                    476:       elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
                    477:       else echo "  OK"
                    478:       fi
                    479:     done
                    480:   fi
                    481: fi
                    482: 
                    483: # Test non-Perl-compatible Unicode property support
                    484: 
                    485: if [ $do13 = yes ] ; then
                    486:   echo "Test 13: API, internals, and non-Perl stuff for Unicode property support"
                    487:   if [ $utf8 -eq 0 -o $ucp -eq 0 ] ; then
                    488:     echo "  Skipped because Unicode property support is not available"
                    489:   else
                    490:     for opt in "" "-s" $jitopt; do
                    491:       $sim $valgrind ./pcretest -q $opt $testdata/testinput13 testtry
                    492:       if [ $? = 0 ] ; then
                    493:         $cf $testdata/testoutput13 testtry
                    494:         if [ $? != 0 ] ; then exit 1; fi
                    495:       else exit 1
                    496:       fi
                    497:       if [ "$opt" = "-s" ] ; then echo "  OK with study"
                    498:       elif [ "$opt" = "-s+" ] ; then echo "  OK with JIT study"
                    499:       else echo "  OK"
                    500:       fi
                    501:     done
                    502:   fi
                    503: fi
                    504: 
                    505: # Test JIT-specific features when JIT is available
                    506: 
                    507: if [ $do14 = yes ] ; then
                    508:   echo "Test 14: JIT-specific features (JIT available)"
                    509:   if [ $jit -eq 0 ] ; then
                    510:     echo "  Skipped because JIT is not available or not usable"
                    511:   else
                    512:     $sim $valgrind ./pcretest -q $testdata/testinput14 testtry
                    513:     if [ $? = 0 ] ; then
                    514:       $cf $testdata/testoutput14 testtry
                    515:       if [ $? != 0 ] ; then exit 1; fi
                    516:     else exit 1
                    517:     fi
                    518:     echo "  OK"
                    519:   fi
                    520: fi
                    521: 
                    522: # Test JIT-specific features when JIT is not available
                    523: 
                    524: if [ $do15 = yes ] ; then
                    525:   echo "Test 15: JIT-specific features (JIT not available)"
                    526:   if [ $jit -ne 0 ] ; then
                    527:     echo "  Skipped because JIT is available"
                    528:   else
                    529:     $sim $valgrind ./pcretest -q $testdata/testinput15 testtry
                    530:     if [ $? = 0 ] ; then
                    531:       $cf $testdata/testoutput15 testtry
                    532:       if [ $? != 0 ] ; then exit 1; fi
                    533:     else exit 1
                    534:     fi
                    535:     echo "  OK"
                    536:   fi
                    537: fi
                    538: 
                    539: # End

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>