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

Diff of /code/trunk/RunGrepTest

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

revision 1016 by ph10, Sun Aug 26 16:17:55 2012 UTC revision 1018 by ph10, Mon Aug 27 11:20:22 2012 UTC
# Line 2  Line 2 
2    
3  # Run pcregrep tests. The assumption is that the PCRE tests check the library  # Run pcregrep tests. The assumption is that the PCRE tests check the library
4  # itself. What we are checking here is the file handling and options that are  # itself. What we are checking here is the file handling and options that are
5  # supported by pcregrep.  # supported by pcregrep. This script must be run in the build directory.
6    
7  # Set the C locale, so that sort(1) behaves predictably.  # Set the C locale, so that sort(1) behaves predictably.
8    
# Line 14  export LC_ALL Line 14  export LC_ALL
14  unset PCREGREP_COLOUR PCREGREP_COLOR  unset PCREGREP_COLOUR PCREGREP_COLOR
15  unset cp ls mv rm  unset cp ls mv rm
16    
17  # Set the program to be tested, and valgrind settings when requested.  # Remember the current (build) directory, set the program to be tested, and
18    # valgrind settings when requested.
19    
20  pcregrep=`pwd`/pcregrep  builddir=`pwd`
21    pcregrep=$builddir/pcregrep
22    
23  valgrind=  valgrind=
24  while [ $# -gt 0 ] ; do  while [ $# -gt 0 ] ; do
# Line 28  while [ $# -gt 0 ] ; do Line 30  while [ $# -gt 0 ] ; do
30  done  done
31    
32  echo " "  echo " "
33    pcregrep_version=`$pcregrep -V`
34  if [ "$valgrind" = "" ] ; then  if [ "$valgrind" = "" ] ; then
35    echo "Testing pcregrep"    echo "Testing $pcregrep_version"
36  else  else
37    echo "Testing pcregrep using valgrind"    echo "Testing $pcregrep_version using valgrind"
38  fi  fi
39    
 $pcregrep -V  
   
40  # 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
41  # 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
42  # option as well.  # option as well.
# Line 45  diff -b  /dev/null /dev/null 2>/dev/null Line 46  diff -b  /dev/null /dev/null 2>/dev/null
46  diff -u  /dev/null /dev/null 2>/dev/null && cf="diff -u"  diff -u  /dev/null /dev/null 2>/dev/null && cf="diff -u"
47  diff -ub /dev/null /dev/null 2>/dev/null && cf="diff -ub"  diff -ub /dev/null /dev/null 2>/dev/null && cf="diff -ub"
48    
49  # If PCRE has been built in a directory other than the source directory, and  # If this test is being run from "make check", $srcdir will be set. If not, set
50  # this test is being run from "make check" as usual, then $srcdir will be  # it to the current or parent directory, whichever one contains the test data.
51  # set. If not, set it to the current or parent directory, whichever one  # Subsequently, we run most of the pcregrep tests in the source directory so
52  # contains the test data. We then arrange to run the pcregrep command in the  # that the file names in the output are always the same.
 # source directory so that the file names that appear in the output are always  
 # the same.  
53    
54  if [ -z "$srcdir" -o ! -d "$srcdir/testdata" ] ; then  if [ -z "$srcdir" -o ! -d "$srcdir/testdata" ] ; then
55    if [ -d "./testdata" ] ; then    if [ -d "./testdata" ] ; then
# Line 68  fi Line 67  fi
67  ./pcretest -C utf >/dev/null  ./pcretest -C utf >/dev/null
68  utf8=$?  utf8=$?
69    
70    echo "Testing pcregrep main features"
71    
72  echo "---------------------------- Test 1 ------------------------------" >testtry  echo "---------------------------- Test 1 ------------------------------" >testtry
73  (cd $srcdir; $valgrind $pcregrep PATTERN ./testdata/grepinput) >>testtry  (cd $srcdir; $valgrind $pcregrep PATTERN ./testdata/grepinput) >>testtry
74  echo "RC=$?" >>testtry  echo "RC=$?" >>testtry
# Line 118  echo "RC=$?" >>testtry Line 119  echo "RC=$?" >>testtry
119    
120  echo "---------------------------- Test 13 -----------------------------" >>testtry  echo "---------------------------- Test 13 -----------------------------" >>testtry
121  echo seventeen >testtemp1  echo seventeen >testtemp1
122  (cd $srcdir; $valgrind $pcregrep -f./testdata/greplist -f testtemp1 ./testdata/grepinputx) >>testtry  (cd $srcdir; $valgrind $pcregrep -f./testdata/greplist -f $builddir/testtemp1 ./testdata/grepinputx) >>testtry
123  echo "RC=$?" >>testtry  echo "RC=$?" >>testtry
124    
125  echo "---------------------------- Test 14 -----------------------------" >>testtry  echo "---------------------------- Test 14 -----------------------------" >>testtry
# Line 408  echo "RC=$?" >>testtry Line 409  echo "RC=$?" >>testtry
409    
410  echo "---------------------------- Test 84 -----------------------------" >>testtry  echo "---------------------------- Test 84 -----------------------------" >>testtry
411  echo testdata/grepinput3 >testtemp1  echo testdata/grepinput3 >testtemp1
412  (cd $srcdir; $valgrind $pcregrep --file-list ./testdata/grepfilelist --file-list testtemp1 "fox|complete|t7") >>testtry 2>&1  (cd $srcdir; $valgrind $pcregrep --file-list ./testdata/grepfilelist --file-list $builddir/testtemp1 "fox|complete|t7") >>testtry 2>&1
413  echo "RC=$?" >>testtry  echo "RC=$?" >>testtry
414    
415  echo "---------------------------- Test 85 -----------------------------" >>testtry  echo "---------------------------- Test 85 -----------------------------" >>testtry
# Line 462  echo "RC=$?" >>testtry Line 463  echo "RC=$?" >>testtry
463  echo "---------------------------- Test 97 -----------------------------" >>testtry  echo "---------------------------- Test 97 -----------------------------" >>testtry
464  echo "grepinput$" >testtemp1  echo "grepinput$" >testtemp1
465  echo "grepinput8" >>testtemp1  echo "grepinput8" >>testtemp1
466  (cd $srcdir; $valgrind $pcregrep -L -r --include=grepinput --exclude-from testtemp1 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry  (cd $srcdir; $valgrind $pcregrep -L -r --include=grepinput --exclude-from $builddir/testtemp1 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry
467  echo "RC=$?" >>testtry  echo "RC=$?" >>testtry
468    
469  echo "---------------------------- Test 98 -----------------------------" >>testtry  echo "---------------------------- Test 98 -----------------------------" >>testtry
470  echo "grepinput$" >testtemp1  echo "grepinput$" >testtemp1
471  echo "grepinput8" >>testtemp1  echo "grepinput8" >>testtemp1
472  (cd $srcdir; $valgrind $pcregrep -L -r --exclude=grepinput3 --include=grepinput --exclude-from testtemp1 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry  (cd $srcdir; $valgrind $pcregrep -L -r --exclude=grepinput3 --include=grepinput --exclude-from $builddir/testtemp1 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry
473  echo "RC=$?" >>testtry  echo "RC=$?" >>testtry
474    
475  echo "---------------------------- Test 99 -----------------------------" >>testtry  echo "---------------------------- Test 99 -----------------------------" >>testtry
476  echo "grepinput$" >testtemp1  echo "grepinput$" >testtemp1
477  echo "grepinput8" >testtemp2  echo "grepinput8" >testtemp2
478  (cd $srcdir; $valgrind $pcregrep -L -r --include grepinput --exclude-from testtemp1 --exclude-from=testtemp2 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry  (cd $srcdir; $valgrind $pcregrep -L -r --include grepinput --exclude-from $builddir/testtemp1 --exclude-from=$builddir/testtemp2 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry
479  echo "RC=$?" >>testtry  echo "RC=$?" >>testtry
480    
481  # Now compare the results.  # Now compare the results.
# Line 509  fi Line 510  fi
510  # is not \n. Do not use exported files, whose line endings might be changed.  # is not \n. Do not use exported files, whose line endings might be changed.
511  # Instead, create an input file using printf so that its contents are exactly  # Instead, create an input file using printf so that its contents are exactly
512  # what we want. Note the messy fudge to get printf to write a string that  # what we want. Note the messy fudge to get printf to write a string that
513  # starts with a hyphen.  # starts with a hyphen. These tests are run in the build directory.
514    
515  echo "Testing pcregrep newline settings"  echo "Testing pcregrep newline settings"
516  printf "abc\rdef\r\nghi\njkl" >testNinput  printf "abc\rdef\r\nghi\njkl" >testNinput

Legend:
Removed from v.1016  
changed lines
  Added in v.1018

  ViewVC Help
Powered by ViewVC 1.1.5