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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
|
#!/bin/sh
######################################################
#
# Test rcvstore
#
######################################################
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
# Use proper program, likely not the first one on PATH.
rcvstore="${MH_LIB_DIR}/rcvstore"
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
cat >$expected <<EOF
Usage: rcvstore [+folder] [switches]
switches are:
-[no]create
-[no]unseen
-[no]public
-[no]zero
-sequence name
-version
-help
EOF
run_prog $rcvstore -help >$actual 2>&1
check $expected $actual
# check -version
case `$rcvstore -v` in
rcvstore\ --*) ;;
* ) printf '%s: rcvstore -v generated unexpected output\n' "$0" >&2
failed=`expr ${failed:-0} + 1`;;
esac
# check unknown switch
run_test "$rcvstore -nonexistent" 'rcvstore: -nonexistent unknown'
# check with no switches and zero-length input message
cat >$expected <<EOF
rcvstore: empty file
EOF
run_prog $rcvstore </dev/null >$actual 2>&1
check $expected $actual
# check with no switches
cat >$expected <<EOF
EOF
run_prog $rcvstore <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
check $expected $actual 'keep first'
check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
# check + of existing folder
run_prog $rcvstore +inbox <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
check $expected $actual 'keep first'
check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
# check + of new folder
run_prog $rcvstore +newfolder <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
check $expected $actual 'keep first'
check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/newfolder/1" \
'keep first'
rmdir "${MH_TEST_DIR}/Mail/newfolder"
# check -nocreate
cat >$expected_err <<EOF
rcvstore: folder ${MH_TEST_DIR}/Mail/newfolder doesn't exist
EOF
set +e
run_prog $rcvstore +newfolder -nocreate <${MH_TEST_DIR}/Mail/inbox/1 >$actual \
2>$actual_err
set -e
check $expected $actual 'keep first'
check $expected_err $actual_err
# check -create
run_prog $rcvstore +newfolder -nocreate -create <${MH_TEST_DIR}/Mail/inbox/1 \
>$actual 2>&1
check $expected $actual 'keep first'
check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/newfolder/1" \
'keep first'
rmdir "${MH_TEST_DIR}/Mail/newfolder"
# check addition to unseen sequence
printf 'Unseen-Sequence: unseen\n' >> $MH
run_prog $rcvstore <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
check $expected $actual 'keep first'
run_test 'mark -sequence unseen -list' 'unseen: 11'
check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
#### Need to clear the unseen sequence.
touch "${MH_TEST_DIR}/Mail/inbox/11"
rmm 11
# check -nounseen
run_prog $rcvstore -nounseen <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
check $expected $actual 'keep first'
run_test 'mark -sequence unseen -list' 'unseen: '
check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
# check -unseen
run_prog $rcvstore -nounseen -unseen <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
check $expected $actual 'keep first'
run_test 'mark -sequence unseen -list' 'unseen: 11'
check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
# check -sequence
run_prog $rcvstore -sequence newseq <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
check $expected $actual 'keep first'
run_test 'mark -sequence newseq -list' 'newseq: 11'
check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
# check that default is -nozero
mark -sequence newseq all
run_prog $rcvstore -sequence newseq <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
check $expected $actual 'keep first'
run_test 'mark -sequence newseq -list' 'newseq: 1-11'
check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
# check -zero
mark -sequence newseq all
run_prog $rcvstore -sequence newseq -zero \
<${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
check $expected $actual 'keep first'
run_test 'mark -sequence newseq -list' 'newseq: 11'
check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
# check -nozero
mark -sequence newseq all
run_prog $rcvstore -seq newseq -zero -nozero \
<${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
check $expected $actual 'keep first'
run_test 'mark -sequence newseq -list' 'newseq: 1-11'
check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
# check that default is -public
run_prog $rcvstore -sequence pubseq <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
check $expected $actual 'keep first'
run_test 'mark -sequence pubseq -list' 'pubseq: 11'
check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
# check -nopublic
run_prog $rcvstore -sequence privseq -nopublic \
<${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
check $expected $actual 'keep first'
run_test 'mark -sequence privseq -nopublic -list' 'privseq (private): 11'
check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
# check -public
run_prog $rcvstore -sequence pubseq -nopublic -public \
<${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
check $expected $actual 'keep first'
run_test 'mark -sequence pubseq -public -list' 'pubseq: 11'
check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
#### Windows FAT filesystems don't support file permissions that
#### disallow read access, and chmod doesn't fail. If a test above
#### has failed, report that failure. Otherwise, report that we're
#### skipping the remainer of the test if chmod can't remove read
#### permission.
printf '\n' >${MH_TEST_DIR}/Mail/test-read-perms
chmod 600 ${MH_TEST_DIR}/Mail/test-read-perms
if [ "`find ${MH_TEST_DIR}/Mail/test-read-perms -perm 600`"x = ''x ]; then
if [ ${failed:-0} -eq 0 ]; then
echo "$Test $0 SKIP (cannot remove read permission on plain files)"
exit 77
else
exit $failed
fi
else
rm -f ${MH_TEST_DIR}/Mail/test-read-perms
fi
# check default Msg-Protect
msgprot=`mhparam msgprot`
run_prog $rcvstore <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
check $expected $actual 'keep first'
run_test "find ${MH_TEST_DIR}/Mail/inbox/11 -perm $msgprot" \
"${MH_TEST_DIR}/Mail/inbox/11"
check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
# check Msg-Protect profile entry
msgprot=640
printf 'Msg-Protect: %s\n' "$msgprot" >>$MH
run_prog $rcvstore <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1
check $expected $actual
run_test "find ${MH_TEST_DIR}/Mail/inbox/11 -perm $msgprot" \
"${MH_TEST_DIR}/Mail/inbox/11"
check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"
exit ${failed:-0}
|