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