##
## Important note: the "cleanup" test should always be last
##
-TESTS = test/ali/test-ali \
+TESTS = test/ali/test-ali test/anno/test-anno \
test/bad-input/test-header \
test/burst/test-burst \
- test/comp/test-comp-format \
+ test/comp/test-comp-format test/dist/test-dist \
test/folder/test-create test/folder/test-packf \
test/folder/test-recurse test/folder/test-sortm \
test/folder/test-total \
test/format/test-myhost test/format/test-mymbox \
test/forw/test-forw-digest test/forw/test-forw-format \
test/inc/test-deb359167 test/inc/test-eom-align \
- test/inc/test-inc-scanout test/install-mh/test-install-mh \
- test/manpages/test-manpages \
+ test/inc/test-inc-scanout test/inc/test-msgchk \
+ test/install-mh/test-install-mh test/manpages/test-manpages \
test/mhbuild/test-forw test/mhbuild/test-utf8-body \
test/mhlist/test-mhlist test/mhmail/test-mhmail \
test/mhparam/test-mhparam test/mhpath/test-mhpath \
test/post/test-post-group test/post/test-mts test/post/test-messageid \
test/prompter/test-prompter \
test/rcv/test-rcvdist test/rcv/test-rcvpack test/rcv/test-rcvstore \
- test/refile/test-refile \
+ test/rcv/test-rcvtty test/refile/test-refile \
test/repl/test-if-str test/repl/test-trailing-newline \
test/repl/test-multicomp test/repl/test-repl \
test/scan/test-scan test/scan/test-scan-multibyte \
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test anno
+#
+######################################################
+
+set -e
+
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
+fi
+
+. "$MH_OBJ_DIR/test/common.sh"
+
+setup_test
+
+expected=$MH_TEST_DIR/$$.expected
+expected_err=$MH_TEST_DIR/$$.expected_err
+actual=$MH_TEST_DIR/$$.actual
+actual_err=$MH_TEST_DIR/$$.actual_err
+
+# check -help
+cat >"$expected" <<EOF
+Usage: anno [+folder] [msgs] [switches]
+ switches are:
+ -component field
+ -[no]inplace
+ -[no]date
+ -text body
+ -version
+ -help
+ -(dr)aft
+ -(l)ist
+ -(de)lete
+ -(nu)mber
+ -(a)ppend
+ -([no]p)reserve
+EOF
+
+anno -help >"$actual" 2>&1
+check "$expected" "$actual"
+
+# check -version
+case `anno -v` in
+ anno\ --*) ;;
+ * ) printf "$0: anno -v generated unexpected output\n" >&2
+ failed=`expr ${failed:-0} + 1`;;
+esac
+
+# check unknown switch
+run_test "anno -nonexistent" 'anno: -nonexistent unknown'
+
+cat "${MH_TEST_DIR}/Mail/inbox/1" >"${MH_TEST_DIR}/Mail/inbox/11"
+
+# check with no switches
+printf 'Nmh-test:\n' >"$expected"
+cat "${MH_TEST_DIR}/Mail/inbox/1" >>"$expected"
+folder -fast 1 >/dev/null
+
+printf 'Nmh-test' | anno >/dev/null
+sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
+check "$expected" "$actual" 'keep first'
+cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
+
+# check -component
+anno -component Nmh-test
+sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
+check "$expected" "$actual" 'keep first'
+cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
+
+# check +folder
+anno -component Nmh-test +inbox
+sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
+check "$expected" "$actual" 'keep first'
+cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
+
+# check msg
+folder -fast 2 >/dev/null
+anno 1 -component Nmh-test
+sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
+check "$expected" "$actual" 'keep first'
+cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
+
+check_for_hard_links
+if [ $hard_links_supported -eq 1 ]; then
+ # check -noinplace
+ # Hard link the message and verify that the new one doesn't get annotated.
+ cp "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.copy"
+ ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
+ anno 8 -component Nmh-test -noinplace
+ mv -f "${MH_TEST_DIR}/Mail/inbox/8.copy" "${MH_TEST_DIR}/Mail/inbox/8"
+ check "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link" \
+ 'keep first'
+
+ # check -inplace
+ # Hard link the message and verify that the new one does get annotated.
+ ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
+ anno 8 -component Nmh-test -noinplace -inplace
+ check "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
+fi
+
+# check -nodate. Without -text, it doesn't change the message.
+cp -f "${MH_TEST_DIR}/Mail/inbox/11" "$expected-nodate"
+anno 1 -component Nmh-test -nodate
+cp -f "${MH_TEST_DIR}/Mail/inbox/1" "$actual"
+check "$expected-nodate" "$actual"
+cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
+
+# check -date
+anno 1 -component Nmh-test -nodate -date
+sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
+check "$expected" "$actual" 'keep first'
+cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
+
+# check -draft.
+cp -f "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/draft"
+anno -draft -component Nmh-test
+sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/draft" >"$actual"
+check "$expected" "$actual"
+rm "${MH_TEST_DIR}/Mail/draft"
+
+# check -append
+sed -s '4a\Nmh-test:' "${MH_TEST_DIR}/Mail/inbox/1" >"$expected"
+anno 1 -component Nmh-test -append
+sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
+check "$expected" "$actual"
+cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
+
+# check -list
+printf 'Nmh-test: test of anno -list\n' >"$expected"
+cat "${MH_TEST_DIR}/Mail/inbox/1" >>"$expected"
+anno 1 -component Nmh-test -nodate -text 'test of anno -list'
+run_test 'anno 1 -component Nmh-test -list' 'test of anno -list'
+# check -text
+check "$expected" "${MH_TEST_DIR}/Mail/inbox/1" "$actual"
+cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
+
+# check -list -number
+printf 'Nmh-test: test of anno -list -number\n' >"$expected"
+cat "${MH_TEST_DIR}/Mail/inbox/1" >>"$expected"
+anno 1 -component Nmh-test -nodate -text 'test of anno -list -number'
+run_test 'anno 1 -component Nmh-test -list -number' \
+ '1 test of anno -list -number'
+check "$expected" "${MH_TEST_DIR}/Mail/inbox/1" "$actual"
+cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
+
+# check -delete
+cp "${MH_TEST_DIR}/Mail/inbox/1" "$expected"
+anno 1 -component Nmh-test
+anno 1 -component Nmh-test -delete
+sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
+check "$expected" "$actual"
+cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
+
+# check -delete -number
+printf 'Nmh-test: 1\nNmh-test: 3\n' >"$expected"
+cat "${MH_TEST_DIR}/Mail/inbox/1" >>"$expected"
+anno 1 -component Nmh-test -nodate -text 3
+anno 1 -component Nmh-test -nodate -text 2
+anno 1 -component Nmh-test -nodate -text 1
+anno 1 -component Nmh-test -delete -number 2
+cp -f "${MH_TEST_DIR}/Mail/inbox/1" "$actual"
+check "$expected" "$actual"
+cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
+
+# check -delete -all
+cp "${MH_TEST_DIR}/Mail/inbox/1" "$expected"
+anno 1 -component Nmh-test -nodate -text 3
+anno 1 -component Nmh-test -nodate -text 2
+anno 1 -component Nmh-test -nodate -text 1
+anno 1 -component Nmh-test -delete -number all
+cp -f "${MH_TEST_DIR}/Mail/inbox/1" "$actual"
+check "$expected" "$actual"
+cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
+
+# check -preserve
+touch -t '201210010000.00' "${MH_TEST_DIR}/Mail/inbox/1"
+ls -l "${MH_TEST_DIR}/Mail/inbox/1" >"$actual-ls1"
+anno 1 -component Nmh-test -preserve
+anno 1 -component Nmh-test -preserve -delete
+ls -l "${MH_TEST_DIR}/Mail/inbox/1" >"$actual-ls2"
+check "$actual-ls1" "$actual-ls2"
+cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
+
+# check -nopreserve
+touch -t '2012100100.00' "${MH_TEST_DIR}/Mail/inbox/1"
+ls -l "${MH_TEST_DIR}/Mail/inbox/1" >"$actual-ls1"
+anno 1 -component Nmh-test -preserve -nopreserve
+anno 1 -component Nmh-test -preserve -nopreserve -delete
+ls -l "${MH_TEST_DIR}/Mail/inbox/1" >"$actual-ls2"
+set +e
+diff "$actual-ls1" "$actual-ls2" >/dev/null
+run_test 'printf 1' "$?"
+set -e
+rm "$actual-ls1" "$actual-ls2"
+
+
+exit ${failed:-0}
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test dist
+#
+######################################################
+
+set -e
+
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
+fi
+
+. "$MH_OBJ_DIR/test/common.sh"
+
+setup_test
+
+expected=$MH_TEST_DIR/$$.expected
+expected_err=$MH_TEST_DIR/$$.expected_err
+actual=$MH_TEST_DIR/$$.actual
+actual_err=$MH_TEST_DIR/$$.actual_err
+localmbox=`${MH_LIB_DIR}/ap -format "%(localmbox)" 0`
+
+#### Use sendmail/pipe below to override default mts.
+mts_fakesendmail="${MHMTSCONF}-fakesendmail"
+sed -e 's/^mts:.*/mts: sendmail\/pipe/' "${MHMTSCONF}" > "$mts_fakesendmail"
+printf "sendmail: ${srcdir}/test/fakesendmail\n" >>"$mts_fakesendmail"
+MHMTSCONF="$mts_fakesendmail"
+
+# arguments: dist switches
+test_dist ()
+{
+ printf "send" | dist "$@" >/dev/null
+
+ # fakesendmail drops the message and any cc's into this mbox.
+ mbox="${MH_TEST_DIR}"/Mail/fakesendmail.mbox
+ inc -silent -file "$mbox"
+ rm -f "$mbox" "$mbox.map"
+
+ # It's hard to calculate the exact Date: header post is going to
+ # use, so we'll just use sed to remove the actual date so we can
+ # easily compare it against our "correct" output.
+ sed -e 's/^Resent-Date:.*/Resent-Date:/' `mhpath last` > "$actual"
+
+ check "$expected" "$actual"
+}
+
+
+# check -help
+cat >"$expected" <<EOF
+Usage: dist [+folder] [msg] [switches]
+ switches are:
+ -[no]annotate
+ -draftfolder +folder
+ -draftmessage msg
+ -nodraftfolder
+ -editor editor
+ -noedit
+ -form formfile
+ -[no]inplace
+ -whatnowproc program
+ -nowhatnowproc
+ -version
+ -help
+ -from address
+ -to address
+ -cc address
+ -fcc mailbox
+ -width columns
+ -[no]atfile
+EOF
+
+dist -help >"$actual" 2>&1
+check "$expected" "$actual"
+
+# check -version
+case `dist -v` in
+ dist\ --*) ;;
+ * ) printf "$0: dist -v generated unexpected output\n" >&2
+ failed=`expr ${failed:-0} + 1`;;
+esac
+
+# check unknown switch
+run_test "dist -nonexistent" 'dist: -nonexistent unknown'
+
+folder +outbox -create -fast >/dev/null
+folder +inbox -fast 1 >/dev/null
+
+# For most tests, use -nowhatnow and just check that the draft
+# looks correct.
+
+# check basic dist operation, including -noedit and -to
+cat >"$expected" <<EOF
+From: Test1 <test1@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Subject: Testing message 1
+Resent-From: ${localmbox}
+Resent-To: somebody@example.com
+Resent-Date:
+
+This is message number 1
+EOF
+
+test_dist -noedit -to somebody@example.com
+
+# check +folder and msg
+folder +outbox -fast >/dev/null
+
+cat >"$expected" <<EOF
+From: Test1 <test1@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Subject: Testing message 1
+Resent-From: ${localmbox}
+Resent-To: somebody@example.com
+Resent-Date:
+
+This is message number 1
+EOF
+
+test_dist +inbox 1 -noedit -to somebody@example.com
+
+# check -form
+cat >"${MH_TEST_DIR}/Mail/distform" <<'EOF'
+Resent-From: me@example.com
+Resent-To: you@example.com
+EOF
+
+cat >"$expected" <<EOF
+From: Test1 <test1@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Subject: Testing message 1
+Resent-From: me@example.com
+Resent-To: you@example.com
+Resent-Date:
+
+This is message number 1
+EOF
+
+test_dist 1 -noedit -form "${MH_TEST_DIR}"/Mail/distform
+
+rm "${MH_TEST_DIR}"/Mail/distform
+
+# check -annotate
+cat >"$expected" <<EOF
+From: Test2 <test2@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Subject: Testing message 2
+Resent-From: ${localmbox}
+Resent-To: somebody@example.com
+Resent-Date:
+
+This is message number 2
+EOF
+
+test_dist 2 -noedit -to somebody@example.com -annotate
+
+cat >"$expected" <<EOF
+Resent:
+Resent: somebody@example.com
+From: Test2 <test2@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Subject: Testing message 2
+
+This is message number 2
+EOF
+
+# The annotation is done by a separate process, so we need to wait for
+# it to complete.
+i=1
+until grep '^Resent:' "${MH_TEST_DIR}"/Mail/inbox/2 >/dev/null; do
+ sleep 2
+ arith_eval $i + 1
+ i=$arith_val
+ if [ $i -gt 60 ]; then
+ printf "$0: -annotate failed, will not wait any longer\n"
+ break
+ fi
+done
+
+# Strip date from line of this form:
+# Resent: Sat, 06 Oct 2012 08:24:08 -0500
+sed -e 's/^Resent:.*:.*/Resent:/' "${MH_TEST_DIR}"/Mail/inbox/2 >"$actual"
+
+check "$expected" "$actual"
+
+# check -noannotate
+cat >"$expected" <<EOF
+From: Test1 <test1@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Subject: Testing message 1
+Resent-From: ${localmbox}
+Resent-To: somebody@example.com
+Resent-Date:
+
+This is message number 1
+EOF
+
+test_dist 1 -noedit -to somebody@example.com -annotate -noannotate
+
+cat >"$expected" <<EOF
+From: Test1 <test1@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Subject: Testing message 1
+
+This is message number 1
+EOF
+
+check "${MH_TEST_DIR}"/Mail/inbox/1 "$expected" 'keep first'
+
+check_for_hard_links
+if [ $hard_links_supported -eq 1 ]; then
+ # check -noinplace
+ # Hard link the message and verify that the new one doesn't get annotated.
+ cp "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.copy"
+ ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
+ cat >"$expected" <<EOF
+From: Test8 <test8@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Subject: Testing message 8
+Resent-From: ${localmbox}
+Resent-To: somebody@example.com
+Resent-Date:
+
+This is message number 8
+EOF
+ test_dist 8 -noedit -to somebody@example.com -annotate -noinplace
+ mv -f "${MH_TEST_DIR}/Mail/inbox/8.copy" "${MH_TEST_DIR}/Mail/inbox/8"
+ check "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link" \
+ 'keep first'
+
+ # check -inplace
+ # Hard link the message and verify that the new one does get annotated.
+ ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
+ cat >"$expected" <<EOF
+From: Test8 <test8@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Subject: Testing message 8
+Resent-From: ${localmbox}
+Resent-To: somebody@example.com
+Resent-Date:
+
+This is message number 8
+EOF
+ test_dist 8 -noedit -to somebody@example.com -annotate -noinplace -inplace
+ check "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
+fi
+
+# check -draftfolder
+cat >"$expected" <<EOF
+From: Test3 <test3@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Subject: Testing message 3
+Resent-From: ${localmbox}
+Resent-To: somebody@example.com
+Resent-Date:
+
+This is message number 3
+EOF
+
+test_dist 3 -noedit -to somebody@example.com -draftfolder drafts
+
+# check -draftmsg
+cat >"$expected" <<EOF
+From: Test3 <test3@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Subject: Testing message 3
+Resent-From: ${localmbox}
+Resent-To: somebody@example.com
+Resent-Date:
+
+This is message number 3
+EOF
+
+touch $MH_TEST_DIR/Mail/drafts/3
+test_dist 3 -noedit -to somebody@example.com -draftfolder drafts -draftmessage 2
+
+# check -nodraftfolder
+cat >"$expected" <<EOF
+From: Test3 <test3@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Subject: Testing message 3
+Resent-From: ${localmbox}
+Resent-To: somebody@example.com
+Resent-Date:
+
+This is message number 3
+EOF
+
+test_dist 3 -noedit -to somebody@example.com -draftfolder nonexistent \
+ -nodraftfolder
+if test -d "${MH_TEST_DIR}/Mail/nonexistent"; then
+ echo "$0: -nodraftfolder test failed."
+ failed=`expr ${failed:-0} + 1`
+fi
+
+# check -from
+cat >"$expected" <<EOF
+From: Test1 <test1@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Subject: Testing message 1
+Resent-From: me@example.com
+Resent-To: somebody@example.com
+Resent-Date:
+
+This is message number 1
+EOF
+
+test_dist 1 -noedit -to somebody@example.com -from me@example.com
+
+# check -cc
+cat >"$expected" <<EOF
+From: Test1 <test1@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Subject: Testing message 1
+Resent-From: ${localmbox}
+Resent-To: somebody@example.com
+Resent-cc: cc@example.com
+Resent-Date:
+
+This is message number 1
+EOF
+
+test_dist 1 -noedit -to somebody@example.com -cc cc@example.com
+
+# check -fcc
+cat >"$expected" <<EOF
+From: Test1 <test1@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Subject: Testing message 1
+Resent-From: ${localmbox}
+Resent-To: somebody@example.com
+Resent-Date:
+
+This is message number 1
+EOF
+
+test_dist 1 -noedit -to somebody@example.com -fcc outbox
+run_test 'scan +outbox -width 6' ' 1 '
+
+cat >"$expected" <<EOF
+From: Test1 <test1@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Subject: Testing message 1
+Resent-From: ${localmbox}
+Resent-To: somebody@example.com
+Resent-Date:
+
+This is message number 1
+EOF
+
+test_dist +inbox 1 -noedit -to somebody@example.com -fcc +outbox
+run_test 'scan +outbox -width 6 2' ' 2 '
+
+
+exit ${failed:-0}
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test msgchk
+# Only tests checking of local maildrop, does not
+# test checking of POP server.
+#
+######################################################
+
+set -e
+
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
+fi
+
+. "$MH_OBJ_DIR/test/common.sh"
+
+setup_test
+
+expected=$MH_TEST_DIR/$$.expected
+expected_err=$MH_TEST_DIR/$$.expected_err
+actual=$MH_TEST_DIR/$$.actual
+actual_err=$MH_TEST_DIR/$$.actual_err
+
+
+# check -help
+# Only look at first 9 lines because the rest depend on
+# whether sasl support was configured in.
+cat >"$expected" <<EOF
+Usage: msgchk [switches] [users ...]
+ switches are:
+ -[no]date
+ -[no]notify type
+ -host hostname
+ -user username
+ -port name/number
+ -version
+ -help
+EOF
+
+msgchk -help | head -9 >"$actual" 2>&1
+check "$expected" "$actual"
+
+# check -version
+case `msgchk -v` in
+ msgchk\ --*) ;;
+ * ) printf "$0: msgchk -v generated unexpected output\n" >&2
+ failed=`expr ${failed:-0} + 1`;;
+esac
+
+# check unknown switch
+run_test "msgchk -nonexistent" 'msgchk: -nonexistent unknown'
+
+# check with no arguments and no mail waiting
+run_test 'msgchk' "You don't have any mail waiting"
+
+# Use maildrop specified in mts.conf, i.e.,
+# ${MH_TEST_DIR}/Mail/maildrop, which should not yet exist.
+"${MH_LIB_DIR}"/rcvpack <"${MH_TEST_DIR}"/Mail/inbox/1 \
+ "${MH_TEST_DIR}"/Mail/maildrop
+
+# check with no arguments and mail waiting
+cat >"$expected" <<EOF
+You have new mail waiting; last read on
+EOF
+
+msgchk | sed -e 's/last read on.*/last read on/' >"$actual"
+check "$expected" "$actual"
+
+# check -date
+cat >"$expected" <<EOF
+You have new mail waiting; last read on
+EOF
+
+msgchk -nodate -date | sed -e 's/last read on.*/last read on/' >"$actual"
+check "$expected" "$actual"
+
+# check -nodate
+run_test 'msgchk -nodate' 'You have new mail waiting'
+
+# check -notify mail, when there is mail
+run_test 'msgchk -notify mail -nodate' 'You have new mail waiting'
+
+# check -notify nomail, when there is mail
+run_test 'msgchk -notify nomail -nodate' 'You have new mail waiting'
+
+# check -notify all, when there is mail
+run_test 'msgchk -notify nomail -notify all -nodate' 'You have new mail waiting'
+
+# check -nonotify mail, when there is mail
+run_test 'msgchk -nonotify mail -nodate' ''
+
+# check -nonotify nomail, when there is mail
+run_test 'msgchk -nonotify nomail -nodate' 'You have new mail waiting'
+
+# check -nonotify all, when there is mail
+run_test 'msgchk -nonotify nomail -nonotify all -nodate' ''
+
+inc -silent
+
+# check -notify mail, when there is no mail
+run_test 'msgchk -notify mail -nodate' "You don't have any mail waiting"
+
+# check -notify nomail, when there is no mail
+run_test 'msgchk -notify nomail -nodate' "You don't have any mail waiting"
+
+# check -notify all, when there is no mail
+run_test 'msgchk -notify nomail -nonotify all -nodate' ''
+
+# check -nonotify mail, when there is no mail
+run_test 'msgchk -nonotify mail -nodate' "You don't have any mail waiting"
+
+# check -nonotify nomail, when there is no mail
+run_test 'msgchk -nonotify nomail -nodate' ''
+
+# check -nonotify all, when there is no mail
+run_test 'msgchk -nonotify nomail -nonotify all -nodate' ''
+
+
+exit ${failed:-0}
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test rcvtty
+#
+######################################################
+
+set -e
+
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
+fi
+
+. "$MH_OBJ_DIR/test/common.sh"
+
+setup_test
+
+# Use proper program, likely not the first one on PATH.
+rcvtty="${MH_LIB_DIR}/rcvtty"
+
+expected="$MH_TEST_DIR/$$.expected"
+actual="$MH_TEST_DIR/$$.actual"
+
+
+# check -help
+cat >"$expected" <<EOF
+Usage: rcvtty [command ...]
+ switches are:
+ -biff
+ -form formatfile
+ -(forma)t string
+ -width columns
+ -[no]newline
+ -[no]bell
+ -version
+ -help
+EOF
+
+$rcvtty -help >"$actual" 2>&1
+check "$expected" "$actual"
+
+# check -version
+case `$rcvtty -v` in
+ rcvtty\ --*) ;;
+ * ) printf "$0: rcvtty -v generated unexpected output\n" >&2
+ failed=`expr ${failed:-0} + 1`;;
+esac
+
+# check normal operation. Use -biff to avoid sending notification to
+# each of the user's terminals. So this command shouldn't do
+# anything. It will write the notification(s) if the user actually
+# has actually enabled biff notification, or has set the exec bit of
+# any of their ttys.
+cat >"$expected" <<EOF
+EOF
+$rcvtty <${MH_TEST_DIR}/Mail/inbox/1 -biff >"$actual" 2>&1
+check "$expected" "$actual"
+
+
+exit ${failed:-0}