Added test-anno, test-dist, test-msgchk, and test-rcvtty.
[mmh] / test / inc / test-msgchk
1 #!/bin/sh
2 ######################################################
3 #
4 # Test msgchk
5 # Only tests checking of local maildrop, does not
6 # test checking of POP server.
7 #
8 ######################################################
9
10 set -e
11
12 if test -z "${MH_OBJ_DIR}"; then
13     srcdir=`dirname $0`/../..
14     MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 fi
16
17 . "$MH_OBJ_DIR/test/common.sh"
18
19 setup_test
20
21 expected=$MH_TEST_DIR/$$.expected
22 expected_err=$MH_TEST_DIR/$$.expected_err
23 actual=$MH_TEST_DIR/$$.actual
24 actual_err=$MH_TEST_DIR/$$.actual_err
25
26
27 # check -help
28 # Only look at first 9 lines because the rest depend on
29 # whether sasl support was configured in.
30 cat >"$expected" <<EOF
31 Usage: msgchk [switches] [users ...]
32   switches are:
33   -[no]date
34   -[no]notify type
35   -host hostname
36   -user username
37   -port name/number
38   -version
39   -help
40 EOF
41
42 msgchk -help | head -9 >"$actual" 2>&1
43 check "$expected" "$actual"
44
45 # check -version
46 case `msgchk -v` in
47   msgchk\ --*) ;;
48   *          ) printf "$0: msgchk -v generated unexpected output\n" >&2
49                failed=`expr ${failed:-0} + 1`;;
50 esac
51
52 # check unknown switch
53 run_test "msgchk -nonexistent" 'msgchk: -nonexistent unknown'
54
55 # check with no arguments and no mail waiting
56 run_test 'msgchk' "You don't have any mail waiting"
57
58 # Use maildrop specified in mts.conf, i.e.,
59 # ${MH_TEST_DIR}/Mail/maildrop, which should not yet exist.
60 "${MH_LIB_DIR}"/rcvpack <"${MH_TEST_DIR}"/Mail/inbox/1 \
61   "${MH_TEST_DIR}"/Mail/maildrop
62
63 # check with no arguments and mail waiting
64 cat >"$expected" <<EOF
65 You have new mail waiting; last read on
66 EOF
67
68 msgchk | sed -e 's/last read on.*/last read on/' >"$actual"
69 check "$expected" "$actual"
70
71 # check -date
72 cat >"$expected" <<EOF
73 You have new mail waiting; last read on
74 EOF
75
76 msgchk -nodate -date | sed -e 's/last read on.*/last read on/' >"$actual"
77 check "$expected" "$actual"
78
79 # check -nodate
80 run_test 'msgchk -nodate' 'You have new mail waiting'
81
82 # check -notify mail, when there is mail
83 run_test 'msgchk -notify mail -nodate' 'You have new mail waiting'
84
85 # check -notify nomail, when there is mail
86 run_test 'msgchk -notify nomail -nodate' 'You have new mail waiting'
87
88 # check -notify all, when there is mail
89 run_test 'msgchk -notify nomail -notify all -nodate' 'You have new mail waiting'
90
91 # check -nonotify mail, when there is mail
92 run_test 'msgchk -nonotify mail -nodate' ''
93
94 # check -nonotify nomail, when there is mail
95 run_test 'msgchk -nonotify nomail -nodate' 'You have new mail waiting'
96
97 # check -nonotify all, when there is mail
98 run_test 'msgchk -nonotify nomail -nonotify all -nodate' ''
99
100 inc -silent
101
102 # check -notify mail, when there is no mail
103 run_test 'msgchk -notify mail -nodate' "You don't have any mail waiting"
104
105 # check -notify nomail, when there is no mail
106 run_test 'msgchk -notify nomail -nodate' "You don't have any mail waiting"
107
108 # check -notify all, when there is no mail
109 run_test 'msgchk -notify nomail -nonotify all -nodate' ''
110
111 # check -nonotify mail, when there is no mail
112 run_test 'msgchk -nonotify mail -nodate' "You don't have any mail waiting"
113
114 # check -nonotify nomail, when there is no mail
115 run_test 'msgchk -nonotify nomail -nodate' ''
116
117 # check -nonotify all, when there is no mail
118 run_test 'msgchk -nonotify nomail -nonotify all -nodate' ''
119
120
121 exit ${failed:-0}