From a4e7170a9547aa64fdbd9001014f36de61134e39 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Tue, 28 May 2019 00:18:26 +0200 Subject: tests/run: Honor $TMPDIR if the variable is set. Otherwise use /dev/shm. --- tests/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/run b/tests/run index 31af03e..d823f0a 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" -- cgit v1.2.3 From d385fd2817a96bc952b086533798bbf009d3d54f Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Tue, 28 May 2019 00:19:17 +0200 Subject: tests/run: Don't void the command's standard error. --- tests/run | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/run b/tests/run index d823f0a..60d9d01 100755 --- a/tests/run +++ b/tests/run @@ -102,12 +102,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 } -- cgit v1.2.3 From 03460fe3d2657c626d406e57d75f6f9c6fa4338e Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Tue, 28 May 2019 00:21:43 +0200 Subject: tests: don't fail when a pid can't be killed. (Usually on ESRCH.) --- tests/00-db-exclusive/run | 4 ++-- tests/07-sync-live-multi/run | 12 ++++++------ tests/07-sync-live/run | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'tests') 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/07-sync-live-multi/run b/tests/07-sync-live-multi/run index bf0d2f5..9dca2cf 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 diff --git a/tests/07-sync-live/run b/tests/07-sync-live/run index 1950e0b..00cd826 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 -- cgit v1.2.3 From 350217c321cf30ebf2a6655d6ad925898f40a992 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Tue, 28 May 2019 00:28:33 +0200 Subject: tests/run: set 'mailbox_list_index = yes' in dovecot.conf. LAYOUT=index requires mailbox_list_index = yes. It's the default since dovecot 2.3, but we set it explicitly to support older versions. --- tests/run | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/run b/tests/run index 60d9d01..91319f3 100755 --- a/tests/run +++ b/tests/run @@ -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" -- cgit v1.2.3 From a07043f308ee91223b1048a6ca1c878c31b0f83a Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Tue, 28 May 2019 16:46:41 +0200 Subject: tests/run: use the current date as Message-ID in `sample_message`. A random 128-bit UUID obtained from /proc/sys/kernel/random/uuid works too but is Linux-specific and requires the proc(5) pseudo-filesystem to be mounted at /proc. --- tests/run | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/run b/tests/run index 91319f3..fca4919 100755 --- a/tests/run +++ b/tests/run @@ -133,11 +133,12 @@ doveadm() { # Sample (random) message sample_message() { + local date="$(date +"%s.%N")" cat <<-EOF From: To: - 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)" -- cgit v1.2.3 From db844d8979c17469012a079a051f60044532b6ed Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Mon, 3 Jun 2019 03:50:12 +0200 Subject: long-lived tests: sleep between 1ms and 999ms. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `shuf -n1 -i1-99` produces a number between 1 and 99, hence `sleep "0.$(shuf -n1 -i1-99)"` pauses for some time between 100ms and 990ms. Moreover it's not uniformly distributed as multiples of 100ms (0.100, 0.200, …, 0.900) have twice the probability of other numbers. --- tests/07-sync-live-multi/run | 2 +- tests/07-sync-live/run | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/07-sync-live-multi/run b/tests/07-sync-live-multi/run index 9dca2cf..15a27fd 100644 --- a/tests/07-sync-live-multi/run +++ b/tests/07-sync-live-multi/run @@ -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 00cd826..04d8247 100644 --- a/tests/07-sync-live/run +++ b/tests/07-sync-live/run @@ -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 -- cgit v1.2.3 From 93e66f34629f248d14e9123fc5a1050bd3b71108 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Thu, 27 Jun 2019 20:46:26 +0200 Subject: test suite: make sqlite3 ignore ~/.sqliterc --- tests/run | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/run b/tests/run index fca4919..32931d6 100755 --- a/tests/run +++ b/tests/run @@ -130,6 +130,9 @@ doveadm() { shift 2 "$home/.local/bin/doveadm" "$@" } +sqlite3() { + command sqlite3 -init /dev/null "$@" +} # Sample (random) message sample_message() { @@ -321,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" -- cgit v1.2.3 From 53ea6efb89aade69c921fc57ad809eb61e9133a8 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Thu, 27 Jun 2019 21:00:56 +0200 Subject: tests/run: fix minor space damage --- tests/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/run b/tests/run index 32931d6..4f828d6 100755 --- a/tests/run +++ b/tests/run @@ -220,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 -- cgit v1.2.3 From b62c567af680d569ee3c6393de77468dfc874288 Mon Sep 17 00:00:00 2001 From: Gustav Eek Date: Thu, 27 Jun 2019 21:03:23 +0200 Subject: test suite: import+dump before comparing SQLite dumps. The dumping quoting style differ between sqlite versions. Compensate with re-dumping also the reference file --- tests/00-db-migration-0-to-1/run | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests') 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 : -- cgit v1.2.3 From c4abd6128c3ca5471afc84225533a958ce273875 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Fri, 5 Jul 2019 02:42:08 +0200 Subject: Fix minor space damage. --- tests/05-repair/run | 2 +- tests/06-largeint/run | 4 ++-- tests/run | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') 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/run b/tests/run index 4f828d6..ee11757 100755 --- a/tests/run +++ b/tests/run @@ -161,7 +161,7 @@ deliver() { doveadm "${argv[@]}" exec dovecot-lda -e "$@" } -# Dump test results +# Dump test results dump_test_result() { local below=">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" local above="<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" -- cgit v1.2.3