aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/00-db-exclusive/run4
-rw-r--r--tests/00-db-migration-0-to-1/run9
-rw-r--r--tests/05-repair/run2
-rw-r--r--tests/06-largeint/run4
-rw-r--r--tests/07-sync-live-multi/run14
-rw-r--r--tests/07-sync-live/run6
-rwxr-xr-xtests/run21
7 files changed, 36 insertions, 24 deletions
diff --git a/tests/00-db-exclusive/run b/tests/00-db-exclusive/run
index 1ae27b6..1528b3b 100644
--- a/tests/00-db-exclusive/run
+++ b/tests/00-db-exclusive/run
@@ -9,8 +9,8 @@ interimap
interimap --watch=60 & pid=$!
cleanup() {
# kill interimap process and its children
- pkill -P "$pid" -TERM
- kill -TERM "$pid"
+ pkill -P "$pid" -TERM || true
+ kill -TERM "$pid" || true
wait
}
trap cleanup EXIT INT TERM
diff --git a/tests/00-db-migration-0-to-1/run b/tests/00-db-migration-0-to-1/run
index e4eb770..757fe04 100644
--- a/tests/00-db-migration-0-to-1/run
+++ b/tests/00-db-migration-0-to-1/run
@@ -18,9 +18,16 @@ sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/dump.sql" <<-EOF
.dump
EOF
+# re-import and dump the expected dump to work around SQLite format
+# differences across versions
+sqlite3 "$XDG_DATA_HOME/interimap/remote2.db" <"$TESTDIR/after.sql"
+sqlite3 "$XDG_DATA_HOME/interimap/remote2.db" >"$TMPDIR/dump-expected.sql" <<-EOF
+ .dump
+EOF
+
# XXX need 'user_version' PRAGMA in the dump for future migrations
# http://sqlite.1065341.n5.nabble.com/dump-command-and-user-version-td101228.html
diff -u --label="a/dump.sql" --label="b/dump.sql" \
- "$TESTDIR/after.sql" "$TMPDIR/dump.sql"
+ "$TMPDIR/dump-expected.sql" "$TMPDIR/dump.sql"
# vim: set filetype=sh :
diff --git a/tests/05-repair/run b/tests/05-repair/run
index 747b974..15553e0 100644
--- a/tests/05-repair/run
+++ b/tests/05-repair/run
@@ -65,7 +65,7 @@ spoof UIDNEXT "local"
spoof HIGHESTMODSEQ "local" "remote"
# now repair
-interimap --repair "baz" "foo.bar"
+interimap --repair "baz" "foo.bar"
# 6 updates with \Answered (luid 4,8,11:13,16), 2 of which (luid 12,13) vanished from remote
# 3 updates with \Seen (ruid 6,8,10), 1 of which (uid 10) vanished from remote
diff --git a/tests/06-largeint/run b/tests/06-largeint/run
index edcbd31..b08bcfa 100644
--- a/tests/06-largeint/run
+++ b/tests/06-largeint/run
@@ -7,9 +7,9 @@ doveadm -u "local" mailbox update --uid-validity 2147483648 "bar" # 2^31
doveadm -u "local" mailbox update --uid-validity 4294967295 "baz" # 2^32-1
doveadm -u "remote" mailbox update --uid-validity 4294967295 "INBOX" # 2^32-1
-doveadm -u "remote" mailbox update --uid-validity 2147483648 "foo" # 2^31
+doveadm -u "remote" mailbox update --uid-validity 2147483648 "foo" # 2^31
doveadm -u "remote" mailbox update --uid-validity 2147483647 "bar" # 2^31-1
-doveadm -u "remote" mailbox update --uid-validity 1 "baz" #
+doveadm -u "remote" mailbox update --uid-validity 1 "baz" #
run() {
local u m
diff --git a/tests/07-sync-live-multi/run b/tests/07-sync-live-multi/run
index bf0d2f5..15a27fd 100644
--- a/tests/07-sync-live-multi/run
+++ b/tests/07-sync-live-multi/run
@@ -15,12 +15,12 @@ interimap --config="config3" --watch=1 & pid3=$!
abort() {
# kill interimap process and its children
- pkill -P "$pid" -TERM
- kill -TERM "$pid"
- pkill -P "$pid2" -TERM
- kill -TERM "$pid2"
- pkill -P "$pid3" -TERM
- kill -TERM "$pid3"
+ pkill -P "$pid" -TERM || true
+ kill -TERM "$pid" || true
+ pkill -P "$pid2" -TERM || true
+ kill -TERM "$pid2" || true
+ pkill -P "$pid3" -TERM || true
+ kill -TERM "$pid3" || true
wait
}
trap abort EXIT INT TERM
@@ -101,7 +101,7 @@ while [ $(date +%s) -le $timer ]; do
done
# sleep a little bit
- sleep "0.$(shuf -n1 -i1-99)"
+ sleep "$(printf "0.%03d" "$(shuf -n1 -i1-999)")"
done
# wait a little longer so interimap has time to run loop() again and
diff --git a/tests/07-sync-live/run b/tests/07-sync-live/run
index 1950e0b..04d8247 100644
--- a/tests/07-sync-live/run
+++ b/tests/07-sync-live/run
@@ -6,8 +6,8 @@ interimap --watch=1 & pid=$!
abort() {
# kill interimap process and its children
- pkill -P "$pid" -TERM
- kill -TERM "$pid"
+ pkill -P "$pid" -TERM || true
+ kill -TERM "$pid" || true
wait
}
trap abort EXIT INT TERM
@@ -63,7 +63,7 @@ while [ $(date +%s) -le $timer ]; do
done
# sleep a little bit
- sleep "0.$(shuf -n1 -i1-99)"
+ sleep "$(printf "0.%03d" "$(shuf -n1 -i1-999)")"
done
# wait a little longer so interimap has time to run loop() again and
diff --git a/tests/run b/tests/run
index 31af03e..ee11757 100755
--- a/tests/run
+++ b/tests/run
@@ -36,7 +36,7 @@ if [ ! -d "$TESTDIR" ]; then
exit 1
fi
-ROOTDIR="$(mktemp --tmpdir=/dev/shm --directory "$NAME.XXXXXXXXXX")"
+ROOTDIR="$(mktemp --tmpdir="${TMPDIR:-/dev/shm}" --directory "$NAME.XXXXXXXXXX")"
trap 'rm -rf -- "$ROOTDIR"' EXIT INT TERM
STDOUT="$ROOTDIR/stdout"
@@ -73,6 +73,7 @@ prepare() {
cat >"$home/.config/dovecot/config" <<-EOF
log_path = /dev/null
mail_home = $ROOTDIR/home/%u
+ mailbox_list_index = yes
ssl = no
EOF
cat >>"$home/.config/dovecot/config" <"$src"
@@ -102,12 +103,12 @@ prepare() {
[local]
type = tunnel
command = exec ${HOME_local@Q}/.local/bin/doveadm exec imap
- null-stderr = YES
+ null-stderr = NO
[remote]
type = tunnel
command = exec ${home@Q}/.local/bin/doveadm exec imap
- null-stderr = YES
+ null-stderr = NO
EOF
done
}
@@ -129,14 +130,18 @@ doveadm() {
shift 2
"$home/.local/bin/doveadm" "$@"
}
+sqlite3() {
+ command sqlite3 -init /dev/null "$@"
+}
# Sample (random) message
sample_message() {
+ local date="$(date +"%s.%N")"
cat <<-EOF
From: <sender@example.net>
To: <recipient@example.net>
- Date: $(date -R)
- Message-ID: <$(< /proc/sys/kernel/random/uuid)@example.net>
+ Date: $(date -R -d@"$date")
+ Message-ID: <$date@example.net>
EOF
local len="$(shuf -i1-4096 -n1)"
@@ -156,7 +161,7 @@ deliver() {
doveadm "${argv[@]}" exec dovecot-lda -e "$@"
}
-# Dump test results
+# Dump test results
dump_test_result() {
local below=">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
local above="<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
@@ -215,7 +220,7 @@ check_mailbox_status2() {
read MESSAGES < <( sqlite3 "$XDG_DATA_HOME/interimap/$u.db" <<-EOF
.mode csv
.separator " " "\\n"
- SELECT COUNT(*)
+ SELECT COUNT(*)
FROM mailboxes a JOIN mapping b ON a.idx = b.idx
WHERE mailbox = $blob
EOF
@@ -319,7 +324,7 @@ xcgrep() {
declare -a ENVIRON=()
environ_set "local"
export TMPDIR TESTDIR STDOUT STDERR "${ENVIRON[@]}"
-export -f environ_set doveadm interimap sample_message deliver
+export -f environ_set doveadm interimap sqlite3 sample_message deliver
export -f check_mailbox_status check_mailbox_status_values check_mailbox_status2
export -f check_mailboxes_status check_mailbox_list xgrep xcgrep
printf "%s..." "$TEST"