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 expected=$MH_TEST_DIR/$$.expected
23 expected_err=$MH_TEST_DIR/$$.expected_err
24 actual=$MH_TEST_DIR/$$.actual
25 actual_err=$MH_TEST_DIR/$$.actual_err
30 Usage: rcvstore [+folder] [switches]
41 run_prog $rcvstore -help >$actual 2>&1
42 check $expected $actual
45 case `$rcvstore -v` in
47 * ) printf '%s: rcvstore -v generated unexpected output\n' "$0" >&2
48 failed=`expr ${failed:-0} + 1`;;
51 # check unknown switch
52 run_test "$rcvstore -nonexistent" 'rcvstore: -nonexistent unknown'
54 # check with no switches and zero-length input message
59 run_prog $rcvstore </dev/null >$actual 2>&1
60 check $expected $actual
62 # check with no switches
65 run_prog $rcvstore <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
66 check $expected $actual 'keep first'
67 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
69 # check + of existing folder
70 run_prog $rcvstore +inbox <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
71 check $expected $actual 'keep first'
72 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
74 # check + of new folder
75 run_prog $rcvstore +newfolder <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
76 check $expected $actual 'keep first'
77 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/newfolder/1" \
79 rmdir "${MH_TEST_DIR}/Mail/newfolder"
82 cat >$expected_err <<EOF
83 rcvstore: folder ${MH_TEST_DIR}/Mail/newfolder doesn't exist
87 run_prog $rcvstore +newfolder -nocreate <${MH_TEST_DIR}/Mail/inbox/1 >$actual \
90 check $expected $actual 'keep first'
91 check $expected_err $actual_err
94 run_prog $rcvstore +newfolder -nocreate -create <${MH_TEST_DIR}/Mail/inbox/1 \
96 check $expected $actual 'keep first'
97 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/newfolder/1" \
99 rmdir "${MH_TEST_DIR}/Mail/newfolder"
101 # check addition to unseen sequence
102 printf 'Unseen-Sequence: unseen\n' >> $MH
103 run_prog $rcvstore <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
104 check $expected $actual 'keep first'
105 run_test 'mark -sequence unseen -list' 'unseen: 11'
106 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
107 #### Need to clear the unseen sequence.
108 touch "${MH_TEST_DIR}/Mail/inbox/11"
112 run_prog $rcvstore -nounseen <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
113 check $expected $actual 'keep first'
114 run_test 'mark -sequence unseen -list' 'unseen: '
115 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
118 run_prog $rcvstore -nounseen -unseen <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
119 check $expected $actual 'keep first'
120 run_test 'mark -sequence unseen -list' 'unseen: 11'
121 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
124 run_prog $rcvstore -sequence newseq <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
125 check $expected $actual 'keep first'
126 run_test 'mark -sequence newseq -list' 'newseq: 11'
127 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
129 # check that default is -nozero
130 mark -sequence newseq all
131 run_prog $rcvstore -sequence newseq <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
132 check $expected $actual 'keep first'
133 run_test 'mark -sequence newseq -list' 'newseq: 1-11'
134 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
137 mark -sequence newseq all
138 run_prog $rcvstore -sequence newseq -zero \
139 <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
140 check $expected $actual 'keep first'
141 run_test 'mark -sequence newseq -list' 'newseq: 11'
142 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
145 mark -sequence newseq all
146 run_prog $rcvstore -seq newseq -zero -nozero \
147 <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
148 check $expected $actual 'keep first'
149 run_test 'mark -sequence newseq -list' 'newseq: 1-11'
150 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
152 # check that default is -public
153 run_prog $rcvstore -sequence pubseq <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
154 check $expected $actual 'keep first'
155 run_test 'mark -sequence pubseq -list' 'pubseq: 11'
156 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
159 run_prog $rcvstore -sequence privseq -nopublic \
160 <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
161 check $expected $actual 'keep first'
162 run_test 'mark -sequence privseq -nopublic -list' 'privseq (private): 11'
163 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
166 run_prog $rcvstore -sequence pubseq -nopublic -public \
167 <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
168 check $expected $actual 'keep first'
169 run_test 'mark -sequence pubseq -public -list' 'pubseq: 11'
170 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
172 #### Windows FAT filesystems don't support file permissions that
173 #### disallow read access, and chmod doesn't fail. If a test above
174 #### has failed, report that failure. Otherwise, report that we're
175 #### skipping the remainer of the test if chmod can't remove read
177 printf '\n' >${MH_TEST_DIR}/Mail/test-read-perms
178 chmod 600 ${MH_TEST_DIR}/Mail/test-read-perms
179 if [ "`find ${MH_TEST_DIR}/Mail/test-read-perms -perm 600`"x = ''x ]; then
180 if [ ${failed:-0} -eq 0 ]; then
181 echo "$Test $0 SKIP (cannot remove read permission on plain files)"
187 rm -f ${MH_TEST_DIR}/Mail/test-read-perms
190 # check default Msg-Protect
191 msgprot=`mhparam msgprot`
192 run_prog $rcvstore <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
193 check $expected $actual 'keep first'
194 run_test "find ${MH_TEST_DIR}/Mail/inbox/11 -perm $msgprot" \
195 "${MH_TEST_DIR}/Mail/inbox/11"
196 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
198 # check Msg-Protect profile entry
200 printf 'Msg-Protect: %s\n' "$msgprot" >>$MH
201 run_prog $rcvstore <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
202 check $expected $actual
203 run_test "find ${MH_TEST_DIR}/Mail/inbox/11 -perm $msgprot" \
204 "${MH_TEST_DIR}/Mail/inbox/11"
205 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"