From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 135E3431FC7 for ; Sat, 26 Jul 2014 20:53:30 -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 4ReiTNrmX+9K for ; Sat, 26 Jul 2014 20:53:24 -0700 (PDT) Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu [18.7.68.37]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 76C0E431FCB for ; Sat, 26 Jul 2014 20:53:08 -0700 (PDT) X-AuditID: 12074425-f79766d000006da8-b9-53d477a051ef Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) (using TLS with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP id C0.5E.28072.0A774D35; Sat, 26 Jul 2014 23:53:04 -0400 (EDT) Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id s6R3r20P009547; Sat, 26 Jul 2014 23:53:03 -0400 Received: from drake.dyndns.org (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com [216.15.114.40]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s6R3r05D016398 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sat, 26 Jul 2014 23:53:02 -0400 Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1XBFW8-00051L-AV; Sat, 26 Jul 2014 23:53:00 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 06/14] test: Tool to build DB with specific version and features Date: Sat, 26 Jul 2014 23:52:45 -0400 Message-Id: <1406433173-19169-7-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1406433173-19169-1-git-send-email-amdragon@mit.edu> References: <1406433173-19169-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsUixG6nrrug/EqwweOr7BbXb85kdmD0eLbq FnMAYxSXTUpqTmZZapG+XQJXRt/KO8wFU4Uqju3ewdzAeIWvi5GTQ0LARGLO9f9MELaYxIV7 69m6GLk4hARmM0ms+ncfytnIKLH8wy0mCOcOk8T+C5/ZIZy5jBJbl2xkBOlnE9CQ2LZ/OZgt IiAtsfPubNYuRg4OZgE1iT9dKiBhYYEAid2LmphBbBYBVYm9l1+BlfMKOEi0bD/GBnGGnETD jU9gNqeAo8TxZyfYQMYIAdXcupQ4gZF/ASPDKkbZlNwq3dzEzJzi1GTd4uTEvLzUIl0LvdzM Er3UlNJNjOCgcVHdwTjhkNIhRgEORiUeXgGWK8FCrIllxZW5hxglOZiURHn3mwGF+JLyUyoz Eosz4otKc1KLDzFKcDArifAKFQPleFMSK6tSi/JhUtIcLErivG+trYKFBNITS1KzU1MLUotg sjIcHEoSvF9LgRoFi1LTUyvSMnNKENJMHJwgw3mAhm8AqeEtLkjMLc5Mh8ifYlSUEuf9BZIQ AElklObB9cKi+hWjONArwrysZUBVPMCEANf9CmgwE9BgFv/LIINLEhFSUg2MK7+9P1e5o3fJ jvY9JzRS/l1IdLkddHuVp/c6teTGDW6TVuu45iw7s5ShdN9szrVH4s8H36hcHnqCR/K7zetT RyeLb/i34+XpQGf/JyHSxcJ7Lb+eXrMwP/6ILM8VT3Nz96n379wOvFS5iikuc8tThuk/dJ8b zjgr+TXLQ+xFm3T+sZoJrRalFkosxRmJhlrMRcWJAHrqYSLFAgAA 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: Sun, 27 Jul 2014 03:53:30 -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