--- /dev/null
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 292706DE091C\r
+ for <notmuch@notmuchmail.org>; Sat, 4 Jun 2016 05:29:59 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.012\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.012 tagged_above=-999 required=5\r
+ tests=[AWL=-0.001, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id A5hDbifBI6dc for <notmuch@notmuchmail.org>;\r
+ Sat, 4 Jun 2016 05:29:51 -0700 (PDT)\r
+Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 8A5886DE0261\r
+ for <notmuch@notmuchmail.org>; Sat, 4 Jun 2016 05:29:34 -0700 (PDT)\r
+Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1b9Ahc-0004z6-SF; Sat, 04 Jun 2016 08:29:20 -0400\r
+Received: (nullmailer pid 23495 invoked by uid 1000);\r
+ Sat, 04 Jun 2016 12:29:27 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: Istvan Marko <notmuch@kismala.com>, Jani Nikula <jani@nikula.org>,\r
+ notmuch@notmuchmail.org\r
+Subject: [PATCH 3/4] test: initial tests for locking retry\r
+Date: Sat, 4 Jun 2016 09:29:15 -0300\r
+Message-Id: <1465043356-23420-4-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.8.1\r
+In-Reply-To: <1465043356-23420-1-git-send-email-david@tethera.net>\r
+References: <m3wpnb0xc6.fsf@zsu.kismala.com>\r
+ <1465043356-23420-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 04 Jun 2016 12:29:59 -0000\r
+\r
+Currently there's not much to test, so we simulate contention, and check\r
+that the modifications to the database are serialized.\r
+---\r
+ test/T620-lock.sh | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ 1 file changed, 75 insertions(+)\r
+ create mode 100755 test/T620-lock.sh\r
+\r
+diff --git a/test/T620-lock.sh b/test/T620-lock.sh\r
+new file mode 100755\r
+index 0000000..f46475e\r
+--- /dev/null\r
++++ b/test/T620-lock.sh\r
+@@ -0,0 +1,75 @@\r
++#!/usr/bin/env bash\r
++test_description="locking"\r
++. ./test-lib.sh || exit 1\r
++\r
++if [ "${NOTMUCH_HAVE_XAPIAN_DB_RETRY_LOCK}" = "0" ]; then\r
++ test_subtest_missing_external_prereq_["lock retry support"]=t\r
++fi\r
++\r
++add_email_corpus\r
++\r
++test_begin_subtest "blocking open"\r
++test_C ${MAIL_DIR} <<'EOF'\r
++#include <unistd.h>\r
++#include <stdlib.h>\r
++#include <sys/wait.h>\r
++#include <notmuch-test.h>\r
++\r
++void\r
++taggit (notmuch_database_t *db, const char *tag)\r
++{\r
++ notmuch_message_t *message;\r
++\r
++ EXPECT0 (notmuch_database_find_message (db, "4EFC743A.3060609@april.org", &message));\r
++ if (message == NULL) {\r
++ fprintf (stderr, "unable to find message");\r
++ exit (1);\r
++ }\r
++\r
++ EXPECT0 (notmuch_message_add_tag (message, tag));\r
++ notmuch_message_destroy (message);\r
++}\r
++\r
++int\r
++main (int argc, char **argv)\r
++{\r
++ pid_t child;\r
++ const char *path = argv[1];\r
++\r
++ child = fork ();\r
++ if (child == -1) {\r
++ fprintf (stderr, "fork failed\n");\r
++ exit (1);\r
++ }\r
++\r
++ if (child == 0) {\r
++ notmuch_database_t *db2;\r
++\r
++ sleep (1);\r
++ EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_WRITE, &db2));\r
++ taggit (db2, "child");\r
++ EXPECT0 (notmuch_database_close (db2));\r
++ } else {\r
++ notmuch_database_t *db;\r
++\r
++ EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_WRITE, &db));\r
++ taggit (db, "parent");\r
++ sleep (2);\r
++ EXPECT0 (notmuch_database_close (db));\r
++ wait (NULL);\r
++ }\r
++}\r
++\r
++EOF\r
++notmuch search --output=tags id:4EFC743A.3060609@april.org >> OUTPUT\r
++cat <<'EOF' >EXPECTED\r
++== stdout ==\r
++== stderr ==\r
++child\r
++inbox\r
++parent\r
++unread\r
++EOF\r
++test_expect_equal_file EXPECTED OUTPUT\r
++\r
++test_done\r
+-- \r
+2.8.1\r
+\r