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