]> diplodocus.org Git - nmh/blob - test/mhshow/test-subpart
Removed #include of signal.h because it's in h/signals.h.
[nmh] / test / mhshow / test-subpart
1 #!/bin/sh
2 ######################################################
3 #
4 # Test show of one part, fixed by
5 # 31cba404636730df219dd009ca5893ccc56d46af
6 #
7 ######################################################
8
9 set -e
10
11 if test -z "${MH_OBJ_DIR}"; then
12 srcdir=`dirname "$0"`/../..
13 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
14 fi
15
16 . "$MH_OBJ_DIR/test/common.sh"
17
18 setup_test
19
20 expected=$MH_TEST_DIR/$$.expected
21 actual=$MH_TEST_DIR/$$.actual
22
23 # Write message with a text/plain subpart.
24 msgfile=`mhpath new`
25 msgnum=`basename $msgfile`
26 cat > $msgfile <<EOF
27 MIME-Version: 1.0
28 Content-Type: multipart/mixed; boundary="NextPart_001"
29 Content-class: urn:content-classes:message
30 Date: Thu, 19 May 2011 00:00:00 -0000
31 From: sender@example.com
32 To: recipient@example.com
33
34 This is a multi-part message in MIME format.
35
36 --NextPart_001
37 Content-Type: multipart/related;
38 type="multipart/alternative";
39 boundary="NextPart_002"
40
41 --NextPart_002
42 Content-Type: text/plain;
43 charset="utf-8"
44
45 This is the text/plain part.
46
47 --NextPart_002--
48
49 --NextPart_001--
50 EOF
51
52 # Write the expected output.
53 cat > $expected <<EOF
54 [ Message inbox:11 ]
55 [ part 1.1 - text/plain - 29B ]
56 This is the text/plain part.
57 EOF
58
59 # check it
60 run_prog mhshow -part 1.1 -form mhl.null $msgnum > $actual 2>&1
61 check "$expected" "$actual" : part 1.1
62
63
64 # tests of -part/-type/-prefer
65
66 cat > $msgfile <<EOF
67 To: example@example.org
68 From: someone <someone@example.com>
69 Subject: mhshow -part/-type/-prefer test
70 Date: Thu, 29 Jan 2015 18:12:21 +0000 (GMT)
71 Content-Type: multipart/mixed; boundary="BoundaryMixed"
72
73 --BoundaryMixed
74 Content-type: multipart/alternative;
75 boundary="BoundaryAlternative1"
76
77 --BoundaryAlternative1
78 Content-type: text/plain; charset=ISO-8859-1; format=flowed
79 Content-transfer-encoding: 8bit
80
81 This is the body text/plain part.
82 --BoundaryAlternative1
83 Content-type: multipart/related;
84 boundary="BoundaryAlternative2"; type="text/html"
85
86 --BoundaryAlternative2
87 Content-type: text/html; CHARSET=US-ASCII
88 Content-transfer-encoding: quoted-printable
89
90 <html><body><div><span style=3D"line-height: 1.5;">
91 This is the text/html body part.
92 </span></div></body></html>
93
94 --BoundaryAlternative2--
95
96 --BoundaryAlternative1--
97
98 --BoundaryMixed
99 Content-Type: text/plain; charset="us-ascii"
100 MIME-Version: 1.0
101 Content-Transfer-Encoding: 7bit
102 Content-Disposition: inline
103
104 _______________________________________________
105 This is the final text/plain signature part.
106
107 --BoundaryMixed--
108 EOF
109
110 # Write the expected output.
111 cat > $expected <<EOF
112 [ Message inbox:11 ]
113 [ part 1.1.1 - text/html - 111B ]
114 This is the text/html body part.
115 EOF
116
117 # check it
118 run_prog mhshow -part 1.1.1 -form mhl.null $msgnum > $actual 2>&1
119 check "$expected" "$actual" : part 1.1.1
120
121 # Write the expected output.
122 cat > $expected <<EOF
123 [ Message inbox:11 ]
124 [ part 1.2 - text/plain - 33B ]
125 This is the body text/plain part.
126 EOF
127
128 # check it
129 run_prog mhshow -part 1.2 -form mhl.null $msgnum > $actual 2>&1
130 check "$expected" "$actual" : part 1.2
131
132 # Write the expected output.
133 cat > $expected <<EOF
134 [ Message inbox:11 ]
135 [ part 1.1 - text/plain - 33B ]
136 This is the body text/plain part.
137 EOF
138
139 # check it
140 run_prog mhshow -prefer text/plain -part 1 -form mhl.null $msgnum > $actual 2>&1
141 check "$expected" "$actual" : part conflicting text/plain, part 1 switches
142
143 # Write the expected output.
144 cat > $expected <<EOF
145 [ Message inbox:11 ]
146 [ part 2 - text/plain - 93B ]
147 _______________________________________________
148 This is the final text/plain signature part.
149 EOF
150
151 # check it
152 run_prog mhshow -part 2 -form mhl.null $msgnum > $actual 2>&1
153 check "$expected" "$actual" : part 2
154
155 # Write the expected output.
156 cat > $expected <<EOF
157 [ Message inbox:11 ]
158 [ part 1.2 - text/plain - 33B ]
159 This is the body text/plain part.
160 [ part 2 - text/plain - 93B ]
161 _______________________________________________
162 This is the final text/plain signature part.
163 EOF
164
165 # check it
166 run_prog mhshow -type text/plain -form mhl.null $msgnum > $actual 2>&1
167 check "$expected" "$actual" : type text/plain
168
169 # Write the expected output.
170 cat > $expected <<EOF
171 [ Message inbox:11 ]
172 [ part 1.1 - text/plain - 33B ]
173 This is the body text/plain part.
174 [ part 2 - text/plain - 93B ]
175 _______________________________________________
176 This is the final text/plain signature part.
177 EOF
178
179 run_prog mhshow -prefer text/plain -form mhl.null $msgnum > $actual 2>&1
180 check "$expected" "$actual" : prefer text/plain
181
182 exit $failed