version 1.1.1.3, 2012/10/09 09:19:17
|
version 1.1.1.5, 2014/06/15 19:46:04
|
Line 2
|
Line 2
|
|
|
# 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 |
# 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 |
# supported by pcregrep. | # supported by pcregrep. This script must be run in the build directory. |
|
|
# Set the C locale, so that sort(1) behaves predictably. |
# Set the C locale, so that sort(1) behaves predictably. |
|
|
Line 14 export LC_ALL
|
Line 14 export LC_ALL
|
unset PCREGREP_COLOUR PCREGREP_COLOR |
unset PCREGREP_COLOUR PCREGREP_COLOR |
unset cp ls mv rm |
unset cp ls mv rm |
|
|
# Set the program to be tested, and valgrind settings when requested. | # Remember the current (build) directory, set the program to be tested, and |
| # valgrind settings when requested. |
|
|
pcregrep=`pwd`/pcregrep | builddir=`pwd` |
| pcregrep=$builddir/pcregrep |
|
|
valgrind= |
valgrind= |
while [ $# -gt 0 ] ; do |
while [ $# -gt 0 ] ; do |
Line 28 while [ $# -gt 0 ] ; do
|
Line 30 while [ $# -gt 0 ] ; do
|
done |
done |
|
|
echo " " |
echo " " |
|
pcregrep_version=`$pcregrep -V` |
if [ "$valgrind" = "" ] ; then |
if [ "$valgrind" = "" ] ; then |
echo "Testing pcregrep" | echo "Testing $pcregrep_version" |
else |
else |
echo "Testing pcregrep using valgrind" | echo "Testing $pcregrep_version using valgrind" |
fi |
fi |
|
|
$pcregrep -V |
|
|
|
# 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 |
# 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 |
# option as well. |
# option as well. |
|
|
cf="diff -ub" | cf="diff" |
if diff -u /dev/null /dev/null; then | diff -b /dev/null /dev/null 2>/dev/null && cf="diff -b" |
if diff -ub /dev/null /dev/null; then cf="diff -ub"; else cf="diff -u"; fi | diff -u /dev/null /dev/null 2>/dev/null && cf="diff -u" |
else | diff -ub /dev/null /dev/null 2>/dev/null && cf="diff -ub" |
if diff -b /dev/null /dev/null; then cf="diff -b"; else cf="diff"; fi | |
fi | |
|
|
# 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 |
# 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. |
# 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 |
# 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. | |
|
|
if [ -z "$srcdir" -o ! -d "$srcdir/testdata" ] ; then |
if [ -z "$srcdir" -o ! -d "$srcdir/testdata" ] ; then |
if [ -d "./testdata" ] ; then |
if [ -d "./testdata" ] ; then |
Line 70 fi
|
Line 67 fi
|
./pcretest -C utf >/dev/null |
./pcretest -C utf >/dev/null |
utf8=$? |
utf8=$? |
|
|
|
echo "Testing pcregrep main features" |
|
|
echo "---------------------------- Test 1 ------------------------------" >testtry |
echo "---------------------------- Test 1 ------------------------------" >testtry |
(cd $srcdir; $valgrind $pcregrep PATTERN ./testdata/grepinput) >>testtry |
(cd $srcdir; $valgrind $pcregrep PATTERN ./testdata/grepinput) >>testtry |
echo "RC=$?" >>testtry |
echo "RC=$?" >>testtry |
Line 119 echo "---------------------------- Test 12 -----------
|
Line 118 echo "---------------------------- Test 12 -----------
|
echo "RC=$?" >>testtry |
echo "RC=$?" >>testtry |
|
|
echo "---------------------------- Test 13 -----------------------------" >>testtry |
echo "---------------------------- Test 13 -----------------------------" >>testtry |
(cd $srcdir; $valgrind $pcregrep -f./testdata/greplist ./testdata/grepinputx) >>testtry | echo seventeen >testtemp1 |
| (cd $srcdir; $valgrind $pcregrep -f./testdata/greplist -f $builddir/testtemp1 ./testdata/grepinputx) >>testtry |
echo "RC=$?" >>testtry |
echo "RC=$?" >>testtry |
|
|
echo "---------------------------- Test 14 -----------------------------" >>testtry |
echo "---------------------------- Test 14 -----------------------------" >>testtry |
Line 207 echo "---------------------------- Test 34 -----------
|
Line 207 echo "---------------------------- Test 34 -----------
|
echo "RC=$?" >>testtry |
echo "RC=$?" >>testtry |
|
|
echo "---------------------------- Test 35 -----------------------------" >>testtry |
echo "---------------------------- Test 35 -----------------------------" >>testtry |
(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 | sort) >>testtry |
echo "RC=$?" >>testtry |
echo "RC=$?" >>testtry |
|
|
echo "---------------------------- Test 36 -----------------------------" >>testtry |
echo "---------------------------- Test 36 -----------------------------" >>testtry |
(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 |
echo "RC=$?" >>testtry |
echo "RC=$?" >>testtry |
|
|
echo "---------------------------- Test 37 -----------------------------" >>testtry |
echo "---------------------------- Test 37 -----------------------------" >>testtry |
Line 408 echo "---------------------------- Test 83 -----------
|
Line 408 echo "---------------------------- Test 83 -----------
|
echo "RC=$?" >>testtry |
echo "RC=$?" >>testtry |
|
|
echo "---------------------------- Test 84 -----------------------------" >>testtry |
echo "---------------------------- Test 84 -----------------------------" >>testtry |
(cd $srcdir; $valgrind $pcregrep --file-list ./testdata/grepfilelist "fox|complete") >>testtry 2>&1 | echo testdata/grepinput3 >testtemp1 |
| (cd $srcdir; $valgrind $pcregrep --file-list ./testdata/grepfilelist --file-list $builddir/testtemp1 "fox|complete|t7") >>testtry 2>&1 |
echo "RC=$?" >>testtry |
echo "RC=$?" >>testtry |
|
|
echo "---------------------------- Test 85 -----------------------------" >>testtry |
echo "---------------------------- Test 85 -----------------------------" >>testtry |
Line 447 echo "---------------------------- Test 93 -----------
|
Line 448 echo "---------------------------- Test 93 -----------
|
(cd $srcdir; $valgrind $pcregrep --text "dog" ./testdata/grepbinary) >>testtry 2>&1 |
(cd $srcdir; $valgrind $pcregrep --text "dog" ./testdata/grepbinary) >>testtry 2>&1 |
echo "RC=$?" >>testtry |
echo "RC=$?" >>testtry |
|
|
|
echo "---------------------------- Test 94 -----------------------------" >>testtry |
|
(cd $srcdir; $valgrind $pcregrep -L -r --include=grepinputx --include grepinput8 'fox' ./testdata/grepinput* | sort) >>testtry |
|
echo "RC=$?" >>testtry |
|
|
|
echo "---------------------------- Test 95 -----------------------------" >>testtry |
|
(cd $srcdir; $valgrind $pcregrep --file-list ./testdata/grepfilelist --exclude grepinputv "fox|complete") >>testtry 2>&1 |
|
echo "RC=$?" >>testtry |
|
|
|
echo "---------------------------- Test 96 -----------------------------" >>testtry |
|
(cd $srcdir; $valgrind $pcregrep -L -r --include-dir=testdata --exclude '^(?!grepinput)' 'fox' ./test* | sort) >>testtry |
|
echo "RC=$?" >>testtry |
|
|
|
echo "---------------------------- Test 97 -----------------------------" >>testtry |
|
echo "grepinput$" >testtemp1 |
|
echo "grepinput8" >>testtemp1 |
|
(cd $srcdir; $valgrind $pcregrep -L -r --include=grepinput --exclude-from $builddir/testtemp1 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry |
|
echo "RC=$?" >>testtry |
|
|
|
echo "---------------------------- Test 98 -----------------------------" >>testtry |
|
echo "grepinput$" >testtemp1 |
|
echo "grepinput8" >>testtemp1 |
|
(cd $srcdir; $valgrind $pcregrep -L -r --exclude=grepinput3 --include=grepinput --exclude-from $builddir/testtemp1 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry |
|
echo "RC=$?" >>testtry |
|
|
|
echo "---------------------------- Test 99 -----------------------------" >>testtry |
|
echo "grepinput$" >testtemp1 |
|
echo "grepinput8" >testtemp2 |
|
(cd $srcdir; $valgrind $pcregrep -L -r --include grepinput --exclude-from $builddir/testtemp1 --exclude-from=$builddir/testtemp2 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry |
|
echo "RC=$?" >>testtry |
|
|
|
echo "---------------------------- Test 100 ------------------------------" >>testtry |
|
(cd $srcdir; $valgrind $pcregrep -Ho2 --only-matching=1 -o3 '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtry |
|
echo "RC=$?" >>testtry |
|
|
|
echo "---------------------------- Test 101 ------------------------------" >>testtry |
|
(cd $srcdir; $valgrind $pcregrep -o3 -Ho2 -o12 --only-matching=1 -o3 --colour=always --om-separator='|' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtry |
|
echo "RC=$?" >>testtry |
|
|
|
echo "---------------------------- Test 102 -----------------------------" >>testtry |
|
(cd $srcdir; $valgrind $pcregrep -n "^$" ./testdata/grepinput3) >>testtry 2>&1 |
|
echo "RC=$?" >>testtry |
|
|
|
echo "---------------------------- Test 103 -----------------------------" >>testtry |
|
(cd $srcdir; $valgrind $pcregrep --only-matching "^$" ./testdata/grepinput3) >>testtry 2>&1 |
|
echo "RC=$?" >>testtry |
|
|
|
echo "---------------------------- Test 104 -----------------------------" >>testtry |
|
(cd $srcdir; $valgrind $pcregrep -n --only-matching "^$" ./testdata/grepinput3) >>testtry 2>&1 |
|
echo "RC=$?" >>testtry |
|
|
|
echo "---------------------------- Test 105 -----------------------------" >>testtry |
|
(cd $srcdir; $valgrind $pcregrep --colour=always "ipsum|" ./testdata/grepinput3) >>testtry 2>&1 |
|
echo "RC=$?" >>testtry |
|
|
|
echo "---------------------------- Test 106 -----------------------------" >>testtry |
|
(cd $srcdir; echo "a" | $valgrind $pcregrep -M "|a" ) >>testtry 2>&1 |
|
echo "RC=$?" >>testtry |
|
|
|
|
# Now compare the results. |
# Now compare the results. |
|
|
$cf $srcdir/testdata/grepoutput testtry |
$cf $srcdir/testdata/grepoutput testtry |
Line 479 fi
|
Line 539 fi
|
# 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. |
# 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 |
# 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 |
# starts with a hyphen. | # starts with a hyphen. These tests are run in the build directory. |
|
|
echo "Testing pcregrep newline settings" |
echo "Testing pcregrep newline settings" |
printf "abc\rdef\r\nghi\njkl" >testNinput |
printf "abc\rdef\r\nghi\njkl" >testNinput |