--- /dev/null
+Return-Path: <bremner@tethera.net>\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 4831A429E31\r
+ for <notmuch@notmuchmail.org>; Sun, 18 Dec 2011 05:15:50 -0800 (PST)\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 Q--jq1hUts6w for <notmuch@notmuchmail.org>;\r
+ Sun, 18 Dec 2011 05:15:48 -0800 (PST)\r
+Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21])\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 57442429E26\r
+ for <notmuch@notmuchmail.org>; Sun, 18 Dec 2011 05:15:43 -0800 (PST)\r
+Received: from zancas.localnet\r
+ (fctnnbsc36w-156034079193.pppoe-dynamic.High-Speed.nb.bellaliant.net\r
+ [156.34.79.193]) (authenticated bits=0)\r
+ by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id pBIDFc0F017877\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);\r
+ Sun, 18 Dec 2011 09:15:39 -0400\r
+Received: from bremner by zancas.localnet with local (Exim 4.77)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1RcGaY-0008RG-Cd; Sun, 18 Dec 2011 09:15:38 -0400\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH Draft 2 2/9] test/hex-xcode: new test binary\r
+Date: Sun, 18 Dec 2011 09:15:04 -0400\r
+Message-Id: <1324214111-32079-3-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.7.7.3\r
+In-Reply-To: <1324214111-32079-1-git-send-email-david@tethera.net>\r
+References: <id:87sjkmuck7.fsf@gmail.com>\r
+ <1324214111-32079-1-git-send-email-david@tethera.net>\r
+Cc: David Bremner <bremner@debian.org>\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: Sun, 18 Dec 2011 13:15:50 -0000\r
+\r
+From: David Bremner <bremner@debian.org>\r
+\r
+This program is used both as a test-bed/unit-tester for\r
+../util/hex-escape.c, and also as a utility in future tests of dump\r
+and restore.\r
+---\r
+ test/.gitignore | 1 +\r
+ test/Makefile.local | 6 +++-\r
+ test/basic | 2 +-\r
+ test/hex-xcode.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ 4 files changed, 85 insertions(+), 2 deletions(-)\r
+ create mode 100644 test/hex-xcode.c\r
+\r
+diff --git a/test/.gitignore b/test/.gitignore\r
+index e63c689..be7ab5e 100644\r
+--- a/test/.gitignore\r
++++ b/test/.gitignore\r
+@@ -3,4 +3,5 @@ corpus.mail\r
+ smtp-dummy\r
+ symbol-test\r
+ arg-test\r
++hex-xcode\r
+ tmp.*\r
+diff --git a/test/Makefile.local b/test/Makefile.local\r
+index fa2df73..ec507c4 100644\r
+--- a/test/Makefile.local\r
++++ b/test/Makefile.local\r
+@@ -13,6 +13,9 @@ smtp_dummy_modules = $(smtp_dummy_srcs:.c=.o)\r
+ $(dir)/arg-test: $(dir)/arg-test.o command-line-arguments.o util/libutil.a\r
+ $(call quiet,CC) -I. $^ -o $@\r
+ \r
++$(dir)/hex-xcode: $(dir)/hex-xcode.o util/libutil.a\r
++ $(call quiet,CC) -I. $^ -o $@ -ltalloc\r
++\r
+ $(dir)/smtp-dummy: $(smtp_dummy_modules)\r
+ $(call quiet,CC) $^ -o $@\r
+ \r
+@@ -21,7 +24,8 @@ $(dir)/symbol-test: $(dir)/symbol-test.o\r
+ \r
+ .PHONY: test check\r
+ \r
+-test-binaries: $(dir)/arg-test $(dir)/smtp-dummy $(dir)/symbol-test\r
++test-binaries: $(dir)/arg-test $(dir)/hex-xcode \\r
++ $(dir)/smtp-dummy $(dir)/symbol-test\r
+ \r
+ test: all test-binaries\r
+ @${dir}/notmuch-test $(OPTIONS)\r
+diff --git a/test/basic b/test/basic\r
+index d6aed24..af57026 100755\r
+--- a/test/basic\r
++++ b/test/basic\r
+@@ -54,7 +54,7 @@ test_begin_subtest 'Ensure that all available tests will be run by notmuch-test'\r
+ eval $(sed -n -e '/^TESTS="$/,/^"$/p' $TEST_DIRECTORY/notmuch-test)\r
+ tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)\r
+ available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -executable -printf '%f\n' | \\r
+- sed -r -e "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test)$/d" | \\r
++ sed -r -e "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|hex-xcode)$/d" | \\r
+ sort)\r
+ test_expect_equal "$tests_in_suite" "$available"\r
+ \r
+diff --git a/test/hex-xcode.c b/test/hex-xcode.c\r
+new file mode 100644\r
+index 0000000..20c1603\r
+--- /dev/null\r
++++ b/test/hex-xcode.c\r
+@@ -0,0 +1,78 @@\r
++/* No, nothing to to with IDE from Apple Inc.\r
++ testbed for ../util/hex-escape.c.\r
++\r
++ usage: hex-xcode (e|d) < foo\r
++\r
++ e is for encode\r
++ d is for decode\r
++ */\r
++\r
++#include "notmuch-client.h"\r
++#include "hex-escape.h"\r
++#include <assert.h>\r
++\r
++static int\r
++xcode (void *ctx, char dir, char *in, char **buf_p, size_t *size_p)\r
++{\r
++ hex_status_t status;\r
++\r
++ if (dir == 'e')\r
++ status = hex_encode (ctx, in, buf_p, size_p);\r
++ else\r
++ status = hex_decode (ctx, in, buf_p, size_p);\r
++\r
++ if (status == HEX_SUCCESS)\r
++ puts (*buf_p);\r
++\r
++ return status;\r
++}\r
++\r
++\r
++int\r
++main (int argc, char **argv)\r
++{\r
++\r
++ assert (argc > 1 && argv[1]);\r
++\r
++ char dir = argv[1][0];\r
++\r
++ void *ctx = talloc_new (NULL);\r
++\r
++ char *line = NULL;\r
++ size_t line_size;\r
++ ssize_t line_len;\r
++\r
++ char *buffer = NULL;\r
++ size_t buf_size = 0;\r
++\r
++ int arg_index = 2;\r
++ notmuch_bool_t read_stdin = TRUE;\r
++\r
++ for (arg_index = 2; arg_index < argc; arg_index++) {\r
++\r
++ if (xcode (ctx, dir, argv[arg_index],\r
++ &buffer, &buf_size) != HEX_SUCCESS)\r
++ return 1;\r
++\r
++ read_stdin = FALSE;\r
++ }\r
++\r
++ if (!read_stdin)\r
++ return 0;\r
++\r
++ while ((line_len = getline (&line, &line_size, stdin)) != -1) {\r
++\r
++ chomp_newline (line);\r
++\r
++ if (xcode (ctx, dir, line, &buffer, &buf_size) != HEX_SUCCESS)\r
++ return 1;\r
++\r
++ }\r
++\r
++ if (line)\r
++ free (line);\r
++\r
++ talloc_free (ctx);\r
++\r
++ return 0;\r
++}\r
+-- \r
+1.7.7.3\r
+\r