]>
diplodocus.org Git - nmh/blob - test/post/test-sendfiles
2 ######################################################
6 ######################################################
10 if test -z "$MH_OBJ_DIR"; then
11 srcdir
=`dirname $0`/..
/..
12 MH_OBJ_DIR
=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 .
"$MH_OBJ_DIR/test/common.sh"
19 expected
=$MH_TEST_DIR/$$.expected
20 actual
=$MH_TEST_DIR/$$.actual
21 localmbox
=`$MH_LIBEXEC_DIR/ap -format "%(localmbox)" 0`
22 #### Use this script itself for the test file.
23 testfiledir
="$srcdir/test/post"
24 testfile
=`basename $0`
26 (cd "$MH_TEST_DIR" && mkdir -p tmp
)
28 #### Copy fakesendmail and the testfile because we cd to the
29 #### test directory, because tar doesn't like absolute paths.
30 cp "$srcdir/test/fakesendmail" "$testfiledir/$testfile" "$MH_TEST_DIR"
32 #### Use sendmail/pipe below to override default mts.
33 mts_fakesendmail
="$MHMTSCONF-fakesendmail"
34 sed -e 's/^mts:.*/mts: sendmail\/pipe/' "$MHMTSCONF" > "$mts_fakesendmail"
35 printf 'sendmail: %s/fakesendmail\n' "$MH_TEST_DIR" >>"$mts_fakesendmail"
36 MHMTSCONF
="$mts_fakesendmail"
38 # $1: uncompress command
40 # new: -to recipient -subject subject
41 # old: recipient subject
42 # remaining arguments: sendfiles switches
45 uncompress="$1"; shift
48 if [ "$argstyle" = 'new' ]; then
50 run_prog sendfiles
"$@" -to recipient@example.com \
51 -subject "sendfiles test" "$testfile" >/dev
/null
2>&1)
52 elif [ "$argstyle" = 'old' ]; then
54 run_prog sendfiles
"$@" recipient@example.com
"sendfiles test" \
55 "$testfile" >/dev
/null
2>&1)
58 # fakesendmail drops the message and any cc's into this mbox.
59 mbox
="$MH_TEST_DIR"/Mail
/fakesendmail.mbox
60 inc
-silent -file "$mbox"
63 mhlist
-verbose last
| sed -e 's/ *$//' -e 's/\(octet-stream\).*$/\1/' \
65 (cd $MH_TEST_DIR/tmp
&&
66 contents
=`mhstore -noauto last 2>&1 | \
67 sed -e 's/storing message.*as file //'` &&
68 $uncompress <"$contents" | tar xpf
- && rm -f "$contents")
71 check
"$testfiledir/$testfile" "$MH_TEST_DIR/tmp/$testfile" \
74 [ -f "$expected" ] && check
"$expected" "$actual" || rm -f "$actual"
79 cat >"$expected" <<EOF
80 Usage: sendfiles [switches] -to recipient -subject subject file1 [file2 ...]
82 sendfiles [switches] recipient subject file1 [file2 ...]
84 -compress [bzip2 | compress | gzip | lzma | none]
86 -[delay] <delay> (expressed in seconds)
89 Can use PERSON environment variable instead of -from switch.
92 #### Skip nmh intro text.
93 run_prog sendfiles
-help | sed '/^$/,$d' >"$actual" 2>&1
94 check
"$expected" "$actual"
97 case `sendfiles -v` in
99 * ) printf '%s: sendfiles -v generated unexpected output\n' "$0" >&2
100 failed
=`expr ${failed:-0} + 1`;;
103 # check unknown switch
104 run_test
'sendfiles -nonexistent' "Usage: sendfiles [switches] -to recipient \
105 -subject subject file1 [file2 ...]
107 sendfiles [switches] recipient subject file1 [file2 ...]
109 -compress [bzip2 | compress | gzip | lzma | none]
111 -[delay] <delay> (expressed in seconds)
114 Can use PERSON environment variable instead of -from switch."
116 # check unknown compression method
117 run_test
'sendfiles -compress unknown to subject file' \
118 'sendfiles: unknown compression method "unknown"'"
119 Usage: sendfiles [switches] -to recipient \
120 -subject subject file1 [file2 ...]
122 sendfiles [switches] recipient subject file1 [file2 ...]
124 -compress [bzip2 | compress | gzip | lzma | none]
126 -[delay] <delay> (expressed in seconds)
129 Can use PERSON environment variable instead of -from switch."
131 # Check basic operation, using specified compression method.
132 # Don't check the mhlist output, by not creating an $expected file,
133 # because it will vary with compression method and compressed file
135 [ "`findprog bzip2`" ] && test_sendfiles
'bzip2 -cd' new
-compress bzip2
136 [ "`findprog compress`" ] && test_sendfiles
'uncompress -c' new \
138 [ "`findprog gzip`" ] && test_sendfiles
'gzip -cd' new
-compress gzip
139 [ "`findprog gzip`" ] && test_sendfiles
'gzip -cd' new
-gzip
140 [ "`findprog lzma`" ] && test_sendfiles
'lzma -cd' new
-compress lzma
142 # check with no compression
143 cat >"$expected" <<EOF
144 msg part type/subtype size description
145 11 application/octet-stream
147 (extract with cat | tar xvpf -)
150 test_sendfiles
cat new
-compress none
152 # check with no compression, -none
153 cat >"$expected" <<EOF
154 msg part type/subtype size description
155 11 application/octet-stream
157 (extract with cat | tar xvpf -)
160 test_sendfiles
cat new
-none
162 # check old argument style (without -to and -subject)
163 cat >"$expected" <<EOF
164 msg part type/subtype size description
165 11 application/octet-stream
167 (extract with cat | tar xvpf -)
170 test_sendfiles
cat old
-compress none
173 cat >"$expected" <<EOF
174 msg part type/subtype size description
175 11 application/octet-stream
177 (extract with cat | tar xvpf -)
180 test_sendfiles
cat new
-compress none
-from 'Sender <sender@example.com>'
182 # check PERSON environment variable
183 cat >"$expected" <<EOF
184 msg part type/subtype size description
185 11 application/octet-stream
187 (extract with cat | tar xvpf -)
190 PERSON
='Sender <sender@example.com>' test_sendfiles
cat new
-compress none
192 # check -delay, though for a small file it doesn't do anything
193 cat >"$expected" <<EOF
194 msg part type/subtype size description
195 11 application/octet-stream
197 (extract with cat | tar xvpf -)
200 test_sendfiles
cat new
-compress none
-delay 5
202 # check old style -delay, though for a small file it doesn't do anything
203 cat >"$expected" <<EOF
204 msg part type/subtype size description
205 11 application/octet-stream
207 (extract with cat | tar xvpf -)
210 test_sendfiles
cat new
-compress none
-5
212 rm -fr "$MH_TEST_DIR/fakesendmail" "$MH_TEST_DIR/$testfile" "$MH_TEST_DIR/tmp"