1 Return-Path: <bremner@tesseract.cs.unb.ca>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 2EB4B429E3C
\r
6 for <notmuch@notmuchmail.org>; Tue, 14 Aug 2012 02:03:00 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id vWccwqQCVDDU for <notmuch@notmuchmail.org>;
\r
16 Tue, 14 Aug 2012 02:02:58 -0700 (PDT)
\r
17 Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])
\r
18 (using TLSv1 with cipher AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 424A4431FC7
\r
21 for <notmuch@notmuchmail.org>; Tue, 14 Aug 2012 02:02:58 -0700 (PDT)
\r
22 Received: from remotemail by tesseract.cs.unb.ca with local (Exim 4.72)
\r
23 (envelope-from <bremner@tesseract.cs.unb.ca>)
\r
24 id 1T1D1d-00062T-Ol; Tue, 14 Aug 2012 06:02:57 -0300
\r
25 Received: (nullmailer pid 5274 invoked by uid 1000);
\r
26 Mon, 13 Aug 2012 20:14:06 -0000
\r
27 From: David Bremner <bremner@debian.org>
\r
28 To: notmuch@notmuchmail.org
\r
29 Subject: [Patch v2 2/6] test/hex-xcode: new test binary
\r
30 Date: Mon, 13 Aug 2012 22:13:47 +0200
\r
31 Message-Id: <1344888831-4301-3-git-send-email-bremner@debian.org>
\r
32 X-Mailer: git-send-email 1.7.10.4
\r
33 In-Reply-To: <1344888831-4301-1-git-send-email-bremner@debian.org>
\r
34 References: <1344888831-4301-1-git-send-email-bremner@debian.org>
\r
35 Cc: David Bremner <bremner@debian.org>
\r
36 X-BeenThere: notmuch@notmuchmail.org
\r
37 X-Mailman-Version: 2.1.13
\r
39 List-Id: "Use and development of the notmuch mail system."
\r
40 <notmuch.notmuchmail.org>
\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
42 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
44 List-Post: <mailto:notmuch@notmuchmail.org>
\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
48 X-List-Received-Date: Tue, 14 Aug 2012 09:03:00 -0000
\r
50 This program is used both as a test-bed/unit-tester for
\r
51 ../util/hex-escape.c, and also as a utility in future tests of dump
\r
54 test/.gitignore | 1 +
\r
55 test/Makefile.local | 10 ++++-
\r
57 test/hex-xcode.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++
\r
58 4 files changed, 114 insertions(+), 2 deletions(-)
\r
59 create mode 100644 test/hex-xcode.c
\r
61 diff --git a/test/.gitignore b/test/.gitignore
\r
62 index e63c689..be7ab5e 100644
\r
63 --- a/test/.gitignore
\r
64 +++ b/test/.gitignore
\r
65 @@ -3,4 +3,5 @@ corpus.mail
\r
71 diff --git a/test/Makefile.local b/test/Makefile.local
\r
72 index c7f1435..ab13814 100644
\r
73 --- a/test/Makefile.local
\r
74 +++ b/test/Makefile.local
\r
75 @@ -13,6 +13,9 @@ smtp_dummy_modules = $(smtp_dummy_srcs:.c=.o)
\r
76 $(dir)/arg-test: $(dir)/arg-test.o command-line-arguments.o util/libutil.a
\r
77 $(call quiet,CC) -I. $^ -o $@
\r
79 +$(dir)/hex-xcode: $(dir)/hex-xcode.o command-line-arguments.o util/libutil.a
\r
80 + $(call quiet,CC) -I. $^ -o $@ -ltalloc
\r
82 $(dir)/smtp-dummy: $(smtp_dummy_modules)
\r
83 $(call quiet,CC) $^ -o $@
\r
85 @@ -21,7 +24,12 @@ $(dir)/symbol-test: $(dir)/symbol-test.o
\r
89 -test-binaries: $(dir)/arg-test $(dir)/smtp-dummy $(dir)/symbol-test
\r
90 +TEST_BINARIES=$(dir)/arg-test \
\r
91 + $(dir)/hex-xcode \
\r
92 + $(dir)/smtp-dummy \
\r
93 + $(dir)/symbol-test
\r
95 +test-binaries: $(TEST_BINARIES)
\r
97 test: all test-binaries
\r
98 @${dir}/notmuch-test $(OPTIONS)
\r
99 diff --git a/test/basic b/test/basic
\r
100 index d6aed24..3eebb37 100755
\r
103 @@ -54,7 +54,7 @@ test_begin_subtest 'Ensure that all available tests will be run by notmuch-test'
\r
104 eval $(sed -n -e '/^TESTS="$/,/^"$/p' $TEST_DIRECTORY/notmuch-test)
\r
105 tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)
\r
106 available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -executable -printf '%f\n' | \
\r
107 - sed -r -e "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test)$/d" | \
\r
108 + sed -r -e "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|hex-escape)$/d" | \
\r
110 test_expect_equal "$tests_in_suite" "$available"
\r
112 diff --git a/test/hex-xcode.c b/test/hex-xcode.c
\r
113 new file mode 100644
\r
114 index 0000000..eec6541
\r
116 +++ b/test/hex-xcode.c
\r
118 +/* No, nothing to to with IDE from Apple Inc.
\r
119 + testbed for ../util/hex-escape.c.
\r
122 + hex-xcode [--direction=(encode|decode)] [--omit-newline] < file
\r
123 + hex-xcode [--direction=(encode|decode)] [--omit-newline] arg1 arg2 arg3 ...
\r
127 +#include "notmuch-client.h"
\r
128 +#include "hex-escape.h"
\r
129 +#include <assert.h>
\r
138 +xcode (void *ctx, enum direction dir, char *in, char **buf_p, size_t *size_p)
\r
140 + hex_status_t status;
\r
142 + if (dir == ENCODE)
\r
143 + status = hex_encode (ctx, in, buf_p, size_p);
\r
145 + status = hex_decode (ctx, in, buf_p, size_p);
\r
147 + if (status == HEX_SUCCESS)
\r
148 + fputs (*buf_p, stdout);
\r
155 +main (int argc, char **argv)
\r
159 + enum direction dir = DECODE;
\r
160 + int omit_newline = FALSE;
\r
162 + notmuch_opt_desc_t options[] = {
\r
163 + { NOTMUCH_OPT_KEYWORD, &dir, "direction", 'd',
\r
164 + (notmuch_keyword_t []){ { "encode", ENCODE },
\r
165 + { "decode", DECODE },
\r
167 + { NOTMUCH_OPT_BOOLEAN, &omit_newline, "omit-newline", 'n', 0 },
\r
168 + { 0, 0, 0, 0, 0 }
\r
171 + int opt_index = parse_arguments (argc, argv, options, 1);
\r
173 + if (opt_index < 0)
\r
176 + void *ctx = talloc_new (NULL);
\r
178 + char *line = NULL;
\r
179 + size_t line_size;
\r
180 + ssize_t line_len;
\r
182 + char *buffer = NULL;
\r
183 + size_t buf_size = 0;
\r
185 + notmuch_bool_t read_stdin = TRUE;
\r
187 + for (; opt_index < argc; opt_index++) {
\r
189 + if (xcode (ctx, dir, argv[opt_index],
\r
190 + &buffer, &buf_size) != HEX_SUCCESS)
\r
193 + if (!omit_newline)
\r
196 + read_stdin = FALSE;
\r
202 + while ((line_len = getline (&line, &line_size, stdin)) != -1) {
\r
204 + chomp_newline (line);
\r
206 + if (xcode (ctx, dir, line, &buffer, &buf_size) != HEX_SUCCESS)
\r
209 + if (!omit_newline)
\r
217 + talloc_free (ctx);
\r