1 Return-Path: <bremner@tethera.net>
\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 E66B8431FDE
\r
6 for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 13:20:33 -0800 (PST)
\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 lN7Y23ux6kKm for <notmuch@notmuchmail.org>;
\r
16 Sat, 24 Nov 2012 13:20:32 -0800 (PST)
\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 8DB6C431FB6
\r
21 for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 13:20:32 -0800 (PST)
\r
22 Received: from fctnnbsc30w-156034089108.dhcp-dynamic.fibreop.nb.bellaliant.net
\r
23 ([156.34.89.108] helo=zancas.localnet)
\r
24 by tesseract.cs.unb.ca with esmtpsa
\r
25 (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72)
\r
26 (envelope-from <bremner@tethera.net>)
\r
27 id 1TcN9L-0006SI-9f; Sat, 24 Nov 2012 17:20:31 -0400
\r
28 Received: from bremner by zancas.localnet with local (Exim 4.80)
\r
29 (envelope-from <bremner@tethera.net>)
\r
30 id 1TcN9F-0008CT-R9; Sat, 24 Nov 2012 17:20:25 -0400
\r
31 From: david@tethera.net
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [Patch v2 02/17] test/hex-xcode: new test binary
\r
34 Date: Sat, 24 Nov 2012 17:20:02 -0400
\r
35 Message-Id: <1353792017-31459-3-git-send-email-david@tethera.net>
\r
36 X-Mailer: git-send-email 1.7.10.4
\r
37 In-Reply-To: <1353792017-31459-1-git-send-email-david@tethera.net>
\r
38 References: <1353792017-31459-1-git-send-email-david@tethera.net>
\r
40 Cc: David Bremner <bremner@debian.org>
\r
41 X-BeenThere: notmuch@notmuchmail.org
\r
42 X-Mailman-Version: 2.1.13
\r
44 List-Id: "Use and development of the notmuch mail system."
\r
45 <notmuch.notmuchmail.org>
\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
49 List-Post: <mailto:notmuch@notmuchmail.org>
\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
53 X-List-Received-Date: Sat, 24 Nov 2012 21:20:34 -0000
\r
55 From: David Bremner <bremner@debian.org>
\r
57 This program is used both as a test-bed/unit-tester for
\r
58 ../util/hex-escape.c, and also as a utility in future tests of dump
\r
61 test/.gitignore | 1 +
\r
62 test/Makefile.local | 13 ++++++-
\r
64 test/hex-xcode.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++
\r
65 4 files changed, 116 insertions(+), 2 deletions(-)
\r
66 create mode 100644 test/hex-xcode.c
\r
68 diff --git a/test/.gitignore b/test/.gitignore
\r
69 index e63c689..be7ab5e 100644
\r
70 --- a/test/.gitignore
\r
71 +++ b/test/.gitignore
\r
72 @@ -3,4 +3,5 @@ corpus.mail
\r
78 diff --git a/test/Makefile.local b/test/Makefile.local
\r
79 index 9ae130a..8da4c56 100644
\r
80 --- a/test/Makefile.local
\r
81 +++ b/test/Makefile.local
\r
82 @@ -13,6 +13,9 @@ smtp_dummy_modules = $(smtp_dummy_srcs:.c=.o)
\r
83 $(dir)/arg-test: $(dir)/arg-test.o command-line-arguments.o util/libutil.a
\r
84 $(call quiet,CC) -I. $^ -o $@
\r
86 +$(dir)/hex-xcode: $(dir)/hex-xcode.o command-line-arguments.o util/libutil.a
\r
87 + $(call quiet,CC) -I. $^ -o $@ -ltalloc
\r
89 $(dir)/smtp-dummy: $(smtp_dummy_modules)
\r
90 $(call quiet,CC) $^ -o $@
\r
92 @@ -24,8 +27,13 @@ $(dir)/parse-time: $(dir)/parse-time.o parse-time-string/parse-time-string.o
\r
96 -test-binaries: $(dir)/arg-test $(dir)/smtp-dummy $(dir)/symbol-test \
\r
98 +TEST_BINARIES=$(dir)/arg-test \
\r
99 + $(dir)/hex-xcode \
\r
100 + $(dir)/parse-time \
\r
101 + $(dir)/smtp-dummy \
\r
102 + $(dir)/symbol-test
\r
104 +test-binaries: $(TEST_BINARIES)
\r
106 test: all test-binaries
\r
107 @${dir}/notmuch-test $(OPTIONS)
\r
108 @@ -36,5 +44,6 @@ SRCS := $(SRCS) $(smtp_dummy_srcs)
\r
109 CLEAN := $(CLEAN) $(dir)/smtp-dummy $(dir)/smtp-dummy.o \
\r
110 $(dir)/symbol-test $(dir)/symbol-test.o \
\r
111 $(dir)/arg-test $(dir)/arg-test.o \
\r
112 + $(dir)/hex-xcode $(dir)/hex-xcode.o \
\r
113 $(dir)/parse-time $(dir)/parse-time.o \
\r
114 $(dir)/corpus.mail $(dir)/test-results $(dir)/tmp.*
\r
115 diff --git a/test/basic b/test/basic
\r
116 index 1b842d2..2a571ac 100755
\r
119 @@ -56,6 +56,7 @@ tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)
\r
120 available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -perm +111 \
\r
121 ! -name aggregate-results.sh \
\r
123 + ! -name hex-xcode \
\r
124 ! -name notmuch-test \
\r
125 ! -name parse-time \
\r
126 ! -name smtp-dummy \
\r
127 diff --git a/test/hex-xcode.c b/test/hex-xcode.c
\r
128 new file mode 100644
\r
129 index 0000000..eec6541
\r
131 +++ b/test/hex-xcode.c
\r
133 +/* No, nothing to to with IDE from Apple Inc.
\r
134 + testbed for ../util/hex-escape.c.
\r
137 + hex-xcode [--direction=(encode|decode)] [--omit-newline] < file
\r
138 + hex-xcode [--direction=(encode|decode)] [--omit-newline] arg1 arg2 arg3 ...
\r
142 +#include "notmuch-client.h"
\r
143 +#include "hex-escape.h"
\r
144 +#include <assert.h>
\r
153 +xcode (void *ctx, enum direction dir, char *in, char **buf_p, size_t *size_p)
\r
155 + hex_status_t status;
\r
157 + if (dir == ENCODE)
\r
158 + status = hex_encode (ctx, in, buf_p, size_p);
\r
160 + status = hex_decode (ctx, in, buf_p, size_p);
\r
162 + if (status == HEX_SUCCESS)
\r
163 + fputs (*buf_p, stdout);
\r
170 +main (int argc, char **argv)
\r
174 + enum direction dir = DECODE;
\r
175 + int omit_newline = FALSE;
\r
177 + notmuch_opt_desc_t options[] = {
\r
178 + { NOTMUCH_OPT_KEYWORD, &dir, "direction", 'd',
\r
179 + (notmuch_keyword_t []){ { "encode", ENCODE },
\r
180 + { "decode", DECODE },
\r
182 + { NOTMUCH_OPT_BOOLEAN, &omit_newline, "omit-newline", 'n', 0 },
\r
183 + { 0, 0, 0, 0, 0 }
\r
186 + int opt_index = parse_arguments (argc, argv, options, 1);
\r
188 + if (opt_index < 0)
\r
191 + void *ctx = talloc_new (NULL);
\r
193 + char *line = NULL;
\r
194 + size_t line_size;
\r
195 + ssize_t line_len;
\r
197 + char *buffer = NULL;
\r
198 + size_t buf_size = 0;
\r
200 + notmuch_bool_t read_stdin = TRUE;
\r
202 + for (; opt_index < argc; opt_index++) {
\r
204 + if (xcode (ctx, dir, argv[opt_index],
\r
205 + &buffer, &buf_size) != HEX_SUCCESS)
\r
208 + if (!omit_newline)
\r
211 + read_stdin = FALSE;
\r
217 + while ((line_len = getline (&line, &line_size, stdin)) != -1) {
\r
219 + chomp_newline (line);
\r
221 + if (xcode (ctx, dir, line, &buffer, &buf_size) != HEX_SUCCESS)
\r
224 + if (!omit_newline)
\r
232 + talloc_free (ctx);
\r