]>
diplodocus.org Git - nmh/blob - test/rcv/test-rcvstore
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, likely not the first one on PATH.
20 rcvstore
="${MH_LIBEXEC_DIR}/rcvstore"
22 check_exit
'-eq 1' $rcvstore -
24 expected
=$MH_TEST_DIR/$$.expected
25 expected_err
=$MH_TEST_DIR/$$.expected_err
26 actual
=$MH_TEST_DIR/$$.actual
27 actual_err
=$MH_TEST_DIR/$$.actual_err
33 Usage: rcvstore [+folder] [switches]
44 #### Skip nmh intro text.
45 run_prog
"$rcvstore" -help 2>&1 | sed '/^$/,$d' >"$actual"
46 check
"$expected" "$actual"
50 case `$rcvstore -v` in
52 * ) printf '%s: rcvstore -v generated unexpected output\n' "$0" >&2
53 failed
=`expr ${failed:-0} + 1`;;
56 # check unknown switch
57 start_test
"unknown switch"
58 run_test
"$rcvstore -nonexistent" 'rcvstore: -nonexistent unknown'
60 # check with no switches and zero-length input message
61 start_test
"with no switches and zero-length input message"
66 run_prog
$rcvstore </dev
/null
>$actual 2>&1
67 check
$expected $actual
69 # check with no switches
70 start_test
"with no switches"
73 run_prog
$rcvstore <${MH_TEST_DIR}/Mail
/inbox
/1 >$actual 2>&1
74 check
$expected $actual 'keep first'
75 check
"${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
77 # check + of existing folder
78 start_test
"+ of existing folder"
79 run_prog
$rcvstore +inbox
<${MH_TEST_DIR}/Mail
/inbox
/1 >$actual 2>&1
80 check
$expected $actual 'keep first'
81 check
"${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
83 # check + of new folder
84 start_test
"+ of new folder"
85 run_prog
$rcvstore +newfolder
<${MH_TEST_DIR}/Mail
/inbox
/1 >$actual 2>&1
86 check
$expected $actual 'keep first'
87 check
"${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/newfolder/1" \
89 rmdir "${MH_TEST_DIR}/Mail/newfolder"
92 start_test
"-nocreate"
93 cat >$expected_err <<EOF
94 rcvstore: folder ${MH_TEST_DIR}/Mail/newfolder doesn't exist
98 run_prog
$rcvstore +newfolder
-nocreate <${MH_TEST_DIR}/Mail
/inbox
/1 >$actual \
101 check
$expected $actual 'keep first'
102 check
$expected_err $actual_err
106 run_prog
$rcvstore +newfolder
-nocreate -create <${MH_TEST_DIR}/Mail
/inbox
/1 \
108 check
$expected $actual 'keep first'
109 check
"${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/newfolder/1" \
111 rmdir "${MH_TEST_DIR}/Mail/newfolder"
113 # check addition to unseen sequence
114 start_test
"addition to unseen sequence"
115 printf 'Unseen-Sequence: unseen\n' >> $MH
116 run_prog
$rcvstore <${MH_TEST_DIR}/Mail
/inbox
/1 >$actual 2>&1
117 check
$expected $actual 'keep first'
118 run_test
'mark -sequence unseen -list' 'unseen: 11'
119 check
"${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
120 #### Need to clear the unseen sequence.
121 touch "${MH_TEST_DIR}/Mail/inbox/11"
125 start_test
"-nounseen"
126 run_prog
$rcvstore -nounseen <${MH_TEST_DIR}/Mail
/inbox
/1 >$actual 2>&1
127 check
$expected $actual 'keep first'
128 run_test
'mark -sequence unseen -list' 'unseen: '
129 check
"${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
133 run_prog
$rcvstore -nounseen -unseen <${MH_TEST_DIR}/Mail
/inbox
/1 >$actual 2>&1
134 check
$expected $actual 'keep first'
135 run_test
'mark -sequence unseen -list' 'unseen: 11'
136 check
"${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
139 start_test
"-sequence"
140 run_prog
$rcvstore -sequence newseq
<${MH_TEST_DIR}/Mail
/inbox
/1 >$actual 2>&1
141 check
$expected $actual 'keep first'
142 run_test
'mark -sequence newseq -list' 'newseq: 11'
143 check
"${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
145 # check that default is -nozero
146 start_test
"that default is -nozero"
147 mark
-sequence newseq all
148 run_prog
$rcvstore -sequence newseq
<${MH_TEST_DIR}/Mail
/inbox
/1 >$actual 2>&1
149 check
$expected $actual 'keep first'
150 run_test
'mark -sequence newseq -list' 'newseq: 1-11'
151 check
"${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
155 mark
-sequence newseq all
156 run_prog
$rcvstore -sequence newseq
-zero \
157 <${MH_TEST_DIR}/Mail
/inbox
/1 >$actual 2>&1
158 check
$expected $actual 'keep first'
159 run_test
'mark -sequence newseq -list' 'newseq: 11'
160 check
"${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
164 mark
-sequence newseq all
165 run_prog
$rcvstore -seq newseq
-zero -nozero \
166 <${MH_TEST_DIR}/Mail
/inbox
/1 >$actual 2>&1
167 check
$expected $actual 'keep first'
168 run_test
'mark -sequence newseq -list' 'newseq: 1-11'
169 check
"${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
171 # check that default is -public
172 start_test
"that default is -public"
173 run_prog
$rcvstore -sequence pubseq
<${MH_TEST_DIR}/Mail
/inbox
/1 >$actual 2>&1
174 check
$expected $actual 'keep first'
175 run_test
'mark -sequence pubseq -list' 'pubseq: 11'
176 check
"${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
179 start_test
"-nopublic"
180 run_prog
$rcvstore -sequence privseq
-nopublic \
181 <${MH_TEST_DIR}/Mail
/inbox
/1 >$actual 2>&1
182 check
$expected $actual 'keep first'
183 run_test
'mark -sequence privseq -nopublic -list' 'privseq (private): 11'
184 check
"${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
188 run_prog
$rcvstore -sequence pubseq
-nopublic -public \
189 <${MH_TEST_DIR}/Mail
/inbox
/1 >$actual 2>&1
190 check
$expected $actual 'keep first'
191 run_test
'mark -sequence pubseq -public -list' 'pubseq: 11'
192 check
"${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
194 #### Windows FAT filesystems don't support file permissions that
195 #### disallow read access, and chmod doesn't fail. If a test above
196 #### has failed, report that failure. Otherwise, report that we're
197 #### skipping the remainer of the test if chmod can't remove read
199 printf '\n' >${MH_TEST_DIR}/Mail
/test-read-perms
200 chmod 600 ${MH_TEST_DIR}/Mail
/test-read-perms
201 if [ "`find ${MH_TEST_DIR}/Mail/test-read-perms -perm 600`"x
= ''x
]; then
202 if [ ${failed:-0} -eq 0 ]; then
203 echo "$Test $0 SKIP (cannot remove read permission on plain files)"
208 rm -f ${MH_TEST_DIR}/Mail
/test-read-perms
210 # check default Msg-Protect
211 start_test
"default Msg-Protect"
212 msgprot
=`mhparam msgprot`
213 run_prog
$rcvstore <${MH_TEST_DIR}/Mail
/inbox
/1 >$actual 2>&1
214 check
$expected $actual 'keep first'
215 run_test
"find ${MH_TEST_DIR}/Mail/inbox/11 -perm $msgprot" \
216 "${MH_TEST_DIR}/Mail/inbox/11"
217 check
"${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
219 # check Msg-Protect profile entry
220 start_test
"Msg-Protect profile entry"
222 printf 'Msg-Protect: %s\n' "$msgprot" >>$MH
223 run_prog
$rcvstore <${MH_TEST_DIR}/Mail
/inbox
/1 >$actual 2>&1
224 check
$expected $actual
225 run_test
"find ${MH_TEST_DIR}/Mail/inbox/11 -perm $msgprot" \
226 "${MH_TEST_DIR}/Mail/inbox/11"
227 check
"${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"