3 # TODO FIX uh oh this and the inc missing msg cases passed by accident after inc uses ESEARCH
4 # and now switching inc to leave mailbox open has broken it completely!
6 # TODO figure out how to get a server to send a BAD response so we have an accurate fake
8 if test -z "$MH_OBJ_DIR"; then
9 srcdir=`dirname "$0"`/../..
10 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
13 . "$MH_OBJ_DIR/test/common.sh"
15 # common.sh sets this to something crazy; did i do that?!
16 testname=${0#$srcdir/}
18 setup_test_without_data Mail
21 #### Save exit status to use as status for this program.
27 [ -n "$imapd_pid" ] && kill $imapd_pid
28 "$MH_OBJ_DIR/target/debug/mhimap" imap shutdown
30 # TODO have cleanup allow additional cleanup registration?
31 # Or just allow it to accept status as argument.
37 covdir="$MH_OBJ_DIR/covdata/${MH_COVERAGE_PROFILE:-default}/$testname"
39 export LLVM_PROFILE_FILE="$covdir/$profile-%m.profraw"
41 imapd="$MH_TEST_DIR/$$.imapd"
42 start_fakeinetd "$imapd"
43 imapd_pid=$fakeinetd_pid
47 imap-manager: $MH_OBJ_DIR/target/debug/imap-folder-manager
48 imap-socket: $MH_TEST_DIR/Mail/imap.d/socket
49 imap-db: $MH_TEST_DIR/Mail/imap.d
51 imap-port: $fakeinetd_port
52 imap-tls: don't protect my data i know what i'm doing
54 imap-mailbox-root: test/
56 if [ -n "$MH_TEST_IMAP_LOG_LEVEL" ]; then
57 echo "imap-log-level: $MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
58 echo "imap-log-$MH_TEST_IMAP_LOG_LEVEL-to: $MH_TEST_DIR/$profile/imap.d/log.$MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
61 start_test 'unrecoverable error: BAD FETCH'
63 cat > "$imapd" <<EOSCRIPT
66 * PREAUTH [CAPABILITY IMAP4REV1 UIDPLUS] authenticated
67 * LIST (\NoInferiors \UnMarked) "/" test/fold
70 * OK [UIDVALIDITY 1603585238] UID validity status
71 * OK [UIDNEXT 12] Predicted next UID
72 1 OK [READ-WRITE] SELECT completed
74 1 OK UID SEARCH completed
75 fetch11 BAD fake fake fakey fake
77 while read line; do :; done
81 # TODO plumb this error out to inc
83 check_exit '-eq 1' inc +imap
84 if ! grep -q 'BAD.*fake fake fakey fake' "$MH_TEST_DIR/$profile/imap.d/stderr"; then
85 cat "$MH_TEST_DIR/$profile/imap.d/stderr" >&2
86 fail "BAD response not in $MH_TEST_DIR/$profile/imap.d/stderr"