| 1 |
#! /bin/sh |
#! /bin/sh |
| 2 |
|
|
|
# This file is generated by configure from RunGrepTest.in. Make any changes |
|
|
# to that file. |
|
|
|
|
|
echo "Testing pcregrep" |
|
|
./pcregrep -V |
|
|
|
|
| 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. |
| 6 |
|
|
| 7 |
cf=diff |
# Set the C locale, so that sort(1) behaves predictably. |
| 8 |
valgrind= |
LC_ALL=C |
| 9 |
if [ ! -d testdata ] ; then |
export LC_ALL |
| 10 |
ln -s @top_srcdir@/testdata testdata |
|
| 11 |
fi |
pcregrep=`pwd`/pcregrep |
| 12 |
testdata=./testdata |
|
| 13 |
|
echo " " |
| 14 |
|
echo "Testing pcregrep" |
| 15 |
|
$pcregrep -V |
| 16 |
|
|
| 17 |
|
valgrind= |
| 18 |
while [ $# -gt 0 ] ; do |
while [ $# -gt 0 ] ; do |
| 19 |
case $1 in |
case $1 in |
| 20 |
valgrind) valgrind="valgrind -q --leak-check=no";; |
valgrind) valgrind="valgrind -q --leak-check=no";; |
| 21 |
*) echo "Unknown argument $1"; exit 1;; |
*) echo "Unknown argument $1"; exit 1;; |
| 22 |
esac |
esac |
| 23 |
shift |
shift |
| 24 |
done |
done |
| 25 |
|
|
| 26 |
|
cf="diff -ub" |
| 27 |
|
|
| 28 |
|
# Set up a suitable "diff" command for comparison. Some systems have a diff |
| 29 |
|
# that lacks a -u option. Try to deal with this; better do the test for the -b |
| 30 |
|
# option as well. |
| 31 |
|
|
| 32 |
|
if diff -u /dev/null /dev/null; then |
| 33 |
|
if diff -ub /dev/null /dev/null; then cf="diff -ub"; else cf="diff -u"; fi |
| 34 |
|
else |
| 35 |
|
if diff -b /dev/null /dev/null; then cf="diff -b"; else cf="diff"; fi |
| 36 |
|
fi |
| 37 |
|
|
| 38 |
|
# If PCRE has been built in a directory other than the source directory, and |
| 39 |
|
# this test is being run from "make check" as usual, then $(srcdir) will be |
| 40 |
|
# set. If not, set it to the current directory. We then arrange to run the |
| 41 |
|
# pcregrep command in the source directory so that the file names that appear |
| 42 |
|
# in the output are always the same. |
| 43 |
|
|
| 44 |
|
if [ -z "$srcdir" -o ! -d "$srcdir/testdata" ] ; then |
| 45 |
|
srcdir=. |
| 46 |
|
fi |
| 47 |
|
|
| 48 |
|
# Check for the availability of UTF-8 support |
| 49 |
|
|
| 50 |
|
./pcretest -C | ./pcregrep "No UTF-8 support" >/dev/null |
| 51 |
|
utf8=$? |
| 52 |
|
|
| 53 |
echo "---------------------------- Test 1 ------------------------------" >testtry |
echo "---------------------------- Test 1 ------------------------------" >testtry |
| 54 |
$valgrind ./pcregrep PATTERN $testdata/grepinput >>testtry |
(cd $srcdir; $valgrind $pcregrep PATTERN ./testdata/grepinput) >>testtry |
| 55 |
|
echo "RC=$?" >>testtry |
| 56 |
|
|
| 57 |
echo "---------------------------- Test 2 ------------------------------" >>testtry |
echo "---------------------------- Test 2 ------------------------------" >>testtry |
| 58 |
$valgrind ./pcregrep '^PATTERN' $testdata/grepinput >>testtry |
(cd $srcdir; $valgrind $pcregrep '^PATTERN' ./testdata/grepinput) >>testtry |
| 59 |
|
echo "RC=$?" >>testtry |
| 60 |
|
|
| 61 |
echo "---------------------------- Test 3 ------------------------------" >>testtry |
echo "---------------------------- Test 3 ------------------------------" >>testtry |
| 62 |
$valgrind ./pcregrep -in PATTERN $testdata/grepinput >>testtry |
(cd $srcdir; $valgrind $pcregrep -in PATTERN ./testdata/grepinput) >>testtry |
| 63 |
|
echo "RC=$?" >>testtry |
| 64 |
|
|
| 65 |
echo "---------------------------- Test 4 ------------------------------" >>testtry |
echo "---------------------------- Test 4 ------------------------------" >>testtry |
| 66 |
$valgrind ./pcregrep -ic PATTERN $testdata/grepinput >>testtry |
(cd $srcdir; $valgrind $pcregrep -ic PATTERN ./testdata/grepinput) >>testtry |
| 67 |
|
echo "RC=$?" >>testtry |
| 68 |
|
|
| 69 |
echo "---------------------------- Test 5 ------------------------------" >>testtry |
echo "---------------------------- Test 5 ------------------------------" >>testtry |
| 70 |
$valgrind ./pcregrep -in PATTERN $testdata/grepinput $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -in PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry |
| 71 |
|
echo "RC=$?" >>testtry |
| 72 |
|
|
| 73 |
echo "---------------------------- Test 6 ------------------------------" >>testtry |
echo "---------------------------- Test 6 ------------------------------" >>testtry |
| 74 |
$valgrind ./pcregrep -inh PATTERN $testdata/grepinput $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -inh PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry |
| 75 |
|
echo "RC=$?" >>testtry |
| 76 |
|
|
| 77 |
echo "---------------------------- Test 7 ------------------------------" >>testtry |
echo "---------------------------- Test 7 ------------------------------" >>testtry |
| 78 |
$valgrind ./pcregrep -il PATTERN $testdata/grepinput $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -il PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry |
| 79 |
|
echo "RC=$?" >>testtry |
| 80 |
|
|
| 81 |
echo "---------------------------- Test 8 ------------------------------" >>testtry |
echo "---------------------------- Test 8 ------------------------------" >>testtry |
| 82 |
$valgrind ./pcregrep -l PATTERN $testdata/grepinput $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -l PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry |
| 83 |
|
echo "RC=$?" >>testtry |
| 84 |
|
|
| 85 |
echo "---------------------------- Test 9 ------------------------------" >>testtry |
echo "---------------------------- Test 9 ------------------------------" >>testtry |
| 86 |
$valgrind ./pcregrep -q PATTERN $testdata/grepinput $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -q PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry |
| 87 |
echo "RC=$?" >>testtry |
echo "RC=$?" >>testtry |
| 88 |
|
|
| 89 |
echo "---------------------------- Test 10 -----------------------------" >>testtry |
echo "---------------------------- Test 10 -----------------------------" >>testtry |
| 90 |
$valgrind ./pcregrep -q NEVER-PATTERN $testdata/grepinput $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -q NEVER-PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry |
| 91 |
echo "RC=$?" >>testtry |
echo "RC=$?" >>testtry |
| 92 |
|
|
| 93 |
echo "---------------------------- Test 11 -----------------------------" >>testtry |
echo "---------------------------- Test 11 -----------------------------" >>testtry |
| 94 |
$valgrind ./pcregrep -vn pattern $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -vn pattern ./testdata/grepinputx) >>testtry |
| 95 |
|
echo "RC=$?" >>testtry |
| 96 |
|
|
| 97 |
echo "---------------------------- Test 12 -----------------------------" >>testtry |
echo "---------------------------- Test 12 -----------------------------" >>testtry |
| 98 |
$valgrind ./pcregrep -ix pattern $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -ix pattern ./testdata/grepinputx) >>testtry |
| 99 |
|
echo "RC=$?" >>testtry |
| 100 |
|
|
| 101 |
echo "---------------------------- Test 13 -----------------------------" >>testtry |
echo "---------------------------- Test 13 -----------------------------" >>testtry |
| 102 |
$valgrind ./pcregrep -f$testdata/greplist $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -f./testdata/greplist ./testdata/grepinputx) >>testtry |
| 103 |
|
echo "RC=$?" >>testtry |
| 104 |
|
|
| 105 |
echo "---------------------------- Test 14 -----------------------------" >>testtry |
echo "---------------------------- Test 14 -----------------------------" >>testtry |
| 106 |
$valgrind ./pcregrep -w pat $testdata/grepinput $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -w pat ./testdata/grepinput ./testdata/grepinputx) >>testtry |
| 107 |
|
echo "RC=$?" >>testtry |
| 108 |
|
|
| 109 |
echo "---------------------------- Test 15 -----------------------------" >>testtry |
echo "---------------------------- Test 15 -----------------------------" >>testtry |
| 110 |
$valgrind ./pcregrep 'abc^*' $testdata/grepinput 2>>testtry >>testtry |
(cd $srcdir; $valgrind $pcregrep 'abc^*' ./testdata/grepinput) 2>>testtry >>testtry |
| 111 |
|
echo "RC=$?" >>testtry |
| 112 |
|
|
| 113 |
echo "---------------------------- Test 16 -----------------------------" >>testtry |
echo "---------------------------- Test 16 -----------------------------" >>testtry |
| 114 |
$valgrind ./pcregrep abc $testdata/grepinput $testdata/nonexistfile 2>>testtry >>testtry |
(cd $srcdir; $valgrind $pcregrep abc ./testdata/grepinput ./testdata/nonexistfile) 2>>testtry >>testtry |
| 115 |
|
echo "RC=$?" >>testtry |
| 116 |
|
|
| 117 |
echo "---------------------------- Test 17 -----------------------------" >>testtry |
echo "---------------------------- Test 17 -----------------------------" >>testtry |
| 118 |
$valgrind ./pcregrep -M 'the\noutput' $testdata/grepinput >>testtry |
(cd $srcdir; $valgrind $pcregrep -M 'the\noutput' ./testdata/grepinput) >>testtry |
| 119 |
|
echo "RC=$?" >>testtry |
| 120 |
|
|
| 121 |
echo "---------------------------- Test 18 -----------------------------" >>testtry |
echo "---------------------------- Test 18 -----------------------------" >>testtry |
| 122 |
$valgrind ./pcregrep -Mn '(the\noutput|dog\.\n--)' $testdata/grepinput >>testtry |
(cd $srcdir; $valgrind $pcregrep -Mn '(the\noutput|dog\.\n--)' ./testdata/grepinput) >>testtry |
| 123 |
|
echo "RC=$?" >>testtry |
| 124 |
|
|
| 125 |
echo "---------------------------- Test 19 -----------------------------" >>testtry |
echo "---------------------------- Test 19 -----------------------------" >>testtry |
| 126 |
$valgrind ./pcregrep -Mix 'Pattern' $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -Mix 'Pattern' ./testdata/grepinputx) >>testtry |
| 127 |
|
echo "RC=$?" >>testtry |
| 128 |
|
|
| 129 |
echo "---------------------------- Test 20 -----------------------------" >>testtry |
echo "---------------------------- Test 20 -----------------------------" >>testtry |
| 130 |
$valgrind ./pcregrep -Mixn 'complete pair\nof lines' $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -Mixn 'complete pair\nof lines' ./testdata/grepinputx) >>testtry |
| 131 |
|
echo "RC=$?" >>testtry |
| 132 |
|
|
| 133 |
echo "---------------------------- Test 21 -----------------------------" >>testtry |
echo "---------------------------- Test 21 -----------------------------" >>testtry |
| 134 |
$valgrind ./pcregrep -nA3 'four' $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -nA3 'four' ./testdata/grepinputx) >>testtry |
| 135 |
|
echo "RC=$?" >>testtry |
| 136 |
|
|
| 137 |
echo "---------------------------- Test 22 -----------------------------" >>testtry |
echo "---------------------------- Test 22 -----------------------------" >>testtry |
| 138 |
$valgrind ./pcregrep -nB3 'four' $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -nB3 'four' ./testdata/grepinputx) >>testtry |
| 139 |
|
echo "RC=$?" >>testtry |
| 140 |
|
|
| 141 |
echo "---------------------------- Test 23 -----------------------------" >>testtry |
echo "---------------------------- Test 23 -----------------------------" >>testtry |
| 142 |
$valgrind ./pcregrep -C3 'four' $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -C3 'four' ./testdata/grepinputx) >>testtry |
| 143 |
|
echo "RC=$?" >>testtry |
| 144 |
|
|
| 145 |
echo "---------------------------- Test 24 -----------------------------" >>testtry |
echo "---------------------------- Test 24 -----------------------------" >>testtry |
| 146 |
$valgrind ./pcregrep -A9 'four' $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -A9 'four' ./testdata/grepinputx) >>testtry |
| 147 |
|
echo "RC=$?" >>testtry |
| 148 |
|
|
| 149 |
echo "---------------------------- Test 25 -----------------------------" >>testtry |
echo "---------------------------- Test 25 -----------------------------" >>testtry |
| 150 |
$valgrind ./pcregrep -nB9 'four' $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -nB9 'four' ./testdata/grepinputx) >>testtry |
| 151 |
|
echo "RC=$?" >>testtry |
| 152 |
|
|
| 153 |
echo "---------------------------- Test 26 -----------------------------" >>testtry |
echo "---------------------------- Test 26 -----------------------------" >>testtry |
| 154 |
$valgrind ./pcregrep -A9 -B9 'four' $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -A9 -B9 'four' ./testdata/grepinputx) >>testtry |
| 155 |
|
echo "RC=$?" >>testtry |
| 156 |
|
|
| 157 |
echo "---------------------------- Test 27 -----------------------------" >>testtry |
echo "---------------------------- Test 27 -----------------------------" >>testtry |
| 158 |
$valgrind ./pcregrep -A10 'four' $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -A10 'four' ./testdata/grepinputx) >>testtry |
| 159 |
|
echo "RC=$?" >>testtry |
| 160 |
|
|
| 161 |
echo "---------------------------- Test 28 -----------------------------" >>testtry |
echo "---------------------------- Test 28 -----------------------------" >>testtry |
| 162 |
$valgrind ./pcregrep -nB10 'four' $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -nB10 'four' ./testdata/grepinputx) >>testtry |
| 163 |
|
echo "RC=$?" >>testtry |
| 164 |
|
|
| 165 |
echo "---------------------------- Test 29 -----------------------------" >>testtry |
echo "---------------------------- Test 29 -----------------------------" >>testtry |
| 166 |
$valgrind ./pcregrep -C12 -B10 'four' $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -C12 -B10 'four' ./testdata/grepinputx) >>testtry |
| 167 |
|
echo "RC=$?" >>testtry |
| 168 |
|
|
| 169 |
echo "---------------------------- Test 30 -----------------------------" >>testtry |
echo "---------------------------- Test 30 -----------------------------" >>testtry |
| 170 |
$valgrind ./pcregrep -inB3 'pattern' $testdata/grepinput $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -inB3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtry |
| 171 |
|
echo "RC=$?" >>testtry |
| 172 |
|
|
| 173 |
echo "---------------------------- Test 31 -----------------------------" >>testtry |
echo "---------------------------- Test 31 -----------------------------" >>testtry |
| 174 |
$valgrind ./pcregrep -inA3 'pattern' $testdata/grepinput $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -inA3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtry |
| 175 |
|
echo "RC=$?" >>testtry |
| 176 |
|
|
| 177 |
echo "---------------------------- Test 32 -----------------------------" >>testtry |
echo "---------------------------- Test 32 -----------------------------" >>testtry |
| 178 |
$valgrind ./pcregrep -L 'fox' $testdata/grepinput $testdata/grepinputx >>testtry |
(cd $srcdir; $valgrind $pcregrep -L 'fox' ./testdata/grepinput ./testdata/grepinputx) >>testtry |
| 179 |
|
echo "RC=$?" >>testtry |
| 180 |
|
|
| 181 |
echo "---------------------------- Test 33 -----------------------------" >>testtry |
echo "---------------------------- Test 33 -----------------------------" >>testtry |
| 182 |
$valgrind ./pcregrep 'fox' $testdata/grepnonexist >>testtry 2>&1 |
(cd $srcdir; $valgrind $pcregrep 'fox' ./testdata/grepnonexist) >>testtry 2>&1 |
| 183 |
echo "RC=$?" >>testtry |
echo "RC=$?" >>testtry |
| 184 |
|
|
| 185 |
echo "---------------------------- Test 34 -----------------------------" >>testtry |
echo "---------------------------- Test 34 -----------------------------" >>testtry |
| 186 |
$valgrind ./pcregrep -s 'fox' $testdata/grepnonexist >>testtry 2>&1 |
(cd $srcdir; $valgrind $pcregrep -s 'fox' ./testdata/grepnonexist) >>testtry 2>&1 |
| 187 |
echo "RC=$?" >>testtry |
echo "RC=$?" >>testtry |
| 188 |
|
|
| 189 |
echo "---------------------------- Test 35 -----------------------------" >>testtry |
echo "---------------------------- Test 35 -----------------------------" >>testtry |
| 190 |
$valgrind ./pcregrep -L -r --include=grepinputx 'fox' $testdata >>testtry |
(cd $srcdir; $valgrind $pcregrep -L -r --include=grepinputx --exclude_dir='^\.' 'fox' ./testdata) >>testtry |
| 191 |
echo "RC=$?" >>testtry |
echo "RC=$?" >>testtry |
| 192 |
|
|
| 193 |
echo "---------------------------- Test 36 -----------------------------" >>testtry |
echo "---------------------------- Test 36 -----------------------------" >>testtry |
| 194 |
$valgrind ./pcregrep -L -r --include=grepinput --exclude 'grepinput$' 'fox' $testdata >>testtry |
(cd $srcdir; $valgrind $pcregrep -L -r --include=grepinput --exclude 'grepinput$' --exclude_dir='^\.' 'fox' ./testdata | sort) >>testtry |
| 195 |
echo "RC=$?" >>testtry |
echo "RC=$?" >>testtry |
| 196 |
|
|
| 197 |
echo "---------------------------- Test 37 -----------------------------" >>testtry |
echo "---------------------------- Test 37 -----------------------------" >>testtry |
| 198 |
$valgrind ./pcregrep '^(a+)*\d' $testdata/grepinput >>testtry 2>teststderr |
(cd $srcdir; $valgrind $pcregrep '^(a+)*\d' ./testdata/grepinput) >>testtry 2>teststderr |
| 199 |
echo "RC=$?" >>testtry |
echo "RC=$?" >>testtry |
| 200 |
echo "======== STDERR ========" >>testtry |
echo "======== STDERR ========" >>testtry |
| 201 |
cat teststderr >>testtry |
cat teststderr >>testtry |
| 202 |
|
|
| 203 |
echo "---------------------------- Test 38 ------------------------------" >>testtry |
echo "---------------------------- Test 38 ------------------------------" >>testtry |
| 204 |
$valgrind ./pcregrep '>\x00<' $testdata/grepinput >>testtry |
(cd $srcdir; $valgrind $pcregrep '>\x00<' ./testdata/grepinput) >>testtry |
| 205 |
|
echo "RC=$?" >>testtry |
| 206 |
|
|
| 207 |
echo "---------------------------- Test 39 ------------------------------" >>testtry |
echo "---------------------------- Test 39 ------------------------------" >>testtry |
| 208 |
$valgrind ./pcregrep -A1 'before the binary zero' $testdata/grepinput >>testtry |
(cd $srcdir; $valgrind $pcregrep -A1 'before the binary zero' ./testdata/grepinput) >>testtry |
| 209 |
|
echo "RC=$?" >>testtry |
| 210 |
|
|
| 211 |
echo "---------------------------- Test 40 ------------------------------" >>testtry |
echo "---------------------------- Test 40 ------------------------------" >>testtry |
| 212 |
$valgrind ./pcregrep -B1 'after the binary zero' $testdata/grepinput >>testtry |
(cd $srcdir; $valgrind $pcregrep -B1 'after the binary zero' ./testdata/grepinput) >>testtry |
| 213 |
|
echo "RC=$?" >>testtry |
|
echo "---------------------------- Test 41 ------------------------------" >>testtry |
|
|
$valgrind ./pcregrep -B1 -o '\w+ the binary zero' $testdata/grepinput >>testtry |
|
| 214 |
|
|
| 215 |
echo "---------------------------- Test 41 ------------------------------" >>testtry |
echo "---------------------------- Test 41 ------------------------------" >>testtry |
| 216 |
$valgrind ./pcregrep -B1 -onH '\w+ the binary zero' $testdata/grepinput >>testtry |
(cd $srcdir; $valgrind $pcregrep -B1 -o '\w+ the binary zero' ./testdata/grepinput) >>testtry |
| 217 |
|
echo "RC=$?" >>testtry |
| 218 |
|
|
| 219 |
echo "---------------------------- Test 42 ------------------------------" >>testtry |
echo "---------------------------- Test 42 ------------------------------" >>testtry |
| 220 |
$valgrind ./pcregrep -on 'before|zero|after' $testdata/grepinput >>testtry |
(cd $srcdir; $valgrind $pcregrep -B1 -onH '\w+ the binary zero' ./testdata/grepinput) >>testtry |
| 221 |
|
echo "RC=$?" >>testtry |
| 222 |
|
|
| 223 |
echo "---------------------------- Test 43 ------------------------------" >>testtry |
echo "---------------------------- Test 43 ------------------------------" >>testtry |
| 224 |
$valgrind ./pcregrep -on -e before -e zero -e after $testdata/grepinput >>testtry |
(cd $srcdir; $valgrind $pcregrep -on 'before|zero|after' ./testdata/grepinput) >>testtry |
| 225 |
|
echo "RC=$?" >>testtry |
| 226 |
|
|
| 227 |
echo "---------------------------- Test 44 ------------------------------" >>testtry |
echo "---------------------------- Test 44 ------------------------------" >>testtry |
| 228 |
$valgrind ./pcregrep -on -f $testdata/greplist -e binary $testdata/grepinput >>testtry |
(cd $srcdir; $valgrind $pcregrep -on -e before -ezero -e after ./testdata/grepinput) >>testtry |
| 229 |
|
echo "RC=$?" >>testtry |
| 230 |
|
|
| 231 |
echo "---------------------------- Test 45 ------------------------------" >>testtry |
echo "---------------------------- Test 45 ------------------------------" >>testtry |
| 232 |
$valgrind ./pcregrep -e abc -e '(unclosed' $testdata/grepinput 2>>testtry >>testtry |
(cd $srcdir; $valgrind $pcregrep -on -f ./testdata/greplist -e binary ./testdata/grepinput) >>testtry |
| 233 |
|
echo "RC=$?" >>testtry |
| 234 |
|
|
| 235 |
echo "---------------------------- Test 46 ------------------------------" >>testtry |
echo "---------------------------- Test 46 ------------------------------" >>testtry |
| 236 |
$valgrind ./pcregrep -Fx "AB.VE |
(cd $srcdir; $valgrind $pcregrep -eabc -e '(unclosed' ./testdata/grepinput) 2>>testtry >>testtry |
| 237 |
elephant" $testdata/grepinput >>testtry |
echo "RC=$?" >>testtry |
| 238 |
|
|
| 239 |
echo "---------------------------- Test 47 ------------------------------" >>testtry |
echo "---------------------------- Test 47 ------------------------------" >>testtry |
| 240 |
$valgrind ./pcregrep -F "AB.VE |
(cd $srcdir; $valgrind $pcregrep -Fx "AB.VE |
| 241 |
elephant" $testdata/grepinput >>testtry |
elephant" ./testdata/grepinput) >>testtry |
| 242 |
|
echo "RC=$?" >>testtry |
| 243 |
|
|
| 244 |
echo "---------------------------- Test 48 ------------------------------" >>testtry |
echo "---------------------------- Test 48 ------------------------------" >>testtry |
| 245 |
$valgrind ./pcregrep -F -e DATA -e "AB.VE |
(cd $srcdir; $valgrind $pcregrep -F "AB.VE |
| 246 |
elephant" $testdata/grepinput >>testtry |
elephant" ./testdata/grepinput) >>testtry |
| 247 |
|
echo "RC=$?" >>testtry |
| 248 |
|
|
| 249 |
|
echo "---------------------------- Test 49 ------------------------------" >>testtry |
| 250 |
|
(cd $srcdir; $valgrind $pcregrep -F -e DATA -e "AB.VE |
| 251 |
|
elephant" ./testdata/grepinput) >>testtry |
| 252 |
|
echo "RC=$?" >>testtry |
| 253 |
|
|
| 254 |
|
echo "---------------------------- Test 50 ------------------------------" >>testtry |
| 255 |
|
(cd $srcdir; $valgrind $pcregrep "^(abc|def|ghi|jkl)" ./testdata/grepinputx) >>testtry |
| 256 |
|
echo "RC=$?" >>testtry |
| 257 |
|
|
| 258 |
|
echo "---------------------------- Test 51 ------------------------------" >>testtry |
| 259 |
|
(cd $srcdir; $valgrind $pcregrep -Mv "brown\sfox" ./testdata/grepinputv) >>testtry |
| 260 |
|
echo "RC=$?" >>testtry |
| 261 |
|
|
| 262 |
|
echo "---------------------------- Test 52 ------------------------------" >>testtry |
| 263 |
|
(cd $srcdir; $valgrind $pcregrep --colour=always jumps ./testdata/grepinputv) >>testtry |
| 264 |
|
echo "RC=$?" >>testtry |
| 265 |
|
|
| 266 |
|
echo "---------------------------- Test 53 ------------------------------" >>testtry |
| 267 |
|
(cd $srcdir; $valgrind $pcregrep --file-offsets 'before|zero|after' ./testdata/grepinput) >>testtry |
| 268 |
|
echo "RC=$?" >>testtry |
| 269 |
|
|
| 270 |
|
echo "---------------------------- Test 54 ------------------------------" >>testtry |
| 271 |
|
(cd $srcdir; $valgrind $pcregrep --line-offsets 'before|zero|after' ./testdata/grepinput) >>testtry |
| 272 |
|
echo "RC=$?" >>testtry |
| 273 |
|
|
| 274 |
|
echo "---------------------------- Test 55 -----------------------------" >>testtry |
| 275 |
|
(cd $srcdir; $valgrind $pcregrep -f./testdata/greplist --color=always ./testdata/grepinputx) >>testtry |
| 276 |
|
echo "RC=$?" >>testtry |
| 277 |
|
|
| 278 |
|
echo "---------------------------- Test 56 -----------------------------" >>testtry |
| 279 |
|
(cd $srcdir; $valgrind $pcregrep -c lazy ./testdata/grepinput*) >>testtry |
| 280 |
|
echo "RC=$?" >>testtry |
| 281 |
|
|
| 282 |
|
echo "---------------------------- Test 57 -----------------------------" >>testtry |
| 283 |
|
(cd $srcdir; $valgrind $pcregrep -c -l lazy ./testdata/grepinput*) >>testtry |
| 284 |
|
echo "RC=$?" >>testtry |
| 285 |
|
|
| 286 |
|
echo "---------------------------- Test 58 -----------------------------" >>testtry |
| 287 |
|
(cd $srcdir; $valgrind $pcregrep --regex=PATTERN ./testdata/grepinput) >>testtry |
| 288 |
|
echo "RC=$?" >>testtry |
| 289 |
|
|
| 290 |
|
echo "---------------------------- Test 59 -----------------------------" >>testtry |
| 291 |
|
(cd $srcdir; $valgrind $pcregrep --regexp=PATTERN ./testdata/grepinput) >>testtry |
| 292 |
|
echo "RC=$?" >>testtry |
| 293 |
|
|
| 294 |
|
echo "---------------------------- Test 60 -----------------------------" >>testtry |
| 295 |
|
(cd $srcdir; $valgrind $pcregrep --regex PATTERN ./testdata/grepinput) >>testtry |
| 296 |
|
echo "RC=$?" >>testtry |
| 297 |
|
|
| 298 |
|
echo "---------------------------- Test 61 -----------------------------" >>testtry |
| 299 |
|
(cd $srcdir; $valgrind $pcregrep --regexp PATTERN ./testdata/grepinput) >>testtry |
| 300 |
|
echo "RC=$?" >>testtry |
| 301 |
|
|
| 302 |
|
echo "---------------------------- Test 62 -----------------------------" >>testtry |
| 303 |
|
(cd $srcdir; $valgrind $pcregrep --match-limit=1000 -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtry 2>&1 |
| 304 |
|
echo "RC=$?" >>testtry |
| 305 |
|
|
| 306 |
|
echo "---------------------------- Test 63 -----------------------------" >>testtry |
| 307 |
|
(cd $srcdir; $valgrind $pcregrep --recursion-limit=1000 -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtry 2>&1 |
| 308 |
|
echo "RC=$?" >>testtry |
| 309 |
|
|
| 310 |
|
echo "---------------------------- Test 64 ------------------------------" >>testtry |
| 311 |
|
(cd $srcdir; $valgrind $pcregrep -o1 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtry |
| 312 |
|
echo "RC=$?" >>testtry |
| 313 |
|
|
| 314 |
|
echo "---------------------------- Test 65 ------------------------------" >>testtry |
| 315 |
|
(cd $srcdir; $valgrind $pcregrep -o2 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtry |
| 316 |
|
echo "RC=$?" >>testtry |
| 317 |
|
|
| 318 |
|
echo "---------------------------- Test 66 ------------------------------" >>testtry |
| 319 |
|
(cd $srcdir; $valgrind $pcregrep -o3 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtry |
| 320 |
|
echo "RC=$?" >>testtry |
| 321 |
|
|
| 322 |
|
echo "---------------------------- Test 67 ------------------------------" >>testtry |
| 323 |
|
(cd $srcdir; $valgrind $pcregrep -o12 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtry |
| 324 |
|
echo "RC=$?" >>testtry |
| 325 |
|
|
| 326 |
|
echo "---------------------------- Test 68 ------------------------------" >>testtry |
| 327 |
|
(cd $srcdir; $valgrind $pcregrep --only-matching=2 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtry |
| 328 |
|
echo "RC=$?" >>testtry |
| 329 |
|
|
| 330 |
# Now compare the results. |
# Now compare the results. |
| 331 |
|
|
| 332 |
$cf testtry $testdata/grepoutput |
$cf $srcdir/testdata/grepoutput testtry |
| 333 |
if [ $? != 0 ] ; then exit 1; else exit 0; fi |
if [ $? != 0 ] ; then exit 1; fi |
| 334 |
|
|
| 335 |
|
|
| 336 |
|
# These tests require UTF-8 support |
| 337 |
|
|
| 338 |
|
if [ $utf8 -ne 0 ] ; then |
| 339 |
|
echo "Testing pcregrep UTF-8 features" |
| 340 |
|
|
| 341 |
|
echo "---------------------------- Test U1 ------------------------------" >testtry |
| 342 |
|
(cd $srcdir; $valgrind $pcregrep -n -u --newline=any "^X" ./testdata/grepinput8) >>testtry |
| 343 |
|
echo "RC=$?" >>testtry |
| 344 |
|
|
| 345 |
|
echo "---------------------------- Test U2 ------------------------------" >>testtry |
| 346 |
|
(cd $srcdir; $valgrind $pcregrep -n -u -C 3 --newline=any "Match" ./testdata/grepinput8) >>testtry |
| 347 |
|
echo "RC=$?" >>testtry |
| 348 |
|
|
| 349 |
|
$cf $srcdir/testdata/grepoutput8 testtry |
| 350 |
|
if [ $? != 0 ] ; then exit 1; fi |
| 351 |
|
|
| 352 |
|
else |
| 353 |
|
echo "Skipping pcregrep UTF-8 tests: no UTF-8 support in PCRE library" |
| 354 |
|
fi |
| 355 |
|
|
| 356 |
|
|
| 357 |
|
# We go to some contortions to try to ensure that the tests for the various |
| 358 |
|
# newline settings will work in environments where the normal newline sequence |
| 359 |
|
# is not \n. Do not use exported files, whose line endings might be changed. |
| 360 |
|
# Instead, create an input file using printf so that its contents are exactly |
| 361 |
|
# what we want. Note the messy fudge to get printf to write a string that |
| 362 |
|
# starts with a hyphen. |
| 363 |
|
|
| 364 |
|
echo "Testing pcregrep newline settings" |
| 365 |
|
printf "abc\rdef\r\nghi\njkl" >testNinput |
| 366 |
|
|
| 367 |
|
printf "%c--------------------------- Test N1 ------------------------------\r\n" - >testtry |
| 368 |
|
$valgrind $pcregrep -n -N CR "^(abc|def|ghi|jkl)" testNinput >>testtry |
| 369 |
|
|
| 370 |
|
printf "%c--------------------------- Test N2 ------------------------------\r\n" - >>testtry |
| 371 |
|
$valgrind $pcregrep -n --newline=crlf "^(abc|def|ghi|jkl)" testNinput >>testtry |
| 372 |
|
|
| 373 |
|
printf "%c--------------------------- Test N3 ------------------------------\r\n" - >>testtry |
| 374 |
|
pattern=`printf 'def\rjkl'` |
| 375 |
|
$valgrind $pcregrep -n --newline=cr -F "$pattern" testNinput >>testtry |
| 376 |
|
|
| 377 |
|
printf "%c--------------------------- Test N4 ------------------------------\r\n" - >>testtry |
| 378 |
|
pattern=`printf 'xxx\r\njkl'` |
| 379 |
|
$valgrind $pcregrep -n --newline=crlf -F "$pattern" testNinput >>testtry |
| 380 |
|
|
| 381 |
|
printf "%c--------------------------- Test N5 ------------------------------\r\n" - >>testtry |
| 382 |
|
$valgrind $pcregrep -n --newline=any "^(abc|def|ghi|jkl)" testNinput >>testtry |
| 383 |
|
|
| 384 |
|
printf "%c--------------------------- Test N6 ------------------------------\r\n" - >>testtry |
| 385 |
|
$valgrind $pcregrep -n --newline=anycrlf "^(abc|def|ghi|jkl)" testNinput >>testtry |
| 386 |
|
|
| 387 |
|
$cf $srcdir/testdata/grepoutputN testtry |
| 388 |
|
if [ $? != 0 ] ; then exit 1; fi |
| 389 |
|
|
| 390 |
|
exit 0 |
| 391 |
|
|
| 392 |
# End |
# End |