]>
diplodocus.org Git - nmh/blob - test/slocal/test-slocal
2 ######################################################
6 ######################################################
10 if test -z "$MH_OBJ_DIR"; then
11 srcdir
=`dirname $0`/..
/..
12 MH_OBJ_DIR
=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 .
"$MH_OBJ_DIR/test/common.sh"
19 # Use proper program, maybe not the first one on PATH.
20 slocal
="$MH_LIB_DIR"/slocal
22 expected
="$MH_TEST_DIR"/$$.expected
23 actual
="$MH_TEST_DIR"/$$.actual
24 actual2
="$MH_TEST_DIR"/$$.actual2
25 md
="$MH_TEST_DIR"/Mail
/maildelivery
28 cat >"$expected" <<EOF
29 Usage: slocal [switches]
45 $slocal -help >"$actual" 2>&1
46 check
"$expected" "$actual"
49 case `$slocal -vers` in
51 * ) printf '%s: slocal -vers generated unexpected output\n' "$0" >&2
52 failed
=`expr ${failed:-0} + 1`;;
55 # check unknown switch
56 run_test
"$slocal -nonexistent" 'slocal: -nonexistent unknown'
58 # check non-switch argument
59 run_test
"$slocal nonexistent" 'slocal: only switch arguments are supported'
61 # If no mail spool, explicitly specify the mailbox.
62 if grep 'mmdfldir:.*/dev/null' ${MHMTSCONF}.old
>/dev
/null
; then
63 mbox
="-mailbox ${MH_TEST_DIR}/Mail/mbox"
68 #### Need to specify full path to tee on Cygwin.
69 [ -x /usr
/bin
/tee ] && tee=/usr
/bin
/tee || tee=tee
71 # check basic operation
72 # Can't use rcvstore because slocal wipes out the environment.
73 # So, it would put the message in the user's inbox, not the
74 # test inbox. slocal also freopens stdout and stderr to
75 # /dev/null, so we can't view them to verify simulated delivery.
77 * 1 qpipe A "$tee $actual"
80 $slocal -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail
/inbox
/1
81 check
"$MH_TEST_DIR/Mail/inbox/1" "$actual" 'keep first'
84 $slocal -debug -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail
/inbox
/1 \
86 run_test
"grep ^retrieving $actual2" 'retrieving message from stdin'
89 $slocal -verbose -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail
/inbox
/1 \
91 run_test
"grep ^delivering $actual2" "delivering to pipe \"$tee\", success."
94 $slocal -verbose -noverbose -maildelivery $md $mbox \
95 <"$MH_TEST_DIR"/Mail
/inbox
/1 >"$actual2" 2>&1
96 run_test
"grep ^delivering $actual2" ''
101 From test2@example.com qpipe A "$tee $actual"
104 $slocal -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail
/inbox
/2
105 check
"$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'
109 From test3@example.com qpipe R "$tee $actual"
110 From test3@example.com qpipe ? "$tee $actual2"
113 $slocal -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail
/inbox
/3
114 check
"$MH_TEST_DIR/Mail/inbox/3" "$actual" 'keep first'
115 check
"$MH_TEST_DIR/Mail/inbox/3" "$actual2" 'keep first'
119 From test4@example.com qpipe R "$tee $actual"
120 From test4@example.com qpipe N "$tee $actual2"
123 $slocal -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail
/inbox
/4
124 check
"$MH_TEST_DIR/Mail/inbox/4" "$actual" 'keep first'
125 check
"$MH_TEST_DIR/Mail/inbox/4" "$actual2" 'keep first'
129 From test5@example.com qpipe R "$tee $actual"
130 default 1 qpipe A "$tee $actual2"
133 $slocal -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail
/inbox
/5
134 check
"$MH_TEST_DIR/Mail/inbox/5" "$actual" 'keep first'
135 check
"$MH_TEST_DIR/Mail/inbox/5" "$actual2" 'keep first'
137 # Use current login for address, user, etc., because it must be an
138 # existing user on the host.
139 me
=`"$MH_LIB_DIR"/ap -format '%(me)' 0`
143 addr "$me" qpipe A "$tee $actual"
146 $slocal -addr "$me" -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail
/inbox
/6
147 check
"$MH_TEST_DIR/Mail/inbox/6" "$actual" 'keep first'
151 * 1 qpipe A "\$(info) $actual"
154 $slocal -info $tee -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail
/inbox
/7
155 check
"$MH_TEST_DIR/Mail/inbox/7" "$actual" 'keep first'
157 # check -sender, which is compared with "source"
159 source "$me" qpipe A "$tee $actual"
162 $slocal -sender "$me" -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail
/inbox
/8
163 check
"$MH_TEST_DIR/Mail/inbox/8" "$actual" 'keep first'
167 * 1 qpipe A "$tee $actual"
170 $slocal -user "$me" -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail
/inbox
/9
171 check
"$MH_TEST_DIR/Mail/inbox/9" "$actual" 'keep first'
177 $slocal -mailbox "$actual" -maildelivery $md <"$MH_TEST_DIR"/Mail
/inbox
/10
178 inc
-file "$actual" -silent -truncate
180 check
"$MH_TEST_DIR/Mail/inbox/10" "$MH_TEST_DIR/Mail/inbox/11" 'keep first'
183 $slocal -mailbox "$actual" -maildelivery $md -file "$MH_TEST_DIR"/Mail
/inbox
/1
184 inc
-file "$actual" -silent -truncate
186 check
"$MH_TEST_DIR/Mail/inbox/1" "$MH_TEST_DIR/Mail/inbox/11" 'keep first'
190 * 1 qpipe A "$tee $actual"
193 $slocal -suppressdup -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail
/inbox
/2
194 check
"$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'
196 $slocal -suppressdup -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail
/inbox
/2
197 if [ -f "$actual" ]; then
198 echo $0: check
-suppressdup failed
199 failed
=`expr ${failed:-0} + 1`
202 # check -nosuppressdup
203 $slocal -suppress -nosuppressdup -maildelivery $md $mbox \
204 <"$MH_TEST_DIR"/Mail
/inbox
/2
205 check
"$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'