]> diplodocus.org Git - nmh/blob - test/mhlist/test-mhlist
Commented out full output device test in test-scan.
[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 check_exit '-eq 1' mhlist -
20
21 expected=$MH_TEST_DIR/$$.expected
22 actual=$MH_TEST_DIR/$$.actual
23
24
25 start_test 'with no options and no current message'
26 run_test 'mhlist' 'mhlist: no cur message'
27
28 start_test 'with no options and current message'
29 folder +inbox 5 > /dev/null
30 cat > $expected <<EOF
31 msg part type/subtype size description
32 5 text/plain 25
33 EOF
34 run_prog mhlist > $actual 2>&1
35 check $expected $actual 'keep first'
36
37 start_test '-noheaders'
38 run_test 'mhlist 5 -noheaders' ' 5 text/plain 25'
39
40 start_test '-headers'
41 run_prog mhlist -noheaders -headers > $actual 2>&1
42 check $expected $actual 'keep first'
43
44 start_test 'with folder and current message'
45 run_prog mhlist +inbox > $actual 2>&1
46 check $expected $actual 'keep first'
47
48 start_test 'with specified message'
49 run_prog mhlist 5 > $actual 2>&1
50 check $expected $actual 'keep first'
51
52 start_test '-file'
53 run_prog mhlist -file "$MH_TEST_DIR/Mail/inbox/5" > $actual 2>&1
54 check $expected $actual
55
56 start_test '-file -'
57 cat > $expected <<EOF
58 msg part type/subtype size description
59 0 text/plain 25
60 EOF
61 run_prog mhlist -file - < "$MH_TEST_DIR/Mail/inbox/5" > $actual 2>&1
62 check $expected $actual
63
64 start_test 'message with no blank line separating the headers from the body.'
65 # Shouldn't make a difference to the size of the body part.
66 # Bug meant no-blank-line case was one bigger by including the `\n'
67 # ending the last header.
68 f=$MH_TEST_DIR/$$.blank
69 cat >$f-yes <<\E
70 foo: bar
71
72 body1
73 body2
74 E
75 sed '/^$/d' $f-yes >$f-no
76 run_prog mhlist -file $f-yes >$actual-yes
77 run_prog mhlist -file $f-no >$actual-no
78 check $actual-yes $actual-no
79 rm $f-yes $f-no
80
81 start_test 'message number greater than highest'
82 run_test 'mhlist 11' "mhlist: message 11 doesn't exist"
83
84 start_test 'multiple messages'
85 cat > $expected <<EOF
86 msg part type/subtype size description
87 2 text/plain 25
88 8 text/plain 25
89 EOF
90 run_prog mhlist 2 8 > $actual 2>&1
91 check $expected $actual
92
93 # Write message with a text/plain subpart.
94 msgfile=`mhpath new`
95 cat > $msgfile <<EOF
96 To: recipient@example.com
97 From: sender@example.com
98 Subject: mhlist test
99 MIME-Version: 1.0
100 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
101
102 ------- =_aaaaaaaaaa0
103 Content-Type: multipart/related;
104 type="multipart/alternative";
105 boundary="subpart__1.1"
106
107 --subpart__1.1
108 Content-Type: text/plain; charset="iso-8859-1"
109 Content-Disposition: attachment; filename="test1"
110
111 This is the first text/plain part, in a subpart.
112
113 --subpart__1.1--
114
115 ------- =_aaaaaaaaaa0
116 Content-Type: text/plain; charset="iso-8859-1"
117 Content-Disposition: attachment; filename="test2"
118 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
119 Content-Transfer-Encoding: quoted-printable
120
121 This is the second text/plain part.
122
123 ------- =_aaaaaaaaaa0
124 Content-Type: text/plain; charset="iso-8859-1"; name="test3"
125 Content-Disposition: attachment; filename="test3"
126
127 This is the third text/plain part.
128
129 ------- =_aaaaaaaaaa0
130 Content-Type: text/plain; charset="iso-8859-1"
131 Content-Disposition: attachment; filename="test4"
132 Content-Transfer-Encoding: base64
133
134 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
135
136 ------- =_aaaaaaaaaa0--
137 EOF
138
139 start_test '-part'
140 run_test 'mhlist last -part 3 -noheader' \
141 ' 11 multipart/mixed 936
142 1 multipart/related 180
143 3 text/plain 35'
144
145 start_test '-part of a subpart'
146 run_test 'mhlist last -part 1.1 -noheader' \
147 ' 11 multipart/mixed 936
148 1 multipart/related 180
149 1.1 text/plain 49'
150
151 start_test '-type'
152 run_test 'mhlist last -type text/plain -noheader' \
153 ' 11 multipart/mixed 936
154 1 multipart/related 180
155 1.1 text/plain 49
156 2 text/plain 36
157 3 text/plain 35
158 4 text/plain 36'
159
160 start_test '-norealsize'
161 run_test 'mhlist last -part 4 -noheader -norealsize' \
162 ' 11 multipart/mixed 936
163 1 multipart/related 180
164 4 text/plain 49'
165
166 start_test '-realsize, the default'
167 run_test 'mhlist last -part 4 -noheader -norealsize -realsize' \
168 ' 11 multipart/mixed 936
169 1 multipart/related 180
170 4 text/plain 36'
171
172 #
173 # Set the cur sequence to 1 to test default behavior of changecur after
174 # this test.
175 #
176
177 mark 1 -sequence cur -add -zero
178
179 start_test '-verbose'
180 run_test 'mhlist 11 -verbose -noheader' \
181 ' 11 multipart/mixed 936
182 boundary="----- =_aaaaaaaaaa0"
183 1 multipart/related 180
184 type="multipart/alternative"
185 boundary="subpart__1.1"
186 1.1 text/plain 49
187 charset="iso-8859-1"
188 2 text/plain 36
189 charset="iso-8859-1"
190 3 text/plain 35
191 charset="iso-8859-1"
192 name="test3"
193 4 text/plain 36
194 charset="iso-8859-1"'
195
196 #
197 start_test 'default changecur behavior'
198 #
199
200 run_test 'mark -sequence cur -list' 'cur: 11'
201
202 #
203 # Now test -nochangecur
204 #
205
206 mhlist -nochangecur 1 >/dev/null
207
208 run_test 'mark -sequence cur -list' 'cur: 11'
209
210 start_test 'MIME parser and m_getfld'
211 cat > $expected <<EOF
212 msg part type/subtype size description
213 12 multipart/related 204
214 1 multipart/alternative 74
215 1.1 text/plain 17
216 2 text/plain 17
217 EOF
218
219 msgfile=`mhpath new`
220 msgnum=`basename $msgfile`
221 cat > $msgfile <<EOF
222 To: recipient@example.com, recipient@example.com, recipient@example.com,
223 recipient@example.com, recipient@example.com, recipient@example.com,
224 recipient@example.com, recipient@example.com, recipient@example.com,
225 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 re@example.com
335 From: sender@example.com
336 Subject: very long header
337 Date: Wed, 4 Dec 2013 21:12:00 -0500
338 MIME-Version: 1.0
339 Content-Type: multipart/related; boundary="1"
340
341 --1
342 Content-Type: multipart/alternative; boundary="2"
343
344 --2
345 Content-Type: text/plain; charset="us-ascii"
346
347 This is part 1.
348
349
350 --2--
351
352 --1
353 Content-Type: text/plain; charset="us-ascii"
354
355 This is part 2.
356
357
358 --1--
359 EOF
360
361 run_prog mhlist last > $actual 2>&1
362 check $expected $actual
363
364 ## now check mhlist output
365
366 msgfile=`mhpath new`
367 msgnum=`basename $msgfile`
368 cat > $msgfile <<EOF
369 To: example@example.org
370 From: someone <someone@example.com>
371 Subject: mhlist test
372 Date: Thu, 29 Jan 2015 18:12:21 +0000 (GMT)
373 Content-Type: multipart/mixed; boundary="BoundaryMixed"
374
375 --BoundaryMixed
376 Content-type: multipart/alternative;
377 boundary="BoundaryAlternative1"
378
379 --BoundaryAlternative1
380 Content-type: text/enriched; CHARSET=US-ASCII
381 Content-transfer-encoding: 7bit
382
383 This is supposedly enriched.
384
385 --BoundaryAlternative1
386 Content-type: text/plain; charset=ISO-8859-1; format=flowed
387 Content-transfer-encoding: 8bit
388
389 This is the body text/plain part.
390
391 --BoundaryAlternative1
392 Content-type: text/html; CHARSET=US-ASCII
393 Content-transfer-encoding: 7bit
394
395 <html><body><div><span style="line-height: 1.5;">
396 This is the text/html body part.
397 </span></div></body></html>
398
399 --BoundaryAlternative1--
400
401 --BoundaryMixed
402 Content-type: multipart/alternative;
403 boundary="BoundaryAlternative2"
404
405 --BoundaryAlternative2
406 Content-type: audio/wav
407 Content-transfer-encoding: 8bit
408
409 pretend wav audio
410
411 --BoundaryAlternative2
412 Content-type: audio/mp3
413 Content-transfer-encoding: 8bit
414
415 pretend mp3 audio
416
417 --BoundaryAlternative2
418 Content-type: audio/basic
419 Content-transfer-encoding: 8bit
420
421 pretend basic audio
422
423 --BoundaryAlternative2--
424
425 --BoundaryMixed--
426 EOF
427
428 # Write the expected output.
429 cat > $expected <<EOF
430 msg part type/subtype size description
431 13 multipart/mixed 1038
432 1 multipart/alternative 518
433 1.1 text/html 111
434 1.2 text/plain 34
435 1.3 text/enriched 29
436 2 multipart/alternative 326
437 2.1 audio/basic 20
438 2.2 audio/mp3 18
439 2.3 audio/wav 18
440 EOF
441
442 start_test 'vanilla output'
443 run_prog mhlist $msgnum > $actual 2>&1
444 check "$expected" "$actual"
445
446 # Write the expected output.
447 cat > $expected <<EOF
448 msg part type/subtype size description
449 13 multipart/mixed 1038
450 1 multipart/alternative 518
451 1.1 text/html 111
452 1.2 text/plain 34
453 1.3 text/enriched 29
454 2 multipart/alternative 326
455 EOF
456
457 start_test 'just part 1'
458 run_prog mhlist -part 1 $msgnum > $actual 2>&1
459 check "$expected" "$actual"
460
461 # Write the expected output.
462 cat > $expected <<EOF
463 msg part type/subtype size description
464 13 multipart/mixed 1038
465 1 multipart/alternative 518
466 2 multipart/alternative 326
467 EOF
468
469 start_test 'ask for audio/basic in part 1, should get nothing'
470 run_prog mhlist -part 1 -type audio/basic $msgnum > $actual 2>&1
471 check "$expected" "$actual"
472
473 # Write the expected output.
474 cat > $expected <<EOF
475 msg part type/subtype size description
476 13 multipart/mixed 1038
477 1 multipart/alternative 518
478 1.1 text/plain 34
479 1.2 text/html 111
480 1.3 text/enriched 29
481 2 multipart/alternative 326
482 2.1 audio/wav 18
483 2.2 audio/basic 20
484 2.3 audio/mp3 18
485 EOF
486
487 start_test 'bump plain and wav to the top of their parts'
488 run_prog mhlist -prefer text/plain -prefer audio/wav $msgnum > $actual 2>&1
489 check "$expected" "$actual"
490
491 # Write the expected output.
492 cat > $expected <<EOF
493 msg part type/subtype size description
494 13 multipart/mixed 1038
495 1 multipart/alternative 518
496 1.1 text/enriched 29
497 1.2 text/plain 34
498 1.3 text/html 111
499 2 multipart/alternative 326
500 2.1 audio/basic 20
501 2.2 audio/mp3 18
502 2.3 audio/wav 18
503 EOF
504
505 start_test 'bump plain and enriched to the top. add a bogus type as well.'
506 run_prog mhlist -prefer foo/bar -prefer text/plain -prefer text/enriched $msgnum > $actual 2>&1
507 check "$expected" "$actual"
508
509
510 finish_test
511 exit $failed