File: test-msgchk

package info (click to toggle)
nmh 1.8-4
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 7,860 kB
  • sloc: ansic: 50,445; sh: 22,697; makefile: 1,138; lex: 740; perl: 509; yacc: 265
file content (144 lines) | stat: -rwxr-xr-x 4,154 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/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

check_exit '-eq 1' msgchk -

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
start_test "-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

run_prog msgchk -help 2>&1 | head -9 >"$actual"
check "$expected" "$actual"

# check -version
start_test "-version"
case `msgchk -v` in
  msgchk\ --*) ;;
  *          ) printf '%s: msgchk -v generated unexpected output\n' "$0" >&2
               failed=`expr ${failed:-0} + 1`;;
esac

# check unknown switch
start_test "unknown switch"
run_test "msgchk -nonexistent" 'msgchk: -nonexistent unknown'

# check with no arguments and no mail waiting
start_test "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_LIBEXEC_DIR}"/rcvpack <"${MH_TEST_DIR}"/Mail/inbox/1 \
  "${MH_TEST_DIR}"/Mail/maildrop

# check with no arguments and mail waiting
start_test "with no arguments and mail waiting"
cat >"$expected" <<EOF
You have new mail waiting; last read on
EOF

run_prog msgchk | sed -e 's/last read on.*/last read on/' >"$actual"
check "$expected" "$actual"

# check -date
start_test "-date"
cat >"$expected" <<EOF
You have new mail waiting; last read on
EOF

run_prog msgchk -nodate -date | sed -e 's/last read on.*/last read on/' \
  >"$actual"
check "$expected" "$actual"

# check -nodate
start_test "-nodate"
run_test 'msgchk -nodate' 'You have new mail waiting'

# check -notify mail, when there is mail
start_test "-notify mail, when there is mail"
run_test 'msgchk -notify mail -nodate' 'You have new mail waiting'

# check -notify nomail, when there is mail
start_test "-notify nomail, when there is mail"
run_test 'msgchk -notify nomail -nodate' 'You have new mail waiting'

# check -notify all, when there is mail
start_test "-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
start_test "-nonotify mail, when there is mail"
run_test 'msgchk -nonotify mail -nodate' ''

# check -nonotify nomail, when there is mail
start_test "-nonotify nomail, when there is mail"
run_test 'msgchk -nonotify nomail -nodate' 'You have new mail waiting'

# check -nonotify all, when there is mail
start_test "-nonotify all, when there is mail"
run_test 'msgchk -nonotify nomail -nonotify all -nodate' ''

run_prog inc -silent

# check -notify mail, when there is no mail
start_test "-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
start_test "-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
start_test "-notify all, when there is no mail"
run_test 'msgchk -notify nomail -nonotify all -nodate' ''

# check -nonotify mail, when there is no mail
start_test "-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
start_test "-nonotify nomail, when there is no mail"
run_test 'msgchk -nonotify nomail -nodate' ''

# check -nonotify all, when there is no mail
start_test "-nonotify all, when there is no mail"
run_test 'msgchk -nonotify nomail -nonotify all -nodate' ''


finish_test
exit ${failed:-0}