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 E91BB431FAE for ; Mon, 25 Aug 2014 10:28:48 -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 dsSTlM1aWbI2 for ; Mon, 25 Aug 2014 10:28:44 -0700 (PDT) Received: from dmz-mailsec-scanner-6.mit.edu (dmz-mailsec-scanner-6.mit.edu [18.7.68.35]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 692D9431FBC for ; Mon, 25 Aug 2014 10:28:17 -0700 (PDT) X-AuditID: 12074423-f799d6d00000337c-42-53fb7230f575 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-6.mit.edu (Symantec Messaging Gateway) with SMTP id 4B.C0.13180.0327BF35; Mon, 25 Aug 2014 13:28:16 -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 s7PHQENf001077; Mon, 25 Aug 2014 13:26:15 -0400 Received: from drake.dyndns.org (31-35-14.wireless.csail.mit.edu [128.31.35.14]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s7PHQCJQ029609 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Mon, 25 Aug 2014 13:26:13 -0400 Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1XLy1z-0003jP-U8; Mon, 25 Aug 2014 13:26:11 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v4 03/11] test: Tool to build DB with specific version and features Date: Mon, 25 Aug 2014 13:26:01 -0400 Message-Id: <1408987569-14146-4-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1408987569-14146-1-git-send-email-amdragon@mit.edu> References: <1408987569-14146-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOIsWRmVeSWpSXmKPExsUixG6nrmtQ9DvY4O8MS4sbrd2MFk3TnS2u 35zJ7MDscev+a3aPZ6tuMXtsOfSeOYA5issmJTUnsyy1SN8ugSujb+Ud5oKpQhXHdu9gbmC8 wtfFyMkhIWAi8eLtchYIW0ziwr31bF2MXBxCArOZJCbO64NyNjJKrF3YzQrhHGOSOHd4DlRm LqPEh7ZPzCD9bAIaEr9vLWYCsUUEpCV23p3NCmIzC3hJLLvQD2YLCwRLbOxbxQ5iswioSvRN XARm8wo4SCw50gt1h5xEw41PbCA2p4CjxPSFs8FmCgHVfL98nnkCI/8CRoZVjLIpuVW6uYmZ OcWpybrFyYl5ealFumZ6uZkleqkppZsYweHloryD8c9BpUOMAhyMSjy8N+J/BwuxJpYVV+Ye YpTkYFIS5Z2WDxTiS8pPqcxILM6ILyrNSS0+xCjBwawkwtsMkuNNSaysSi3Kh0lJc7AoifO+ tbYKFhJITyxJzU5NLUgtgsnKcHAoSfDmFgA1ChalpqdWpGXmlCCkmTg4QYbzAA2PB6nhLS5I zC3OTIfIn2JUlBLnXQuyVQAkkVGaB9cLi/9XjOJArwjzHgVp5wGmDrjuV0CDmYAGm/b8BBlc koiQkmpgVL71Xr580uKoifuWX7K4o+98a/Kpw7eaGj/Z+UmGsx59vMj9HNuz/401jTN/bP80 JdW05aDPU3ahX/vmRpY0VtSnzj4p3xu8a3nMj/TI/WrSC789VJzCOS184d2j92qDH+0+s6Es 3PLAYo37cybHiUzsOvKGnVvtaNP99CXNb7+L/lniwxekmKrEUpyRaKjFXFScCAANnDXA2gIA AA== 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: Mon, 25 Aug 2014 17:28:49 -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