]> diplodocus.org Git - nmh/blob - test/imap/test-server-drops
expect this commit to be force-replaced periodically
[nmh] / test / imap / test-server-drops
1 #!/bin/sh
2
3 if test -z "$MH_OBJ_DIR"; then
4 srcdir=`dirname "$0"`/../..
5 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
6 fi
7
8 . "$MH_OBJ_DIR/test/common.sh"
9
10 # common.sh sets this to something crazy; did i do that?!
11 testname=${0#$srcdir/}
12
13 setup_test_without_data Mail
14
15 imap_cleanup() {
16 #### Save exit status to use as status for this program.
17 status=$?
18 set +e
19
20 rm -f "$imapd"
21
22 [ -n "$imapd_pid" ] && kill $imapd_pid
23 "$MH_OBJ_DIR/target/debug/mhimap" imap shutdown
24
25 # TODO have cleanup allow additional cleanup registration?
26 # Or just allow it to accept status as argument.
27 (exit $status)
28 cleanup
29 }
30 trap imap_cleanup 0
31
32 covdir="$MH_OBJ_DIR/covdata/${MH_COVERAGE_PROFILE:-default}/$testname"
33 install -d "$covdir"
34 export LLVM_PROFILE_FILE="$covdir/$profile-%m.profraw"
35
36 imapd="$MH_TEST_DIR/$$.imapd"
37 start_fakeinetd "$imapd"
38 imapd_pid=$fakeinetd_pid
39
40 cat >> "$MH" <<EOF
41 Managed-Folders: imap
42 imap-manager: $MH_OBJ_DIR/target/debug/imap-folder-manager
43 imap-socket: $MH_TEST_DIR/Mail/imap.d/socket
44 imap-db: $MH_TEST_DIR/Mail/imap.d
45 imap-host: 127.0.0.1
46 imap-port: $fakeinetd_port
47 imap-tls: don't protect my data i know what i'm doing
48 imap-auth: PREAUTH
49 imap-mailbox-root: test/
50 EOF
51 if [ -n "$MH_TEST_IMAP_LOG_LEVEL" ]; then
52 echo "imap-log-level: $MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
53 echo "imap-log-$MH_TEST_IMAP_LOG_LEVEL-to: $MH_TEST_DIR/$profile/imap.d/log.$MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
54 fi
55
56 expected="$MH_TEST_DIR/$$.expected"
57 actual="$MH_TEST_DIR/$$.actual"
58
59 start_test 'unrecoverable error: server closes connection mid-LIST-response'
60
61 cat > "$imapd" <<EOSCRIPT
62 #!/bin/sh
63 cat <<EOF
64 * PREAUTH [CAPABILITY IMAP4REV1 UIDPLUS] authenticated
65 * LIST (\NoInferiors \UnMarked) "/" test/fold
66 EOF
67 read line
68 EOSCRIPT
69 chmod 755 "$imapd"
70
71 # This is similar to but NOT THE SAME as EOF tests in test-login; those are during authentication, these are after.
72
73 cat > "$expected" <<EOF
74 inc: failed to inc folder imap: Received EOF on network read
75 EOF
76 inc +imap > "$actual" 2>&1 || status=$?
77 check "$actual" "$expected"
78 (exit $status) && fail 'inc exited 0 on error'
79
80 finish_test
81 exit ${failed:-0}