/[pcre]/code/trunk/RunGrepTest
ViewVC logotype

Contents of /code/trunk/RunGrepTest

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1324 - (hide annotations) (download)
Fri May 10 11:40:06 2013 UTC (12 days, 3 hours ago) by ph10
File size: 26219 byte(s)
Fix pcregrep so that it can find empty lines.

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

Properties

Name Value
svn:executable *
svn:keywords "Author Date Id Revision Url"

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12