5
5
# supported by pcregrep.
7
7
# Set the C locale, so that sort(1) behaves predictably.
12
# Remove any non-default colouring and aliases that the caller may have set.
14
unset PCREGREP_COLOUR PCREGREP_COLOR
17
# Set the program to be tested, and valgrind settings when requested.
11
19
pcregrep=`pwd`/pcregrep
14
22
while [ $# -gt 0 ] ; do
16
valgrind) valgrind="valgrind -q --leak-check=no";;
24
valgrind) valgrind="valgrind -q --leak-check=no --smc-check=all";;
17
25
*) echo "RunGrepTest: Unknown argument $1"; exit 1;;
33
39
# Set up a suitable "diff" command for comparison. Some systems have a diff
34
40
# that lacks a -u option. Try to deal with this; better do the test for the -b
37
44
if diff -u /dev/null /dev/null; then
38
45
if diff -ub /dev/null /dev/null; then cf="diff -ub"; else cf="diff -u"; fi
43
50
# If PCRE has been built in a directory other than the source directory, and
44
# this test is being run from "make check" as usual, then $(srcdir) will be
45
# set. If not, set it to the current directory. We then arrange to run the
46
# pcregrep command in the source directory so that the file names that appear
47
# in the output are always the same.
51
# this test is being run from "make check" as usual, then $srcdir will be
52
# set. If not, set it to the current or parent directory, whichever one
53
# contains the test data. We then arrange to run the pcregrep command in the
54
# source directory so that the file names that appear in the output are always
49
57
if [ -z "$srcdir" -o ! -d "$srcdir/testdata" ] ; then
58
if [ -d "./testdata" ] ; then
60
elif [ -d "../testdata" ] ; then
63
echo "Cannot find the testdata directory"
53
68
# Check for the availability of UTF-8 support
55
./pcretest -C | ./pcregrep "No UTF-8 support" >/dev/null
70
./pcretest -C utf >/dev/null
58
73
echo "---------------------------- Test 1 ------------------------------" >testtry
305
320
echo "RC=$?" >>testtry
307
322
echo "---------------------------- Test 62 -----------------------------" >>testtry
308
(cd $srcdir; $valgrind $pcregrep --match-limit=1000 -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtry 2>&1
323
(cd $srcdir; $valgrind $pcregrep --match-limit=1000 --no-jit -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtry 2>&1
309
324
echo "RC=$?" >>testtry
311
326
echo "---------------------------- Test 63 -----------------------------" >>testtry
312
(cd $srcdir; $valgrind $pcregrep --recursion-limit=1000 -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtry 2>&1
327
(cd $srcdir; $valgrind $pcregrep --recursion-limit=1000 --no-jit -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtry 2>&1
313
328
echo "RC=$?" >>testtry
315
330
echo "---------------------------- Test 64 ------------------------------" >>testtry
340
355
(cd $srcdir; $valgrind $pcregrep --color=always -M "triple:\t.*\n\n" ./testdata/grepinput3) >>testtry
341
356
echo "RC=$?" >>testtry
358
echo "---------------------------- Test 71 -----------------------------" >>testtry
359
(cd $srcdir; $valgrind $pcregrep -o "^01|^02|^03" ./testdata/grepinput) >>testtry
360
echo "RC=$?" >>testtry
362
echo "---------------------------- Test 72 -----------------------------" >>testtry
363
(cd $srcdir; $valgrind $pcregrep --color=always "^01|^02|^03" ./testdata/grepinput) >>testtry
364
echo "RC=$?" >>testtry
366
echo "---------------------------- Test 73 -----------------------------" >>testtry
367
(cd $srcdir; $valgrind $pcregrep -o --colour=always "^01|^02|^03" ./testdata/grepinput) >>testtry
368
echo "RC=$?" >>testtry
370
echo "---------------------------- Test 74 -----------------------------" >>testtry
371
(cd $srcdir; $valgrind $pcregrep -o "^01|02|^03" ./testdata/grepinput) >>testtry
372
echo "RC=$?" >>testtry
374
echo "---------------------------- Test 75 -----------------------------" >>testtry
375
(cd $srcdir; $valgrind $pcregrep --color=always "^01|02|^03" ./testdata/grepinput) >>testtry
376
echo "RC=$?" >>testtry
378
echo "---------------------------- Test 76 -----------------------------" >>testtry
379
(cd $srcdir; $valgrind $pcregrep -o --colour=always "^01|02|^03" ./testdata/grepinput) >>testtry
380
echo "RC=$?" >>testtry
382
echo "---------------------------- Test 77 -----------------------------" >>testtry
383
(cd $srcdir; $valgrind $pcregrep -o "^01|^02|03" ./testdata/grepinput) >>testtry
384
echo "RC=$?" >>testtry
386
echo "---------------------------- Test 78 -----------------------------" >>testtry
387
(cd $srcdir; $valgrind $pcregrep --color=always "^01|^02|03" ./testdata/grepinput) >>testtry
388
echo "RC=$?" >>testtry
390
echo "---------------------------- Test 79 -----------------------------" >>testtry
391
(cd $srcdir; $valgrind $pcregrep -o --colour=always "^01|^02|03" ./testdata/grepinput) >>testtry
392
echo "RC=$?" >>testtry
394
echo "---------------------------- Test 80 -----------------------------" >>testtry
395
(cd $srcdir; $valgrind $pcregrep -o "\b01|\b02" ./testdata/grepinput) >>testtry
396
echo "RC=$?" >>testtry
398
echo "---------------------------- Test 81 -----------------------------" >>testtry
399
(cd $srcdir; $valgrind $pcregrep --color=always "\\b01|\\b02" ./testdata/grepinput) >>testtry
400
echo "RC=$?" >>testtry
402
echo "---------------------------- Test 82 -----------------------------" >>testtry
403
(cd $srcdir; $valgrind $pcregrep -o --colour=always "\\b01|\\b02" ./testdata/grepinput) >>testtry
404
echo "RC=$?" >>testtry
406
echo "---------------------------- Test 83 -----------------------------" >>testtry
407
(cd $srcdir; $valgrind $pcregrep --buffer-size=100 "^a" ./testdata/grepinput3) >>testtry 2>&1
408
echo "RC=$?" >>testtry
343
410
# Now compare the results.
345
412
$cf $srcdir/testdata/grepoutput testtry
388
455
$valgrind $pcregrep -n --newline=cr -F "$pattern" testNinput >>testtry
390
457
printf "%c--------------------------- Test N4 ------------------------------\r\n" - >>testtry
391
pattern=`printf 'xxx\r\njkl'`
392
$valgrind $pcregrep -n --newline=crlf -F "$pattern" testNinput >>testtry
458
$valgrind $pcregrep -n --newline=crlf -F -f $srcdir/testdata/greppatN4 testNinput >>testtry
394
460
printf "%c--------------------------- Test N5 ------------------------------\r\n" - >>testtry
395
461
$valgrind $pcregrep -n --newline=any "^(abc|def|ghi|jkl)" testNinput >>testtry