]> diplodocus.org Git - nmh/blob - test/inc/test-inc-scanout
Fixed problem in m_getfld() reported by Paul Fox. When
[nmh] / test / inc / test-inc-scanout
1 #!/bin/sh
2 #
3 # Check to see if the scan output is correct if we have a message
4 # right on the stdio buffer boundary
5 #
6
7 set -e
8
9 if test -z "${MH_OBJ_DIR}"; then
10 srcdir=`dirname "$0"`/../..
11 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
12 fi
13
14 . "$MH_OBJ_DIR/test/common.sh"
15
16 setup_test
17
18 thisdir="$srcdir/test/inc"
19 expected="$MH_TEST_DIR/$$.expected"
20 actual="$MH_TEST_DIR/$$.actual"
21
22 cat > "${MH_TEST_DIR}/test.mbox" <<EOF
23 From nobody@nowhereville Jan 1 1970
24 Received: I am the very model of a modern Major-General,
25 Received: I've information vegetable, animal, and mineral,
26 Received: I know the kings of England, and I quote the fights historical
27 Received: From Marathon to Waterloo, in order categorical;
28 Received: I'm very well acquainted, too, with matters mathematical,
29 Received: I understand equations, both the simple and quadratical,
30 Received: About binomial theorem I'm teeming with a lot o' news,
31 Received: With many cheerful facts about the square of the hypotenuse.
32 Received: I'm very good at integral and differential calculus;
33 Received: I know the scientific names of beings animalculous:
34 Received: In short, in matters vegetable, animal, and mineral,
35 Received: I am the very model of a modern Major-General.
36 Received: I know our mythic history, King Arthur's and Sir Caradoc's;
37 Received: I answer hard acrostics, I've a pretty taste for paradox,
38 Received: I quote in elegiacs all the crimes of Heliogabalus,
39 Received: In conics I can floor peculiarities parabolous;
40 Received: I can tell undoubted Raphaels from Gerard Dows and Zoffanies,
41 Received: I know the croaking chorus from The Frogs of Aristophanes!
42 Received: Then I can hum a fugue of which I've heard the music's din afore,c
43 Received: And whistle all the airs from that infernal nonsense Pinafore.
44 Received: Then I can write a washing bill in Babylonic cuneiform,
45 Received: And tell you ev'ry detail of Caractacus's uniform:d
46 Received: In short, in matters vegetable, animal, and mineral,
47 Received: I am the very model of a modern Major-General.
48 Received: In fact, when I know what is meant by "mamelon" and "ravelin",
49 Received: When I can tell at sight a Mauser rifle from a Javelin,
50 Received: When such affairs as sorties and surprises I'm more wary at,
51 Received: And when I know precisely what is meant by "commissariat",
52 Received: When I have learnt what progress has been made in modern gunnery,
53 Received: When I know more of tactics than a novice in a nunnery—
54 Received: In short, when I've a smattering of elemental strategy—
55 Received: You'll say a better Major-General has never sat a gee.
56 Received: For my military knowledge, though I'm plucky and adventury,
57 Received: Has only been brought down to the beginning of the century;
58 Received: But still, in matters vegetable, animal, and mineral,
59 Received: I am the very model of a modern Major-General.
60 Received: For the Angel of Death spread his wings on the blast,
61 Received: And breathed in the face of the foe as he passed:
62 Received: the eyes of the sleepers waxed deadly and chill,
63 Received: And their hearts but once heaved, and for ever grew still!
64 Received: Abbott: Strange as it may seem, they give ball players nowadays very peculiar names.
65 Received: Costello: Funny names?
66 Received: Abbott: Nicknames, nicknames. Now, on the St. Louis team we have Who's on first, What's on second, I Don't Know is on third--
67 Received: Costello: That's what I want to find out. I want you to tell me the names of the fellows on the St. Louis team.
68 Received: Abbott: I'm telling you. Who's on first, What's on second, I Don't Know is on third--
69 Received: Costello: You know the fellows' names?
70 Received: Abbott: Yes.
71 Received: Costello: Well, then who's playing first?
72 Received: Abbott: Yes.
73 Received: Costello: I mean the fellow's name on first base.
74 Received: Abbott: Who.
75 Received: Costello: The fellow playin' first base.
76 Received: Abbott: Who.
77 Received: Costello: The guy on first base.
78 Received: Abbott: Who is on first.
79 Received: Costello: Well, what are you askin' me for?
80 Received: Abbott: I'm not asking you--I'm telling you. Who is on first.
81 Received: Costello: I'm asking you--who's on first?
82 Received: Abbott: That's the man's name.
83 Received: Costello: That's who's name?
84 Received: Abbott: Yes.
85 Received: Costello: When you pay off the first baseman every month, who gets the money?
86 X-Spam-Source: Definitely spam! Seriously!
87 From: Mr Nobody <nobody1@example.com>
88 To: Another Nobody <nobody2@example.com>
89 Date: Thu, 1 Mar 2012 01:02:03 -0500
90 Subject: Who is on first?
91
92 Abbott: Every dollar of it. And why not, the man's entitled to it.
93 Costello: Who is?
94 Abbott: Yes.
95 Costello: So who gets it?
96 Abbott: Why shouldn't he? Sometimes his wife comes down and collects it.
97 Costello: Who's wife?
98 Abbott: Yes. After all, the man earns it.
99 Costello: Who does?
100 Abbott: Absolutely.
101 Costello: Well, all I'm trying to find out is what's the guy's name on first base?
102 Abbott: Oh, no, no. What is on second base.
103 Costello: I'm not asking you who's on second.
104 Abbott: Who's on first!
105 EOF
106
107 cat > "${MH_TEST_DIR}/test.mbox.2" <<EOF
108 Received: I am the very model of a modern Major-General,
109 Received: I've information vegetable, animal, and mineral,
110 Received: I know the kings of England, and I quote the fights historical
111 Received: From Marathon to Waterloo, in order categorical;
112 Received: I'm very well acquainted, too, with matters mathematical,
113 Received: I understand equations, both the simple and quadratical,
114 Received: About binomial theorem I'm teeming with a lot o' news,
115 Received: With many cheerful facts about the square of the hypotenuse.
116 Received: I'm very good at integral and differential calculus;
117 Received: I know the scientific names of beings animalculous:
118 Received: In short, in matters vegetable, animal, and mineral,
119 Received: I am the very model of a modern Major-General.
120 Received: I know our mythic history, King Arthur's and Sir Caradoc's;
121 Received: I answer hard acrostics, I've a pretty taste for paradox,
122 Received: I quote in elegiacs all the crimes of Heliogabalus,
123 Received: In conics I can floor peculiarities parabolous;
124 Received: I can tell undoubted Raphaels from Gerard Dows and Zoffanies,
125 Received: I know the croaking chorus from The Frogs of Aristophanes!
126 Received: Then I can hum a fugue of which I've heard the music's din afore,c
127 Received: And whistle all the airs from that infernal nonsense Pinafore.
128 Received: Then I can write a washing bill in Babylonic cuneiform,
129 Received: And tell you ev'ry detail of Caractacus's uniform:d
130 Received: In short, in matters vegetable, animal, and mineral,
131 Received: I am the very model of a modern Major-General.
132 Received: In fact, when I know what is meant by "mamelon" and "ravelin",
133 Received: When I can tell at sight a Mauser rifle from a Javelin,
134 Received: When such affairs as sorties and surprises I'm more wary at,
135 Received: And when I know precisely what is meant by "commissariat",
136 Received: When I have learnt what progress has been made in modern gunnery,
137 Received: When I know more of tactics than a novice in a nunnery—
138 Received: In short, when I've a smattering of elemental strategy—
139 Received: You'll say a better Major-General has never sat a gee.
140 Received: For my military knowledge, though I'm plucky and adventury,
141 Received: Has only been brought down to the beginning of the century;
142 Received: But still, in matters vegetable, animal, and mineral,
143 Received: I am the very model of a modern Major-General.
144 Received: For the Angel of Death spread his wings on the blast,
145 Received: And breathed in the face of the foe as he passed:
146 Received: the eyes of the sleepers waxed deadly and chill,
147 Received: And their hearts but once heaved, and for ever grew still!
148 Received: Abbott: Strange as it may seem, they give ball players nowadays very peculiar names.
149 Received: Costello: Funny names?
150 Received: Abbott: Nicknames, nicknames. Now, on the St. Louis team we have Who's on first, What's on second, I Don't Know is on third--
151 Received: Costello: That's what I want to find out. I want you to tell me the names of the fellows on the St. Louis team.
152 Received: Abbott: I'm telling you. Who's on first, What's on second, I Don't Know is on third--
153 Received: Costello: You know the fellows' names?
154 Received: Abbott: Yes.
155 Received: Costello: Well, then who's playing first?
156 Received: Abbott: Yes.
157 Received: Costello: I mean the fellow's name on first base.
158 Received: Abbott: Who.
159 Received: Costello: The fellow playin' first base.
160 Received: Abbott: Who.
161 Received: Costello: The guy on first base.
162 Received: Abbott: Who is on first.
163 Received: Costello: Well, what are you askin' me for?
164 Received: Abbott: I'm not asking you--I'm telling you. Who is on first.
165 Received: Costello: I'm asking you--who's on first?
166 Received: Abbott: That's the man's name.
167 Received: Costello: That's who's name?
168 Received: Abbott: Yes.
169 Received: Costello: When you pay off the first baseman every month, who gets the money?
170 X-Spam-Source: Definitely spam! Seriously!
171 From: Mr Nobody <nobody1@example.com>
172 To: Another Nobody <nobody2@example.com>
173 Date: Thu, 1 Mar 2012 01:02:03 -0500
174 Subject: Who is on first?
175
176 Abbott: Every dollar of it. And why not, the man's entitled to it.
177 Costello: Who is?
178 Abbott: Yes.
179 Costello: So who gets it?
180 Abbott: Why shouldn't he? Sometimes his wife comes down and collects it.
181 Costello: Who's wife?
182 Abbott: Yes. After all, the man earns it.
183 Costello: Who does?
184 Abbott: Absolutely.
185 Costello: Well, all I'm trying to find out is what's the guy's name on first base?
186 Abbott: Oh, no, no. What is on second base.
187 Costello: I'm not asking you who's on second.
188 Abbott: Who's on first!
189 EOF
190
191 run_test "inc -file ${MH_TEST_DIR}/test.mbox -width 120 -truncate" \
192 "Incorporating new mail into inbox...
193
194 11+ 03/01 Mr Nobody Who is on first?<<Abbott: Every dollar of it. And why not, the man's entitled to it. Cos"
195
196 check `mhpath +inbox 11` "${MH_TEST_DIR}/test.mbox.2" "keep first"
197 rm -f "${MH_TEST_DIR}/test.mbox" "${MH_TEST_DIR}/test.mbox.2"
198
199 run_test "scan -width 120 +inbox 11" \
200 " 11+ 03/01 Mr Nobody Who is on first?<<Abbott: Every dollar of it. And why not, the man's entitled to it. Cos"
201
202 # check header field name with ':' character than lands on m_getfld() buffer
203 cat >"$MH_TEST_DIR/mess" <<EOF
204 Comments: The important characteristic of this message is that the 4097'th
205 Comments: byte is the ':' at the end of header field name. That tests some
206 Comments: logic in m_getfld (), assuming its MSG_INPUT_SIZE is 4096.
207 Comments: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
208 Comments: BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
209 Comments: CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
210 Comments: DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
211 Comments: EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
212 Comments: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
213 Comments: GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
214 Comments: HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
215 Comments: IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
216 Comments: JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
217 Comments: KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
218 Comments: LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
219 Comments: MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
220 Comments: NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
221 Comments: OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
222 Comments: PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
223 Comments: QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
224 Comments: RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
225 Comments: SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
226 Comments: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
227 Comments: UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
228 Comments: VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
229 Comments: WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
230 Comments: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
231 Comments: YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
232 Comments: ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
233 Comments: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
234 Comments: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
235 Comments: cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
236 Comments: dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
237 Comments: eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
238 Comments: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
239 Comments: gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
240 Comments: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
241 Comments: iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
242 Comments: jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
243 Comments: kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
244 Comments: llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
245 Comments: mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
246 Comments: nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
247 Comments: oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
248 Comments: pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
249 Comments: qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
250 Comments: rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
251 Comments: ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
252 Comments: tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
253 Comments: uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
254 Comments: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
255 Comments: wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
256 Comments: This is it, the line with the 4097'th character of ':'.
257 Comments: From somewhere
258 From: No Such User <nosuch@example.com>
259 To: Some Other User <someother@example.com>
260 Subject: all that and nothing to say?
261 Date: Thu, 10 Jan 2013 19:54:01 -0500
262
263 EOF
264
265 run_test 'scan -width 60 -file '"$MH_TEST_DIR/mess" \
266 ' 1 01/10 No Such User all that and nothing to say?'
267 rm -f "$MH_TEST_DIR/mess"
268
269 # check m_getfld() handling of fields with trailing whitespace
270 # Even though header field names aren't supposed to have spaces (RFC
271 # 28220, m_getfld () trims trailing whitespace from them.
272 cat >`mhpath new` <<EOF
273 Date : Sun, 18 Dec 2005 00:52:39 +0100
274 From : foo@example.edu
275 To: bar@example.edu
276 Subject: test
277 EOF
278 run_test 'scan last' ' 12 12/18 foo@example.edu test'
279
280 # check header field body with more than 511 characters
281 cat >"$MH_TEST_DIR/mess" <<EOF
282 Comments: The important characteristic of this message is that this header
283 field body is more than 511 bytes long. That tests the logic in
284 m_getfld () for transitioning to the FLDPLUS state. This is the
285 only use for the FLDPLUS state, handling header field bodies that
286 are longer than the buffer used to retrieve them. The trailing
287 newline after the last character is the 512th character. The 511th
288 character, counting all spaces, even the leading one, is*
289 From: No Such User <nosuch@example.com>
290 To: Some Other User <someother@example.com>
291 Subject: FLDPLUS test
292 Date: Wed, 16 Jan 2013 20:33:58 -0600
293
294 EOF
295
296 run_test 'scan -width 80 -file '"$MH_TEST_DIR"'/mess' \
297 ' 1 01/16 No Such User FLDPLUS test'
298 rm -f "$MH_TEST_DIR/mess"
299
300 # check scan and inc of mbox with multiple messages
301 echo y | packf -file "$MH_TEST_DIR/msgbox"
302 run_test "scan -width 80 -file $MH_TEST_DIR/msgbox" \
303 ' 1 09/29 Test1 Testing message 1<<This is message number 1 >>
304 2 09/29 Test2 Testing message 2<<This is message number 2 >>
305 3 09/29 Test3 Testing message 3<<This is message number 3 >>
306 4 09/29 Test4 Testing message 4<<This is message number 4 >>
307 5 09/29 Test5 Testing message 5<<This is message number 5 >>
308 6 09/29 Test6 Testing message 6<<This is message number 6 >>
309 7 09/29 Test7 Testing message 7<<This is message number 7 >>
310 8 09/29 Test8 Testing message 8<<This is message number 8 >>
311 9 09/29 Test9 Testing message 9<<This is message number 9 >>
312 10 09/29 Test10 Testing message 10<<This is message number 10 >>
313 11 03/01 Mr Nobody Who is on first?<<Abbott: Every dollar of it. An
314 12 12/18 foo@example.edu test'
315 run_test "inc -width 80 -file $MH_TEST_DIR/msgbox -truncate" \
316 'Incorporating new mail into inbox...
317
318 13+ 09/29 Test1 Testing message 1<<This is message number 1 >>
319 14 09/29 Test2 Testing message 2<<This is message number 2 >>
320 15 09/29 Test3 Testing message 3<<This is message number 3 >>
321 16 09/29 Test4 Testing message 4<<This is message number 4 >>
322 17 09/29 Test5 Testing message 5<<This is message number 5 >>
323 18 09/29 Test6 Testing message 6<<This is message number 6 >>
324 19 09/29 Test7 Testing message 7<<This is message number 7 >>
325 20 09/29 Test8 Testing message 8<<This is message number 8 >>
326 21 09/29 Test9 Testing message 9<<This is message number 9 >>
327 22 09/29 Test10 Testing message 10<<This is message number 10 >>
328 23 03/01 Mr Nobody Who is on first?<<Abbott: Every dollar of it. An
329 24 12/18 foo@example.edu test'
330 rm -f "$MH_TEST_DIR/msgbox"
331
332 # check mbox with two blank lines between header and body
333 cat >>"$MH_TEST_DIR/msgbox" <<EOF
334 From
335 From: me@example.com
336
337
338 test
339 EOF
340
341 run_test "inc -width 80 -file $MH_TEST_DIR/msgbox -truncate" \
342 'Incorporating new mail into inbox...
343
344 25+ 04/15*me@example.com <<test >>'
345 rm -f "$MH_TEST_DIR/msgbox"
346
347
348 exit ${failed:-0}