]> diplodocus.org Git - nmh/blob - test/mhlist/test-mhlist
Remove ./configure's --enable-debug support; it did nothing.
[nmh] / test / mhlist / test-mhlist
1 #!/bin/sh
2 ######################################################
3 #
4 # Test mhlist
5 #
6 ######################################################
7
8 set -e
9
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir=`dirname $0`/../..
12 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
13 fi
14
15 . "$MH_OBJ_DIR/test/common.sh"
16
17 setup_test
18
19 expected=$MH_TEST_DIR/$$.expected
20 actual=$MH_TEST_DIR/$$.actual
21
22
23 # check with no options and no current message
24 run_test 'mhlist' 'mhlist: no cur message'
25
26 # check with no options and current message
27 folder +inbox 5 > /dev/null
28 cat > $expected <<EOF
29 msg part type/subtype size description
30 5 text/plain 25
31 EOF
32 run_prog mhlist > $actual 2>&1
33 check $expected $actual 'keep first'
34
35 # check -noheaders
36 run_test 'mhlist 5 -noheaders' ' 5 text/plain 25'
37
38 # check -headers
39 run_prog mhlist -noheaders -headers > $actual 2>&1
40 check $expected $actual 'keep first'
41
42 # check with folder and current message
43 run_prog mhlist +inbox > $actual 2>&1
44 check $expected $actual 'keep first'
45
46 # check with specified message
47 run_prog mhlist 5 > $actual 2>&1
48 check $expected $actual 'keep first'
49
50 # check -file
51 run_prog mhlist -file "$MH_TEST_DIR/Mail/inbox/5" > $actual 2>&1
52 check $expected $actual
53
54 # check -file -
55 cat > $expected <<EOF
56 msg part type/subtype size description
57 0 text/plain 25
58 EOF
59 run_prog mhlist -file - < "$MH_TEST_DIR/Mail/inbox/5" > $actual 2>&1
60 check $expected $actual
61
62 # check message number greater than highest
63 run_test 'mhlist 11' "mhlist: message 11 doesn't exist"
64
65 # check multiple messages
66 cat > $expected <<EOF
67 msg part type/subtype size description
68 2 text/plain 25
69 8 text/plain 25
70 EOF
71 run_prog mhlist 2 8 > $actual 2>&1
72 check $expected $actual
73
74 # Write message with a text/plain subpart.
75 msgfile=`mhpath new`
76 cat > $msgfile <<EOF
77 To: recipient@example.com
78 From: sender@example.com
79 Subject: mhlist test
80 MIME-Version: 1.0
81 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
82
83 ------- =_aaaaaaaaaa0
84 Content-Type: multipart/related;
85 type="multipart/alternative";
86 boundary="subpart__1.1"
87
88 --subpart__1.1
89 Content-Type: text/plain; charset="iso-8859-1"
90 Content-Disposition: attachment; filename="test1"
91
92 This is the first text/plain part, in a subpart.
93
94 --subpart__1.1--
95
96 ------- =_aaaaaaaaaa0
97 Content-Type: text/plain; charset="iso-8859-1"
98 Content-Disposition: attachment; filename="test2"
99 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
100 Content-Transfer-Encoding: quoted-printable
101
102 This is the second text/plain part.
103
104 ------- =_aaaaaaaaaa0
105 Content-Type: text/plain; charset="iso-8859-1"; name="test3"
106 Content-Disposition: attachment; filename="test3"
107
108 This is the third text/plain part.
109
110 ------- =_aaaaaaaaaa0
111 Content-Type: text/plain; charset="iso-8859-1"
112 Content-Disposition: attachment; filename="test4"
113 Content-Transfer-Encoding: base64
114
115 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
116
117 ------- =_aaaaaaaaaa0--
118 EOF
119
120 # check -part
121 run_test 'mhlist last -part 3 -noheader' \
122 ' 11 multipart/mixed 936
123 1 multipart/related 180
124 3 text/plain 35'
125
126 # check -part of a subpart
127 run_test 'mhlist last -part 1.1 -noheader' \
128 ' 11 multipart/mixed 936
129 1 multipart/related 180
130 1.1 text/plain 49'
131
132 # check -type
133 run_test 'mhlist last -type text/plain -noheader' \
134 ' 11 multipart/mixed 936
135 1 multipart/related 180
136 1.1 text/plain 49
137 2 text/plain 36
138 3 text/plain 35
139 4 text/plain 36'
140
141 # check -norealsize
142 run_test 'mhlist last -part 4 -noheader -norealsize' \
143 ' 11 multipart/mixed 936
144 1 multipart/related 180
145 4 text/plain 49'
146
147 # check -realsize, the default
148 run_test 'mhlist last -part 4 -noheader -norealsize -realsize' \
149 ' 11 multipart/mixed 936
150 1 multipart/related 180
151 4 text/plain 36'
152
153 # check -check
154 run_test 'mhlist last -part 2 -noheader -check' \
155 ' 11 multipart/mixed 936
156 1 multipart/related 180
157 2 text/plain 36'
158
159 # check -check with bad MD5 checksum
160 sed 's/\(Content-MD5: \)kq+Hnc/\1BADBAD/' $msgfile > $MH_TEST_DIR/$$.tmp
161 mv -f $MH_TEST_DIR/$$.tmp $msgfile
162 run_test 'mhlist last -part 2 -noheader -check' \
163 ' 11 multipart/mixed 936
164 1 multipart/related 180
165 2 text/plain 36
166 mhlist: content integrity suspect (digest mismatch) -- continuing
167 (content text/plain in message 11, part 2)'
168
169 # check -nocheck, the default
170 run_test 'mhlist last -part 2 -noheader -check -nocheck' \
171 ' 11 multipart/mixed 936
172 1 multipart/related 180
173 2 text/plain 36'
174
175 #
176 # Set the cur sequence to 1 to test default behavior of changecur after
177 # this test.
178 #
179
180 mark 1 -sequence cur -add -zero
181
182 # check -verbose
183 run_test 'mhlist 11 -verbose -noheader' \
184 ' 11 multipart/mixed 936
185 boundary="----- =_aaaaaaaaaa0"
186 1 multipart/related 180
187 type="multipart/alternative"
188 boundary="subpart__1.1"
189 1.1 text/plain 49
190 charset="iso-8859-1"
191 2 text/plain 36
192 charset="iso-8859-1"
193 3 text/plain 35
194 charset="iso-8859-1"
195 name="test3"
196 4 text/plain 36
197 charset="iso-8859-1"'
198
199 #
200 # Check default changecur behavior
201 #
202
203 run_test 'mark -sequence cur -list' 'cur: 11'
204
205 #
206 # Now test -nochangecur
207 #
208
209 mhlist -nochangecur 1 >/dev/null
210
211 run_test 'mark -sequence cur -list' 'cur: 11'
212
213 # check MIME parser and m_getfld
214 cat > $expected <<EOF
215 msg part type/subtype size description
216 12 multipart/related 204
217 1 multipart/alternative 74
218 1.1 text/plain 17
219 2 text/plain 17
220 EOF
221
222 msgfile=`mhpath new`
223 msgnum=`basename $msgfile`
224 cat > $msgfile <<EOF
225 To: recipient@example.com, recipient@example.com, recipient@example.com,
226 recipient@example.com, recipient@example.com, recipient@example.com,
227 recipient@example.com, recipient@example.com, recipient@example.com,
228 recipient@example.com, recipient@example.com, recipient@example.com,
229 recipient@example.com, recipient@example.com, recipient@example.com,
230 recipient@example.com, recipient@example.com, recipient@example.com,
231 recipient@example.com, recipient@example.com, recipient@example.com,
232 recipient@example.com, recipient@example.com, recipient@example.com,
233 recipient@example.com, recipient@example.com, recipient@example.com,
234 recipient@example.com, recipient@example.com, recipient@example.com,
235 recipient@example.com, recipient@example.com, recipient@example.com,
236 recipient@example.com, recipient@example.com, recipient@example.com,
237 recipient@example.com, recipient@example.com, recipient@example.com,
238 recipient@example.com, recipient@example.com, recipient@example.com,
239 recipient@example.com, recipient@example.com, recipient@example.com,
240 recipient@example.com, recipient@example.com, recipient@example.com,
241 recipient@example.com, recipient@example.com, recipient@example.com,
242 recipient@example.com, recipient@example.com, recipient@example.com,
243 recipient@example.com, recipient@example.com, recipient@example.com,
244 recipient@example.com, recipient@example.com, recipient@example.com,
245 recipient@example.com, recipient@example.com, recipient@example.com,
246 recipient@example.com, recipient@example.com, recipient@example.com,
247 recipient@example.com, recipient@example.com, recipient@example.com,
248 recipient@example.com, recipient@example.com, recipient@example.com,
249 recipient@example.com, recipient@example.com, recipient@example.com,
250 recipient@example.com, recipient@example.com, recipient@example.com,
251 recipient@example.com, recipient@example.com, recipient@example.com,
252 recipient@example.com, recipient@example.com, recipient@example.com,
253 recipient@example.com, recipient@example.com, recipient@example.com,
254 recipient@example.com, recipient@example.com, recipient@example.com,
255 recipient@example.com, recipient@example.com, recipient@example.com,
256 recipient@example.com, recipient@example.com, recipient@example.com,
257 recipient@example.com, recipient@example.com, recipient@example.com,
258 recipient@example.com, recipient@example.com, recipient@example.com,
259 recipient@example.com, recipient@example.com, recipient@example.com,
260 recipient@example.com, recipient@example.com, recipient@example.com,
261 recipient@example.com, recipient@example.com, recipient@example.com,
262 recipient@example.com, recipient@example.com, recipient@example.com,
263 recipient@example.com, recipient@example.com, recipient@example.com,
264 recipient@example.com, recipient@example.com, recipient@example.com,
265 recipient@example.com, recipient@example.com, recipient@example.com,
266 recipient@example.com, recipient@example.com, recipient@example.com,
267 recipient@example.com, recipient@example.com, recipient@example.com,
268 recipient@example.com, recipient@example.com, recipient@example.com,
269 recipient@example.com, recipient@example.com, recipient@example.com,
270 recipient@example.com, recipient@example.com, recipient@example.com,
271 recipient@example.com, recipient@example.com, recipient@example.com,
272 recipient@example.com, recipient@example.com, recipient@example.com,
273 recipient@example.com, recipient@example.com, recipient@example.com,
274 recipient@example.com, recipient@example.com, recipient@example.com,
275 recipient@example.com, recipient@example.com, recipient@example.com,
276 recipient@example.com, recipient@example.com, recipient@example.com,
277 recipient@example.com, recipient@example.com, recipient@example.com,
278 recipient@example.com, recipient@example.com, recipient@example.com,
279 recipient@example.com, recipient@example.com, recipient@example.com,
280 recipient@example.com, recipient@example.com, recipient@example.com,
281 recipient@example.com, recipient@example.com, recipient@example.com,
282 recipient@example.com, recipient@example.com, recipient@example.com,
283 recipient@example.com, recipient@example.com, recipient@example.com,
284 recipient@example.com, recipient@example.com, recipient@example.com,
285 recipient@example.com, recipient@example.com, recipient@example.com,
286 recipient@example.com, recipient@example.com, recipient@example.com,
287 recipient@example.com, recipient@example.com, recipient@example.com,
288 recipient@example.com, recipient@example.com, recipient@example.com,
289 recipient@example.com, recipient@example.com, recipient@example.com,
290 recipient@example.com, recipient@example.com, recipient@example.com,
291 recipient@example.com, recipient@example.com, recipient@example.com,
292 recipient@example.com, recipient@example.com, recipient@example.com,
293 recipient@example.com, recipient@example.com, recipient@example.com,
294 recipient@example.com, recipient@example.com, recipient@example.com,
295 recipient@example.com, recipient@example.com, recipient@example.com,
296 recipient@example.com, recipient@example.com, recipient@example.com,
297 recipient@example.com, recipient@example.com, recipient@example.com,
298 recipient@example.com, recipient@example.com, recipient@example.com,
299 recipient@example.com, recipient@example.com, recipient@example.com,
300 recipient@example.com, recipient@example.com, recipient@example.com,
301 recipient@example.com, recipient@example.com, recipient@example.com,
302 recipient@example.com, recipient@example.com, recipient@example.com,
303 recipient@example.com, recipient@example.com, recipient@example.com,
304 recipient@example.com, recipient@example.com, recipient@example.com,
305 recipient@example.com, recipient@example.com, recipient@example.com,
306 recipient@example.com, recipient@example.com, recipient@example.com,
307 recipient@example.com, recipient@example.com, recipient@example.com,
308 recipient@example.com, recipient@example.com, recipient@example.com,
309 recipient@example.com, recipient@example.com, recipient@example.com,
310 recipient@example.com, recipient@example.com, recipient@example.com,
311 recipient@example.com, recipient@example.com, recipient@example.com,
312 recipient@example.com, recipient@example.com, recipient@example.com,
313 recipient@example.com, recipient@example.com, recipient@example.com,
314 recipient@example.com, recipient@example.com, recipient@example.com,
315 recipient@example.com, recipient@example.com, recipient@example.com,
316 recipient@example.com, recipient@example.com, recipient@example.com,
317 recipient@example.com, recipient@example.com, recipient@example.com,
318 recipient@example.com, recipient@example.com, recipient@example.com,
319 recipient@example.com, recipient@example.com, recipient@example.com,
320 recipient@example.com, recipient@example.com, recipient@example.com,
321 recipient@example.com, recipient@example.com, recipient@example.com,
322 recipient@example.com, recipient@example.com, recipient@example.com,
323 recipient@example.com, recipient@example.com, recipient@example.com,
324 recipient@example.com, recipient@example.com, recipient@example.com,
325 recipient@example.com, recipient@example.com, recipient@example.com,
326 recipient@example.com, recipient@example.com, recipient@example.com,
327 recipient@example.com, recipient@example.com, recipient@example.com,
328 recipient@example.com, recipient@example.com, recipient@example.com,
329 recipient@example.com, recipient@example.com, recipient@example.com,
330 recipient@example.com, recipient@example.com, recipient@example.com,
331 recipient@example.com, recipient@example.com, recipient@example.com,
332 recipient@example.com, recipient@example.com, recipient@example.com,
333 recipient@example.com, recipient@example.com, recipient@example.com,
334 recipient@example.com, recipient@example.com, recipient@example.com,
335 recipient@example.com, recipient@example.com, recipient@example.com,
336 recipient@example.com, recipient@example.com, recipient@example.com,
337 re@example.com
338 From: sender@example.com
339 Subject: very long header
340 Date: Wed, 4 Dec 2013 21:12:00 -0500
341 MIME-Version: 1.0
342 Content-Type: multipart/related; boundary="1"
343
344 --1
345 Content-Type: multipart/alternative; boundary="2"
346
347 --2
348 Content-Type: text/plain; charset="us-ascii"
349
350 This is part 1.
351
352
353 --2--
354
355 --1
356 Content-Type: text/plain; charset="us-ascii"
357
358 This is part 2.
359
360
361 --1--
362 EOF
363
364 run_prog mhlist last > $actual 2>&1
365 check $expected $actual
366
367 ## now check mhlist output
368
369 msgfile=`mhpath new`
370 msgnum=`basename $msgfile`
371 cat > $msgfile <<EOF
372 To: example@example.org
373 From: someone <someone@example.com>
374 Subject: mhlist test
375 Date: Thu, 29 Jan 2015 18:12:21 +0000 (GMT)
376 Content-Type: multipart/mixed; boundary="BoundaryMixed"
377
378 --BoundaryMixed
379 Content-type: multipart/alternative;
380 boundary="BoundaryAlternative1"
381
382 --BoundaryAlternative1
383 Content-type: text/enriched; CHARSET=US-ASCII
384 Content-transfer-encoding: 7bit
385
386 This is supposedly enriched.
387
388 --BoundaryAlternative1
389 Content-type: text/plain; charset=ISO-8859-1; format=flowed
390 Content-transfer-encoding: 8bit
391
392 This is the body text/plain part.
393
394 --BoundaryAlternative1
395 Content-type: text/html; CHARSET=US-ASCII
396 Content-transfer-encoding: 7bit
397
398 <html><body><div><span style="line-height: 1.5;">
399 This is the text/html body part.
400 </span></div></body></html>
401
402 --BoundaryAlternative1--
403
404 --BoundaryMixed
405 Content-type: multipart/alternative;
406 boundary="BoundaryAlternative2"
407
408 --BoundaryAlternative2
409 Content-type: audio/wav
410 Content-transfer-encoding: 8bit
411
412 pretend wav audio
413
414 --BoundaryAlternative2
415 Content-type: audio/mp3
416 Content-transfer-encoding: 8bit
417
418 pretend mp3 audio
419
420 --BoundaryAlternative2
421 Content-type: audio/basic
422 Content-transfer-encoding: 8bit
423
424 pretend basic audio
425
426 --BoundaryAlternative2--
427
428 --BoundaryMixed--
429 EOF
430
431 # Write the expected output.
432 cat > $expected <<EOF
433 msg part type/subtype size description
434 13 multipart/mixed 1038
435 1 multipart/alternative 518
436 1.1 text/html 111
437 1.2 text/plain 34
438 1.3 text/enriched 29
439 2 multipart/alternative 326
440 2.1 audio/basic 20
441 2.2 audio/mp3 18
442 2.3 audio/wav 18
443 EOF
444
445 # check it -- vanilla output
446 run_prog mhlist $msgnum > $actual 2>&1
447 check "$expected" "$actual"
448
449 # Write the expected output.
450 cat > $expected <<EOF
451 msg part type/subtype size description
452 13 multipart/mixed 1038
453 1 multipart/alternative 518
454 1.1 text/html 111
455 1.2 text/plain 34
456 1.3 text/enriched 29
457 2 multipart/alternative 326
458 EOF
459
460 # check it -- just part 1
461 run_prog mhlist -part 1 $msgnum > $actual 2>&1
462 check "$expected" "$actual"
463
464 # Write the expected output.
465 cat > $expected <<EOF
466 msg part type/subtype size description
467 13 multipart/mixed 1038
468 1 multipart/alternative 518
469 2 multipart/alternative 326
470 EOF
471
472 # check it -- ask for audio/basic in part 1, should get nothing
473 run_prog mhlist -part 1 -type audio/basic $msgnum > $actual 2>&1
474 check "$expected" "$actual"
475
476 # Write the expected output.
477 cat > $expected <<EOF
478 msg part type/subtype size description
479 13 multipart/mixed 1038
480 1 multipart/alternative 518
481 1.1 text/plain 34
482 1.2 text/html 111
483 1.3 text/enriched 29
484 2 multipart/alternative 326
485 2.1 audio/wav 18
486 2.2 audio/basic 20
487 2.3 audio/mp3 18
488 EOF
489
490 # check it -- bump plain and wav to the top of their parts
491 run_prog mhlist -prefer text/plain -prefer audio/wav $msgnum > $actual 2>&1
492 check "$expected" "$actual"
493
494 # Write the expected output.
495 cat > $expected <<EOF
496 msg part type/subtype size description
497 13 multipart/mixed 1038
498 1 multipart/alternative 518
499 1.1 text/plain 34
500 1.2 text/enriched 29
501 1.3 text/html 111
502 2 multipart/alternative 326
503 2.1 audio/basic 20
504 2.2 audio/mp3 18
505 2.3 audio/wav 18
506 EOF
507
508 # check it -- bump plain and enriched to the top. add a bogus type as well.
509 run_prog mhlist -prefer foo/bar -prefer text/plain -prefer text/enriched $msgnum > $actual 2>&1
510 check "$expected" "$actual"
511
512
513 exit $failed