[PATCH v2 06/14] test: Tool to build DB with specific version and features
authorAustin Clements <amdragon@MIT.EDU>
Tue, 29 Jul 2014 16:48:04 +0000 (12:48 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:03:56 +0000 (10:03 -0800)
14/49cd967dcd28b1e4bbeb62e9a6fc6ef1e5f42d [new file with mode: 0644]

diff --git a/14/49cd967dcd28b1e4bbeb62e9a6fc6ef1e5f42d b/14/49cd967dcd28b1e4bbeb62e9a6fc6ef1e5f42d
new file mode 100644 (file)
index 0000000..87f5451
--- /dev/null
@@ -0,0 +1,161 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id F0D4B431FD8\r
+       for <notmuch@notmuchmail.org>; Tue, 29 Jul 2014 09:49:12 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id ugfjXxNrCCLU for <notmuch@notmuchmail.org>;\r
+       Tue, 29 Jul 2014 09:49:07 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-2.mit.edu (dmz-mailsec-scanner-2.mit.edu\r
+       [18.9.25.13])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 37D4E431FD9\r
+       for <notmuch@notmuchmail.org>; Tue, 29 Jul 2014 09:48:30 -0700 (PDT)\r
+X-AuditID: 1209190d-f79c06d000002f07-aa-53d7d05de0b6\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+       (using TLS with cipher AES256-SHA (256/256 bits))\r
+       (Client did not present a certificate)\r
+       by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 3E.0D.12039.D50D7D35; Tue, 29 Jul 2014 12:48:29 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+       by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id s6TGmI2U003294; \r
+       Tue, 29 Jul 2014 12:48:18 -0400\r
+Received: from drake.dyndns.org (31-33-71.wireless.csail.mit.edu\r
+       [128.31.33.71]) (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s6TGmFCk030256\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Tue, 29 Jul 2014 12:48:17 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1XCAZS-0007Gq-Qs; Tue, 29 Jul 2014 12:48:14 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 06/14] test: Tool to build DB with specific version and\r
+       features\r
+Date: Tue, 29 Jul 2014 12:48:04 -0400\r
+Message-Id: <1406652492-27803-7-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 2.0.0\r
+In-Reply-To: <1406652492-27803-1-git-send-email-amdragon@mit.edu>\r
+References: <1406652492-27803-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrLIsWRmVeSWpSXmKPExsUixG6noht74XqwwdYHyhar5/JYXL85k9mB\r
+       yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgyuhbeYe5YKpQxbHdO5gbGK/wdTFyckgImEj8\r
+       fv+MBcIWk7hwbz1bFyMXh5DAbCaJRZ8mskM4Gxklmh9Pg3KOMUk0Hp3CDOHMZZR49e4bE0g/\r
+       m4CGxLb9yxlBbBEBaYmdd2ezgtjMAo4Sn/cvYgOxhQWCJX68uwAWZxFQlTjdOB0szivgIHHh\r
+       SwsjxB1yEg03PoHFOYF6b927CzZfCKjm0KzNLBMY+RcwMqxilE3JrdLNTczMKU5N1i1OTszL\r
+       Sy3SNdLLzSzRS00p3cQICiVOSd4djO8OKh1iFOBgVOLh5VhwLViINbGsuDL3EKMkB5OSKK/e\r
+       vuvBQnxJ+SmVGYnFGfFFpTmpxYcYJTiYlUR4+c4C5XhTEiurUovyYVLSHCxK4rxvra2ChQTS\r
+       E0tSs1NTC1KLYLIyHBxKErxrzwM1ChalpqdWpGXmlCCkmTg4QYbzAA3fB1LDW1yQmFucmQ6R\r
+       P8WoKCXOm30OKCEAksgozYPrhcX6K0ZxoFeEedtA2nmAaQKu+xXQYCagwawuYINLEhFSUg2M\r
+       rp9v7379MCXdljGXvS907a7tIbKPBIJFVvesYXGSMrLptb9nZrXnw4QvMRHz5izctPFPzL2s\r
+       VzeTDyz93SoaPOXxYT8t5rySxZ45SdHx9oHzijbEKZWaHjDKqrP6GNyk3fWzWK6raW2phHjc\r
+       0R1Rj8SPLd+c8zHkY3bPESMj4eKAyN9/GZYqsRRnJBpqMRcVJwIAbOFz5tACAAA=\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://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: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 29 Jul 2014 16:49:13 -0000\r
+\r
+This will let us test basic version and feature handling.\r
+---\r
+ test/.gitignore         |  1 +\r
+ test/Makefile.local     |  4 ++++\r
+ test/make-db-version.cc | 35 +++++++++++++++++++++++++++++++++++\r
+ 3 files changed, 40 insertions(+)\r
+ create mode 100644 test/make-db-version.cc\r
+\r
+diff --git a/test/.gitignore b/test/.gitignore\r
+index b3b706d..0f7d5bf 100644\r
+--- a/test/.gitignore\r
++++ b/test/.gitignore\r
+@@ -5,5 +5,6 @@ parse-time\r
+ random-corpus\r
+ smtp-dummy\r
+ symbol-test\r
++make-db-version\r
+ test-results\r
+ tmp.*\r
+diff --git a/test/Makefile.local b/test/Makefile.local\r
+index 916dd0b..a2d58fc 100644\r
+--- a/test/Makefile.local\r
++++ b/test/Makefile.local\r
+@@ -35,6 +35,9 @@ $(dir)/symbol-test: $(dir)/symbol-test.o lib/$(LINKER_NAME)\r
+ $(dir)/parse-time: $(dir)/parse-time.o parse-time-string/parse-time-string.o\r
+       $(call quiet,CC) $^ -o $@\r
\r
++$(dir)/make-db-version: $(dir)/make-db-version.o\r
++      $(call quiet,CXX) $^ -o $@ $(XAPIAN_LDFLAGS)\r
++\r
+ .PHONY: test check\r
\r
+ test_main_srcs=$(dir)/arg-test.c \\r
+@@ -43,6 +46,7 @@ test_main_srcs=$(dir)/arg-test.c \\r
+             $(dir)/parse-time.c \\r
+             $(dir)/smtp-dummy.c \\r
+             $(dir)/symbol-test.cc \\r
++            $(dir)/make-db-version.cc \\r
\r
+ test_srcs=$(test_main_srcs) $(dir)/database-test.c\r
\r
+diff --git a/test/make-db-version.cc b/test/make-db-version.cc\r
+new file mode 100644\r
+index 0000000..fa80cac\r
+--- /dev/null\r
++++ b/test/make-db-version.cc\r
+@@ -0,0 +1,35 @@\r
++/* Create an empty notmuch database with a specific version and\r
++ * features. */\r
++\r
++#include <stdio.h>\r
++#include <stdlib.h>\r
++#include <sys/stat.h>\r
++#include <sys/types.h>\r
++\r
++#include <xapian.h>\r
++\r
++int main(int argc, char **argv)\r
++{\r
++    if (argc != 4) {\r
++      fprintf (stderr, "Usage: %s mailpath version features\n", argv[0]);\r
++      exit (2);\r
++    }\r
++\r
++    std::string nmpath (argv[1]);\r
++    nmpath += "/.notmuch";\r
++    if (mkdir (nmpath.c_str (), 0777) < 0) {\r
++      perror (("failed to create " + nmpath).c_str ());\r
++      exit (1);\r
++    }\r
++\r
++    try {\r
++      Xapian::WritableDatabase db (\r
++          nmpath + "/xapian", Xapian::DB_CREATE_OR_OPEN);\r
++      db.set_metadata ("version", argv[2]);\r
++      db.set_metadata ("features", argv[3]);\r
++      db.commit ();\r
++    } catch (const Xapian::Error &e) {\r
++      fprintf (stderr, "%s\n", e.get_description ().c_str ());\r
++      exit (1);\r
++    }\r
++}\r
+-- \r
+2.0.0\r
+\r