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