aboutsummaryrefslogtreecommitdiffstats
path: root/tests/00-db-exclusive
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2019-05-27 00:40:24 +0200
committerGuilhem Moulin <guilhem@fripost.org>2019-05-27 00:40:24 +0200
commite86590ad6858d0d597278393b8de2923dfed4084 (patch)
treefae8916cc9a81107460df6af0baa26af6d2e0727 /tests/00-db-exclusive
parent6b9e183ea2abbe5137c7551eb8c5184eea51571e (diff)
parent8e379c62a48d68cd5ab2a32c6fc9244b1ae94084 (diff)
Merge branch 'master' into HEAD
Diffstat (limited to 'tests/00-db-exclusive')
-rw-r--r--tests/00-db-exclusive/local.conf5
-rw-r--r--tests/00-db-exclusive/remote.conf5
-rw-r--r--tests/00-db-exclusive/run25
3 files changed, 35 insertions, 0 deletions
diff --git a/tests/00-db-exclusive/local.conf b/tests/00-db-exclusive/local.conf
new file mode 100644
index 0000000..9c838fd
--- /dev/null
+++ b/tests/00-db-exclusive/local.conf
@@ -0,0 +1,5 @@
+namespace inbox {
+ location = maildir:~/inbox:LAYOUT=index
+ inbox = yes
+ list = yes
+}
diff --git a/tests/00-db-exclusive/remote.conf b/tests/00-db-exclusive/remote.conf
new file mode 100644
index 0000000..9c838fd
--- /dev/null
+++ b/tests/00-db-exclusive/remote.conf
@@ -0,0 +1,5 @@
+namespace inbox {
+ location = maildir:~/inbox:LAYOUT=index
+ inbox = yes
+ list = yes
+}
diff --git a/tests/00-db-exclusive/run b/tests/00-db-exclusive/run
new file mode 100644
index 0000000..1ae27b6
--- /dev/null
+++ b/tests/00-db-exclusive/run
@@ -0,0 +1,25 @@
+# verify that database isn't created in --watch mode
+! interimap --watch=60
+xgrep -E "^DBI connect\(.*\) failed: unable to open database file at " <"$STDERR"
+
+# now create database
+interimap
+
+# start a background process
+interimap --watch=60 & pid=$!
+cleanup() {
+ # kill interimap process and its children
+ pkill -P "$pid" -TERM
+ kill -TERM "$pid"
+ wait
+}
+trap cleanup EXIT INT TERM
+
+sleep .05 # wait a short while so we have time to lock the database (ugly and racy...)
+# verify that subsequent runs fail as we can't acquire the exclusive lock
+! interimap
+
+# line 177 is `$DBH->do("PRAGMA locking_mode = EXCLUSIVE");`
+xgrep -Fx "DBD::SQLite::db do failed: database is locked at ./interimap line 177." <"$STDERR"
+
+# vim: set filetype=sh :