]> diplodocus.org Git - nmh/blob - test/mhbuild/test-cte
test/mhbuild/test-cte: Add missing check() for earlier run_prog().
[nmh] / test / mhbuild / test-cte
1 #!/bin/sh
2 #########################################################
3 #
4 # Test the use of explicit Content-Transfer-Encoding tags
5 #
6 #########################################################
7
8 if test -z "${MH_OBJ_DIR}"; then
9 srcdir=`dirname "$0"`/../..
10 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
11 fi
12
13 . "$MH_OBJ_DIR/test/common.sh"
14
15 setup_test
16
17 set -e
18
19 require_locale en_US.UTF-8 en_US.UTF8 en_US.utf-8 en_US.utf8
20
21 draft="$MH_TEST_DIR/$$.draft"
22 backup="${MH_TEST_DIR}/`mhparam sbackup`$$.draft.orig"
23 expected="$MH_TEST_DIR/$$.expected"
24
25 #
26 # Force some text to be quoted-printable
27 #
28
29 cat > "$draft" <<EOF
30 To: Mr Test <mrtest@example.com>
31 cc:
32 Fcc: +outbox
33 ------
34 #<text/plain *qp
35 This is a test of a message with a shørt line.
36 EOF
37
38 run_prog mhbuild "$draft"
39
40 cat > "$expected" <<EOF
41 To: Mr Test <mrtest@example.com>
42 cc:
43 Fcc: +outbox
44 MIME-Version: 1.0
45 Content-Type: text/plain; charset="UTF-8"
46 Content-Transfer-Encoding: quoted-printable
47
48 This is a test of a message with a sh=C3=B8rt line.
49 EOF
50
51 check "$draft" "$expected"
52
53 #
54 # Force some text to be base64, to test out the encoder. Try at different
55 # line lengths to check out the padding on the routines to convert LF to
56 # CR LF. The current implementation reads in using a 3 byte buffer, so make
57 # sure we catch all of those cases.
58 #
59
60 cat > "$draft" <<EOF
61 To: Mr Test <mrtest@example.com>
62 cc:
63 Fcc: +outbox
64 ------
65 #<text/plain *b64
66 This is a test of a message with a shørt line.
67 EOF
68
69 run_prog mhbuild "$draft"
70
71 cat > "$expected" <<EOF
72 To: Mr Test <mrtest@example.com>
73 cc:
74 Fcc: +outbox
75 MIME-Version: 1.0
76 Content-Type: text/plain; charset="UTF-8"
77 Content-Transfer-Encoding: base64
78
79 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtZXNzYWdlIHdpdGggYSBzaMO4cnQgbGluZS4NCg==
80 EOF
81
82 check "$draft" "$expected"
83
84 cat > "$draft" <<EOF
85 To: Mr Test <mrtest@example.com>
86 cc:
87 Fcc: +outbox
88 ------
89 #<text/plain *b64
90 This is a test of a mëssage with a shørt line.
91 EOF
92
93 run_prog mhbuild "$draft"
94
95 cat > "$expected" <<EOF
96 To: Mr Test <mrtest@example.com>
97 cc:
98 Fcc: +outbox
99 MIME-Version: 1.0
100 Content-Type: text/plain; charset="UTF-8"
101 Content-Transfer-Encoding: base64
102
103 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc2FnZSB3aXRoIGEgc2jDuHJ0IGxpbmUuDQo=
104 EOF
105
106 check "$draft" "$expected"
107
108 cat > "$draft" <<EOF
109 To: Mr Test <mrtest@example.com>
110 cc:
111 Fcc: +outbox
112 ------
113 #<text/plain *b64
114 This is a test of a mëssäge with a shørt line.
115 EOF
116
117 run_prog mhbuild "$draft"
118
119 cat > "$expected" <<EOF
120 To: Mr Test <mrtest@example.com>
121 cc:
122 Fcc: +outbox
123 MIME-Version: 1.0
124 Content-Type: text/plain; charset="UTF-8"
125 Content-Transfer-Encoding: base64
126
127 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0K
128 EOF
129
130 check "$draft" "$expected"
131
132 cat > "$draft" <<EOF
133 To: Mr Test <mrtest@example.com>
134 cc:
135 Fcc: +outbox
136 ------
137 #<text/plain *b64
138 This is a test of a message with a shørt line.
139 This is a second line.
140 EOF
141
142 run_prog mhbuild "$draft"
143
144 cat > "$expected" <<EOF
145 To: Mr Test <mrtest@example.com>
146 cc:
147 Fcc: +outbox
148 MIME-Version: 1.0
149 Content-Type: text/plain; charset="UTF-8"
150 Content-Transfer-Encoding: base64
151
152 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtZXNzYWdlIHdpdGggYSBzaMO4cnQgbGluZS4NClRoaXMgaXMg
153 YSBzZWNvbmQgbGluZS4NCg==
154 EOF
155
156 check "$draft" "$expected"
157
158 cat > "$draft" <<EOF
159 To: Mr Test <mrtest@example.com>
160 cc:
161 Fcc: +outbox
162 ------
163 #<text/plain *b64
164 This is a test of a mëssage with a shørt line.
165 This is a second line.
166 EOF
167
168 run_prog mhbuild "$draft"
169
170 cat > "$expected" <<EOF
171 To: Mr Test <mrtest@example.com>
172 cc:
173 Fcc: +outbox
174 MIME-Version: 1.0
175 Content-Type: text/plain; charset="UTF-8"
176 Content-Transfer-Encoding: base64
177
178 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc2FnZSB3aXRoIGEgc2jDuHJ0IGxpbmUuDQpUaGlzIGlz
179 IGEgc2Vjb25kIGxpbmUuDQo=
180 EOF
181
182 check "$draft" "$expected"
183
184 cat > "$draft" <<EOF
185 To: Mr Test <mrtest@example.com>
186 cc:
187 Fcc: +outbox
188 ------
189 #<text/plain *b64
190 This is a test of a mëssäge with a shørt line.
191 This is a second line.
192 EOF
193
194 run_prog mhbuild "$draft"
195
196 cat > "$expected" <<EOF
197 To: Mr Test <mrtest@example.com>
198 cc:
199 Fcc: +outbox
200 MIME-Version: 1.0
201 Content-Type: text/plain; charset="UTF-8"
202 Content-Transfer-Encoding: base64
203
204 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0KVGhpcyBp
205 cyBhIHNlY29uZCBsaW5lLg0K
206 EOF
207
208 check "$draft" "$expected"
209
210 cat > "$draft" <<EOF
211 To: Mr Test <mrtest@example.com>
212 cc:
213 Fcc: +outbox
214 ------
215 #<text/plain *b64
216 This is a test of a mëssäge with a shørt line.
217
218
219 This is a second line.
220
221
222
223
224 EOF
225
226 run_prog mhbuild "$draft"
227
228 cat > "$expected" <<EOF
229 To: Mr Test <mrtest@example.com>
230 cc:
231 Fcc: +outbox
232 MIME-Version: 1.0
233 Content-Type: text/plain; charset="UTF-8"
234 Content-Transfer-Encoding: base64
235
236 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0KDQoNClRo
237 aXMgaXMgYSBzZWNvbmQgbGluZS4NCg0KDQoNCg0K
238 EOF
239
240 check "$draft" "$expected"
241
242 #
243 # Test out some "long" text. By default it should end up as quoted-printable.
244 # But if we request 8bit we should error out if the line is greater than
245 # 998.
246 #
247
248 cat > "$draft" <<EOF
249 To: Mr Test <mrtest@example.com>
250 cc:
251 Fcc: +outbox
252 ------
253 This is a test of a messege with a long line. This line needs to be longer than 998 to test out the encoding rules. Will that work? That's a good question; I don't know if it will or not. I am the very model of a modern Major-General, I've information vegetable, animal, and mineral, I know the kings of England, and I quote the fights historical From Marathon to Waterloo, in order categorical, I'm very well acquainted, too, with matters mathematical, I understand equations, both the simple and quadratical, About binomial theorem I'm teeming with a lot o' news, With many cheerful facts about the square of the hypotenuse. I'm very good at integral and differential calculus; I know the scientific names of beings animalculous: In short, in matters vegetable, animal, and mineral, I am the very model of a modern Major-General. I know our mythic history, King Arthur's and Sir Caradoc's; I answer hard acrostics, I've a pretty taste for paradox, I quote in elegiacs all the crimes of Heliogabalus, In conics I can floor peculiarities parabolous; I can tell undoubted Raphaels from Gerard Dows and Zoffanies, I know the croaking chorus from The Frogs of Aristophanes! Then I can hum a fugue of which I've heard the music's din afore, And whistle all the airs from that infernal nonsense Pinafore.
254
255 This is a second line.
256 EOF
257
258 run_prog mhbuild "$draft"
259
260 cat > "$expected" <<EOF
261 To: Mr Test <mrtest@example.com>
262 cc:
263 Fcc: +outbox
264 MIME-Version: 1.0
265 Content-Type: text/plain; charset="us-ascii"
266 Content-Transfer-Encoding: quoted-printable
267
268 This is a test of a messege with a long line. This line needs to be longe=
269 r than 998 to test out the encoding rules. Will that work? That's a good=
270 question; I don't know if it will or not. I am the very model of a moder=
271 n Major-General, I've information vegetable, animal, and mineral, I know t=
272 he kings of England, and I quote the fights historical From Marathon to Wa=
273 terloo, in order categorical, I'm very well acquainted, too, with matters =
274 mathematical, I understand equations, both the simple and quadratical, Abo=
275 ut binomial theorem I'm teeming with a lot o' news, With many cheerful fac=
276 ts about the square of the hypotenuse. I'm very good at integral and diffe=
277 rential calculus; I know the scientific names of beings animalculous: In s=
278 hort, in matters vegetable, animal, and mineral, I am the very model of a =
279 modern Major-General. I know our mythic history, King Arthur's and Sir Car=
280 adoc's; I answer hard acrostics, I've a pretty taste for paradox, I quote =
281 in elegiacs all the crimes of Heliogabalus, In conics I can floor peculiar=
282 ities parabolous; I can tell undoubted Raphaels from Gerard Dows and Zoffa=
283 nies, I know the croaking chorus from The Frogs of Aristophanes! Then I c=
284 an hum a fugue of which I've heard the music's din afore, And whistle all =
285 the airs from that infernal nonsense Pinafore. =
286
287
288 This is a second line.
289 EOF
290
291 check "$draft" "$expected"
292
293 cat > "$draft" <<EOF
294 To: Mr Test <mrtest@example.com>
295 cc:
296 Fcc: +outbox
297 ------
298 This is a test of a messege with a long line. This line needs to be longer than 998 to test out the encoding rules. Will that work? That's a good question; I don't know if it will or not. I am the very model of a modern Major-General, I've information vegetable, animal, and mineral, I know the kings of England, and I quote the fights historical From Marathon to Waterloo, in order categorical, I'm very well acquainted, too, with matters mathematical, I understand equations, both the simple and quadratical, About binomial theorem I'm teeming with a lot o' news, With many cheerful facts about the square of the hypotenuse. I'm very good at integral and differential calculus; I know the scientific names of beings animalculous: In short, in matters vegetable, animal, and mineral, I am the very model of a modern Major-General. I know our mythic history, King Arthur's and Sir Caradoc's; I answer hard acrostics, I've a pretty taste for paradox, I quote in elegiacs all the crimes of Heliogabalus, In conics I can floor peculiarities parabolous; I can tell undoubted Raphaels from Gerard Dows and Zoffanies, I know the croaking chorus from The Frogs of Aristophanes! Then I can hum a fugue of which I've heard the music's din afore, And whistle all the airs from that infernal nonsense Pinafore.
299
300 This is a secönd line.
301 EOF
302
303 run_prog mhbuild "$draft"
304
305 cat > "$expected" <<EOF
306 To: Mr Test <mrtest@example.com>
307 cc:
308 Fcc: +outbox
309 MIME-Version: 1.0
310 Content-Type: text/plain; charset="UTF-8"
311 Content-Transfer-Encoding: quoted-printable
312
313 This is a test of a messege with a long line. This line needs to be longe=
314 r than 998 to test out the encoding rules. Will that work? That's a good=
315 question; I don't know if it will or not. I am the very model of a moder=
316 n Major-General, I've information vegetable, animal, and mineral, I know t=
317 he kings of England, and I quote the fights historical From Marathon to Wa=
318 terloo, in order categorical, I'm very well acquainted, too, with matters =
319 mathematical, I understand equations, both the simple and quadratical, Abo=
320 ut binomial theorem I'm teeming with a lot o' news, With many cheerful fac=
321 ts about the square of the hypotenuse. I'm very good at integral and diffe=
322 rential calculus; I know the scientific names of beings animalculous: In s=
323 hort, in matters vegetable, animal, and mineral, I am the very model of a =
324 modern Major-General. I know our mythic history, King Arthur's and Sir Car=
325 adoc's; I answer hard acrostics, I've a pretty taste for paradox, I quote =
326 in elegiacs all the crimes of Heliogabalus, In conics I can floor peculiar=
327 ities parabolous; I can tell undoubted Raphaels from Gerard Dows and Zoffa=
328 nies, I know the croaking chorus from The Frogs of Aristophanes! Then I c=
329 an hum a fugue of which I've heard the music's din afore, And whistle all =
330 the airs from that infernal nonsense Pinafore. =
331
332
333 This is a sec=C3=B6nd line.
334 EOF
335
336 check "$draft" "$expected"
337
338 cat > "$draft" <<EOF
339 To: Mr Test <mrtest@example.com>
340 cc:
341 Fcc: +outbox
342 ------
343 #<text/plain *8bit
344 This is a test of a messege with a long line. This line needs to be longer than 998 to test out the encoding rules. Will that work? That's a good question; I don't know if it will or not. I am the very model of a modern Major-General, I've information vegetable, animal, and mineral, I know the kings of England, and I quote the fights historical From Marathon to Waterloo, in order categorical, I'm very well acquainted, too, with matters mathematical, I understand equations, both the simple and quadratical, About binomial theorem I'm teeming with a lot o' news, With many cheerful facts about the square of the hypotenuse. I'm very good at integral and differential calculus; I know the scientific names of beings animalculous: In short, in matters vegetable, animal, and mineral, I am the very model of a modern Major-General. I know our mythic history, King Arthur's and Sir Caradoc's; I answer hard acrostics, I've a pretty taste for paradox, I quote in elegiacs all the crimes of Heliogabalus, In conics I can floor peculiarities parabolous; I can tell undoubted Raphaels from Gerard Dows and Zoffanies, I know the croaking chorus from The Frogs of Aristophanes! Then I can hum a fugue of which I've heard the music's din afore, And whistle all the airs from that infernal nonsense Pinafore.
345
346 This is a secönd line.
347 EOF
348
349 set +e
350 run_test 'eval mhbuild "$draft" 2>&1' 'mhbuild: Line in content exceeds maximum line limit (998)'
351 set -e
352
353 #
354 # Check to make sure -maxunencoded does what we want.
355 #
356
357 cat > "$draft" <<EOF
358 To: Mr Test <mrtest@example.com>
359 cc:
360 Fcc: +outbox
361 ------
362 This is the test of a lønger line than the usual limit. Assuming we set the maxunencded parameter properly, this should end up as 8bit?
363 EOF
364
365 run_prog mhbuild -maxunencoded 200 "$draft"
366
367 cat > "$expected" <<EOF
368 To: Mr Test <mrtest@example.com>
369 cc:
370 Fcc: +outbox
371 MIME-Version: 1.0
372 Content-Type: text/plain; charset="UTF-8"
373 Content-Transfer-Encoding: 8bit
374
375 This is the test of a lønger line than the usual limit. Assuming we set the maxunencded parameter properly, this should end up as 8bit?
376 EOF
377
378 check "$draft" "$expected"
379
380 [ ${failed:=0} -eq 0 ] && rm -f ${backup}
381
382 exit ${failed:-0}