diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2007-03-29 15:20:15 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2007-03-29 15:20:15 +0000 |
commit | 50dcde8c8eac3579ac0fe78d5cd298555fe9fa29 (patch) | |
tree | 7309b81075920a571b1298f022ce39e0fcba5cfb /RunGrepTest | |
parent | 0223e786f31293f120cec10de1dea43a6169fd8b (diff) | |
download | pcre-50dcde8c8eac3579ac0fe78d5cd298555fe9fa29.tar.gz |
Fix RunGrepTest so that it can be run when the build directory is not the
source directory.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@138 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'RunGrepTest')
-rwxr-xr-x | RunGrepTest | 154 |
1 files changed, 79 insertions, 75 deletions
diff --git a/RunGrepTest b/RunGrepTest index c357540..131ceeb 100755 --- a/RunGrepTest +++ b/RunGrepTest @@ -1,27 +1,21 @@ #! /bin/sh -# This file is generated by configure from RunGrepTest.in. Make any changes -# to that file. +# 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 +# supported by pcregrep. # Set the C locale, so that sort(1) behaves predictably. LC_ALL=C export LC_ALL +pcregrep=`pwd`/pcregrep + echo " " echo "Testing pcregrep" -./pcregrep -V - -# 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 -# supported by pcregrep. +$pcregrep -V cf="diff -ub" valgrind= -testdata=testdata - -if [ -n "$srcdir" -a -d "$srcdir/testdata" ] ; then - testdata="$srcdir/testdata" -fi while [ $# -gt 0 ] ; do case $1 in @@ -31,176 +25,186 @@ while [ $# -gt 0 ] ; do shift done +# If PCRE has been built in a directory other than the source directory, and +# this test is being run from "make check" as usual, then $(srcdir) will be +# set. If not, set it to the current directory. We then arrange to run the +# pcregrep command in the source directory so that the file names that appear +# in the output are always the same. + +if [ -z "$srcdir" -o ! -d "$srcdir/testdata" ] ; then + srcdir=. +fi + # Check for the availability of UTF-8 support ./pcretest -C | ./pcregrep "No UTF-8 support" >/dev/null utf8=$? echo "---------------------------- Test 1 ------------------------------" >testtry -$valgrind ./pcregrep PATTERN $testdata/grepinput >>testtry +(cd $srcdir; $valgrind $pcregrep PATTERN ./testdata/grepinput) >>testtry echo "---------------------------- Test 2 ------------------------------" >>testtry -$valgrind ./pcregrep '^PATTERN' $testdata/grepinput >>testtry +(cd $srcdir; $valgrind $pcregrep '^PATTERN' ./testdata/grepinput) >>testtry echo "---------------------------- Test 3 ------------------------------" >>testtry -$valgrind ./pcregrep -in PATTERN $testdata/grepinput >>testtry +(cd $srcdir; $valgrind $pcregrep -in PATTERN ./testdata/grepinput) >>testtry echo "---------------------------- Test 4 ------------------------------" >>testtry -$valgrind ./pcregrep -ic PATTERN $testdata/grepinput >>testtry +(cd $srcdir; $valgrind $pcregrep -ic PATTERN ./testdata/grepinput) >>testtry echo "---------------------------- Test 5 ------------------------------" >>testtry -$valgrind ./pcregrep -in PATTERN $testdata/grepinput $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -in PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry echo "---------------------------- Test 6 ------------------------------" >>testtry -$valgrind ./pcregrep -inh PATTERN $testdata/grepinput $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -inh PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry echo "---------------------------- Test 7 ------------------------------" >>testtry -$valgrind ./pcregrep -il PATTERN $testdata/grepinput $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -il PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry echo "---------------------------- Test 8 ------------------------------" >>testtry -$valgrind ./pcregrep -l PATTERN $testdata/grepinput $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -l PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry echo "---------------------------- Test 9 ------------------------------" >>testtry -$valgrind ./pcregrep -q PATTERN $testdata/grepinput $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -q PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry echo "RC=$?" >>testtry echo "---------------------------- Test 10 -----------------------------" >>testtry -$valgrind ./pcregrep -q NEVER-PATTERN $testdata/grepinput $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -q NEVER-PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry echo "RC=$?" >>testtry echo "---------------------------- Test 11 -----------------------------" >>testtry -$valgrind ./pcregrep -vn pattern $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -vn pattern ./testdata/grepinputx) >>testtry echo "---------------------------- Test 12 -----------------------------" >>testtry -$valgrind ./pcregrep -ix pattern $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -ix pattern ./testdata/grepinputx) >>testtry echo "---------------------------- Test 13 -----------------------------" >>testtry -$valgrind ./pcregrep -f$testdata/greplist $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -f./testdata/greplist ./testdata/grepinputx) >>testtry echo "---------------------------- Test 14 -----------------------------" >>testtry -$valgrind ./pcregrep -w pat $testdata/grepinput $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -w pat ./testdata/grepinput ./testdata/grepinputx) >>testtry echo "---------------------------- Test 15 -----------------------------" >>testtry -$valgrind ./pcregrep 'abc^*' $testdata/grepinput 2>>testtry >>testtry +(cd $srcdir; $valgrind $pcregrep 'abc^*' ./testdata/grepinput) 2>>testtry >>testtry echo "---------------------------- Test 16 -----------------------------" >>testtry -$valgrind ./pcregrep abc $testdata/grepinput $testdata/nonexistfile 2>>testtry >>testtry +(cd $srcdir; $valgrind $pcregrep abc ./testdata/grepinput ./testdata/nonexistfile) 2>>testtry >>testtry echo "---------------------------- Test 17 -----------------------------" >>testtry -$valgrind ./pcregrep -M 'the\noutput' $testdata/grepinput >>testtry +(cd $srcdir; $valgrind $pcregrep -M 'the\noutput' ./testdata/grepinput) >>testtry echo "---------------------------- Test 18 -----------------------------" >>testtry -$valgrind ./pcregrep -Mn '(the\noutput|dog\.\n--)' $testdata/grepinput >>testtry +(cd $srcdir; $valgrind $pcregrep -Mn '(the\noutput|dog\.\n--)' ./testdata/grepinput) >>testtry echo "---------------------------- Test 19 -----------------------------" >>testtry -$valgrind ./pcregrep -Mix 'Pattern' $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -Mix 'Pattern' ./testdata/grepinputx) >>testtry echo "---------------------------- Test 20 -----------------------------" >>testtry -$valgrind ./pcregrep -Mixn 'complete pair\nof lines' $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -Mixn 'complete pair\nof lines' ./testdata/grepinputx) >>testtry echo "---------------------------- Test 21 -----------------------------" >>testtry -$valgrind ./pcregrep -nA3 'four' $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -nA3 'four' ./testdata/grepinputx) >>testtry echo "---------------------------- Test 22 -----------------------------" >>testtry -$valgrind ./pcregrep -nB3 'four' $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -nB3 'four' ./testdata/grepinputx) >>testtry echo "---------------------------- Test 23 -----------------------------" >>testtry -$valgrind ./pcregrep -C3 'four' $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -C3 'four' ./testdata/grepinputx) >>testtry echo "---------------------------- Test 24 -----------------------------" >>testtry -$valgrind ./pcregrep -A9 'four' $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -A9 'four' ./testdata/grepinputx) >>testtry echo "---------------------------- Test 25 -----------------------------" >>testtry -$valgrind ./pcregrep -nB9 'four' $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -nB9 'four' ./testdata/grepinputx) >>testtry echo "---------------------------- Test 26 -----------------------------" >>testtry -$valgrind ./pcregrep -A9 -B9 'four' $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -A9 -B9 'four' ./testdata/grepinputx) >>testtry echo "---------------------------- Test 27 -----------------------------" >>testtry -$valgrind ./pcregrep -A10 'four' $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -A10 'four' ./testdata/grepinputx) >>testtry echo "---------------------------- Test 28 -----------------------------" >>testtry -$valgrind ./pcregrep -nB10 'four' $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -nB10 'four' ./testdata/grepinputx) >>testtry echo "---------------------------- Test 29 -----------------------------" >>testtry -$valgrind ./pcregrep -C12 -B10 'four' $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -C12 -B10 'four' ./testdata/grepinputx) >>testtry echo "---------------------------- Test 30 -----------------------------" >>testtry -$valgrind ./pcregrep -inB3 'pattern' $testdata/grepinput $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -inB3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtry echo "---------------------------- Test 31 -----------------------------" >>testtry -$valgrind ./pcregrep -inA3 'pattern' $testdata/grepinput $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -inA3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtry echo "---------------------------- Test 32 -----------------------------" >>testtry -$valgrind ./pcregrep -L 'fox' $testdata/grepinput $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -L 'fox' ./testdata/grepinput ./testdata/grepinputx) >>testtry echo "---------------------------- Test 33 -----------------------------" >>testtry -$valgrind ./pcregrep 'fox' $testdata/grepnonexist >>testtry 2>&1 +(cd $srcdir; $valgrind $pcregrep 'fox' ./testdata/grepnonexist) >>testtry 2>&1 echo "RC=$?" >>testtry echo "---------------------------- Test 34 -----------------------------" >>testtry -$valgrind ./pcregrep -s 'fox' $testdata/grepnonexist >>testtry 2>&1 +(cd $srcdir; $valgrind $pcregrep -s 'fox' ./testdata/grepnonexist) >>testtry 2>&1 echo "RC=$?" >>testtry echo "---------------------------- Test 35 -----------------------------" >>testtry -$valgrind ./pcregrep -L -r --include=grepinputx 'fox' $testdata >>testtry +(cd $srcdir; $valgrind $pcregrep -L -r --include=grepinputx 'fox' ./testdata) >>testtry echo "RC=$?" >>testtry echo "---------------------------- Test 36 -----------------------------" >>testtry -$valgrind ./pcregrep -L -r --include=grepinput --exclude 'grepinput$' 'fox' $testdata | sort >>testtry +(cd $srcdir; $valgrind $pcregrep -L -r --include=grepinput --exclude 'grepinput$' 'fox' ./testdata | sort) >>testtry echo "RC=$?" >>testtry echo "---------------------------- Test 37 -----------------------------" >>testtry -$valgrind ./pcregrep '^(a+)*\d' $testdata/grepinput >>testtry 2>teststderr +(cd $srcdir; $valgrind $pcregrep '^(a+)*\d' ./testdata/grepinput) >>testtry 2>teststderr echo "RC=$?" >>testtry echo "======== STDERR ========" >>testtry cat teststderr >>testtry echo "---------------------------- Test 38 ------------------------------" >>testtry -$valgrind ./pcregrep '>\x00<' $testdata/grepinput >>testtry +(cd $srcdir; $valgrind $pcregrep '>\x00<' ./testdata/grepinput) >>testtry echo "---------------------------- Test 39 ------------------------------" >>testtry -$valgrind ./pcregrep -A1 'before the binary zero' $testdata/grepinput >>testtry +(cd $srcdir; $valgrind $pcregrep -A1 'before the binary zero' ./testdata/grepinput) >>testtry echo "---------------------------- Test 40 ------------------------------" >>testtry -$valgrind ./pcregrep -B1 'after the binary zero' $testdata/grepinput >>testtry +(cd $srcdir; $valgrind $pcregrep -B1 'after the binary zero' ./testdata/grepinput) >>testtry echo "---------------------------- Test 41 ------------------------------" >>testtry -$valgrind ./pcregrep -B1 -o '\w+ the binary zero' $testdata/grepinput >>testtry +(cd $srcdir; $valgrind $pcregrep -B1 -o '\w+ the binary zero' ./testdata/grepinput) >>testtry echo "---------------------------- Test 41 ------------------------------" >>testtry -$valgrind ./pcregrep -B1 -onH '\w+ the binary zero' $testdata/grepinput >>testtry +(cd $srcdir; $valgrind $pcregrep -B1 -onH '\w+ the binary zero' ./testdata/grepinput) >>testtry echo "---------------------------- Test 42 ------------------------------" >>testtry -$valgrind ./pcregrep -on 'before|zero|after' $testdata/grepinput >>testtry +(cd $srcdir; $valgrind $pcregrep -on 'before|zero|after' ./testdata/grepinput) >>testtry echo "---------------------------- Test 43 ------------------------------" >>testtry -$valgrind ./pcregrep -on -e before -e zero -e after $testdata/grepinput >>testtry +(cd $srcdir; $valgrind $pcregrep -on -e before -e zero -e after ./testdata/grepinput) >>testtry echo "---------------------------- Test 44 ------------------------------" >>testtry -$valgrind ./pcregrep -on -f $testdata/greplist -e binary $testdata/grepinput >>testtry +(cd $srcdir; $valgrind $pcregrep -on -f ./testdata/greplist -e binary ./testdata/grepinput) >>testtry echo "---------------------------- Test 45 ------------------------------" >>testtry -$valgrind ./pcregrep -e abc -e '(unclosed' $testdata/grepinput 2>>testtry >>testtry +(cd $srcdir; $valgrind $pcregrep -e abc -e '(unclosed' ./testdata/grepinput) 2>>testtry >>testtry echo "---------------------------- Test 46 ------------------------------" >>testtry -$valgrind ./pcregrep -Fx "AB.VE -elephant" $testdata/grepinput >>testtry +(cd $srcdir; $valgrind $pcregrep -Fx "AB.VE +elephant" ./testdata/grepinput) >>testtry echo "---------------------------- Test 47 ------------------------------" >>testtry -$valgrind ./pcregrep -F "AB.VE -elephant" $testdata/grepinput >>testtry +(cd $srcdir; $valgrind $pcregrep -F "AB.VE +elephant" ./testdata/grepinput) >>testtry echo "---------------------------- Test 48 ------------------------------" >>testtry -$valgrind ./pcregrep -F -e DATA -e "AB.VE -elephant" $testdata/grepinput >>testtry +(cd $srcdir; $valgrind $pcregrep -F -e DATA -e "AB.VE +elephant" ./testdata/grepinput) >>testtry echo "---------------------------- Test 49 ------------------------------" >>testtry -$valgrind ./pcregrep "^(abc|def|ghi|jkl)" $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep "^(abc|def|ghi|jkl)" ./testdata/grepinputx) >>testtry # Now compare the results. -$cf testtry $testdata/grepoutput +$cf testtry $srcdir/testdata/grepoutput if [ $? != 0 ] ; then exit 1; fi @@ -210,12 +214,12 @@ if [ $utf8 -ne 0 ] ; then echo "Testing pcregrep UTF-8 features" echo "---------------------------- Test U1 ------------------------------" >testtry - $valgrind ./pcregrep -n -u --newline=any "^X" $testdata/grepinput8 >>testtry + (cd $srcdir; $valgrind $pcregrep -n -u --newline=any "^X" ./testdata/grepinput8) >>testtry echo "---------------------------- Test U2 ------------------------------" >>testtry - $valgrind ./pcregrep -n -u -C 3 --newline=any "Match" $testdata/grepinput8 >>testtry + (cd $srcdir; $valgrind $pcregrep -n -u -C 3 --newline=any "Match" ./testdata/grepinput8) >>testtry - $cf testtry $testdata/grepoutput8 + $cf testtry $srcdir/testdata/grepoutput8 if [ $? != 0 ] ; then exit 1; fi else @@ -229,23 +233,23 @@ fi echo "Testing pcregrep newline settings" echo "---------------------------- Test N1 ------------------------------" >testtry -$valgrind ./pcregrep -N CR "^(abc|def|ghi|jkl)" $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -N CR "^(abc|def|ghi|jkl)" ./testdata/grepinputx) >>testtry echo "---------------------------- Test N2 ------------------------------" >>testtry -$valgrind ./pcregrep --newline=crlf "^(abc|def|ghi|jkl)" $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep --newline=crlf "^(abc|def|ghi|jkl)" ./testdata/grepinputx) >>testtry echo "---------------------------- Test N3 ------------------------------" >>testtry pattern=`printf 'def\rjkl'` -$valgrind ./pcregrep --newline=cr -F "$pattern" $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep --newline=cr -F "$pattern" ./testdata/grepinputx) >>testtry echo "---------------------------- Test n$ ------------------------------" >>testtry pattern=`printf 'xxx\r\njkl'` -$valgrind ./pcregrep --newline=crlf -F "$pattern" $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep --newline=crlf -F "$pattern" ./testdata/grepinputx) >>testtry echo "---------------------------- Test N5 ------------------------------" >>testtry -$valgrind ./pcregrep -n --newline=any "^(abc|def|ghi|jkl)" $testdata/grepinputx >>testtry +(cd $srcdir; $valgrind $pcregrep -n --newline=any "^(abc|def|ghi|jkl)" ./testdata/grepinputx) >>testtry -$cf testtry $testdata/grepoutputN +$cf testtry $srcdir/testdata/grepoutputN if [ $? != 0 ] ; then exit 1; fi exit 0 |