From: Austin Clements Date: Fri, 1 Aug 2014 02:09:55 +0000 (+2000) Subject: [PATCH v3 05/13] test: Tool to build DB with specific version and features X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f5722ba0f2ded924e75f9a2d00c98deefef85d92;p=notmuch-archives.git [PATCH v3 05/13] test: Tool to build DB with specific version and features --- diff --git a/f1/c359e0c42fc4bb42f595b496db071fb5160ecf b/f1/c359e0c42fc4bb42f595b496db071fb5160ecf new file mode 100644 index 000000000..a09107df9 --- /dev/null +++ b/f1/c359e0c42fc4bb42f595b496db071fb5160ecf @@ -0,0 +1,162 @@ +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 9D02A429E29 + for ; Thu, 31 Jul 2014 19:10:35 -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 ntc7rUpMUqrz for ; + Thu, 31 Jul 2014 19:10:29 -0700 (PDT) +Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.mit.edu + [18.9.25.14]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 94F13431FC3 + for ; Thu, 31 Jul 2014 19:10:13 -0700 (PDT) +X-AuditID: 1209190e-f79946d000007db1-3a-53daf7036d8d +Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) + (using TLS with cipher AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP + id 43.DF.32177.307FAD35; Thu, 31 Jul 2014 22:10:11 -0400 (EDT) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id s712AA4e008864; + Thu, 31 Jul 2014 22:10:11 -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 s712A6Hj029979 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Thu, 31 Jul 2014 22:10:10 -0400 +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1XD2IH-00033f-W6; Thu, 31 Jul 2014 22:10:05 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH v3 05/13] test: Tool to build DB with specific version and + features +Date: Thu, 31 Jul 2014 22:09:55 -0400 +Message-Id: <1406859003-11561-6-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 2.0.0 +In-Reply-To: <1406859003-11561-1-git-send-email-amdragon@mit.edu> +References: <1406859003-11561-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrLIsWRmVeSWpSXmKPExsUixCmqrcv8/VawwYV3shar5/JYXL85k9mB + yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgyuhbeYe5YKpQxbHdO5gbGK/wdTFyckgImEj8 + /32IFcIWk7hwbz1bFyMXh5DAbCaJr5++s0A4Gxklbh26zATh3GGSWP/nAjOEM5dR4s6Bc0wg + /WwCGhLb9i9nBLFFBKQldt6dDTaXWcBR4vP+RWwgtrBAsMS7hhnMIDaLgKrEuUPvwWp4BRwk + 3t95yQJxh5xEw41PYPWcQL3//y0AqxECqmk9vZV5AiP/AkaGVYyyKblVurmJmTnFqcm6xcmJ + eXmpRbrGermZJXqpKaWbGMGhJMm3g/HrQaVDjAIcjEo8vDPCbwULsSaWFVfmHmKU5GBSEuW1 + +QgU4kvKT6nMSCzOiC8qzUktPsQowcGsJML78gNQjjclsbIqtSgfJiXNwaIkzvvW2ipYSCA9 + sSQ1OzW1ILUIJivDwaEkwXvmK1CjYFFqempFWmZOCUKaiYMTZDgP0HChbyDDiwsSc4sz0yHy + pxgVpcR594A0C4AkMkrz4Hphsf6KURzoFWHehyBVPMA0Adf9CmgwE9Dg57eugwwuSURISTUw + 1rWor1Ct8855wrlzFteLIxVaGfqipwTELH9EGNuvWzDfJaBoEYf3o8oZmmxFKyU5PRtd58hv + m6/y8IV3lPWdqjV7l/dn/MgMi7H45pYkHbnf299a49cx00eOR+fFin9cJWzCvsGVeSGj1ZHT + LNNylyQFi7+9/9E7+M/ZRYpf0sIdmI0v/61UYinOSDTUYi4qTgQAV4B4vNACAAA= +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: Fri, 01 Aug 2014 02:10:36 -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 +