]>
diplodocus.org Git - nmh/blob - test/post/test-messageid
8 if test -z "${MH_OBJ_DIR}"; then
9 srcdir
=`dirname "$0"`/..
/..
10 MH_OBJ_DIR
=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
13 .
"${MH_OBJ_DIR}/test/common.sh"
16 testname
="${MH_TEST_DIR}/$$"
19 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
20 From: Mr Nobody <nobody@example.com>
21 To: Somebody Else <somebody@example.com>
27 cat > "${testname}.expected" <<EOF
28 EHLO nosuchhost.example.com
29 MAIL FROM:<nobody@example.com>
30 RCPT TO:<somebody@example.com>
32 From: Mr Nobody <nobody@example.com>
33 To: Somebody Else <somebody@example.com>
36 Content-Type: text/plain; charset="us-ascii"
44 # check invalid -messageid selection
45 run_test
"send -draft -messageid invalid" \
46 "post: unsupported messageid \"invalid\"
47 send: message not delivered to anyone"
49 #### Rely on sendmail/pipe below to override default mts.
50 mts_fakesendmail
="${MHMTSCONF}-fakesendmail"
51 cp "${MHMTSCONF}" "$mts_fakesendmail"
52 printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail"
53 MHMTSCONF
="$mts_fakesendmail"
55 # $1: -messageid switch selection
56 # arguments: expected output(s)
60 run_prog send
-draft -mts sendmail
/pipe
-msgid -messageid "$msgid_style"
63 # fakesendmail drops the message and any cc's into this mbox.
64 mbox
="${MH_TEST_DIR}"/Mail
/fakesendmail.mbox
65 inc
-silent -file "$mbox"
66 rm -f "$mbox" "$mbox.map"
69 for expected
in "$@"; do
71 # Verify that Message-ID is of the right form. We'll see how
72 # portable these grep regular expressions are.
75 # e.g., Message-ID: <5348.1342884222@localhost.localdomain>
76 id
='^Message-ID: <[0-9]\{1,\}\.[0-9]\{1,\}@'
79 # e.g., Message-ID: <5364-1342884222.165897@ldYM.FXwU.bBqK>
80 id
='^Message-ID: <[0-9]\{1,\}-[0-9]\{1,\}\.[0-9]\{6,6\}@[-_0-9A-Za-z]\{4,4\}\.[-_0-9A-Za-z]\{4,4\}\.[-_0-9A-Za-z]\{4,4\}'
82 *) printf '%s: unexpected messageid: %s\n' "$0" "$msgid_style"; exit 1 ;;
85 if grep "$id" "$cur" >/dev
/null
; then
88 mv "$cur" "${testname}.actual"
89 printf '%s: unexpected %s Message-ID format, see %s\n' "$0" \
90 "$msgid_style" "${testname}.actual"
95 # It's hard to calculate the exact Date: header post is going to
96 # use, so we'll just use sed to remove the actual date so we can easily
97 # compare it against our "correct" output. And same for
100 sed -e 's/^Date:.*/Date:/' \
101 -e 's/^Message-ID:.*/Message-ID:/' \
102 "$cur" > "${testname}.actual$n"
104 check
"${testname}.actual$n" "$expected"
106 if [ "$cur" != "`mhpath last`" ]; then
107 folder next
>/dev
/null
108 arith_eval
$n + 1; n
=$arith_val
113 # check -messageid localname (the default)
114 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
115 From: Mr Nobody <nobody@example.com>
116 To: Somebody Else <somebody@example.com>
123 cat > "${testname}.expected" <<EOF
124 From: Mr Nobody <nobody@example.com>
125 To: Somebody Else <somebody@example.com>
128 Content-Type: text/plain; charset="us-ascii"
136 test_messageid localname
"${testname}.expected"
138 # check -messageid random
139 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
140 From: Mr Nobody <nobody@example.com>
141 To: Somebody Else <somebody@example.com>
148 cat > "${testname}.expected" <<EOF
149 From: Mr Nobody <nobody@example.com>
150 To: Somebody Else <somebody@example.com>
153 Content-Type: text/plain; charset="us-ascii"
161 test_messageid random
"${testname}.expected"