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_LIB_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 $rcvstore -help >$actual 2>&1
42 check $expected $actual
45 case `$rcvstore -v` in
47 * ) printf "$0: rcvstore -v generated unexpected output\n" >&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 $rcvstore </dev/null >$actual 2>&1
60 check $expected $actual
62 # check with no switches
65 $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 $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 $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 $rcvstore +newfolder -nocreate <${MH_TEST_DIR}/Mail/inbox/1 >$actual \
90 check $expected $actual 'keep first'
91 check $expected_err $actual_err
94 $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 $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 $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 $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 $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 $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 $rcvstore -sequence newseq -zero <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
139 check $expected $actual 'keep first'
140 run_test 'mark -sequence newseq -list' 'newseq: 11'
141 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
144 mark -sequence newseq all
145 $rcvstore -seq newseq -zero -nozero <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
146 check $expected $actual 'keep first'
147 run_test 'mark -sequence newseq -list' 'newseq: 1-11'
148 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
150 # check that default is -public
151 $rcvstore -sequence pubseq <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
152 check $expected $actual 'keep first'
153 run_test 'mark -sequence pubseq -list' 'pubseq: 11'
154 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
157 $rcvstore -sequence privseq -nopublic <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
158 check $expected $actual 'keep first'
159 run_test 'mark -sequence privseq -nopublic -list' 'privseq (private): 11'
160 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
163 $rcvstore -sequence pubseq -nopublic -public <${MH_TEST_DIR}/Mail/inbox/1 \
165 check $expected $actual 'keep first'
166 run_test 'mark -sequence pubseq -public -list' 'pubseq: 11'
167 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
169 #### Windows FAT filesystems don't support file permissions that
170 #### disallow read access, and chmod doesn't fail. If a test above
171 #### has failed, report that failure. Otherwise, report that we're
172 #### skipping the remainer of the test if chmod can't remove read
174 printf '\n' >${MH_TEST_DIR}/Mail/test-read-perms
175 chmod 600 ${MH_TEST_DIR}/Mail/test-read-perms
176 if [ "`find ${MH_TEST_DIR}/Mail/test-read-perms -perm 600`"x = ''x ]; then
177 if [ ${failed:-0} -eq 0 ]; then
178 echo "$Test $0 SKIP (cannot remove read permission on plain files)"
184 rm -f ${MH_TEST_DIR}/Mail/test-read-perms
187 # check default Msg-Protect
188 msgprot=`mhparam msgprot`
189 $rcvstore <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
190 check $expected $actual 'keep first'
191 run_test "find ${MH_TEST_DIR}/Mail/inbox/11 -perm $msgprot" \
192 "${MH_TEST_DIR}/Mail/inbox/11"
193 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
195 # check Msg-Protect profile entry
197 printf "Msg-Protect: $msgprot\n" >>$MH
198 $rcvstore <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
199 check $expected $actual
200 run_test "find ${MH_TEST_DIR}/Mail/inbox/11 -perm $msgprot" \
201 "${MH_TEST_DIR}/Mail/inbox/11"
202 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"