Elliott Hughes | 5b80804 | 2021-10-01 10:56:10 -0700 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | |
| 3 | # Run pcre2grep tests. The assumption is that the PCRE2 tests check the library |
| 4 | # itself. What we are checking here is the file handling and options that are |
| 5 | # supported by pcre2grep. This script must be run in the build directory. |
| 6 | |
| 7 | # CODING CONVENTIONS: |
| 8 | # * Put printf arguments in single, not double quotes to avoid unwanted |
| 9 | # escaping. |
| 10 | # * Use \0 for binary zero in printf, not \x0, for the benefit of older |
| 11 | # versions (and use octal for other special values). |
| 12 | |
| 13 | # Set the C locale, so that sort(1) behaves predictably. |
| 14 | |
| 15 | LC_ALL=C |
| 16 | export LC_ALL |
| 17 | |
| 18 | # Remove any non-default colouring and aliases that the caller may have set. |
| 19 | |
| 20 | unset PCRE2GREP_COLOUR PCRE2GREP_COLOR PCREGREP_COLOUR PCREGREP_COLOR |
| 21 | unset GREP_COLOR GREP_COLORS |
| 22 | unset cp ls mv rm |
| 23 | |
| 24 | # Remember the current (build) directory, set the program to be tested, and |
| 25 | # valgrind settings when requested. |
| 26 | |
| 27 | builddir=`pwd` |
| 28 | pcre2grep=$builddir/pcre2grep |
| 29 | pcre2test=$builddir/pcre2test |
| 30 | |
| 31 | if [ ! -x $pcre2grep ] ; then |
| 32 | echo "** $pcre2grep does not exist or is not executable." |
| 33 | exit 1 |
| 34 | fi |
| 35 | |
| 36 | if [ ! -x $pcre2test ] ; then |
| 37 | echo "** $pcre2test does not exist or is not executable." |
| 38 | exit 1 |
| 39 | fi |
| 40 | |
| 41 | valgrind= |
| 42 | while [ $# -gt 0 ] ; do |
| 43 | case $1 in |
| 44 | valgrind) valgrind="valgrind -q --leak-check=no --smc-check=all-non-file";; |
| 45 | *) echo "RunGrepTest: Unknown argument $1"; exit 1;; |
| 46 | esac |
| 47 | shift |
| 48 | done |
| 49 | |
| 50 | vjs= |
| 51 | pcre2grep_version=`$pcre2grep -V` |
| 52 | if [ "$valgrind" = "" ] ; then |
| 53 | echo "Testing $pcre2grep_version" |
| 54 | else |
| 55 | echo "Testing $pcre2grep_version using valgrind" |
| 56 | $pcre2test -C jit >/dev/null |
| 57 | if [ $? -ne 0 ]; then |
| 58 | vjs="--suppressions=./testdata/valgrind-jit.supp" |
| 59 | fi |
| 60 | fi |
| 61 | |
| 62 | # Set up a suitable "diff" command for comparison. Some systems have a diff |
| 63 | # that lacks a -u option. Try to deal with this; better do the test for the -b |
| 64 | # option as well. |
| 65 | |
| 66 | cf="diff" |
| 67 | diff -b /dev/null /dev/null 2>/dev/null && cf="diff -b" |
| 68 | diff -u /dev/null /dev/null 2>/dev/null && cf="diff -u" |
| 69 | diff -ub /dev/null /dev/null 2>/dev/null && cf="diff -ub" |
| 70 | |
| 71 | # If this test is being run from "make check", $srcdir will be set. If not, set |
| 72 | # it to the current or parent directory, whichever one contains the test data. |
| 73 | # Subsequently, we run most of the pcre2grep tests in the source directory so |
| 74 | # that the file names in the output are always the same. |
| 75 | |
| 76 | if [ -z "$srcdir" -o ! -d "$srcdir/testdata" ] ; then |
| 77 | if [ -d "./testdata" ] ; then |
| 78 | srcdir=. |
| 79 | elif [ -d "../testdata" ] ; then |
| 80 | srcdir=.. |
| 81 | else |
| 82 | echo "Cannot find the testdata directory" |
| 83 | exit 1 |
| 84 | fi |
| 85 | fi |
| 86 | |
| 87 | # Check for the availability of UTF-8 support |
| 88 | |
| 89 | $pcre2test -C unicode >/dev/null |
| 90 | utf8=$? |
| 91 | |
| 92 | # Check default newline convention. If it does not include LF, force LF. |
| 93 | |
| 94 | nl=`$pcre2test -C newline` |
| 95 | if [ "$nl" != "LF" -a "$nl" != "ANY" -a "$nl" != "ANYCRLF" ]; then |
| 96 | pcre2grep="$pcre2grep -N LF" |
| 97 | echo "Default newline setting forced to LF" |
| 98 | fi |
| 99 | |
| 100 | # ------ Function to run and check a special pcre2grep arguments test ------- |
| 101 | |
| 102 | checkspecial() |
| 103 | { |
| 104 | $valgrind $pcre2grep $1 >>testtrygrep 2>&1 |
| 105 | if [ $? -ne $2 ] ; then |
| 106 | echo "** pcre2grep $1 failed - check testtrygrep" |
| 107 | exit 1 |
| 108 | fi |
| 109 | } |
| 110 | |
| 111 | # ------ Normal tests ------ |
| 112 | |
| 113 | echo "Testing pcre2grep main features" |
| 114 | |
| 115 | echo "---------------------------- Test 1 ------------------------------" >testtrygrep |
| 116 | (cd $srcdir; $valgrind $vjs $pcre2grep PATTERN ./testdata/grepinput) >>testtrygrep |
| 117 | echo "RC=$?" >>testtrygrep |
| 118 | |
| 119 | echo "---------------------------- Test 2 ------------------------------" >>testtrygrep |
| 120 | (cd $srcdir; $valgrind $vjs $pcre2grep '^PATTERN' ./testdata/grepinput) >>testtrygrep |
| 121 | echo "RC=$?" >>testtrygrep |
| 122 | |
| 123 | echo "---------------------------- Test 3 ------------------------------" >>testtrygrep |
| 124 | (cd $srcdir; $valgrind $vjs $pcre2grep -in PATTERN ./testdata/grepinput) >>testtrygrep |
| 125 | echo "RC=$?" >>testtrygrep |
| 126 | |
| 127 | echo "---------------------------- Test 4 ------------------------------" >>testtrygrep |
| 128 | (cd $srcdir; $valgrind $vjs $pcre2grep -ic PATTERN ./testdata/grepinput) >>testtrygrep |
| 129 | echo "RC=$?" >>testtrygrep |
| 130 | |
| 131 | echo "---------------------------- Test 5 ------------------------------" >>testtrygrep |
| 132 | (cd $srcdir; $valgrind $vjs $pcre2grep -in PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep |
| 133 | echo "RC=$?" >>testtrygrep |
| 134 | |
| 135 | echo "---------------------------- Test 6 ------------------------------" >>testtrygrep |
| 136 | (cd $srcdir; $valgrind $vjs $pcre2grep -inh PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep |
| 137 | echo "RC=$?" >>testtrygrep |
| 138 | |
| 139 | echo "---------------------------- Test 7 ------------------------------" >>testtrygrep |
| 140 | (cd $srcdir; $valgrind $vjs $pcre2grep -il PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep |
| 141 | echo "RC=$?" >>testtrygrep |
| 142 | |
| 143 | echo "---------------------------- Test 8 ------------------------------" >>testtrygrep |
| 144 | (cd $srcdir; $valgrind $vjs $pcre2grep -l PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep |
| 145 | echo "RC=$?" >>testtrygrep |
| 146 | |
| 147 | echo "---------------------------- Test 9 ------------------------------" >>testtrygrep |
| 148 | (cd $srcdir; $valgrind $vjs $pcre2grep -q PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep |
| 149 | echo "RC=$?" >>testtrygrep |
| 150 | |
| 151 | echo "---------------------------- Test 10 -----------------------------" >>testtrygrep |
| 152 | (cd $srcdir; $valgrind $vjs $pcre2grep -q NEVER-PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep |
| 153 | echo "RC=$?" >>testtrygrep |
| 154 | |
| 155 | echo "---------------------------- Test 11 -----------------------------" >>testtrygrep |
| 156 | (cd $srcdir; $valgrind $vjs $pcre2grep -vn pattern ./testdata/grepinputx) >>testtrygrep |
| 157 | echo "RC=$?" >>testtrygrep |
| 158 | |
| 159 | echo "---------------------------- Test 12 -----------------------------" >>testtrygrep |
| 160 | (cd $srcdir; $valgrind $vjs $pcre2grep -ix pattern ./testdata/grepinputx) >>testtrygrep |
| 161 | echo "RC=$?" >>testtrygrep |
| 162 | |
| 163 | echo "---------------------------- Test 13 -----------------------------" >>testtrygrep |
| 164 | echo seventeen >testtemp1grep |
| 165 | (cd $srcdir; $valgrind $vjs $pcre2grep -f./testdata/greplist -f $builddir/testtemp1grep ./testdata/grepinputx) >>testtrygrep |
| 166 | echo "RC=$?" >>testtrygrep |
| 167 | |
| 168 | echo "---------------------------- Test 14 -----------------------------" >>testtrygrep |
| 169 | (cd $srcdir; $valgrind $vjs $pcre2grep -w pat ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep |
| 170 | echo "RC=$?" >>testtrygrep |
| 171 | |
| 172 | echo "---------------------------- Test 15 -----------------------------" >>testtrygrep |
| 173 | (cd $srcdir; $valgrind $vjs $pcre2grep 'abc^*' ./testdata/grepinput) >>testtrygrep 2>&1 |
| 174 | echo "RC=$?" >>testtrygrep |
| 175 | |
| 176 | echo "---------------------------- Test 16 -----------------------------" >>testtrygrep |
| 177 | (cd $srcdir; $valgrind $vjs $pcre2grep abc ./testdata/grepinput ./testdata/nonexistfile) >>testtrygrep 2>&1 |
| 178 | echo "RC=$?" >>testtrygrep |
| 179 | |
| 180 | echo "---------------------------- Test 17 -----------------------------" >>testtrygrep |
| 181 | (cd $srcdir; $valgrind $vjs $pcre2grep -M 'the\noutput' ./testdata/grepinput) >>testtrygrep |
| 182 | echo "RC=$?" >>testtrygrep |
| 183 | |
| 184 | echo "---------------------------- Test 18 -----------------------------" >>testtrygrep |
| 185 | (cd $srcdir; $valgrind $vjs $pcre2grep -Mn '(the\noutput|dog\.\n--)' ./testdata/grepinput) >>testtrygrep |
| 186 | echo "RC=$?" >>testtrygrep |
| 187 | |
| 188 | echo "---------------------------- Test 19 -----------------------------" >>testtrygrep |
| 189 | (cd $srcdir; $valgrind $vjs $pcre2grep -Mix 'Pattern' ./testdata/grepinputx) >>testtrygrep |
| 190 | echo "RC=$?" >>testtrygrep |
| 191 | |
| 192 | echo "---------------------------- Test 20 -----------------------------" >>testtrygrep |
| 193 | (cd $srcdir; $valgrind $vjs $pcre2grep -Mixn 'complete pair\nof lines' ./testdata/grepinputx) >>testtrygrep |
| 194 | echo "RC=$?" >>testtrygrep |
| 195 | |
| 196 | echo "---------------------------- Test 21 -----------------------------" >>testtrygrep |
| 197 | (cd $srcdir; $valgrind $vjs $pcre2grep -nA3 'four' ./testdata/grepinputx) >>testtrygrep |
| 198 | echo "RC=$?" >>testtrygrep |
| 199 | |
| 200 | echo "---------------------------- Test 22 -----------------------------" >>testtrygrep |
| 201 | (cd $srcdir; $valgrind $vjs $pcre2grep -nB3 'four' ./testdata/grepinputx) >>testtrygrep |
| 202 | echo "RC=$?" >>testtrygrep |
| 203 | |
| 204 | echo "---------------------------- Test 23 -----------------------------" >>testtrygrep |
| 205 | (cd $srcdir; $valgrind $vjs $pcre2grep -C3 'four' ./testdata/grepinputx) >>testtrygrep |
| 206 | echo "RC=$?" >>testtrygrep |
| 207 | |
| 208 | echo "---------------------------- Test 24 -----------------------------" >>testtrygrep |
| 209 | (cd $srcdir; $valgrind $vjs $pcre2grep -A9 'four' ./testdata/grepinputx) >>testtrygrep |
| 210 | echo "RC=$?" >>testtrygrep |
| 211 | |
| 212 | echo "---------------------------- Test 25 -----------------------------" >>testtrygrep |
| 213 | (cd $srcdir; $valgrind $vjs $pcre2grep -nB9 'four' ./testdata/grepinputx) >>testtrygrep |
| 214 | echo "RC=$?" >>testtrygrep |
| 215 | |
| 216 | echo "---------------------------- Test 26 -----------------------------" >>testtrygrep |
| 217 | (cd $srcdir; $valgrind $vjs $pcre2grep -A9 -B9 'four' ./testdata/grepinputx) >>testtrygrep |
| 218 | echo "RC=$?" >>testtrygrep |
| 219 | |
| 220 | echo "---------------------------- Test 27 -----------------------------" >>testtrygrep |
| 221 | (cd $srcdir; $valgrind $vjs $pcre2grep -A10 'four' ./testdata/grepinputx) >>testtrygrep |
| 222 | echo "RC=$?" >>testtrygrep |
| 223 | |
| 224 | echo "---------------------------- Test 28 -----------------------------" >>testtrygrep |
| 225 | (cd $srcdir; $valgrind $vjs $pcre2grep -nB10 'four' ./testdata/grepinputx) >>testtrygrep |
| 226 | echo "RC=$?" >>testtrygrep |
| 227 | |
| 228 | echo "---------------------------- Test 29 -----------------------------" >>testtrygrep |
| 229 | (cd $srcdir; $valgrind $vjs $pcre2grep -C12 -B10 'four' ./testdata/grepinputx) >>testtrygrep |
| 230 | echo "RC=$?" >>testtrygrep |
| 231 | |
| 232 | echo "---------------------------- Test 30 -----------------------------" >>testtrygrep |
| 233 | (cd $srcdir; $valgrind $vjs $pcre2grep -inB3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep |
| 234 | echo "RC=$?" >>testtrygrep |
| 235 | |
| 236 | echo "---------------------------- Test 31 -----------------------------" >>testtrygrep |
| 237 | (cd $srcdir; $valgrind $vjs $pcre2grep -inA3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep |
| 238 | echo "RC=$?" >>testtrygrep |
| 239 | |
| 240 | echo "---------------------------- Test 32 -----------------------------" >>testtrygrep |
| 241 | (cd $srcdir; $valgrind $vjs $pcre2grep -L 'fox' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep |
| 242 | echo "RC=$?" >>testtrygrep |
| 243 | |
| 244 | echo "---------------------------- Test 33 -----------------------------" >>testtrygrep |
| 245 | (cd $srcdir; $valgrind $vjs $pcre2grep 'fox' ./testdata/grepnonexist) >>testtrygrep 2>&1 |
| 246 | echo "RC=$?" >>testtrygrep |
| 247 | |
| 248 | echo "---------------------------- Test 34 -----------------------------" >>testtrygrep |
| 249 | (cd $srcdir; $valgrind $vjs $pcre2grep -s 'fox' ./testdata/grepnonexist) >>testtrygrep 2>&1 |
| 250 | echo "RC=$?" >>testtrygrep |
| 251 | |
| 252 | echo "---------------------------- Test 35 -----------------------------" >>testtrygrep |
| 253 | (cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include=grepinputx --include grepinput8 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep |
| 254 | echo "RC=$?" >>testtrygrep |
| 255 | |
| 256 | echo "---------------------------- Test 36 -----------------------------" >>testtrygrep |
| 257 | (cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include=grepinput --exclude 'grepinput$' --exclude=grepinput8 --exclude=grepinputM --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep |
| 258 | echo "RC=$?" >>testtrygrep |
| 259 | |
| 260 | echo "---------------------------- Test 37 -----------------------------" >>testtrygrep |
| 261 | (cd $srcdir; $valgrind $vjs $pcre2grep '^(a+)*\d' ./testdata/grepinput) >>testtrygrep 2>teststderrgrep |
| 262 | echo "RC=$?" >>testtrygrep |
| 263 | echo "======== STDERR ========" >>testtrygrep |
| 264 | cat teststderrgrep >>testtrygrep |
| 265 | |
| 266 | echo "---------------------------- Test 38 ------------------------------" >>testtrygrep |
| 267 | (cd $srcdir; $valgrind $vjs $pcre2grep '>\x00<' ./testdata/grepinput) >>testtrygrep |
| 268 | echo "RC=$?" >>testtrygrep |
| 269 | |
| 270 | echo "---------------------------- Test 39 ------------------------------" >>testtrygrep |
| 271 | (cd $srcdir; $valgrind $vjs $pcre2grep -A1 'before the binary zero' ./testdata/grepinput) >>testtrygrep |
| 272 | echo "RC=$?" >>testtrygrep |
| 273 | |
| 274 | echo "---------------------------- Test 40 ------------------------------" >>testtrygrep |
| 275 | (cd $srcdir; $valgrind $vjs $pcre2grep -B1 'after the binary zero' ./testdata/grepinput) >>testtrygrep |
| 276 | echo "RC=$?" >>testtrygrep |
| 277 | |
| 278 | echo "---------------------------- Test 41 ------------------------------" >>testtrygrep |
| 279 | (cd $srcdir; $valgrind $vjs $pcre2grep -B1 -o '\w+ the binary zero' ./testdata/grepinput) >>testtrygrep |
| 280 | echo "RC=$?" >>testtrygrep |
| 281 | |
| 282 | echo "---------------------------- Test 42 ------------------------------" >>testtrygrep |
| 283 | (cd $srcdir; $valgrind $vjs $pcre2grep -B1 -onH '\w+ the binary zero' ./testdata/grepinput) >>testtrygrep |
| 284 | echo "RC=$?" >>testtrygrep |
| 285 | |
| 286 | echo "---------------------------- Test 43 ------------------------------" >>testtrygrep |
| 287 | (cd $srcdir; $valgrind $vjs $pcre2grep -on 'before|zero|after' ./testdata/grepinput) >>testtrygrep |
| 288 | echo "RC=$?" >>testtrygrep |
| 289 | |
| 290 | echo "---------------------------- Test 44 ------------------------------" >>testtrygrep |
| 291 | (cd $srcdir; $valgrind $vjs $pcre2grep -on -e before -ezero -e after ./testdata/grepinput) >>testtrygrep |
| 292 | echo "RC=$?" >>testtrygrep |
| 293 | |
| 294 | echo "---------------------------- Test 45 ------------------------------" >>testtrygrep |
| 295 | (cd $srcdir; $valgrind $vjs $pcre2grep -on -f ./testdata/greplist -e binary ./testdata/grepinput) >>testtrygrep |
| 296 | echo "RC=$?" >>testtrygrep |
| 297 | |
| 298 | echo "---------------------------- Test 46 ------------------------------" >>testtrygrep |
| 299 | (cd $srcdir; $valgrind $vjs $pcre2grep -eabc -e '(unclosed' ./testdata/grepinput) >>testtrygrep 2>&1 |
| 300 | echo "RC=$?" >>testtrygrep |
| 301 | |
| 302 | echo "---------------------------- Test 47 ------------------------------" >>testtrygrep |
| 303 | (cd $srcdir; $valgrind $vjs $pcre2grep -Fx "AB.VE |
| 304 | elephant" ./testdata/grepinput) >>testtrygrep |
| 305 | echo "RC=$?" >>testtrygrep |
| 306 | |
| 307 | echo "---------------------------- Test 48 ------------------------------" >>testtrygrep |
| 308 | (cd $srcdir; $valgrind $vjs $pcre2grep -F "AB.VE |
| 309 | elephant" ./testdata/grepinput) >>testtrygrep |
| 310 | echo "RC=$?" >>testtrygrep |
| 311 | |
| 312 | echo "---------------------------- Test 49 ------------------------------" >>testtrygrep |
| 313 | (cd $srcdir; $valgrind $vjs $pcre2grep -F -e DATA -e "AB.VE |
| 314 | elephant" ./testdata/grepinput) >>testtrygrep |
| 315 | echo "RC=$?" >>testtrygrep |
| 316 | |
| 317 | echo "---------------------------- Test 50 ------------------------------" >>testtrygrep |
| 318 | (cd $srcdir; $valgrind $vjs $pcre2grep "^(abc|def|ghi|jkl)" ./testdata/grepinputx) >>testtrygrep |
| 319 | echo "RC=$?" >>testtrygrep |
| 320 | |
| 321 | echo "---------------------------- Test 51 ------------------------------" >>testtrygrep |
| 322 | (cd $srcdir; $valgrind $vjs $pcre2grep -Mv "brown\sfox" ./testdata/grepinputv) >>testtrygrep |
| 323 | echo "RC=$?" >>testtrygrep |
| 324 | |
| 325 | echo "---------------------------- Test 52 ------------------------------" >>testtrygrep |
| 326 | (cd $srcdir; $valgrind $vjs $pcre2grep --colour=always jumps ./testdata/grepinputv) >>testtrygrep |
| 327 | echo "RC=$?" >>testtrygrep |
| 328 | |
| 329 | echo "---------------------------- Test 53 ------------------------------" >>testtrygrep |
| 330 | (cd $srcdir; $valgrind $vjs $pcre2grep --file-offsets 'before|zero|after' ./testdata/grepinput) >>testtrygrep |
| 331 | echo "RC=$?" >>testtrygrep |
| 332 | |
| 333 | echo "---------------------------- Test 54 ------------------------------" >>testtrygrep |
| 334 | (cd $srcdir; $valgrind $vjs $pcre2grep --line-offsets 'before|zero|after' ./testdata/grepinput) >>testtrygrep |
| 335 | echo "RC=$?" >>testtrygrep |
| 336 | |
| 337 | echo "---------------------------- Test 55 -----------------------------" >>testtrygrep |
| 338 | (cd $srcdir; $valgrind $vjs $pcre2grep -f./testdata/greplist --color=always ./testdata/grepinputx) >>testtrygrep |
| 339 | echo "RC=$?" >>testtrygrep |
| 340 | |
| 341 | echo "---------------------------- Test 56 -----------------------------" >>testtrygrep |
| 342 | (cd $srcdir; $valgrind $vjs $pcre2grep -c lazy ./testdata/grepinput*) >>testtrygrep |
| 343 | echo "RC=$?" >>testtrygrep |
| 344 | |
| 345 | echo "---------------------------- Test 57 -----------------------------" >>testtrygrep |
| 346 | (cd $srcdir; $valgrind $vjs $pcre2grep -c -l lazy ./testdata/grepinput*) >>testtrygrep |
| 347 | echo "RC=$?" >>testtrygrep |
| 348 | |
| 349 | echo "---------------------------- Test 58 -----------------------------" >>testtrygrep |
| 350 | (cd $srcdir; $valgrind $vjs $pcre2grep --regex=PATTERN ./testdata/grepinput) >>testtrygrep |
| 351 | echo "RC=$?" >>testtrygrep |
| 352 | |
| 353 | echo "---------------------------- Test 59 -----------------------------" >>testtrygrep |
| 354 | (cd $srcdir; $valgrind $vjs $pcre2grep --regexp=PATTERN ./testdata/grepinput) >>testtrygrep |
| 355 | echo "RC=$?" >>testtrygrep |
| 356 | |
| 357 | echo "---------------------------- Test 60 -----------------------------" >>testtrygrep |
| 358 | (cd $srcdir; $valgrind $vjs $pcre2grep --regex PATTERN ./testdata/grepinput) >>testtrygrep |
| 359 | echo "RC=$?" >>testtrygrep |
| 360 | |
| 361 | echo "---------------------------- Test 61 -----------------------------" >>testtrygrep |
| 362 | (cd $srcdir; $valgrind $vjs $pcre2grep --regexp PATTERN ./testdata/grepinput) >>testtrygrep |
| 363 | echo "RC=$?" >>testtrygrep |
| 364 | |
| 365 | echo "---------------------------- Test 62 -----------------------------" >>testtrygrep |
| 366 | (cd $srcdir; $valgrind $pcre2grep --match-limit=1000 --no-jit -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtrygrep 2>&1 |
| 367 | echo "RC=$?" >>testtrygrep |
| 368 | |
| 369 | echo "---------------------------- Test 63 -----------------------------" >>testtrygrep |
| 370 | (cd $srcdir; $valgrind $pcre2grep --recursion-limit=1000 --no-jit -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtrygrep 2>&1 |
| 371 | echo "RC=$?" >>testtrygrep |
| 372 | |
| 373 | echo "---------------------------- Test 64 ------------------------------" >>testtrygrep |
| 374 | (cd $srcdir; $valgrind $vjs $pcre2grep -o1 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep |
| 375 | echo "RC=$?" >>testtrygrep |
| 376 | |
| 377 | echo "---------------------------- Test 65 ------------------------------" >>testtrygrep |
| 378 | (cd $srcdir; $valgrind $vjs $pcre2grep -o2 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep |
| 379 | echo "RC=$?" >>testtrygrep |
| 380 | |
| 381 | echo "---------------------------- Test 66 ------------------------------" >>testtrygrep |
| 382 | (cd $srcdir; $valgrind $vjs $pcre2grep -o3 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep |
| 383 | echo "RC=$?" >>testtrygrep |
| 384 | |
| 385 | echo "---------------------------- Test 67 ------------------------------" >>testtrygrep |
| 386 | (cd $srcdir; $valgrind $vjs $pcre2grep -o12 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep |
| 387 | echo "RC=$?" >>testtrygrep |
| 388 | |
| 389 | echo "---------------------------- Test 68 ------------------------------" >>testtrygrep |
| 390 | (cd $srcdir; $valgrind $vjs $pcre2grep --only-matching=2 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep |
| 391 | echo "RC=$?" >>testtrygrep |
| 392 | |
| 393 | echo "---------------------------- Test 69 -----------------------------" >>testtrygrep |
| 394 | (cd $srcdir; $valgrind $vjs $pcre2grep -vn --colour=always pattern ./testdata/grepinputx) >>testtrygrep |
| 395 | echo "RC=$?" >>testtrygrep |
| 396 | |
| 397 | echo "---------------------------- Test 70 -----------------------------" >>testtrygrep |
| 398 | (cd $srcdir; $valgrind $vjs $pcre2grep --color=always -M "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep |
| 399 | echo "RC=$?" >>testtrygrep |
| 400 | (cd $srcdir; $valgrind $vjs $pcre2grep --color=always -M -n "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep |
| 401 | echo "RC=$?" >>testtrygrep |
| 402 | (cd $srcdir; $valgrind $vjs $pcre2grep -M "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep |
| 403 | echo "RC=$?" >>testtrygrep |
| 404 | (cd $srcdir; $valgrind $vjs $pcre2grep -M -n "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep |
| 405 | echo "RC=$?" >>testtrygrep |
| 406 | |
| 407 | echo "---------------------------- Test 71 -----------------------------" >>testtrygrep |
| 408 | (cd $srcdir; $valgrind $vjs $pcre2grep -o "^01|^02|^03" ./testdata/grepinput) >>testtrygrep |
| 409 | echo "RC=$?" >>testtrygrep |
| 410 | |
| 411 | echo "---------------------------- Test 72 -----------------------------" >>testtrygrep |
| 412 | (cd $srcdir; $valgrind $vjs $pcre2grep --color=always "^01|^02|^03" ./testdata/grepinput) >>testtrygrep |
| 413 | echo "RC=$?" >>testtrygrep |
| 414 | |
| 415 | echo "---------------------------- Test 73 -----------------------------" >>testtrygrep |
| 416 | (cd $srcdir; $valgrind $vjs $pcre2grep -o --colour=always "^01|^02|^03" ./testdata/grepinput) >>testtrygrep |
| 417 | echo "RC=$?" >>testtrygrep |
| 418 | |
| 419 | echo "---------------------------- Test 74 -----------------------------" >>testtrygrep |
| 420 | (cd $srcdir; $valgrind $vjs $pcre2grep -o "^01|02|^03" ./testdata/grepinput) >>testtrygrep |
| 421 | echo "RC=$?" >>testtrygrep |
| 422 | |
| 423 | echo "---------------------------- Test 75 -----------------------------" >>testtrygrep |
| 424 | (cd $srcdir; $valgrind $vjs $pcre2grep --color=always "^01|02|^03" ./testdata/grepinput) >>testtrygrep |
| 425 | echo "RC=$?" >>testtrygrep |
| 426 | |
| 427 | echo "---------------------------- Test 76 -----------------------------" >>testtrygrep |
| 428 | (cd $srcdir; $valgrind $vjs $pcre2grep -o --colour=always "^01|02|^03" ./testdata/grepinput) >>testtrygrep |
| 429 | echo "RC=$?" >>testtrygrep |
| 430 | |
| 431 | echo "---------------------------- Test 77 -----------------------------" >>testtrygrep |
| 432 | (cd $srcdir; $valgrind $vjs $pcre2grep -o "^01|^02|03" ./testdata/grepinput) >>testtrygrep |
| 433 | echo "RC=$?" >>testtrygrep |
| 434 | |
| 435 | echo "---------------------------- Test 78 -----------------------------" >>testtrygrep |
| 436 | (cd $srcdir; $valgrind $vjs $pcre2grep --color=always "^01|^02|03" ./testdata/grepinput) >>testtrygrep |
| 437 | echo "RC=$?" >>testtrygrep |
| 438 | |
| 439 | echo "---------------------------- Test 79 -----------------------------" >>testtrygrep |
| 440 | (cd $srcdir; $valgrind $vjs $pcre2grep -o --colour=always "^01|^02|03" ./testdata/grepinput) >>testtrygrep |
| 441 | echo "RC=$?" >>testtrygrep |
| 442 | |
| 443 | echo "---------------------------- Test 80 -----------------------------" >>testtrygrep |
| 444 | (cd $srcdir; $valgrind $vjs $pcre2grep -o "\b01|\b02" ./testdata/grepinput) >>testtrygrep |
| 445 | echo "RC=$?" >>testtrygrep |
| 446 | |
| 447 | echo "---------------------------- Test 81 -----------------------------" >>testtrygrep |
| 448 | (cd $srcdir; $valgrind $vjs $pcre2grep --color=always "\\b01|\\b02" ./testdata/grepinput) >>testtrygrep |
| 449 | echo "RC=$?" >>testtrygrep |
| 450 | |
| 451 | echo "---------------------------- Test 82 -----------------------------" >>testtrygrep |
| 452 | (cd $srcdir; $valgrind $vjs $pcre2grep -o --colour=always "\\b01|\\b02" ./testdata/grepinput) >>testtrygrep |
| 453 | echo "RC=$?" >>testtrygrep |
| 454 | |
| 455 | echo "---------------------------- Test 83 -----------------------------" >>testtrygrep |
| 456 | (cd $srcdir; $valgrind $vjs $pcre2grep --buffer-size=10 --max-buffer-size=100 "^a" ./testdata/grepinput3) >>testtrygrep 2>&1 |
| 457 | echo "RC=$?" >>testtrygrep |
| 458 | |
| 459 | echo "---------------------------- Test 84 -----------------------------" >>testtrygrep |
| 460 | echo testdata/grepinput3 >testtemp1grep |
| 461 | (cd $srcdir; $valgrind $vjs $pcre2grep --file-list ./testdata/grepfilelist --file-list $builddir/testtemp1grep "fox|complete|t7") >>testtrygrep 2>&1 |
| 462 | echo "RC=$?" >>testtrygrep |
| 463 | |
| 464 | echo "---------------------------- Test 85 -----------------------------" >>testtrygrep |
| 465 | (cd $srcdir; $valgrind $vjs $pcre2grep --file-list=./testdata/grepfilelist "dolor" ./testdata/grepinput3) >>testtrygrep 2>&1 |
| 466 | echo "RC=$?" >>testtrygrep |
| 467 | |
| 468 | echo "---------------------------- Test 86 -----------------------------" >>testtrygrep |
| 469 | (cd $srcdir; $valgrind $vjs $pcre2grep "dog" ./testdata/grepbinary) >>testtrygrep 2>&1 |
| 470 | echo "RC=$?" >>testtrygrep |
| 471 | |
| 472 | echo "---------------------------- Test 87 -----------------------------" >>testtrygrep |
| 473 | (cd $srcdir; $valgrind $vjs $pcre2grep "cat" ./testdata/grepbinary) >>testtrygrep 2>&1 |
| 474 | echo "RC=$?" >>testtrygrep |
| 475 | |
| 476 | echo "---------------------------- Test 88 -----------------------------" >>testtrygrep |
| 477 | (cd $srcdir; $valgrind $vjs $pcre2grep -v "cat" ./testdata/grepbinary) >>testtrygrep 2>&1 |
| 478 | echo "RC=$?" >>testtrygrep |
| 479 | |
| 480 | echo "---------------------------- Test 89 -----------------------------" >>testtrygrep |
| 481 | (cd $srcdir; $valgrind $vjs $pcre2grep -I "dog" ./testdata/grepbinary) >>testtrygrep 2>&1 |
| 482 | echo "RC=$?" >>testtrygrep |
| 483 | |
| 484 | echo "---------------------------- Test 90 -----------------------------" >>testtrygrep |
| 485 | (cd $srcdir; $valgrind $vjs $pcre2grep --binary-files=without-match "dog" ./testdata/grepbinary) >>testtrygrep 2>&1 |
| 486 | echo "RC=$?" >>testtrygrep |
| 487 | |
| 488 | echo "---------------------------- Test 91 -----------------------------" >>testtrygrep |
| 489 | (cd $srcdir; $valgrind $vjs $pcre2grep -a "dog" ./testdata/grepbinary) >>testtrygrep 2>&1 |
| 490 | echo "RC=$?" >>testtrygrep |
| 491 | |
| 492 | echo "---------------------------- Test 92 -----------------------------" >>testtrygrep |
| 493 | (cd $srcdir; $valgrind $vjs $pcre2grep --binary-files=text "dog" ./testdata/grepbinary) >>testtrygrep 2>&1 |
| 494 | echo "RC=$?" >>testtrygrep |
| 495 | |
| 496 | echo "---------------------------- Test 93 -----------------------------" >>testtrygrep |
| 497 | (cd $srcdir; $valgrind $vjs $pcre2grep --text "dog" ./testdata/grepbinary) >>testtrygrep 2>&1 |
| 498 | echo "RC=$?" >>testtrygrep |
| 499 | |
| 500 | echo "---------------------------- Test 94 -----------------------------" >>testtrygrep |
| 501 | (cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include=grepinputx --include grepinput8 'fox' ./testdata/grepinput* | sort) >>testtrygrep |
| 502 | echo "RC=$?" >>testtrygrep |
| 503 | |
| 504 | echo "---------------------------- Test 95 -----------------------------" >>testtrygrep |
| 505 | (cd $srcdir; $valgrind $vjs $pcre2grep --file-list ./testdata/grepfilelist --exclude grepinputv "fox|complete") >>testtrygrep 2>&1 |
| 506 | echo "RC=$?" >>testtrygrep |
| 507 | |
| 508 | echo "---------------------------- Test 96 -----------------------------" >>testtrygrep |
| 509 | (cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include-dir=testdata --exclude '^(?!grepinput)' --exclude=grepinputM 'fox' ./test* | sort) >>testtrygrep |
| 510 | echo "RC=$?" >>testtrygrep |
| 511 | |
| 512 | echo "---------------------------- Test 97 -----------------------------" >>testtrygrep |
| 513 | echo "grepinput$" >testtemp1grep |
| 514 | echo "grepinput8" >>testtemp1grep |
| 515 | (cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include=grepinput --exclude=grepinputM --exclude-from $builddir/testtemp1grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep |
| 516 | echo "RC=$?" >>testtrygrep |
| 517 | |
| 518 | echo "---------------------------- Test 98 -----------------------------" >>testtrygrep |
| 519 | echo "grepinput$" >testtemp1grep |
| 520 | echo "grepinput8" >>testtemp1grep |
| 521 | (cd $srcdir; $valgrind $vjs $pcre2grep -L -r --exclude=grepinput3 --exclude=grepinputM --include=grepinput --exclude-from $builddir/testtemp1grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep |
| 522 | echo "RC=$?" >>testtrygrep |
| 523 | |
| 524 | echo "---------------------------- Test 99 -----------------------------" >>testtrygrep |
| 525 | echo "grepinput$" >testtemp1grep |
| 526 | echo "grepinput8" >testtemp2grep |
| 527 | (cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include grepinput --exclude=grepinputM --exclude-from $builddir/testtemp1grep --exclude-from=$builddir/testtemp2grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep |
| 528 | echo "RC=$?" >>testtrygrep |
| 529 | |
| 530 | echo "---------------------------- Test 100 ------------------------------" >>testtrygrep |
| 531 | (cd $srcdir; $valgrind $vjs $pcre2grep -Ho2 --only-matching=1 -o3 '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep |
| 532 | echo "RC=$?" >>testtrygrep |
| 533 | |
| 534 | echo "---------------------------- Test 101 ------------------------------" >>testtrygrep |
| 535 | (cd $srcdir; $valgrind $vjs $pcre2grep -o3 -Ho2 -o12 --only-matching=1 -o3 --colour=always --om-separator='|' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep |
| 536 | echo "RC=$?" >>testtrygrep |
| 537 | |
| 538 | echo "---------------------------- Test 102 -----------------------------" >>testtrygrep |
| 539 | (cd $srcdir; $valgrind $vjs $pcre2grep -n "^$" ./testdata/grepinput3) >>testtrygrep 2>&1 |
| 540 | echo "RC=$?" >>testtrygrep |
| 541 | |
| 542 | echo "---------------------------- Test 103 -----------------------------" >>testtrygrep |
| 543 | (cd $srcdir; $valgrind $vjs $pcre2grep --only-matching "^$" ./testdata/grepinput3) >>testtrygrep 2>&1 |
| 544 | echo "RC=$?" >>testtrygrep |
| 545 | |
| 546 | echo "---------------------------- Test 104 -----------------------------" >>testtrygrep |
| 547 | (cd $srcdir; $valgrind $vjs $pcre2grep -n --only-matching "^$" ./testdata/grepinput3) >>testtrygrep 2>&1 |
| 548 | echo "RC=$?" >>testtrygrep |
| 549 | |
| 550 | echo "---------------------------- Test 105 -----------------------------" >>testtrygrep |
| 551 | (cd $srcdir; $valgrind $vjs $pcre2grep --colour=always "ipsum|" ./testdata/grepinput3) >>testtrygrep 2>&1 |
| 552 | echo "RC=$?" >>testtrygrep |
| 553 | |
| 554 | echo "---------------------------- Test 106 -----------------------------" >>testtrygrep |
| 555 | (cd $srcdir; echo "a" | $valgrind $vjs $pcre2grep -M "|a" ) >>testtrygrep 2>&1 |
| 556 | echo "RC=$?" >>testtrygrep |
| 557 | |
| 558 | echo "---------------------------- Test 107 -----------------------------" >>testtrygrep |
| 559 | echo "a" >testtemp1grep |
| 560 | echo "aaaaa" >>testtemp1grep |
| 561 | (cd $srcdir; $valgrind $vjs $pcre2grep --line-offsets --allow-lookaround-bsk '(?<=\Ka)' $builddir/testtemp1grep) >>testtrygrep 2>&1 |
| 562 | echo "RC=$?" >>testtrygrep |
| 563 | |
| 564 | echo "---------------------------- Test 108 ------------------------------" >>testtrygrep |
| 565 | (cd $srcdir; $valgrind $vjs $pcre2grep -lq PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep |
| 566 | echo "RC=$?" >>testtrygrep |
| 567 | |
| 568 | echo "---------------------------- Test 109 -----------------------------" >>testtrygrep |
| 569 | (cd $srcdir; $valgrind $vjs $pcre2grep -cq lazy ./testdata/grepinput*) >>testtrygrep |
| 570 | echo "RC=$?" >>testtrygrep |
| 571 | |
| 572 | echo "---------------------------- Test 110 -----------------------------" >>testtrygrep |
| 573 | (cd $srcdir; $valgrind $vjs $pcre2grep --om-separator / -Mo0 -o1 -o2 'match (\d+):\n (.)\n' testdata/grepinput) >>testtrygrep |
| 574 | echo "RC=$?" >>testtrygrep |
| 575 | |
| 576 | echo "---------------------------- Test 111 -----------------------------" >>testtrygrep |
| 577 | (cd $srcdir; $valgrind $vjs $pcre2grep --line-offsets -M 'match (\d+):\n (.)\n' testdata/grepinput) >>testtrygrep |
| 578 | echo "RC=$?" >>testtrygrep |
| 579 | |
| 580 | echo "---------------------------- Test 112 -----------------------------" >>testtrygrep |
| 581 | (cd $srcdir; $valgrind $vjs $pcre2grep --file-offsets -M 'match (\d+):\n (.)\n' testdata/grepinput) >>testtrygrep |
| 582 | echo "RC=$?" >>testtrygrep |
| 583 | |
| 584 | echo "---------------------------- Test 113 -----------------------------" >>testtrygrep |
| 585 | (cd $srcdir; $valgrind $vjs $pcre2grep --total-count 'the' testdata/grepinput*) >>testtrygrep |
| 586 | echo "RC=$?" >>testtrygrep |
| 587 | |
| 588 | echo "---------------------------- Test 114 -----------------------------" >>testtrygrep |
| 589 | (cd $srcdir; $valgrind $vjs $pcre2grep -tc 'the' testdata/grepinput*) >>testtrygrep |
| 590 | echo "RC=$?" >>testtrygrep |
| 591 | |
| 592 | echo "---------------------------- Test 115 -----------------------------" >>testtrygrep |
| 593 | (cd $srcdir; $valgrind $vjs $pcre2grep -tlc 'the' testdata/grepinput*) >>testtrygrep |
| 594 | echo "RC=$?" >>testtrygrep |
| 595 | |
| 596 | echo "---------------------------- Test 116 -----------------------------" >>testtrygrep |
| 597 | (cd $srcdir; $valgrind $vjs $pcre2grep --exclude=grepinputM -th 'the' testdata/grepinput*) >>testtrygrep |
| 598 | echo "RC=$?" >>testtrygrep |
| 599 | |
| 600 | echo "---------------------------- Test 117 -----------------------------" >>testtrygrep |
| 601 | (cd $srcdir; $valgrind $vjs $pcre2grep -tch 'the' testdata/grepinput*) >>testtrygrep |
| 602 | echo "RC=$?" >>testtrygrep |
| 603 | |
| 604 | echo "---------------------------- Test 118 -----------------------------" >>testtrygrep |
| 605 | (cd $srcdir; $valgrind $vjs $pcre2grep -tL 'the' testdata/grepinput*) >>testtrygrep |
| 606 | echo "RC=$?" >>testtrygrep |
| 607 | |
| 608 | echo "---------------------------- Test 119 -----------------------------" >>testtrygrep |
| 609 | printf '123\n456\n789\n---abc\ndef\nxyz\n---\n' >testNinputgrep |
| 610 | $valgrind $vjs $pcre2grep -Mo '(\n|[^-])*---' testNinputgrep >>testtrygrep |
| 611 | echo "RC=$?" >>testtrygrep |
| 612 | |
| 613 | echo "---------------------------- Test 120 ------------------------------" >>testtrygrep |
| 614 | (cd $srcdir; $valgrind $vjs $pcre2grep -HO '$0:$2$1$3' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep |
| 615 | echo "RC=$?" >>testtrygrep |
| 616 | |
| 617 | echo "---------------------------- Test 121 -----------------------------" >>testtrygrep |
| 618 | (cd $srcdir; $valgrind $vjs $pcre2grep -F '\E and (regex)' testdata/grepinputv) >>testtrygrep |
| 619 | echo "RC=$?" >>testtrygrep |
| 620 | |
| 621 | echo "---------------------------- Test 122 -----------------------------" >>testtrygrep |
| 622 | (cd $srcdir; $valgrind $vjs $pcre2grep -w 'cat|dog' testdata/grepinputv) >>testtrygrep |
| 623 | echo "RC=$?" >>testtrygrep |
| 624 | |
| 625 | echo "---------------------------- Test 123 -----------------------------" >>testtrygrep |
| 626 | (cd $srcdir; $valgrind $vjs $pcre2grep -w 'dog|cat' testdata/grepinputv) >>testtrygrep |
| 627 | echo "RC=$?" >>testtrygrep |
| 628 | |
| 629 | echo "---------------------------- Test 124 -----------------------------" >>testtrygrep |
| 630 | (cd $srcdir; $valgrind $vjs $pcre2grep -Mn --colour=always 'start[\s]+end' testdata/grepinputM) >>testtrygrep |
| 631 | echo "RC=$?" >>testtrygrep |
| 632 | (cd $srcdir; $valgrind $vjs $pcre2grep -Mn --colour=always -A2 'start[\s]+end' testdata/grepinputM) >>testtrygrep |
| 633 | echo "RC=$?" >>testtrygrep |
| 634 | (cd $srcdir; $valgrind $vjs $pcre2grep -Mn 'start[\s]+end' testdata/grepinputM) >>testtrygrep |
| 635 | echo "RC=$?" >>testtrygrep |
| 636 | (cd $srcdir; $valgrind $vjs $pcre2grep -Mn -A2 'start[\s]+end' testdata/grepinputM) >>testtrygrep |
| 637 | echo "RC=$?" >>testtrygrep |
| 638 | |
| 639 | echo "---------------------------- Test 125 -----------------------------" >>testtrygrep |
| 640 | printf 'abcd\n' >testNinputgrep |
| 641 | $valgrind $vjs $pcre2grep --colour=always --allow-lookaround-bsk '(?<=\K.)' testNinputgrep >>testtrygrep |
| 642 | echo "RC=$?" >>testtrygrep |
| 643 | $valgrind $vjs $pcre2grep --colour=always --allow-lookaround-bsk '(?=.\K)' testNinputgrep >>testtrygrep |
| 644 | echo "RC=$?" >>testtrygrep |
| 645 | $valgrind $vjs $pcre2grep --colour=always --allow-lookaround-bsk '(?<=\K[ac])' testNinputgrep >>testtrygrep |
| 646 | echo "RC=$?" >>testtrygrep |
| 647 | $valgrind $vjs $pcre2grep --colour=always --allow-lookaround-bsk '(?=[ac]\K)' testNinputgrep >>testtrygrep |
| 648 | echo "RC=$?" >>testtrygrep |
| 649 | |
| 650 | echo "---------------------------- Test 126 -----------------------------" >>testtrygrep |
| 651 | printf 'Next line pattern has binary zero\nABC\0XYZ\n' >testtemp1grep |
| 652 | printf 'ABC\0XYZ\nABCDEF\nDEFABC\n' >testtemp2grep |
| 653 | $valgrind $vjs $pcre2grep -a -f testtemp1grep testtemp2grep >>testtrygrep |
| 654 | echo "RC=$?" >>testtrygrep |
| 655 | |
| 656 | echo "---------------------------- Test 127 -----------------------------" >>testtrygrep |
| 657 | (cd $srcdir; $valgrind $vjs $pcre2grep -o --om-capture=0 'pattern()()()()' testdata/grepinput) >>testtrygrep |
| 658 | echo "RC=$?" >>testtrygrep |
| 659 | |
| 660 | echo "---------------------------- Test 128 -----------------------------" >>testtrygrep |
| 661 | (cd $srcdir; $valgrind $vjs $pcre2grep -o1 --om-capture=0 'pattern()()()()' testdata/grepinput) >>testtrygrep 2>&1 |
| 662 | echo "RC=$?" >>testtrygrep |
| 663 | |
| 664 | echo "---------------------------- Test 129 -----------------------------" >>testtrygrep |
| 665 | (cd $srcdir; $valgrind $vjs $pcre2grep -m 2 'fox' testdata/grepinput) >>testtrygrep 2>&1 |
| 666 | echo "RC=$?" >>testtrygrep |
| 667 | |
| 668 | echo "---------------------------- Test 130 -----------------------------" >>testtrygrep |
| 669 | (cd $srcdir; $valgrind $vjs $pcre2grep -o -m2 'fox' testdata/grepinput) >>testtrygrep 2>&1 |
| 670 | echo "RC=$?" >>testtrygrep |
| 671 | |
| 672 | echo "---------------------------- Test 131 -----------------------------" >>testtrygrep |
| 673 | (cd $srcdir; $valgrind $vjs $pcre2grep -oc -m2 'fox' testdata/grepinput) >>testtrygrep 2>&1 |
| 674 | echo "RC=$?" >>testtrygrep |
| 675 | |
| 676 | echo "---------------------------- Test 132 -----------------------------" >>testtrygrep |
Elliott Hughes | 4e19c8e | 2022-04-15 15:11:02 -0700 | [diff] [blame] | 677 | (cd $srcdir; exec 3<testdata/grepinput; $valgrind $vjs $pcre2grep -m1 -A3 '^match' <&3; echo '---'; head -1 <&3; exec 3<&-) >>testtrygrep 2>&1 |
Elliott Hughes | 5b80804 | 2021-10-01 10:56:10 -0700 | [diff] [blame] | 678 | echo "RC=$?" >>testtrygrep |
| 679 | |
| 680 | echo "---------------------------- Test 133 -----------------------------" >>testtrygrep |
Elliott Hughes | 4e19c8e | 2022-04-15 15:11:02 -0700 | [diff] [blame] | 681 | (cd $srcdir; exec 3<testdata/grepinput; $valgrind $vjs $pcre2grep -m1 -A3 '^match' <&3; echo '---'; $valgrind $vjs $pcre2grep -m1 -A3 '^match' <&3; exec 3<&-) >>testtrygrep 2>&1 |
| 682 | echo "RC=$?" >>testtrygrep |
| 683 | |
| 684 | echo "---------------------------- Test 134 -----------------------------" >>testtrygrep |
Elliott Hughes | 5b80804 | 2021-10-01 10:56:10 -0700 | [diff] [blame] | 685 | (cd $srcdir; $valgrind $vjs $pcre2grep -m1 -O '=$x{41}$x423$o{103}$o1045=' 'fox') <$srcdir/testdata/grepinputv >>testtrygrep 2>&1 |
| 686 | echo "RC=$?" >>testtrygrep |
| 687 | |
| 688 | # Now compare the results. |
| 689 | |
| 690 | $cf $srcdir/testdata/grepoutput testtrygrep |
| 691 | if [ $? != 0 ] ; then exit 1; fi |
| 692 | |
| 693 | |
| 694 | # These tests require UTF-8 support |
| 695 | |
| 696 | if [ $utf8 -ne 0 ] ; then |
| 697 | echo "Testing pcre2grep UTF-8 features" |
| 698 | |
| 699 | echo "---------------------------- Test U1 ------------------------------" >testtrygrep |
| 700 | (cd $srcdir; $valgrind $vjs $pcre2grep -n -u --newline=any "^X" ./testdata/grepinput8) >>testtrygrep |
| 701 | echo "RC=$?" >>testtrygrep |
| 702 | |
| 703 | echo "---------------------------- Test U2 ------------------------------" >>testtrygrep |
| 704 | (cd $srcdir; $valgrind $vjs $pcre2grep -n -u -C 3 --newline=any "Match" ./testdata/grepinput8) >>testtrygrep |
| 705 | echo "RC=$?" >>testtrygrep |
| 706 | |
| 707 | echo "---------------------------- Test U3 ------------------------------" >>testtrygrep |
| 708 | (cd $srcdir; $valgrind $vjs $pcre2grep --line-offsets -u --newline=any --allow-lookaround-bsk '(?<=\K\x{17f})' ./testdata/grepinput8) >>testtrygrep |
| 709 | echo "RC=$?" >>testtrygrep |
| 710 | |
| 711 | echo "---------------------------- Test U4 ------------------------------" >>testtrygrep |
| 712 | printf 'A\341\200\200\200CD\342\200\200Z\n' >testtemp1grep |
| 713 | (cd $srcdir; $valgrind $vjs $pcre2grep -u -o '....' $builddir/testtemp1grep) >>testtrygrep 2>&1 |
| 714 | echo "RC=$?" >>testtrygrep |
| 715 | |
| 716 | echo "---------------------------- Test U5 ------------------------------" >>testtrygrep |
| 717 | printf 'A\341\200\200\200CD\342\200\200Z\n' >testtemp1grep |
| 718 | (cd $srcdir; $valgrind $vjs $pcre2grep -U -o '....' $builddir/testtemp1grep) >>testtrygrep |
| 719 | echo "RC=$?" >>testtrygrep |
| 720 | |
| 721 | echo "---------------------------- Test U6 -----------------------------" >>testtrygrep |
| 722 | (cd $srcdir; $valgrind $vjs $pcre2grep -u -m1 -O '=$x{1d3}$o{744}=' 'fox') <$srcdir/testdata/grepinputv >>testtrygrep 2>&1 |
| 723 | echo "RC=$?" >>testtrygrep |
| 724 | |
| 725 | $cf $srcdir/testdata/grepoutput8 testtrygrep |
| 726 | if [ $? != 0 ] ; then exit 1; fi |
| 727 | |
| 728 | else |
| 729 | echo "Skipping pcre2grep UTF-8 tests: no UTF-8 support in PCRE2 library" |
| 730 | fi |
| 731 | |
| 732 | |
| 733 | # We go to some contortions to try to ensure that the tests for the various |
| 734 | # newline settings will work in environments where the normal newline sequence |
| 735 | # is not \n. Do not use exported files, whose line endings might be changed. |
| 736 | # Instead, create an input file using printf so that its contents are exactly |
| 737 | # what we want. Note the messy fudge to get printf to write a string that |
| 738 | # starts with a hyphen. These tests are run in the build directory. |
| 739 | |
| 740 | echo "Testing pcre2grep newline settings" |
| 741 | printf 'abc\rdef\r\nghi\njkl' >testNinputgrep |
| 742 | |
| 743 | printf '%c--------------------------- Test N1 ------------------------------\r\n' - >testtrygrep |
| 744 | $valgrind $vjs $pcre2grep -n -N CR "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep |
| 745 | |
| 746 | printf '%c--------------------------- Test N2 ------------------------------\r\n' - >>testtrygrep |
| 747 | $valgrind $vjs $pcre2grep -n --newline=crlf "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep |
| 748 | |
| 749 | printf '%c--------------------------- Test N3 ------------------------------\r\n' - >>testtrygrep |
| 750 | pattern=`printf 'def\rjkl'` |
| 751 | $valgrind $vjs $pcre2grep -n --newline=cr -F "$pattern" testNinputgrep >>testtrygrep |
| 752 | |
| 753 | printf '%c--------------------------- Test N4 ------------------------------\r\n' - >>testtrygrep |
| 754 | $valgrind $vjs $pcre2grep -n --newline=crlf -F -f $srcdir/testdata/greppatN4 testNinputgrep >>testtrygrep |
| 755 | |
| 756 | printf '%c--------------------------- Test N5 ------------------------------\r\n' - >>testtrygrep |
| 757 | $valgrind $vjs $pcre2grep -n --newline=any "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep |
| 758 | |
| 759 | printf '%c--------------------------- Test N6 ------------------------------\r\n' - >>testtrygrep |
| 760 | $valgrind $vjs $pcre2grep -n --newline=anycrlf "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep |
| 761 | |
| 762 | # This next test involves NUL characters. It seems impossible to handle them |
| 763 | # easily in many operating systems. An earlier version of this script used sed |
| 764 | # to translate NUL into the string ZERO, but this didn't work on Solaris (aka |
| 765 | # SunOS), where the version of sed explicitly doesn't like them, and also MacOS |
| 766 | # (Darwin), OpenBSD, FreeBSD, NetBSD, and some Linux distributions like Alpine, |
| 767 | # even when using GNU sed. A user suggested using tr instead, which |
| 768 | # necessitates translating to a single character (@). However, on (some |
| 769 | # versions of?) Solaris, the normal "tr" cannot handle binary zeros, but if |
| 770 | # /usr/xpg4/bin/tr is available, it can do so, so test for that. |
| 771 | |
| 772 | if [ -x /usr/xpg4/bin/tr ] ; then |
| 773 | tr=/usr/xpg4/bin/tr |
| 774 | else |
| 775 | tr=tr |
| 776 | fi |
| 777 | |
| 778 | printf '%c--------------------------- Test N7 ------------------------------\r\n' - >>testtrygrep |
| 779 | printf 'abc\0def' >testNinputgrep |
| 780 | $valgrind $vjs $pcre2grep -na --newline=nul "^(abc|def)" testNinputgrep | $tr '\000' '@' >>testtrygrep |
| 781 | echo "" >>testtrygrep |
| 782 | |
| 783 | $cf $srcdir/testdata/grepoutputN testtrygrep |
| 784 | if [ $? != 0 ] ; then exit 1; fi |
| 785 | |
| 786 | # If pcre2grep supports script callouts, run some tests on them. It is possible |
| 787 | # to restrict these callouts to the non-fork case, either for security, or for |
| 788 | # environments that do not support fork(). This is handled by comparing to a |
| 789 | # different output. |
| 790 | |
| 791 | if $valgrind $vjs $pcre2grep --help | $valgrind $vjs $pcre2grep -q 'callout scripts in patterns are supported'; then |
| 792 | echo "Testing pcre2grep script callouts" |
| 793 | $valgrind $vjs $pcre2grep '(T)(..(.))(?C"/bin/echo|Arg1: [$1] [$2] [$3]|Arg2: $|${1}$| ($4) ($14) ($0)")()' $srcdir/testdata/grepinputv >testtrygrep |
| 794 | $valgrind $vjs $pcre2grep '(T)(..(.))()()()()()()()(..)(?C"/bin/echo|Arg1: [$11] [${11}]")' $srcdir/testdata/grepinputv >>testtrygrep |
| 795 | $valgrind $vjs $pcre2grep '(T)(?C"|$0:$1$n")' $srcdir/testdata/grepinputv >>testtrygrep |
| 796 | $valgrind $vjs $pcre2grep '(T)(?C"|$1$n")(*F)' $srcdir/testdata/grepinputv >>testtrygrep |
| 797 | $valgrind $vjs $pcre2grep -m1 '(T)(?C"|$0:$1:$x{41}$o{101}$n")' $srcdir/testdata/grepinputv >>testtrygrep |
| 798 | |
| 799 | if $valgrind $vjs $pcre2grep --help | $valgrind $vjs $pcre2grep -q 'Non-fork callout scripts in patterns are supported'; then |
| 800 | $cf $srcdir/testdata/grepoutputCN testtrygrep |
| 801 | else |
| 802 | $cf $srcdir/testdata/grepoutputC testtrygrep |
| 803 | fi |
| 804 | |
| 805 | if [ $? != 0 ] ; then exit 1; fi |
| 806 | else |
| 807 | echo "Script callouts are not supported" |
| 808 | fi |
| 809 | |
| 810 | # Finally, some tests to exercise code that is not tested above, just to be |
| 811 | # sure that it runs OK. Doing this improves the coverage statistics. The output |
| 812 | # is not checked. |
| 813 | |
| 814 | echo "Testing miscellaneous pcre2grep arguments (unchecked)" |
| 815 | echo '' >testtrygrep |
| 816 | checkspecial '-xxxxx' 2 |
| 817 | checkspecial '--help' 0 |
| 818 | checkspecial '--line-buffered --colour=auto abc /dev/null' 1 |
| 819 | |
| 820 | # Clean up local working files |
| 821 | rm -f testNinputgrep teststderrgrep testtrygrep testtemp1grep testtemp2grep |
| 822 | |
| 823 | exit 0 |
| 824 | |
| 825 | # End |