better error handling in whatnow2
[mmh] / test / tests / mhlist / test-mhlist
1 #!/bin/sh
2 ######################################################
3 #
4 # Test mhlist
5 #
6 ######################################################
7
8 . "$MH_TEST_COMMON"
9
10
11 # check with no options and no current message
12
13
14 runandcheck 'mhlist' <<!
15 mhlist: no c message
16 !
17
18
19 # check with no options and current message
20 folder +inbox 5 > /dev/null
21 runandcheck mhlist <<!
22  msg part  type/subtype              size description                         
23    5       text/plain                  25
24 !
25 # FIXME: three should be no trailing spaces
26
27
28
29 # check with folder and current message
30 runandcheck "mhlist +inbox" <<!
31  msg part  type/subtype              size description                         
32    5       text/plain                  25
33 !
34 # FIXME: three should be no trailing spaces
35
36 # check with specified message
37 runandcheck "mhlist 5" <<!
38  msg part  type/subtype              size description                         
39    5       text/plain                  25
40 !
41 # FIXME: three should be no trailing spaces
42
43
44 # check -file
45 runandcheck "mhlist -file $MH_TEST_DIR/Mail/inbox/5" <<!
46  msg part  type/subtype              size description                         
47    5       text/plain                  25
48 !
49 # FIXME: three should be no trailing spaces
50
51 # check -file -
52 runandcheck "mhlist -file - < $MH_TEST_DIR/Mail/inbox/5" <<!
53  msg part  type/subtype              size description                         
54    0       text/plain                  25
55 !
56 # FIXME: three should be no trailing spaces
57
58
59 # check message number greater than highest
60 runandcheck 'mhlist 11' <<!
61 mhlist: message 11 doesn't exist
62 !
63
64
65 # check multiple messages
66 runandcheck "mhlist 2 8" <<!
67  msg part  type/subtype              size description                         
68    2       text/plain                  25
69    8       text/plain                  25
70 !
71
72
73 # Write message with a text/plain subpart.
74
75 msgfile=`mhpath b`
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 runandcheck 'mhlist l -part 3' <<!
122  msg part  type/subtype              size description                         
123   11       multipart/mixed            936
124      1     multipart/related          180
125      3     text/plain                  35
126 !
127
128
129 # check -part of a subpart
130 runandcheck 'mhlist l -part 1.1' <<!
131  msg part  type/subtype              size description                         
132   11       multipart/mixed            936
133      1     multipart/related          180
134      1.1   text/plain                  49
135 !
136
137
138 # check -type
139 runandcheck 'mhlist l -type text/plain' <<!
140  msg part  type/subtype              size description                         
141   11       multipart/mixed            936
142      1     multipart/related          180
143      1.1   text/plain                  49
144      2     text/plain                  36
145      3     text/plain                  35
146      4     text/plain                  36
147 !
148
149
150
151
152 # check -verbose
153 runandcheck 'mhlist 11 -verbose' <<!
154  msg part  type/subtype              size description                         
155   11       multipart/mixed            936
156                 boundary="----- =_aaaaaaaaaa0"
157      1     multipart/related          180
158                 type="multipart/alternative"
159                 boundary="subpart__1.1"
160      1.1   text/plain                  49
161                 charset="iso-8859-1"
162      2     text/plain                  36
163                 charset="iso-8859-1"
164      3     text/plain                  35
165                 charset="iso-8859-1"
166                 name="test3"
167      4     text/plain                  36
168                 charset="iso-8859-1"
169 !
170
171
172
173 # check MIME parser and m_getfld
174
175 msgfile=`mhpath b`
176 msgnum=`basename $msgfile`
177 cat > $msgfile <<EOF
178 To: recipient@example.com, recipient@example.com, recipient@example.com,
179     recipient@example.com, recipient@example.com, recipient@example.com,
180     recipient@example.com, recipient@example.com, recipient@example.com,
181     recipient@example.com, recipient@example.com, recipient@example.com,
182     recipient@example.com, recipient@example.com, recipient@example.com,
183     recipient@example.com, recipient@example.com, recipient@example.com,
184     recipient@example.com, recipient@example.com, recipient@example.com,
185     recipient@example.com, recipient@example.com, recipient@example.com,
186     recipient@example.com, recipient@example.com, recipient@example.com,
187     recipient@example.com, recipient@example.com, recipient@example.com,
188     recipient@example.com, recipient@example.com, recipient@example.com,
189     recipient@example.com, recipient@example.com, recipient@example.com,
190     recipient@example.com, recipient@example.com, recipient@example.com,
191     recipient@example.com, recipient@example.com, recipient@example.com,
192     recipient@example.com, recipient@example.com, recipient@example.com,
193     recipient@example.com, recipient@example.com, recipient@example.com,
194     recipient@example.com, recipient@example.com, recipient@example.com,
195     recipient@example.com, recipient@example.com, recipient@example.com,
196     recipient@example.com, recipient@example.com, recipient@example.com,
197     recipient@example.com, recipient@example.com, recipient@example.com,
198     recipient@example.com, recipient@example.com, recipient@example.com,
199     recipient@example.com, recipient@example.com, recipient@example.com,
200     recipient@example.com, recipient@example.com, recipient@example.com,
201     recipient@example.com, recipient@example.com, recipient@example.com,
202     recipient@example.com, recipient@example.com, recipient@example.com,
203     recipient@example.com, recipient@example.com, recipient@example.com,
204     recipient@example.com, recipient@example.com, recipient@example.com,
205     recipient@example.com, recipient@example.com, recipient@example.com,
206     recipient@example.com, recipient@example.com, recipient@example.com,
207     recipient@example.com, recipient@example.com, recipient@example.com,
208     recipient@example.com, recipient@example.com, recipient@example.com,
209     recipient@example.com, recipient@example.com, recipient@example.com,
210     recipient@example.com, recipient@example.com, recipient@example.com,
211     recipient@example.com, recipient@example.com, recipient@example.com,
212     recipient@example.com, recipient@example.com, recipient@example.com,
213     recipient@example.com, recipient@example.com, recipient@example.com,
214     recipient@example.com, recipient@example.com, recipient@example.com,
215     recipient@example.com, recipient@example.com, recipient@example.com,
216     recipient@example.com, recipient@example.com, recipient@example.com,
217     recipient@example.com, recipient@example.com, recipient@example.com,
218     recipient@example.com, recipient@example.com, recipient@example.com,
219     recipient@example.com, recipient@example.com, recipient@example.com,
220     recipient@example.com, recipient@example.com, recipient@example.com,
221     recipient@example.com, recipient@example.com, recipient@example.com,
222     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     re@example.com
291 From: sender@example.com
292 Subject: very long header
293 Date: Wed, 4 Dec 2013 21:12:00 -0500
294 MIME-Version: 1.0
295 Content-Type: multipart/related; boundary="1"
296
297 --1
298 Content-Type: multipart/alternative; boundary="2"
299
300 --2
301 Content-Type: text/plain; charset="us-ascii"
302
303 This is part 1.
304
305
306 --2--
307
308 --1
309 Content-Type: text/plain; charset="us-ascii"
310
311 This is part 2.
312
313
314 --1--
315 EOF
316
317 runandcheck "mhlist l" <<!
318  msg part  type/subtype              size description                         
319   12       multipart/related          204
320      1     multipart/alternative       74
321      1.1   text/plain                  17
322      2     text/plain                  17
323 !
324
325
326 ##  now check mhlist output
327
328 msgfile=`mhpath b`
329 msgnum=`basename $msgfile`
330 cat > $msgfile <<EOF
331 To: example@example.org
332 From: someone <someone@example.com>
333 Subject: mhlist test
334 Date: Thu, 29 Jan 2015 18:12:21 +0000 (GMT)
335 Content-Type: multipart/mixed; boundary="BoundaryMixed"
336
337 --BoundaryMixed
338 Content-type: multipart/alternative;
339  boundary="BoundaryAlternative1"
340
341 --BoundaryAlternative1
342 Content-type: text/enriched; CHARSET=US-ASCII
343 Content-transfer-encoding: 7bit
344
345 This is supposedly enriched.
346
347 --BoundaryAlternative1
348 Content-type: text/plain; charset=ISO-8859-1; format=flowed
349 Content-transfer-encoding: 8bit
350
351 This is the body text/plain part.
352
353 --BoundaryAlternative1
354 Content-type: text/html; CHARSET=US-ASCII
355 Content-transfer-encoding: 7bit
356
357 <html><body><div><span style="line-height: 1.5;">
358 This is the text/html body part.
359 </span></div></body></html>
360
361 --BoundaryAlternative1--
362
363 --BoundaryMixed
364 Content-type: multipart/alternative;
365  boundary="BoundaryAlternative2"
366
367 --BoundaryAlternative2
368 Content-type: audio/wav
369 Content-transfer-encoding: 8bit
370
371 pretend wav audio
372
373 --BoundaryAlternative2
374 Content-type: audio/mp3
375 Content-transfer-encoding: 8bit
376
377 pretend mp3 audio
378
379 --BoundaryAlternative2
380 Content-type: audio/basic
381 Content-transfer-encoding: 8bit
382
383 pretend basic audio
384
385 --BoundaryAlternative2--
386
387 --BoundaryMixed--
388 EOF
389
390 # check it -- vanilla output
391 runandcheck "mhlist $msgnum" <<!
392  msg part  type/subtype              size description                         
393   13       multipart/mixed           1038
394      1     multipart/alternative      518
395      1.1   text/html                  111
396      1.2   text/plain                  34
397      1.3   text/enriched               29
398      2     multipart/alternative      326
399      2.1   audio/basic                 20
400      2.2   audio/mp3                   18
401      2.3   audio/wav                   18
402 !
403
404
405 # check it -- just part 1
406 runandcheck "mhlist -part 1 $msgnum" <<!
407  msg part  type/subtype              size description                         
408   13       multipart/mixed           1038
409      1     multipart/alternative      518
410      1.1   text/html                  111
411      1.2   text/plain                  34
412      1.3   text/enriched               29
413      2     multipart/alternative      326
414 !
415
416
417
418 # check it -- ask for audio/basic in part 1, should get nothing
419 runandcheck "mhlist -part 1 -type audio/basic $msgnum" <<!
420  msg part  type/subtype              size description                         
421   13       multipart/mixed           1038
422      1     multipart/alternative      518
423      2     multipart/alternative      326
424 !
425