From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [PATCH 2/3] test: initial tests for locking retry
Date: Sun, 26 Jun 2016 17:29:44 +0200 [thread overview]
Message-ID: <1466954985-25761-3-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1466954985-25761-1-git-send-email-david@tethera.net>
Currently there's not much to test, so we simulate contention, and check
that the modifications to the database are serialized.
---
test/T620-lock.sh | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)
create mode 100755 test/T620-lock.sh
diff --git a/test/T620-lock.sh b/test/T620-lock.sh
new file mode 100755
index 0000000..f46475e
--- /dev/null
+++ b/test/T620-lock.sh
@@ -0,0 +1,75 @@
+#!/usr/bin/env bash
+test_description="locking"
+. ./test-lib.sh || exit 1
+
+if [ "${NOTMUCH_HAVE_XAPIAN_DB_RETRY_LOCK}" = "0" ]; then
+ test_subtest_missing_external_prereq_["lock retry support"]=t
+fi
+
+add_email_corpus
+
+test_begin_subtest "blocking open"
+test_C ${MAIL_DIR} <<'EOF'
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <notmuch-test.h>
+
+void
+taggit (notmuch_database_t *db, const char *tag)
+{
+ notmuch_message_t *message;
+
+ EXPECT0 (notmuch_database_find_message (db, "4EFC743A.3060609@april.org", &message));
+ if (message == NULL) {
+ fprintf (stderr, "unable to find message");
+ exit (1);
+ }
+
+ EXPECT0 (notmuch_message_add_tag (message, tag));
+ notmuch_message_destroy (message);
+}
+
+int
+main (int argc, char **argv)
+{
+ pid_t child;
+ const char *path = argv[1];
+
+ child = fork ();
+ if (child == -1) {
+ fprintf (stderr, "fork failed\n");
+ exit (1);
+ }
+
+ if (child == 0) {
+ notmuch_database_t *db2;
+
+ sleep (1);
+ EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_WRITE, &db2));
+ taggit (db2, "child");
+ EXPECT0 (notmuch_database_close (db2));
+ } else {
+ notmuch_database_t *db;
+
+ EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_WRITE, &db));
+ taggit (db, "parent");
+ sleep (2);
+ EXPECT0 (notmuch_database_close (db));
+ wait (NULL);
+ }
+}
+
+EOF
+notmuch search --output=tags id:4EFC743A.3060609@april.org >> OUTPUT
+cat <<'EOF' >EXPECTED
+== stdout ==
+== stderr ==
+child
+inbox
+parent
+unread
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_done
--
2.8.1
next prev parent reply other threads:[~2016-06-26 15:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-26 15:29 v4 of DB_RETRY_LOCK patches David Bremner
2016-06-26 15:29 ` [PATCH 1/3] Use the Xapian::DB_RETRY_LOCK flag when available David Bremner
2016-06-29 7:10 ` David Bremner
2016-06-26 15:29 ` David Bremner [this message]
2016-06-26 15:29 ` [PATCH 3/3] lib: add built_with handling for XAPIAN_DB_RETRY_LOCK David Bremner
2016-06-26 19:24 ` v4 of DB_RETRY_LOCK patches Istvan Marko
2016-06-26 20:28 ` Tomi Ollila
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1466954985-25761-3-git-send-email-david@tethera.net \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).