Added -mts switch to post, send, and whom. Replaced test-sendmail-pipe
[mmh] / test / post / test-post-common.sh
1 #!/bin/sh
2 #
3 # Common routines for the post tests
4 #
5
6 set -e
7
8 . "${MH_OBJ_DIR}/test/common.sh"
9
10 setup_test
11
12 localport=65412
13 testname="${MH_TEST_DIR}/$$"
14
15 #
16 # Set this for the EHLO command
17 #
18
19 echo "clientname: nosuchhost.example.com" >> ${MHMTSCONF}
20
21 #
22 # One "post" test run.  Ok, yeah, we're using "send", but that's just
23 # because it's easier.
24 # $1: output filename for fakesmtp, i.e., the sent message
25 # $2: expected output
26 # $3: optional switches for send
27
28 test_post ()
29 { "${MH_OBJ_DIR}/test/fakesmtp" "$1" $localport &
30     pid="$!"
31
32     # The server doesn't always come up fast enough, so sleep and
33     # retry a few times if it fails...
34     status=1
35     for i in 0 1 2 3 4 5 6 7 8 9; do
36         if send -draft -server 127.0.0.1 -port $localport $3 >/dev/null 2>&1
37         then
38             status=0
39             break
40         fi
41         sleep 1
42     done
43     [ $status -eq 0 ] || exit 1
44
45     wait ${pid}
46
47     #
48     # It's hard to calculate the exact Date: header post is going to
49     # use, so we'll just use sed to remove the actual date so we can easily
50     # compare it against our "correct" output.
51     #
52
53     sed -e 's/^Date:.*/Date:/' "$1" > "$1".nodate
54     rm -f "$1"
55
56     check "$1".nodate "$2"
57 }