/[pcre]/code/branches/pcre16/RunGrepTest
ViewVC logotype

Contents of /code/branches/pcre16/RunGrepTest

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (hide annotations) (download)
Wed Dec 5 20:56:03 2007 UTC (6 years, 8 months ago) by ph10
Original Path: code/trunk/RunGrepTest
File size: 13105 byte(s)
Add --line-offsets and --file-offsets to pcregrep.

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     # supported by pcregrep.
6 nigel 77
7 ph10 97 # Set the C locale, so that sort(1) behaves predictably.
8     LC_ALL=C
9     export LC_ALL
10    
11 ph10 138 pcregrep=`pwd`/pcregrep
12    
13 ph10 128 echo " "
14 nigel 77 echo "Testing pcregrep"
15 ph10 138 $pcregrep -V
16 nigel 77
17 ph10 131 cf="diff -ub"
18 nigel 87 valgrind=
19 ph10 137
20 nigel 87 while [ $# -gt 0 ] ; do
21     case $1 in
22 ph10 97 valgrind) valgrind="valgrind -q --leak-check=no";;
23 nigel 87 *) echo "Unknown argument $1"; exit 1;;
24     esac
25     shift
26     done
27 nigel 77
28 ph10 138 # If PCRE has been built in a directory other than the source directory, and
29     # this test is being run from "make check" as usual, then $(srcdir) will be
30     # set. If not, set it to the current directory. We then arrange to run the
31     # pcregrep command in the source directory so that the file names that appear
32     # in the output are always the same.
33    
34     if [ -z "$srcdir" -o ! -d "$srcdir/testdata" ] ; then
35     srcdir=.
36 ph10 142 fi
37 ph10 138
38 ph10 116 # Check for the availability of UTF-8 support
39    
40 nigel 93 ./pcretest -C | ./pcregrep "No UTF-8 support" >/dev/null
41 ph10 116 utf8=$?
42 nigel 93
43 nigel 87 echo "---------------------------- Test 1 ------------------------------" >testtry
44 ph10 138 (cd $srcdir; $valgrind $pcregrep PATTERN ./testdata/grepinput) >>testtry
45 nigel 77
46     echo "---------------------------- Test 2 ------------------------------" >>testtry
47 ph10 138 (cd $srcdir; $valgrind $pcregrep '^PATTERN' ./testdata/grepinput) >>testtry
48 nigel 77
49     echo "---------------------------- Test 3 ------------------------------" >>testtry
50 ph10 138 (cd $srcdir; $valgrind $pcregrep -in PATTERN ./testdata/grepinput) >>testtry
51 nigel 77
52     echo "---------------------------- Test 4 ------------------------------" >>testtry
53 ph10 138 (cd $srcdir; $valgrind $pcregrep -ic PATTERN ./testdata/grepinput) >>testtry
54 nigel 77
55     echo "---------------------------- Test 5 ------------------------------" >>testtry
56 ph10 138 (cd $srcdir; $valgrind $pcregrep -in PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry
57 nigel 77
58     echo "---------------------------- Test 6 ------------------------------" >>testtry
59 ph10 138 (cd $srcdir; $valgrind $pcregrep -inh PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry
60 nigel 77
61     echo "---------------------------- Test 7 ------------------------------" >>testtry
62 ph10 138 (cd $srcdir; $valgrind $pcregrep -il PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry
63 nigel 77
64     echo "---------------------------- Test 8 ------------------------------" >>testtry
65 ph10 138 (cd $srcdir; $valgrind $pcregrep -l PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry
66 nigel 77
67     echo "---------------------------- Test 9 ------------------------------" >>testtry
68 ph10 138 (cd $srcdir; $valgrind $pcregrep -q PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry
69 nigel 77 echo "RC=$?" >>testtry
70    
71     echo "---------------------------- Test 10 -----------------------------" >>testtry
72 ph10 138 (cd $srcdir; $valgrind $pcregrep -q NEVER-PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry
73 nigel 77 echo "RC=$?" >>testtry
74    
75     echo "---------------------------- Test 11 -----------------------------" >>testtry
76 ph10 138 (cd $srcdir; $valgrind $pcregrep -vn pattern ./testdata/grepinputx) >>testtry
77 nigel 77
78     echo "---------------------------- Test 12 -----------------------------" >>testtry
79 ph10 138 (cd $srcdir; $valgrind $pcregrep -ix pattern ./testdata/grepinputx) >>testtry
80 nigel 77
81     echo "---------------------------- Test 13 -----------------------------" >>testtry
82 ph10 138 (cd $srcdir; $valgrind $pcregrep -f./testdata/greplist ./testdata/grepinputx) >>testtry
83 nigel 77
84     echo "---------------------------- Test 14 -----------------------------" >>testtry
85 ph10 138 (cd $srcdir; $valgrind $pcregrep -w pat ./testdata/grepinput ./testdata/grepinputx) >>testtry
86 nigel 77
87     echo "---------------------------- Test 15 -----------------------------" >>testtry
88 ph10 138 (cd $srcdir; $valgrind $pcregrep 'abc^*' ./testdata/grepinput) 2>>testtry >>testtry
89 nigel 77
90     echo "---------------------------- Test 16 -----------------------------" >>testtry
91 ph10 138 (cd $srcdir; $valgrind $pcregrep abc ./testdata/grepinput ./testdata/nonexistfile) 2>>testtry >>testtry
92 nigel 77
93     echo "---------------------------- Test 17 -----------------------------" >>testtry
94 ph10 138 (cd $srcdir; $valgrind $pcregrep -M 'the\noutput' ./testdata/grepinput) >>testtry
95 nigel 77
96     echo "---------------------------- Test 18 -----------------------------" >>testtry
97 ph10 138 (cd $srcdir; $valgrind $pcregrep -Mn '(the\noutput|dog\.\n--)' ./testdata/grepinput) >>testtry
98 nigel 77
99     echo "---------------------------- Test 19 -----------------------------" >>testtry
100 ph10 138 (cd $srcdir; $valgrind $pcregrep -Mix 'Pattern' ./testdata/grepinputx) >>testtry
101 nigel 77
102     echo "---------------------------- Test 20 -----------------------------" >>testtry
103 ph10 138 (cd $srcdir; $valgrind $pcregrep -Mixn 'complete pair\nof lines' ./testdata/grepinputx) >>testtry
104 nigel 77
105     echo "---------------------------- Test 21 -----------------------------" >>testtry
106 ph10 138 (cd $srcdir; $valgrind $pcregrep -nA3 'four' ./testdata/grepinputx) >>testtry
107 nigel 77
108     echo "---------------------------- Test 22 -----------------------------" >>testtry
109 ph10 138 (cd $srcdir; $valgrind $pcregrep -nB3 'four' ./testdata/grepinputx) >>testtry
110 nigel 77
111     echo "---------------------------- Test 23 -----------------------------" >>testtry
112 ph10 138 (cd $srcdir; $valgrind $pcregrep -C3 'four' ./testdata/grepinputx) >>testtry
113 nigel 77
114     echo "---------------------------- Test 24 -----------------------------" >>testtry
115 ph10 138 (cd $srcdir; $valgrind $pcregrep -A9 'four' ./testdata/grepinputx) >>testtry
116 nigel 77
117     echo "---------------------------- Test 25 -----------------------------" >>testtry
118 ph10 138 (cd $srcdir; $valgrind $pcregrep -nB9 'four' ./testdata/grepinputx) >>testtry
119 nigel 77
120     echo "---------------------------- Test 26 -----------------------------" >>testtry
121 ph10 138 (cd $srcdir; $valgrind $pcregrep -A9 -B9 'four' ./testdata/grepinputx) >>testtry
122 nigel 77
123     echo "---------------------------- Test 27 -----------------------------" >>testtry
124 ph10 138 (cd $srcdir; $valgrind $pcregrep -A10 'four' ./testdata/grepinputx) >>testtry
125 nigel 77
126     echo "---------------------------- Test 28 -----------------------------" >>testtry
127 ph10 138 (cd $srcdir; $valgrind $pcregrep -nB10 'four' ./testdata/grepinputx) >>testtry
128 nigel 77
129     echo "---------------------------- Test 29 -----------------------------" >>testtry
130 ph10 138 (cd $srcdir; $valgrind $pcregrep -C12 -B10 'four' ./testdata/grepinputx) >>testtry
131 nigel 77
132     echo "---------------------------- Test 30 -----------------------------" >>testtry
133 ph10 138 (cd $srcdir; $valgrind $pcregrep -inB3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtry
134 nigel 77
135     echo "---------------------------- Test 31 -----------------------------" >>testtry
136 ph10 138 (cd $srcdir; $valgrind $pcregrep -inA3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtry
137 nigel 77
138     echo "---------------------------- Test 32 -----------------------------" >>testtry
139 ph10 138 (cd $srcdir; $valgrind $pcregrep -L 'fox' ./testdata/grepinput ./testdata/grepinputx) >>testtry
140 nigel 77
141     echo "---------------------------- Test 33 -----------------------------" >>testtry
142 ph10 138 (cd $srcdir; $valgrind $pcregrep 'fox' ./testdata/grepnonexist) >>testtry 2>&1
143 nigel 77 echo "RC=$?" >>testtry
144    
145     echo "---------------------------- Test 34 -----------------------------" >>testtry
146 ph10 138 (cd $srcdir; $valgrind $pcregrep -s 'fox' ./testdata/grepnonexist) >>testtry 2>&1
147 nigel 77 echo "RC=$?" >>testtry
148    
149     echo "---------------------------- Test 35 -----------------------------" >>testtry
150 ph10 138 (cd $srcdir; $valgrind $pcregrep -L -r --include=grepinputx 'fox' ./testdata) >>testtry
151 nigel 77 echo "RC=$?" >>testtry
152    
153     echo "---------------------------- Test 36 -----------------------------" >>testtry
154 ph10 138 (cd $srcdir; $valgrind $pcregrep -L -r --include=grepinput --exclude 'grepinput$' 'fox' ./testdata | sort) >>testtry
155 nigel 77 echo "RC=$?" >>testtry
156    
157 nigel 87 echo "---------------------------- Test 37 -----------------------------" >>testtry
158 ph10 138 (cd $srcdir; $valgrind $pcregrep '^(a+)*\d' ./testdata/grepinput) >>testtry 2>teststderr
159 nigel 87 echo "RC=$?" >>testtry
160     echo "======== STDERR ========" >>testtry
161     cat teststderr >>testtry
162 nigel 77
163 nigel 87 echo "---------------------------- Test 38 ------------------------------" >>testtry
164 ph10 138 (cd $srcdir; $valgrind $pcregrep '>\x00<' ./testdata/grepinput) >>testtry
165 nigel 87
166     echo "---------------------------- Test 39 ------------------------------" >>testtry
167 ph10 138 (cd $srcdir; $valgrind $pcregrep -A1 'before the binary zero' ./testdata/grepinput) >>testtry
168 nigel 87
169     echo "---------------------------- Test 40 ------------------------------" >>testtry
170 ph10 138 (cd $srcdir; $valgrind $pcregrep -B1 'after the binary zero' ./testdata/grepinput) >>testtry
171 nigel 87
172     echo "---------------------------- Test 41 ------------------------------" >>testtry
173 ph10 138 (cd $srcdir; $valgrind $pcregrep -B1 -o '\w+ the binary zero' ./testdata/grepinput) >>testtry
174 nigel 87
175     echo "---------------------------- Test 41 ------------------------------" >>testtry
176 ph10 138 (cd $srcdir; $valgrind $pcregrep -B1 -onH '\w+ the binary zero' ./testdata/grepinput) >>testtry
177 nigel 87
178     echo "---------------------------- Test 42 ------------------------------" >>testtry
179 ph10 138 (cd $srcdir; $valgrind $pcregrep -on 'before|zero|after' ./testdata/grepinput) >>testtry
180 nigel 87
181     echo "---------------------------- Test 43 ------------------------------" >>testtry
182 ph10 138 (cd $srcdir; $valgrind $pcregrep -on -e before -e zero -e after ./testdata/grepinput) >>testtry
183 nigel 87
184     echo "---------------------------- Test 44 ------------------------------" >>testtry
185 ph10 138 (cd $srcdir; $valgrind $pcregrep -on -f ./testdata/greplist -e binary ./testdata/grepinput) >>testtry
186 nigel 87
187     echo "---------------------------- Test 45 ------------------------------" >>testtry
188 ph10 138 (cd $srcdir; $valgrind $pcregrep -e abc -e '(unclosed' ./testdata/grepinput) 2>>testtry >>testtry
189 nigel 87
190     echo "---------------------------- Test 46 ------------------------------" >>testtry
191 ph10 138 (cd $srcdir; $valgrind $pcregrep -Fx "AB.VE
192     elephant" ./testdata/grepinput) >>testtry
193 nigel 87
194     echo "---------------------------- Test 47 ------------------------------" >>testtry
195 ph10 138 (cd $srcdir; $valgrind $pcregrep -F "AB.VE
196     elephant" ./testdata/grepinput) >>testtry
197 nigel 87
198     echo "---------------------------- Test 48 ------------------------------" >>testtry
199 ph10 138 (cd $srcdir; $valgrind $pcregrep -F -e DATA -e "AB.VE
200     elephant" ./testdata/grepinput) >>testtry
201 nigel 87
202 nigel 91 echo "---------------------------- Test 49 ------------------------------" >>testtry
203 ph10 138 (cd $srcdir; $valgrind $pcregrep "^(abc|def|ghi|jkl)" ./testdata/grepinputx) >>testtry
204 nigel 91
205 ph10 222 echo "---------------------------- Test 50 ------------------------------" >>testtry
206     (cd $srcdir; $valgrind $pcregrep -Mv "brown\sfox" ./testdata/grepinputv) >>testtry
207    
208 ph10 239 echo "---------------------------- Test 51 ------------------------------" >>testtry
209     (cd $srcdir; $valgrind $pcregrep --colour=always jumps ./testdata/grepinputv) >>testtry
210    
211 ph10 280 echo "---------------------------- Test 52 ------------------------------" >>testtry
212     (cd $srcdir; $valgrind $pcregrep --file-offsets 'before|zero|after' ./testdata/grepinput) >>testtry
213    
214     echo "---------------------------- Test 53 ------------------------------" >>testtry
215     (cd $srcdir; $valgrind $pcregrep --line-offsets 'before|zero|after' ./testdata/grepinput) >>testtry
216    
217 nigel 77 # Now compare the results.
218    
219 ph10 158 $cf $srcdir/testdata/grepoutput testtry
220 nigel 93 if [ $? != 0 ] ; then exit 1; fi
221 nigel 77
222 ph10 131
223 nigel 93 # These tests require UTF-8 support
224    
225 ph10 116 if [ $utf8 -ne 0 ] ; then
226 nigel 93 echo "Testing pcregrep UTF-8 features"
227 ph10 97
228 nigel 93 echo "---------------------------- Test U1 ------------------------------" >testtry
229 ph10 138 (cd $srcdir; $valgrind $pcregrep -n -u --newline=any "^X" ./testdata/grepinput8) >>testtry
230 nigel 93
231     echo "---------------------------- Test U2 ------------------------------" >>testtry
232 ph10 138 (cd $srcdir; $valgrind $pcregrep -n -u -C 3 --newline=any "Match" ./testdata/grepinput8) >>testtry
233 nigel 93
234 ph10 158 $cf $srcdir/testdata/grepoutput8 testtry
235 nigel 93 if [ $? != 0 ] ; then exit 1; fi
236    
237     else
238     echo "Skipping pcregrep UTF-8 tests: no UTF-8 support in PCRE library"
239     fi
240    
241 ph10 131
242 ph10 158 # We go to some contortions to try to ensure that the tests for the various
243 ph10 159 # newline settings will work in environments where the normal newline sequence
244 ph10 160 # is not \n. Do not use exported files, whose line endings might be changed.
245     # Instead, create an input file using printf so that its contents are exactly
246     # what we want. Note the messy fudge to get printf to write a string that
247     # starts with a hyphen.
248 ph10 131
249     echo "Testing pcregrep newline settings"
250 ph10 160 printf "abc\rdef\r\nghi\njkl" >testNinput
251 ph10 131
252 ph10 158 printf "%c--------------------------- Test N1 ------------------------------\r\n" - >testtry
253 ph10 160 $valgrind $pcregrep -n -N CR "^(abc|def|ghi|jkl)" testNinput >>testtry
254 ph10 131
255 ph10 158 printf "%c--------------------------- Test N2 ------------------------------\r\n" - >>testtry
256 ph10 160 $valgrind $pcregrep -n --newline=crlf "^(abc|def|ghi|jkl)" testNinput >>testtry
257 ph10 158
258     printf "%c--------------------------- Test N3 ------------------------------\r\n" - >>testtry
259 ph10 131 pattern=`printf 'def\rjkl'`
260 ph10 160 $valgrind $pcregrep -n --newline=cr -F "$pattern" testNinput >>testtry
261 ph10 131
262 ph10 158 printf "%c--------------------------- Test N4 ------------------------------\r\n" - >>testtry
263 ph10 131 pattern=`printf 'xxx\r\njkl'`
264 ph10 160 $valgrind $pcregrep -n --newline=crlf -F "$pattern" testNinput >>testtry
265 ph10 131
266 ph10 158 printf "%c--------------------------- Test N5 ------------------------------\r\n" - >>testtry
267 ph10 160 $valgrind $pcregrep -n --newline=any "^(abc|def|ghi|jkl)" testNinput >>testtry
268 ph10 131
269 ph10 158 printf "%c--------------------------- Test N6 ------------------------------\r\n" - >>testtry
270 ph10 160 $valgrind $pcregrep -n --newline=anycrlf "^(abc|def|ghi|jkl)" testNinput >>testtry
271 ph10 149
272 ph10 158 $cf $srcdir/testdata/grepoutputN testtry
273 ph10 131 if [ $? != 0 ] ; then exit 1; fi
274    
275 ph10 97 exit 0
276 nigel 93
277 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