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

Diff of /code/trunk/RunGrepTest

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

revision 571 by ph10, Tue Nov 16 17:51:37 2010 UTC revision 1013 by ph10, Sat Aug 25 16:50:00 2012 UTC
# Line 5  Line 5 
5  # supported by pcregrep.  # supported by pcregrep.
6    
7  # Set the C locale, so that sort(1) behaves predictably.  # Set the C locale, so that sort(1) behaves predictably.
8    
9  LC_ALL=C  LC_ALL=C
10  export LC_ALL  export LC_ALL
11    
12  pcregrep=`pwd`/pcregrep  # Remove any non-default colouring and aliases that the caller may have set.
13    
14  echo " "  unset PCREGREP_COLOUR PCREGREP_COLOR
15  echo "Testing pcregrep"  unset cp ls mv rm
16  $pcregrep -V  
17    # Set the program to be tested, and valgrind settings when requested.
18    
19    pcregrep=`pwd`/pcregrep
20    
21  valgrind=  valgrind=
22  while [ $# -gt 0 ] ; do  while [ $# -gt 0 ] ; do
23    case $1 in    case $1 in
24      valgrind) valgrind="valgrind -q --leak-check=no";;      valgrind) valgrind="valgrind -q --leak-check=no --smc-check=all";;
25      *) echo "Unknown argument $1"; exit 1;;      *) echo "RunGrepTest: Unknown argument $1"; exit 1;;
26    esac    esac
27    shift    shift
28  done  done
29    
30  cf="diff -ub"  echo " "
31    if [ "$valgrind" = "" ] ; then
32      echo "Testing pcregrep"
33    else
34      echo "Testing pcregrep using valgrind"
35    fi
36    
37    $pcregrep -V
38    
39  # Set up a suitable "diff" command for comparison. Some systems have a diff  # Set up a suitable "diff" command for comparison. Some systems have a diff
40  # that lacks a -u option. Try to deal with this; better do the test for the -b  # that lacks a -u option. Try to deal with this; better do the test for the -b
41  # option as well.  # option as well.
42    
43    cf="diff -ub"
44  if diff -u /dev/null /dev/null; then  if diff -u /dev/null /dev/null; then
45    if diff -ub /dev/null /dev/null; then cf="diff -ub"; else cf="diff -u"; fi    if diff -ub /dev/null /dev/null; then cf="diff -ub"; else cf="diff -u"; fi
46  else  else
# Line 36  else Line 48  else
48  fi  fi
49    
50  # If PCRE has been built in a directory other than the source directory, and  # If PCRE has been built in a directory other than the source directory, and
51  # this test is being run from "make check" as usual, then $(srcdir) will be  # this test is being run from "make check" as usual, then $srcdir will be
52  # set. If not, set it to the current directory. We then arrange to run the  # set. If not, set it to the current or parent directory, whichever one
53  # pcregrep command in the source directory so that the file names that appear  # contains the test data. We then arrange to run the pcregrep command in the
54  # in the output are always the same.  # source directory so that the file names that appear in the output are always
55    # the same.
56    
57  if [ -z "$srcdir" -o ! -d "$srcdir/testdata" ] ; then  if [ -z "$srcdir" -o ! -d "$srcdir/testdata" ] ; then
58    srcdir=.    if [ -d "./testdata" ] ; then
59        srcdir=.
60      elif [ -d "../testdata" ] ; then
61        srcdir=..
62      else
63        echo "Cannot find the testdata directory"
64        exit 1
65      fi
66  fi  fi
67    
68  # Check for the availability of UTF-8 support  # Check for the availability of UTF-8 support
69    
70  ./pcretest -C | ./pcregrep "No UTF-8 support" >/dev/null  ./pcretest -C utf >/dev/null
71  utf8=$?  utf8=$?
72    
73  echo "---------------------------- Test 1 ------------------------------" >testtry  echo "---------------------------- Test 1 ------------------------------" >testtry
# Line 99  echo "---------------------------- Test Line 119  echo "---------------------------- Test
119  echo "RC=$?" >>testtry  echo "RC=$?" >>testtry
120    
121  echo "---------------------------- Test 13 -----------------------------" >>testtry  echo "---------------------------- Test 13 -----------------------------" >>testtry
122  (cd $srcdir; $valgrind $pcregrep -f./testdata/greplist ./testdata/grepinputx) >>testtry  echo seventeen >testtemp1
123    (cd $srcdir; $valgrind $pcregrep -f./testdata/greplist -f testtemp1 ./testdata/grepinputx) >>testtry
124  echo "RC=$?" >>testtry  echo "RC=$?" >>testtry
125    
126  echo "---------------------------- Test 14 -----------------------------" >>testtry  echo "---------------------------- Test 14 -----------------------------" >>testtry
# Line 187  echo "---------------------------- Test Line 208  echo "---------------------------- Test
208  echo "RC=$?" >>testtry  echo "RC=$?" >>testtry
209    
210  echo "---------------------------- Test 35 -----------------------------" >>testtry  echo "---------------------------- Test 35 -----------------------------" >>testtry
211  (cd $srcdir; $valgrind $pcregrep -L -r --include=grepinputx --exclude-dir='^\.' 'fox' ./testdata) >>testtry  (cd $srcdir; $valgrind $pcregrep -L -r --include=grepinputx --include grepinput8 --exclude-dir='^\.' 'fox' ./testdata) >>testtry
212  echo "RC=$?" >>testtry  echo "RC=$?" >>testtry
213    
214  echo "---------------------------- Test 36 -----------------------------" >>testtry  echo "---------------------------- Test 36 -----------------------------" >>testtry
215  (cd $srcdir; $valgrind $pcregrep -L -r --include=grepinput --exclude 'grepinput$' --exclude_dir='^\.' 'fox' ./testdata | sort) >>testtry  (cd $srcdir; $valgrind $pcregrep -L -r --include=grepinput --exclude 'grepinput$' --exclude=grepinput8 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry
216  echo "RC=$?" >>testtry  echo "RC=$?" >>testtry
217    
218  echo "---------------------------- Test 37 -----------------------------" >>testtry  echo "---------------------------- Test 37 -----------------------------" >>testtry
# Line 300  echo "---------------------------- Test Line 321  echo "---------------------------- Test
321  echo "RC=$?" >>testtry  echo "RC=$?" >>testtry
322    
323  echo "---------------------------- Test 62 -----------------------------" >>testtry  echo "---------------------------- Test 62 -----------------------------" >>testtry
324  (cd $srcdir; $valgrind $pcregrep --match-limit=1000 -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtry 2>&1  (cd $srcdir; $valgrind $pcregrep --match-limit=1000 --no-jit -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtry 2>&1
325  echo "RC=$?" >>testtry  echo "RC=$?" >>testtry
326    
327  echo "---------------------------- Test 63 -----------------------------" >>testtry  echo "---------------------------- Test 63 -----------------------------" >>testtry
328  (cd $srcdir; $valgrind $pcregrep --recursion-limit=1000 -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtry 2>&1  (cd $srcdir; $valgrind $pcregrep --recursion-limit=1000 --no-jit -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtry 2>&1
329  echo "RC=$?" >>testtry  echo "RC=$?" >>testtry
330    
331  echo "---------------------------- Test 64 ------------------------------" >>testtry  echo "---------------------------- Test 64 ------------------------------" >>testtry
# Line 327  echo "---------------------------- Test Line 348  echo "---------------------------- Test
348  (cd $srcdir; $valgrind $pcregrep --only-matching=2 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtry  (cd $srcdir; $valgrind $pcregrep --only-matching=2 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtry
349  echo "RC=$?" >>testtry  echo "RC=$?" >>testtry
350    
351    echo "---------------------------- Test 69 -----------------------------" >>testtry
352    (cd $srcdir; $valgrind $pcregrep -vn --colour=always pattern ./testdata/grepinputx) >>testtry
353    echo "RC=$?" >>testtry
354    
355    echo "---------------------------- Test 70 -----------------------------" >>testtry
356    (cd $srcdir; $valgrind $pcregrep --color=always -M "triple:\t.*\n\n" ./testdata/grepinput3) >>testtry
357    echo "RC=$?" >>testtry
358    
359    echo "---------------------------- Test 71 -----------------------------" >>testtry
360    (cd $srcdir; $valgrind $pcregrep -o "^01|^02|^03" ./testdata/grepinput) >>testtry
361    echo "RC=$?" >>testtry
362    
363    echo "---------------------------- Test 72 -----------------------------" >>testtry
364    (cd $srcdir; $valgrind $pcregrep --color=always "^01|^02|^03" ./testdata/grepinput) >>testtry
365    echo "RC=$?" >>testtry
366    
367    echo "---------------------------- Test 73 -----------------------------" >>testtry
368    (cd $srcdir; $valgrind $pcregrep -o --colour=always "^01|^02|^03" ./testdata/grepinput) >>testtry
369    echo "RC=$?" >>testtry
370    
371    echo "---------------------------- Test 74 -----------------------------" >>testtry
372    (cd $srcdir; $valgrind $pcregrep -o "^01|02|^03" ./testdata/grepinput) >>testtry
373    echo "RC=$?" >>testtry
374    
375    echo "---------------------------- Test 75 -----------------------------" >>testtry
376    (cd $srcdir; $valgrind $pcregrep --color=always "^01|02|^03" ./testdata/grepinput) >>testtry
377    echo "RC=$?" >>testtry
378    
379    echo "---------------------------- Test 76 -----------------------------" >>testtry
380    (cd $srcdir; $valgrind $pcregrep -o --colour=always "^01|02|^03" ./testdata/grepinput) >>testtry
381    echo "RC=$?" >>testtry
382    
383    echo "---------------------------- Test 77 -----------------------------" >>testtry
384    (cd $srcdir; $valgrind $pcregrep -o "^01|^02|03" ./testdata/grepinput) >>testtry
385    echo "RC=$?" >>testtry
386    
387    echo "---------------------------- Test 78 -----------------------------" >>testtry
388    (cd $srcdir; $valgrind $pcregrep --color=always "^01|^02|03" ./testdata/grepinput) >>testtry
389    echo "RC=$?" >>testtry
390    
391    echo "---------------------------- Test 79 -----------------------------" >>testtry
392    (cd $srcdir; $valgrind $pcregrep -o --colour=always "^01|^02|03" ./testdata/grepinput) >>testtry
393    echo "RC=$?" >>testtry
394    
395    echo "---------------------------- Test 80 -----------------------------" >>testtry
396    (cd $srcdir; $valgrind $pcregrep -o "\b01|\b02" ./testdata/grepinput) >>testtry
397    echo "RC=$?" >>testtry
398    
399    echo "---------------------------- Test 81 -----------------------------" >>testtry
400    (cd $srcdir; $valgrind $pcregrep --color=always "\\b01|\\b02" ./testdata/grepinput) >>testtry
401    echo "RC=$?" >>testtry
402    
403    echo "---------------------------- Test 82 -----------------------------" >>testtry
404    (cd $srcdir; $valgrind $pcregrep -o --colour=always "\\b01|\\b02" ./testdata/grepinput) >>testtry
405    echo "RC=$?" >>testtry
406    
407    echo "---------------------------- Test 83 -----------------------------" >>testtry
408    (cd $srcdir; $valgrind $pcregrep --buffer-size=100 "^a" ./testdata/grepinput3) >>testtry 2>&1
409    echo "RC=$?" >>testtry
410    
411    echo "---------------------------- Test 84 -----------------------------" >>testtry
412    echo testdata/grepinput3 >testtemp1
413    (cd $srcdir; $valgrind $pcregrep --file-list ./testdata/grepfilelist --file-list testtemp1 "fox|complete|t7") >>testtry 2>&1
414    echo "RC=$?" >>testtry
415    
416    echo "---------------------------- Test 85 -----------------------------" >>testtry
417    (cd $srcdir; $valgrind $pcregrep --file-list=./testdata/grepfilelist "dolor" ./testdata/grepinput3) >>testtry 2>&1
418    echo "RC=$?" >>testtry
419    
420    echo "---------------------------- Test 86 -----------------------------" >>testtry
421    (cd $srcdir; $valgrind $pcregrep "dog" ./testdata/grepbinary) >>testtry 2>&1
422    echo "RC=$?" >>testtry
423    
424    echo "---------------------------- Test 87 -----------------------------" >>testtry
425    (cd $srcdir; $valgrind $pcregrep "cat" ./testdata/grepbinary) >>testtry 2>&1
426    echo "RC=$?" >>testtry
427    
428    echo "---------------------------- Test 88 -----------------------------" >>testtry
429    (cd $srcdir; $valgrind $pcregrep -v "cat" ./testdata/grepbinary) >>testtry 2>&1
430    echo "RC=$?" >>testtry
431    
432    echo "---------------------------- Test 89 -----------------------------" >>testtry
433    (cd $srcdir; $valgrind $pcregrep -I "dog" ./testdata/grepbinary) >>testtry 2>&1
434    echo "RC=$?" >>testtry
435    
436    echo "---------------------------- Test 90 -----------------------------" >>testtry
437    (cd $srcdir; $valgrind $pcregrep --binary-files=without-match "dog" ./testdata/grepbinary) >>testtry 2>&1
438    echo "RC=$?" >>testtry
439    
440    echo "---------------------------- Test 91 -----------------------------" >>testtry
441    (cd $srcdir; $valgrind $pcregrep -a "dog" ./testdata/grepbinary) >>testtry 2>&1
442    echo "RC=$?" >>testtry
443    
444    echo "---------------------------- Test 92 -----------------------------" >>testtry
445    (cd $srcdir; $valgrind $pcregrep --binary-files=text "dog" ./testdata/grepbinary) >>testtry 2>&1
446    echo "RC=$?" >>testtry
447    
448    echo "---------------------------- Test 93 -----------------------------" >>testtry
449    (cd $srcdir; $valgrind $pcregrep --text "dog" ./testdata/grepbinary) >>testtry 2>&1
450    echo "RC=$?" >>testtry
451    
452    echo "---------------------------- Test 94 -----------------------------" >>testtry
453    (cd $srcdir; $valgrind $pcregrep -L -r --include=grepinputx --include grepinput8 'fox' ./testdata/grepinput* | sort) >>testtry
454    echo "RC=$?" >>testtry
455    
456    echo "---------------------------- Test 95 -----------------------------" >>testtry
457    (cd $srcdir; $valgrind $pcregrep --file-list ./testdata/grepfilelist --exclude grepinputv "fox|complete") >>testtry 2>&1
458    echo "RC=$?" >>testtry
459    
460    echo "---------------------------- Test 96 -----------------------------" >>testtry
461    (cd $srcdir; $valgrind $pcregrep -L -r --include-dir=testdata --exclude '^(?!grepinput)' 'fox' ./test* | sort) >>testtry
462    echo "RC=$?" >>testtry
463    
464    echo "---------------------------- Test 97 -----------------------------" >>testtry
465    echo "grepinput$" >testtemp1
466    echo "grepinput8" >>testtemp1
467    (cd $srcdir; $valgrind $pcregrep -L -r --include=grepinput --exclude-from testtemp1 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry
468    echo "RC=$?" >>testtry
469    
470    echo "---------------------------- Test 98 -----------------------------" >>testtry
471    echo "grepinput$" >testtemp1
472    echo "grepinput8" >>testtemp1
473    (cd $srcdir; $valgrind $pcregrep -L -r --exclude=grepinput3 --include=grepinput --exclude-from testtemp1 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry
474    echo "RC=$?" >>testtry
475    
476    echo "---------------------------- Test 99 -----------------------------" >>testtry
477    echo "grepinput$" >testtemp1
478    echo "grepinput8" >testtemp2
479    (cd $srcdir; $valgrind $pcregrep -L -r --include grepinput --exclude-from testtemp1 --exclude-from=testtemp2 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry
480    echo "RC=$?" >>testtry
481    
482  # Now compare the results.  # Now compare the results.
483    
484  $cf $srcdir/testdata/grepoutput testtry  $cf $srcdir/testdata/grepoutput testtry
# Line 375  pattern=`printf 'def\rjkl'` Line 527  pattern=`printf 'def\rjkl'`
527  $valgrind $pcregrep -n --newline=cr -F "$pattern" testNinput >>testtry  $valgrind $pcregrep -n --newline=cr -F "$pattern" testNinput >>testtry
528    
529  printf "%c--------------------------- Test N4 ------------------------------\r\n" - >>testtry  printf "%c--------------------------- Test N4 ------------------------------\r\n" - >>testtry
530  pattern=`printf 'xxx\r\njkl'`  $valgrind $pcregrep -n --newline=crlf -F -f $srcdir/testdata/greppatN4 testNinput >>testtry
 $valgrind $pcregrep -n --newline=crlf -F "$pattern" testNinput >>testtry  
531    
532  printf "%c--------------------------- Test N5 ------------------------------\r\n" - >>testtry  printf "%c--------------------------- Test N5 ------------------------------\r\n" - >>testtry
533  $valgrind $pcregrep -n --newline=any "^(abc|def|ghi|jkl)" testNinput >>testtry  $valgrind $pcregrep -n --newline=any "^(abc|def|ghi|jkl)" testNinput >>testtry

Legend:
Removed from v.571  
changed lines
  Added in v.1013

  ViewVC Help
Powered by ViewVC 1.1.5