]> diplodocus.org Git - nmh/blob - test/inc/test-msgchk
Update XOAUTH2 documentation.
[nmh] / 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 check_exit '-eq 1' msgchk -
22
23 expected=$MH_TEST_DIR/$$.expected
24 expected_err=$MH_TEST_DIR/$$.expected_err
25 actual=$MH_TEST_DIR/$$.actual
26 actual_err=$MH_TEST_DIR/$$.actual_err
27
28
29 # check -help
30 start_test "-help"
31 # Only look at first 9 lines because the rest depend on
32 # whether sasl support was configured in.
33 cat >"$expected" <<EOF
34 Usage: msgchk [switches] [users ...]
35 switches are:
36 -[no]date
37 -[no]notify type
38 -host hostname
39 -user username
40 -port name/number
41 -version
42 -help
43 EOF
44
45 run_prog msgchk -help 2>&1 | head -9 >"$actual"
46 check "$expected" "$actual"
47
48 # check -version
49 start_test "-version"
50 case `msgchk -v` in
51 msgchk\ --*) ;;
52 * ) printf '%s: msgchk -v generated unexpected output\n' "$0" >&2
53 failed=`expr ${failed:-0} + 1`;;
54 esac
55
56 # check unknown switch
57 start_test "unknown switch"
58 run_test "msgchk -nonexistent" 'msgchk: -nonexistent unknown'
59
60 # check with no arguments and no mail waiting
61 start_test "with no arguments and no mail waiting"
62 run_test 'msgchk' "You don't have any mail waiting"
63
64 # Use maildrop specified in mts.conf, i.e.,
65 # ${MH_TEST_DIR}/Mail/maildrop, which should not yet exist.
66 "${MH_LIBEXEC_DIR}"/rcvpack <"${MH_TEST_DIR}"/Mail/inbox/1 \
67 "${MH_TEST_DIR}"/Mail/maildrop
68
69 # check with no arguments and mail waiting
70 start_test "with no arguments and mail waiting"
71 cat >"$expected" <<EOF
72 You have new mail waiting; last read on
73 EOF
74
75 run_prog msgchk | sed -e 's/last read on.*/last read on/' >"$actual"
76 check "$expected" "$actual"
77
78 # check -date
79 start_test "-date"
80 cat >"$expected" <<EOF
81 You have new mail waiting; last read on
82 EOF
83
84 run_prog msgchk -nodate -date | sed -e 's/last read on.*/last read on/' \
85 >"$actual"
86 check "$expected" "$actual"
87
88 # check -nodate
89 start_test "-nodate"
90 run_test 'msgchk -nodate' 'You have new mail waiting'
91
92 # check -notify mail, when there is mail
93 start_test "-notify mail, when there is mail"
94 run_test 'msgchk -notify mail -nodate' 'You have new mail waiting'
95
96 # check -notify nomail, when there is mail
97 start_test "-notify nomail, when there is mail"
98 run_test 'msgchk -notify nomail -nodate' 'You have new mail waiting'
99
100 # check -notify all, when there is mail
101 start_test "-notify all, when there is mail"
102 run_test 'msgchk -notify nomail -notify all -nodate' 'You have new mail waiting'
103
104 # check -nonotify mail, when there is mail
105 start_test "-nonotify mail, when there is mail"
106 run_test 'msgchk -nonotify mail -nodate' ''
107
108 # check -nonotify nomail, when there is mail
109 start_test "-nonotify nomail, when there is mail"
110 run_test 'msgchk -nonotify nomail -nodate' 'You have new mail waiting'
111
112 # check -nonotify all, when there is mail
113 start_test "-nonotify all, when there is mail"
114 run_test 'msgchk -nonotify nomail -nonotify all -nodate' ''
115
116 run_prog inc -silent
117
118 # check -notify mail, when there is no mail
119 start_test "-notify mail, when there is no mail"
120 run_test 'msgchk -notify mail -nodate' "You don't have any mail waiting"
121
122 # check -notify nomail, when there is no mail
123 start_test "-notify nomail, when there is no mail"
124 run_test 'msgchk -notify nomail -nodate' "You don't have any mail waiting"
125
126 # check -notify all, when there is no mail
127 start_test "-notify all, when there is no mail"
128 run_test 'msgchk -notify nomail -nonotify all -nodate' ''
129
130 # check -nonotify mail, when there is no mail
131 start_test "-nonotify mail, when there is no mail"
132 run_test 'msgchk -nonotify mail -nodate' "You don't have any mail waiting"
133
134 # check -nonotify nomail, when there is no mail
135 start_test "-nonotify nomail, when there is no mail"
136 run_test 'msgchk -nonotify nomail -nodate' ''
137
138 # check -nonotify all, when there is no mail
139 start_test "-nonotify all, when there is no mail"
140 run_test 'msgchk -nonotify nomail -nonotify all -nodate' ''
141
142
143 finish_test
144 exit ${failed:-0}