1#! /bin/sh 2 3# 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 5# supported by pcregrep. This script must be run in the build directory. 6 7# Set the C locale, so that sort(1) behaves predictably. 8 9LC_ALL=C 10export LC_ALL 11 12# Remove any non-default colouring and aliases that the caller may have set. 13 14unset PCREGREP_COLOUR PCREGREP_COLOR 15unset cp ls mv rm 16 17# Remember the current (build) directory, set the program to be tested, and 18# valgrind settings when requested. 19 20builddir=`pwd` 21pcregrep=$builddir/pcregrep 22 23valgrind= 24while [ $# -gt 0 ] ; do 25 case $1 in 26 valgrind) valgrind="valgrind -q --leak-check=no --smc-check=all";; 27 *) echo "RunGrepTest: Unknown argument $1"; exit 1;; 28 esac 29 shift 30done 31 32echo " " 33pcregrep_version=`$pcregrep -V` 34if [ "$valgrind" = "" ] ; then 35 echo "Testing $pcregrep_version" 36else 37 echo "Testing $pcregrep_version using valgrind" 38fi 39 40# 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 42# option as well. 43 44cf="diff" 45diff -b /dev/null /dev/null 2>/dev/null && cf="diff -b" 46diff -u /dev/null /dev/null 2>/dev/null && cf="diff -u" 47diff -ub /dev/null /dev/null 2>/dev/null && cf="diff -ub" 48 49# If this test is being run from "make check", $srcdir will be set. If not, set 50# it to the current or parent directory, whichever one contains the test data. 51# Subsequently, we run most of the pcregrep tests in the source directory so 52# that the file names in the output are always the same. 53 54if [ -z "$srcdir" -o ! -d "$srcdir/testdata" ] ; then 55 if [ -d "./testdata" ] ; then 56 srcdir=. 57 elif [ -d "../testdata" ] ; then 58 srcdir=.. 59 else 60 echo "Cannot find the testdata directory" 61 exit 1 62 fi 63fi 64 65# Check for the availability of UTF-8 support 66 67./pcretest -C utf >/dev/null 68utf8=$? 69 70# We need valgrind suppressions when JIT is in use. (This isn't perfect because 71# some tests are run with -no-jit, but as PCRE1 is in maintenance only, I have 72# not bothered about that.) 73 74./pcretest -C jit >/dev/null 75if [ $? -eq 1 -a "$valgrind" != "" ] ; then 76 valgrind="$valgrind --suppressions=./testdata/valgrind-jit.supp" 77fi 78 79echo "Testing pcregrep main features" 80 81echo "---------------------------- Test 1 ------------------------------" >testtrygrep 82(cd $srcdir; $valgrind $pcregrep PATTERN ./testdata/grepinput) >>testtrygrep 83echo "RC=$?" >>testtrygrep 84 85echo "---------------------------- Test 2 ------------------------------" >>testtrygrep 86(cd $srcdir; $valgrind $pcregrep '^PATTERN' ./testdata/grepinput) >>testtrygrep 87echo "RC=$?" >>testtrygrep 88 89echo "---------------------------- Test 3 ------------------------------" >>testtrygrep 90(cd $srcdir; $valgrind $pcregrep -in PATTERN ./testdata/grepinput) >>testtrygrep 91echo "RC=$?" >>testtrygrep 92 93echo "---------------------------- Test 4 ------------------------------" >>testtrygrep 94(cd $srcdir; $valgrind $pcregrep -ic PATTERN ./testdata/grepinput) >>testtrygrep 95echo "RC=$?" >>testtrygrep 96 97echo "---------------------------- Test 5 ------------------------------" >>testtrygrep 98(cd $srcdir; $valgrind $pcregrep -in PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep 99echo "RC=$?" >>testtrygrep 100 101echo "---------------------------- Test 6 ------------------------------" >>testtrygrep 102(cd $srcdir; $valgrind $pcregrep -inh PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep 103echo "RC=$?" >>testtrygrep 104 105echo "---------------------------- Test 7 ------------------------------" >>testtrygrep 106(cd $srcdir; $valgrind $pcregrep -il PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep 107echo "RC=$?" >>testtrygrep 108 109echo "---------------------------- Test 8 ------------------------------" >>testtrygrep 110(cd $srcdir; $valgrind $pcregrep -l PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep 111echo "RC=$?" >>testtrygrep 112 113echo "---------------------------- Test 9 ------------------------------" >>testtrygrep 114(cd $srcdir; $valgrind $pcregrep -q PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep 115echo "RC=$?" >>testtrygrep 116 117echo "---------------------------- Test 10 -----------------------------" >>testtrygrep 118(cd $srcdir; $valgrind $pcregrep -q NEVER-PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep 119echo "RC=$?" >>testtrygrep 120 121echo "---------------------------- Test 11 -----------------------------" >>testtrygrep 122(cd $srcdir; $valgrind $pcregrep -vn pattern ./testdata/grepinputx) >>testtrygrep 123echo "RC=$?" >>testtrygrep 124 125echo "---------------------------- Test 12 -----------------------------" >>testtrygrep 126(cd $srcdir; $valgrind $pcregrep -ix pattern ./testdata/grepinputx) >>testtrygrep 127echo "RC=$?" >>testtrygrep 128 129echo "---------------------------- Test 13 -----------------------------" >>testtrygrep 130echo seventeen >testtemp1grep 131(cd $srcdir; $valgrind $pcregrep -f./testdata/greplist -f $builddir/testtemp1grep ./testdata/grepinputx) >>testtrygrep 132echo "RC=$?" >>testtrygrep 133 134echo "---------------------------- Test 14 -----------------------------" >>testtrygrep 135(cd $srcdir; $valgrind $pcregrep -w pat ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep 136echo "RC=$?" >>testtrygrep 137 138echo "---------------------------- Test 15 -----------------------------" >>testtrygrep 139(cd $srcdir; $valgrind $pcregrep 'abc^*' ./testdata/grepinput) 2>>testtrygrep >>testtrygrep 140echo "RC=$?" >>testtrygrep 141 142echo "---------------------------- Test 16 -----------------------------" >>testtrygrep 143(cd $srcdir; $valgrind $pcregrep abc ./testdata/grepinput ./testdata/nonexistfile) 2>>testtrygrep >>testtrygrep 144echo "RC=$?" >>testtrygrep 145 146echo "---------------------------- Test 17 -----------------------------" >>testtrygrep 147(cd $srcdir; $valgrind $pcregrep -M 'the\noutput' ./testdata/grepinput) >>testtrygrep 148echo "RC=$?" >>testtrygrep 149 150echo "---------------------------- Test 18 -----------------------------" >>testtrygrep 151(cd $srcdir; $valgrind $pcregrep -Mn '(the\noutput|dog\.\n--)' ./testdata/grepinput) >>testtrygrep 152echo "RC=$?" >>testtrygrep 153 154echo "---------------------------- Test 19 -----------------------------" >>testtrygrep 155(cd $srcdir; $valgrind $pcregrep -Mix 'Pattern' ./testdata/grepinputx) >>testtrygrep 156echo "RC=$?" >>testtrygrep 157 158echo "---------------------------- Test 20 -----------------------------" >>testtrygrep 159(cd $srcdir; $valgrind $pcregrep -Mixn 'complete pair\nof lines' ./testdata/grepinputx) >>testtrygrep 160echo "RC=$?" >>testtrygrep 161 162echo "---------------------------- Test 21 -----------------------------" >>testtrygrep 163(cd $srcdir; $valgrind $pcregrep -nA3 'four' ./testdata/grepinputx) >>testtrygrep 164echo "RC=$?" >>testtrygrep 165 166echo "---------------------------- Test 22 -----------------------------" >>testtrygrep 167(cd $srcdir; $valgrind $pcregrep -nB3 'four' ./testdata/grepinputx) >>testtrygrep 168echo "RC=$?" >>testtrygrep 169 170echo "---------------------------- Test 23 -----------------------------" >>testtrygrep 171(cd $srcdir; $valgrind $pcregrep -C3 'four' ./testdata/grepinputx) >>testtrygrep 172echo "RC=$?" >>testtrygrep 173 174echo "---------------------------- Test 24 -----------------------------" >>testtrygrep 175(cd $srcdir; $valgrind $pcregrep -A9 'four' ./testdata/grepinputx) >>testtrygrep 176echo "RC=$?" >>testtrygrep 177 178echo "---------------------------- Test 25 -----------------------------" >>testtrygrep 179(cd $srcdir; $valgrind $pcregrep -nB9 'four' ./testdata/grepinputx) >>testtrygrep 180echo "RC=$?" >>testtrygrep 181 182echo "---------------------------- Test 26 -----------------------------" >>testtrygrep 183(cd $srcdir; $valgrind $pcregrep -A9 -B9 'four' ./testdata/grepinputx) >>testtrygrep 184echo "RC=$?" >>testtrygrep 185 186echo "---------------------------- Test 27 -----------------------------" >>testtrygrep 187(cd $srcdir; $valgrind $pcregrep -A10 'four' ./testdata/grepinputx) >>testtrygrep 188echo "RC=$?" >>testtrygrep 189 190echo "---------------------------- Test 28 -----------------------------" >>testtrygrep 191(cd $srcdir; $valgrind $pcregrep -nB10 'four' ./testdata/grepinputx) >>testtrygrep 192echo "RC=$?" >>testtrygrep 193 194echo "---------------------------- Test 29 -----------------------------" >>testtrygrep 195(cd $srcdir; $valgrind $pcregrep -C12 -B10 'four' ./testdata/grepinputx) >>testtrygrep 196echo "RC=$?" >>testtrygrep 197 198echo "---------------------------- Test 30 -----------------------------" >>testtrygrep 199(cd $srcdir; $valgrind $pcregrep -inB3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep 200echo "RC=$?" >>testtrygrep 201 202echo "---------------------------- Test 31 -----------------------------" >>testtrygrep 203(cd $srcdir; $valgrind $pcregrep -inA3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep 204echo "RC=$?" >>testtrygrep 205 206echo "---------------------------- Test 32 -----------------------------" >>testtrygrep 207(cd $srcdir; $valgrind $pcregrep -L 'fox' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep 208echo "RC=$?" >>testtrygrep 209 210echo "---------------------------- Test 33 -----------------------------" >>testtrygrep 211(cd $srcdir; $valgrind $pcregrep 'fox' ./testdata/grepnonexist) >>testtrygrep 2>&1 212echo "RC=$?" >>testtrygrep 213 214echo "---------------------------- Test 34 -----------------------------" >>testtrygrep 215(cd $srcdir; $valgrind $pcregrep -s 'fox' ./testdata/grepnonexist) >>testtrygrep 2>&1 216echo "RC=$?" >>testtrygrep 217 218echo "---------------------------- Test 35 -----------------------------" >>testtrygrep 219(cd $srcdir; $valgrind $pcregrep -L -r --include=grepinputx --include grepinput8 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep 220echo "RC=$?" >>testtrygrep 221 222echo "---------------------------- Test 36 -----------------------------" >>testtrygrep 223(cd $srcdir; $valgrind $pcregrep -L -r --include=grepinput --exclude 'grepinput$' --exclude=grepinput8 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep 224echo "RC=$?" >>testtrygrep 225 226echo "---------------------------- Test 37 -----------------------------" >>testtrygrep 227(cd $srcdir; $valgrind $pcregrep '^(a+)*\d' ./testdata/grepinput) >>testtrygrep 2>teststderrgrep 228echo "RC=$?" >>testtrygrep 229echo "======== STDERR ========" >>testtrygrep 230cat teststderrgrep >>testtrygrep 231 232echo "---------------------------- Test 38 ------------------------------" >>testtrygrep 233(cd $srcdir; $valgrind $pcregrep '>\x00<' ./testdata/grepinput) >>testtrygrep 234echo "RC=$?" >>testtrygrep 235 236echo "---------------------------- Test 39 ------------------------------" >>testtrygrep 237(cd $srcdir; $valgrind $pcregrep -A1 'before the binary zero' ./testdata/grepinput) >>testtrygrep 238echo "RC=$?" >>testtrygrep 239 240echo "---------------------------- Test 40 ------------------------------" >>testtrygrep 241(cd $srcdir; $valgrind $pcregrep -B1 'after the binary zero' ./testdata/grepinput) >>testtrygrep 242echo "RC=$?" >>testtrygrep 243 244echo "---------------------------- Test 41 ------------------------------" >>testtrygrep 245(cd $srcdir; $valgrind $pcregrep -B1 -o '\w+ the binary zero' ./testdata/grepinput) >>testtrygrep 246echo "RC=$?" >>testtrygrep 247 248echo "---------------------------- Test 42 ------------------------------" >>testtrygrep 249(cd $srcdir; $valgrind $pcregrep -B1 -onH '\w+ the binary zero' ./testdata/grepinput) >>testtrygrep 250echo "RC=$?" >>testtrygrep 251 252echo "---------------------------- Test 43 ------------------------------" >>testtrygrep 253(cd $srcdir; $valgrind $pcregrep -on 'before|zero|after' ./testdata/grepinput) >>testtrygrep 254echo "RC=$?" >>testtrygrep 255 256echo "---------------------------- Test 44 ------------------------------" >>testtrygrep 257(cd $srcdir; $valgrind $pcregrep -on -e before -ezero -e after ./testdata/grepinput) >>testtrygrep 258echo "RC=$?" >>testtrygrep 259 260echo "---------------------------- Test 45 ------------------------------" >>testtrygrep 261(cd $srcdir; $valgrind $pcregrep -on -f ./testdata/greplist -e binary ./testdata/grepinput) >>testtrygrep 262echo "RC=$?" >>testtrygrep 263 264echo "---------------------------- Test 46 ------------------------------" >>testtrygrep 265(cd $srcdir; $valgrind $pcregrep -eabc -e '(unclosed' ./testdata/grepinput) 2>>testtrygrep >>testtrygrep 266echo "RC=$?" >>testtrygrep 267 268echo "---------------------------- Test 47 ------------------------------" >>testtrygrep 269(cd $srcdir; $valgrind $pcregrep -Fx "AB.VE 270elephant" ./testdata/grepinput) >>testtrygrep 271echo "RC=$?" >>testtrygrep 272 273echo "---------------------------- Test 48 ------------------------------" >>testtrygrep 274(cd $srcdir; $valgrind $pcregrep -F "AB.VE 275elephant" ./testdata/grepinput) >>testtrygrep 276echo "RC=$?" >>testtrygrep 277 278echo "---------------------------- Test 49 ------------------------------" >>testtrygrep 279(cd $srcdir; $valgrind $pcregrep -F -e DATA -e "AB.VE 280elephant" ./testdata/grepinput) >>testtrygrep 281echo "RC=$?" >>testtrygrep 282 283echo "---------------------------- Test 50 ------------------------------" >>testtrygrep 284(cd $srcdir; $valgrind $pcregrep "^(abc|def|ghi|jkl)" ./testdata/grepinputx) >>testtrygrep 285echo "RC=$?" >>testtrygrep 286 287echo "---------------------------- Test 51 ------------------------------" >>testtrygrep 288(cd $srcdir; $valgrind $pcregrep -Mv "brown\sfox" ./testdata/grepinputv) >>testtrygrep 289echo "RC=$?" >>testtrygrep 290 291echo "---------------------------- Test 52 ------------------------------" >>testtrygrep 292(cd $srcdir; $valgrind $pcregrep --colour=always jumps ./testdata/grepinputv) >>testtrygrep 293echo "RC=$?" >>testtrygrep 294 295echo "---------------------------- Test 53 ------------------------------" >>testtrygrep 296(cd $srcdir; $valgrind $pcregrep --file-offsets 'before|zero|after' ./testdata/grepinput) >>testtrygrep 297echo "RC=$?" >>testtrygrep 298 299echo "---------------------------- Test 54 ------------------------------" >>testtrygrep 300(cd $srcdir; $valgrind $pcregrep --line-offsets 'before|zero|after' ./testdata/grepinput) >>testtrygrep 301echo "RC=$?" >>testtrygrep 302 303echo "---------------------------- Test 55 -----------------------------" >>testtrygrep 304(cd $srcdir; $valgrind $pcregrep -f./testdata/greplist --color=always ./testdata/grepinputx) >>testtrygrep 305echo "RC=$?" >>testtrygrep 306 307echo "---------------------------- Test 56 -----------------------------" >>testtrygrep 308(cd $srcdir; $valgrind $pcregrep -c lazy ./testdata/grepinput*) >>testtrygrep 309echo "RC=$?" >>testtrygrep 310 311echo "---------------------------- Test 57 -----------------------------" >>testtrygrep 312(cd $srcdir; $valgrind $pcregrep -c -l lazy ./testdata/grepinput*) >>testtrygrep 313echo "RC=$?" >>testtrygrep 314 315echo "---------------------------- Test 58 -----------------------------" >>testtrygrep 316(cd $srcdir; $valgrind $pcregrep --regex=PATTERN ./testdata/grepinput) >>testtrygrep 317echo "RC=$?" >>testtrygrep 318 319echo "---------------------------- Test 59 -----------------------------" >>testtrygrep 320(cd $srcdir; $valgrind $pcregrep --regexp=PATTERN ./testdata/grepinput) >>testtrygrep 321echo "RC=$?" >>testtrygrep 322 323echo "---------------------------- Test 60 -----------------------------" >>testtrygrep 324(cd $srcdir; $valgrind $pcregrep --regex PATTERN ./testdata/grepinput) >>testtrygrep 325echo "RC=$?" >>testtrygrep 326 327echo "---------------------------- Test 61 -----------------------------" >>testtrygrep 328(cd $srcdir; $valgrind $pcregrep --regexp PATTERN ./testdata/grepinput) >>testtrygrep 329echo "RC=$?" >>testtrygrep 330 331echo "---------------------------- Test 62 -----------------------------" >>testtrygrep 332(cd $srcdir; $valgrind $pcregrep --match-limit=1000 --no-jit -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtrygrep 2>&1 333echo "RC=$?" >>testtrygrep 334 335echo "---------------------------- Test 63 -----------------------------" >>testtrygrep 336(cd $srcdir; $valgrind $pcregrep --recursion-limit=1000 --no-jit -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtrygrep 2>&1 337echo "RC=$?" >>testtrygrep 338 339echo "---------------------------- Test 64 ------------------------------" >>testtrygrep 340(cd $srcdir; $valgrind $pcregrep -o1 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep 341echo "RC=$?" >>testtrygrep 342 343echo "---------------------------- Test 65 ------------------------------" >>testtrygrep 344(cd $srcdir; $valgrind $pcregrep -o2 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep 345echo "RC=$?" >>testtrygrep 346 347echo "---------------------------- Test 66 ------------------------------" >>testtrygrep 348(cd $srcdir; $valgrind $pcregrep -o3 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep 349echo "RC=$?" >>testtrygrep 350 351echo "---------------------------- Test 67 ------------------------------" >>testtrygrep 352(cd $srcdir; $valgrind $pcregrep -o12 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep 353echo "RC=$?" >>testtrygrep 354 355echo "---------------------------- Test 68 ------------------------------" >>testtrygrep 356(cd $srcdir; $valgrind $pcregrep --only-matching=2 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep 357echo "RC=$?" >>testtrygrep 358 359echo "---------------------------- Test 69 -----------------------------" >>testtrygrep 360(cd $srcdir; $valgrind $pcregrep -vn --colour=always pattern ./testdata/grepinputx) >>testtrygrep 361echo "RC=$?" >>testtrygrep 362 363echo "---------------------------- Test 70 -----------------------------" >>testtrygrep 364(cd $srcdir; $valgrind $pcregrep --color=always -M "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep 365echo "RC=$?" >>testtrygrep 366 367echo "---------------------------- Test 71 -----------------------------" >>testtrygrep 368(cd $srcdir; $valgrind $pcregrep -o "^01|^02|^03" ./testdata/grepinput) >>testtrygrep 369echo "RC=$?" >>testtrygrep 370 371echo "---------------------------- Test 72 -----------------------------" >>testtrygrep 372(cd $srcdir; $valgrind $pcregrep --color=always "^01|^02|^03" ./testdata/grepinput) >>testtrygrep 373echo "RC=$?" >>testtrygrep 374 375echo "---------------------------- Test 73 -----------------------------" >>testtrygrep 376(cd $srcdir; $valgrind $pcregrep -o --colour=always "^01|^02|^03" ./testdata/grepinput) >>testtrygrep 377echo "RC=$?" >>testtrygrep 378 379echo "---------------------------- Test 74 -----------------------------" >>testtrygrep 380(cd $srcdir; $valgrind $pcregrep -o "^01|02|^03" ./testdata/grepinput) >>testtrygrep 381echo "RC=$?" >>testtrygrep 382 383echo "---------------------------- Test 75 -----------------------------" >>testtrygrep 384(cd $srcdir; $valgrind $pcregrep --color=always "^01|02|^03" ./testdata/grepinput) >>testtrygrep 385echo "RC=$?" >>testtrygrep 386 387echo "---------------------------- Test 76 -----------------------------" >>testtrygrep 388(cd $srcdir; $valgrind $pcregrep -o --colour=always "^01|02|^03" ./testdata/grepinput) >>testtrygrep 389echo "RC=$?" >>testtrygrep 390 391echo "---------------------------- Test 77 -----------------------------" >>testtrygrep 392(cd $srcdir; $valgrind $pcregrep -o "^01|^02|03" ./testdata/grepinput) >>testtrygrep 393echo "RC=$?" >>testtrygrep 394 395echo "---------------------------- Test 78 -----------------------------" >>testtrygrep 396(cd $srcdir; $valgrind $pcregrep --color=always "^01|^02|03" ./testdata/grepinput) >>testtrygrep 397echo "RC=$?" >>testtrygrep 398 399echo "---------------------------- Test 79 -----------------------------" >>testtrygrep 400(cd $srcdir; $valgrind $pcregrep -o --colour=always "^01|^02|03" ./testdata/grepinput) >>testtrygrep 401echo "RC=$?" >>testtrygrep 402 403echo "---------------------------- Test 80 -----------------------------" >>testtrygrep 404(cd $srcdir; $valgrind $pcregrep -o "\b01|\b02" ./testdata/grepinput) >>testtrygrep 405echo "RC=$?" >>testtrygrep 406 407echo "---------------------------- Test 81 -----------------------------" >>testtrygrep 408(cd $srcdir; $valgrind $pcregrep --color=always "\\b01|\\b02" ./testdata/grepinput) >>testtrygrep 409echo "RC=$?" >>testtrygrep 410 411echo "---------------------------- Test 82 -----------------------------" >>testtrygrep 412(cd $srcdir; $valgrind $pcregrep -o --colour=always "\\b01|\\b02" ./testdata/grepinput) >>testtrygrep 413echo "RC=$?" >>testtrygrep 414 415echo "---------------------------- Test 83 -----------------------------" >>testtrygrep 416(cd $srcdir; $valgrind $pcregrep --buffer-size=100 "^a" ./testdata/grepinput3) >>testtrygrep 2>&1 417echo "RC=$?" >>testtrygrep 418 419echo "---------------------------- Test 84 -----------------------------" >>testtrygrep 420echo testdata/grepinput3 >testtemp1grep 421(cd $srcdir; $valgrind $pcregrep --file-list ./testdata/grepfilelist --file-list $builddir/testtemp1grep "fox|complete|t7") >>testtrygrep 2>&1 422echo "RC=$?" >>testtrygrep 423 424echo "---------------------------- Test 85 -----------------------------" >>testtrygrep 425(cd $srcdir; $valgrind $pcregrep --file-list=./testdata/grepfilelist "dolor" ./testdata/grepinput3) >>testtrygrep 2>&1 426echo "RC=$?" >>testtrygrep 427 428echo "---------------------------- Test 86 -----------------------------" >>testtrygrep 429(cd $srcdir; $valgrind $pcregrep "dog" ./testdata/grepbinary) >>testtrygrep 2>&1 430echo "RC=$?" >>testtrygrep 431 432echo "---------------------------- Test 87 -----------------------------" >>testtrygrep 433(cd $srcdir; $valgrind $pcregrep "cat" ./testdata/grepbinary) >>testtrygrep 2>&1 434echo "RC=$?" >>testtrygrep 435 436echo "---------------------------- Test 88 -----------------------------" >>testtrygrep 437(cd $srcdir; $valgrind $pcregrep -v "cat" ./testdata/grepbinary) >>testtrygrep 2>&1 438echo "RC=$?" >>testtrygrep 439 440echo "---------------------------- Test 89 -----------------------------" >>testtrygrep 441(cd $srcdir; $valgrind $pcregrep -I "dog" ./testdata/grepbinary) >>testtrygrep 2>&1 442echo "RC=$?" >>testtrygrep 443 444echo "---------------------------- Test 90 -----------------------------" >>testtrygrep 445(cd $srcdir; $valgrind $pcregrep --binary-files=without-match "dog" ./testdata/grepbinary) >>testtrygrep 2>&1 446echo "RC=$?" >>testtrygrep 447 448echo "---------------------------- Test 91 -----------------------------" >>testtrygrep 449(cd $srcdir; $valgrind $pcregrep -a "dog" ./testdata/grepbinary) >>testtrygrep 2>&1 450echo "RC=$?" >>testtrygrep 451 452echo "---------------------------- Test 92 -----------------------------" >>testtrygrep 453(cd $srcdir; $valgrind $pcregrep --binary-files=text "dog" ./testdata/grepbinary) >>testtrygrep 2>&1 454echo "RC=$?" >>testtrygrep 455 456echo "---------------------------- Test 93 -----------------------------" >>testtrygrep 457(cd $srcdir; $valgrind $pcregrep --text "dog" ./testdata/grepbinary) >>testtrygrep 2>&1 458echo "RC=$?" >>testtrygrep 459 460echo "---------------------------- Test 94 -----------------------------" >>testtrygrep 461(cd $srcdir; $valgrind $pcregrep -L -r --include=grepinputx --include grepinput8 'fox' ./testdata/grepinput* | sort) >>testtrygrep 462echo "RC=$?" >>testtrygrep 463 464echo "---------------------------- Test 95 -----------------------------" >>testtrygrep 465(cd $srcdir; $valgrind $pcregrep --file-list ./testdata/grepfilelist --exclude grepinputv "fox|complete") >>testtrygrep 2>&1 466echo "RC=$?" >>testtrygrep 467 468echo "---------------------------- Test 96 -----------------------------" >>testtrygrep 469(cd $srcdir; $valgrind $pcregrep -L -r --include-dir=testdata --exclude '^(?!grepinput)' 'fox' ./test* | sort) >>testtrygrep 470echo "RC=$?" >>testtrygrep 471 472echo "---------------------------- Test 97 -----------------------------" >>testtrygrep 473echo "grepinput$" >testtemp1grep 474echo "grepinput8" >>testtemp1grep 475(cd $srcdir; $valgrind $pcregrep -L -r --include=grepinput --exclude-from $builddir/testtemp1grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep 476echo "RC=$?" >>testtrygrep 477 478echo "---------------------------- Test 98 -----------------------------" >>testtrygrep 479echo "grepinput$" >testtemp1grep 480echo "grepinput8" >>testtemp1grep 481(cd $srcdir; $valgrind $pcregrep -L -r --exclude=grepinput3 --include=grepinput --exclude-from $builddir/testtemp1grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep 482echo "RC=$?" >>testtrygrep 483 484echo "---------------------------- Test 99 -----------------------------" >>testtrygrep 485echo "grepinput$" >testtemp1grep 486echo "grepinput8" >testtemp2grep 487(cd $srcdir; $valgrind $pcregrep -L -r --include grepinput --exclude-from $builddir/testtemp1grep --exclude-from=$builddir/testtemp2grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep 488echo "RC=$?" >>testtrygrep 489 490echo "---------------------------- Test 100 ------------------------------" >>testtrygrep 491(cd $srcdir; $valgrind $pcregrep -Ho2 --only-matching=1 -o3 '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep 492echo "RC=$?" >>testtrygrep 493 494echo "---------------------------- Test 101 ------------------------------" >>testtrygrep 495(cd $srcdir; $valgrind $pcregrep -o3 -Ho2 -o12 --only-matching=1 -o3 --colour=always --om-separator='|' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep 496echo "RC=$?" >>testtrygrep 497 498echo "---------------------------- Test 102 -----------------------------" >>testtrygrep 499(cd $srcdir; $valgrind $pcregrep -n "^$" ./testdata/grepinput3) >>testtrygrep 2>&1 500echo "RC=$?" >>testtrygrep 501 502echo "---------------------------- Test 103 -----------------------------" >>testtrygrep 503(cd $srcdir; $valgrind $pcregrep --only-matching "^$" ./testdata/grepinput3) >>testtrygrep 2>&1 504echo "RC=$?" >>testtrygrep 505 506echo "---------------------------- Test 104 -----------------------------" >>testtrygrep 507(cd $srcdir; $valgrind $pcregrep -n --only-matching "^$" ./testdata/grepinput3) >>testtrygrep 2>&1 508echo "RC=$?" >>testtrygrep 509 510echo "---------------------------- Test 105 -----------------------------" >>testtrygrep 511(cd $srcdir; $valgrind $pcregrep --colour=always "ipsum|" ./testdata/grepinput3) >>testtrygrep 2>&1 512echo "RC=$?" >>testtrygrep 513 514echo "---------------------------- Test 106 -----------------------------" >>testtrygrep 515(cd $srcdir; echo "a" | $valgrind $pcregrep -M "|a" ) >>testtrygrep 2>&1 516echo "RC=$?" >>testtrygrep 517 518echo "---------------------------- Test 107 -----------------------------" >>testtrygrep 519echo "a" >testtemp1grep 520echo "aaaaa" >>testtemp1grep 521(cd $srcdir; $valgrind $pcregrep --line-offsets '(?<=\Ka)' $builddir/testtemp1grep) >>testtrygrep 2>&1 522echo "RC=$?" >>testtrygrep 523 524echo "---------------------------- Test 108 ------------------------------" >>testtrygrep 525(cd $srcdir; $valgrind $pcregrep -lq PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep 526echo "RC=$?" >>testtrygrep 527 528echo "---------------------------- Test 109 -----------------------------" >>testtrygrep 529(cd $srcdir; $valgrind $pcregrep -cq lazy ./testdata/grepinput*) >>testtrygrep 530echo "RC=$?" >>testtrygrep 531 532# Now compare the results. 533 534$cf $srcdir/testdata/grepoutput testtrygrep 535if [ $? != 0 ] ; then exit 1; fi 536 537 538# These tests require UTF-8 support 539 540if [ $utf8 -ne 0 ] ; then 541 echo "Testing pcregrep UTF-8 features" 542 543 echo "---------------------------- Test U1 ------------------------------" >testtrygrep 544 (cd $srcdir; $valgrind $pcregrep -n -u --newline=any "^X" ./testdata/grepinput8) >>testtrygrep 545 echo "RC=$?" >>testtrygrep 546 547 echo "---------------------------- Test U2 ------------------------------" >>testtrygrep 548 (cd $srcdir; $valgrind $pcregrep -n -u -C 3 --newline=any "Match" ./testdata/grepinput8) >>testtrygrep 549 echo "RC=$?" >>testtrygrep 550 551 $cf $srcdir/testdata/grepoutput8 testtrygrep 552 if [ $? != 0 ] ; then exit 1; fi 553 554else 555 echo "Skipping pcregrep UTF-8 tests: no UTF-8 support in PCRE library" 556fi 557 558 559# We go to some contortions to try to ensure that the tests for the various 560# newline settings will work in environments where the normal newline sequence 561# is not \n. Do not use exported files, whose line endings might be changed. 562# Instead, create an input file using printf so that its contents are exactly 563# what we want. Note the messy fudge to get printf to write a string that 564# starts with a hyphen. These tests are run in the build directory. 565 566echo "Testing pcregrep newline settings" 567printf "abc\rdef\r\nghi\njkl" >testNinputgrep 568 569printf "%c--------------------------- Test N1 ------------------------------\r\n" - >testtrygrep 570$valgrind $pcregrep -n -N CR "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep 571 572printf "%c--------------------------- Test N2 ------------------------------\r\n" - >>testtrygrep 573$valgrind $pcregrep -n --newline=crlf "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep 574 575printf "%c--------------------------- Test N3 ------------------------------\r\n" - >>testtrygrep 576pattern=`printf 'def\rjkl'` 577$valgrind $pcregrep -n --newline=cr -F "$pattern" testNinputgrep >>testtrygrep 578 579printf "%c--------------------------- Test N4 ------------------------------\r\n" - >>testtrygrep 580$valgrind $pcregrep -n --newline=crlf -F -f $srcdir/testdata/greppatN4 testNinputgrep >>testtrygrep 581 582printf "%c--------------------------- Test N5 ------------------------------\r\n" - >>testtrygrep 583$valgrind $pcregrep -n --newline=any "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep 584 585printf "%c--------------------------- Test N6 ------------------------------\r\n" - >>testtrygrep 586$valgrind $pcregrep -n --newline=anycrlf "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep 587 588$cf $srcdir/testdata/grepoutputN testtrygrep 589if [ $? != 0 ] ; then exit 1; fi 590 591exit 0 592 593# End 594