]> diplodocus.org Git - nmh/blob - test/inc/test-msgchk
netsec_set_tls(): Return a value in the !TLS_SUPPORT && !tls case.
[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 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 run_prog msgchk -help | head -9 >"$actual" 2>&1
43 check "$expected" "$actual"
44
45 # check -version
46 case `msgchk -v` in
47 msgchk\ --*) ;;
48 * ) printf '%s: msgchk -v generated unexpected output\n' "$0" >&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_LIBEXEC_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 run_prog 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 run_prog msgchk -nodate -date | sed -e 's/last read on.*/last read on/' \
77 >"$actual"
78 check "$expected" "$actual"
79
80 # check -nodate
81 run_test 'msgchk -nodate' 'You have new mail waiting'
82
83 # check -notify mail, when there is mail
84 run_test 'msgchk -notify mail -nodate' 'You have new mail waiting'
85
86 # check -notify nomail, when there is mail
87 run_test 'msgchk -notify nomail -nodate' 'You have new mail waiting'
88
89 # check -notify all, when there is mail
90 run_test 'msgchk -notify nomail -notify all -nodate' 'You have new mail waiting'
91
92 # check -nonotify mail, when there is mail
93 run_test 'msgchk -nonotify mail -nodate' ''
94
95 # check -nonotify nomail, when there is mail
96 run_test 'msgchk -nonotify nomail -nodate' 'You have new mail waiting'
97
98 # check -nonotify all, when there is mail
99 run_test 'msgchk -nonotify nomail -nonotify all -nodate' ''
100
101 run_prog inc -silent
102
103 # check -notify mail, when there is no mail
104 run_test 'msgchk -notify mail -nodate' "You don't have any mail waiting"
105
106 # check -notify nomail, when there is no mail
107 run_test 'msgchk -notify nomail -nodate' "You don't have any mail waiting"
108
109 # check -notify all, when there is no mail
110 run_test 'msgchk -notify nomail -nonotify all -nodate' ''
111
112 # check -nonotify mail, when there is no mail
113 run_test 'msgchk -nonotify mail -nodate' "You don't have any mail waiting"
114
115 # check -nonotify nomail, when there is no mail
116 run_test 'msgchk -nonotify nomail -nodate' ''
117
118 # check -nonotify all, when there is no mail
119 run_test 'msgchk -nonotify nomail -nonotify all -nodate' ''
120
121
122 exit ${failed:-0}