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