]> diplodocus.org Git - nmh/blob - test/burst/test-burst-mime
If we're searching for commands, prefer xpg4 versions on Solaris.
[nmh] / test / burst / test-burst-mime
1 #!/bin/sh
2 #
3 # Tests to see if bursting MIME messages works correctly.
4 #
5
6 set -e
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 #
18 # Create a one-part test message that we can burst
19 #
20
21 cat > "${MH_TEST_DIR}/Mail/inbox/11" <<EOF
22 From: Test Burst Message <burst1@example.com>
23 To: Test Recipient <recipient@example.com>
24 Date: Friday, 29 Sep 2006 00:00:00
25 Subject: Test MIME digest
26 MIME-Version: 1.0
27 Content-type: message/rfc822
28
29 From: Mister Burster <burst2@example.com>
30 To: Nobody 1 <nobody1@example.com>
31 Date: Thursday, 28 Sep 2006 00:01:00
32 Subject: Message one
33
34 - - This line should not be unstuffed
35
36 EOF
37
38 burst 11
39
40 run_test 'scan -width 80 11-last' \
41 " 11 09/29 Test Burst Messag Test MIME digest<<From: Mister Burster <burst2@e
42 12+ 09/28 Mister Burster Message one<<- - This line should not be unstuff"
43
44 #
45 # Create another test message that does multipart/digest checking
46 #
47
48 cat > "${MH_TEST_DIR}/Mail/inbox/14" <<EOF
49 From: Test Burst Message <burst1@example.com>
50 To: Test Recipient <recipient@example.com>
51 Date: Friday, 29 Sep 2006 00:00:00
52 Subject: Test digest
53 MIME-Version: 1.0
54 Content-Type: multipart/digest; boundary="----- =_aaaaaaaaaa0"
55
56 This is a preamble
57 ------- =_aaaaaaaaaa0
58 Content-Type: message/rfc822
59
60 From: Mister Burster <burst2@example.com>
61 To: Nobody 1 <nobody1@example.com>
62 Date: Thursday, 28 Sep 2006 00:01:00
63 Subject: Message one
64
65 - -This is message one
66
67 ------- =_aaaaaaaaaa0
68
69 From: Mister Burster <burst3@example.com>
70 To: Nobody 2 <nobody2@example.com>
71 Date: Thursday, 28 Sep 2006 00:02:00
72 Subject: Message two
73
74 This is message two
75 - For real.
76 ------- =_aaaaaaaaaa0
77
78 From: Mister Burster <burst4@example.com>
79 To: Nobody 3 <nobody3@example.com>
80 Date: Thursday, 28 Sep 2006 00:03:00
81 Subject: Message three
82
83 Will this one work?
84
85
86 ------- =_aaaaaaaaaa0--
87 EOF
88
89 burst 14 || exit
90
91 run_test 'scan -width 80 14-last' \
92 " 14 09/29 Test Burst Messag Test digest<<This is a preamble ------- =_aaaaaa
93 15+ 09/28 Mister Burster Message one<<- -This is message one >>
94 16 09/28 Mister Burster Message two<<This is message two - For real.>>
95 17 09/28 Mister Burster Message three<<Will this one work? >>"
96
97 #
98 # Check to see if each message is what we expect
99 #
100
101 run_test 'show -noheader -noshow 15' \
102 "From: Mister Burster <burst2@example.com>
103 To: Nobody 1 <nobody1@example.com>
104 Date: Thursday, 28 Sep 2006 00:01:00
105 Subject: Message one
106
107 - -This is message one"
108
109 run_test 'show -noheader -noshow 16' \
110 "From: Mister Burster <burst3@example.com>
111 To: Nobody 2 <nobody2@example.com>
112 Date: Thursday, 28 Sep 2006 00:02:00
113 Subject: Message two
114
115 This is message two
116 - For real."
117
118 #
119 # The CR/LF that appears right before the boundary line is considered part
120 # of the boundary line, so this has the practical effect of "eating" a
121 # blank line if it's before the boundary (RFC 2046. 5.1.1). So make sure
122 # a double blank line results in only one blank line at the end of a message.
123 #
124
125 expected="${MH_TEST_DIR}/$$.expected"
126 cat > "${expected}" <<EOF
127 From: Mister Burster <burst4@example.com>
128 To: Nobody 3 <nobody3@example.com>
129 Date: Thursday, 28 Sep 2006 00:03:00
130 Subject: Message three
131
132 Will this one work?
133
134 EOF
135
136 check "${expected}" `mhpath 17`
137
138 exit $failed