1 Return-Path: <jani@nikula.org>
\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 B53F6431FAF
\r
6 for <notmuch@notmuchmail.org>; Fri, 30 Nov 2012 13:51:49 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\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 3mqo3KSlCGQ6 for <notmuch@notmuchmail.org>;
\r
16 Fri, 30 Nov 2012 13:51:44 -0800 (PST)
\r
17 Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com
\r
18 [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 78D7F431FAE
\r
21 for <notmuch@notmuchmail.org>; Fri, 30 Nov 2012 13:51:44 -0800 (PST)
\r
22 Received: by mail-lb0-f181.google.com with SMTP id ge1so916432lbb.26
\r
23 for <notmuch@notmuchmail.org>; Fri, 30 Nov 2012 13:51:42 -0800 (PST)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=google.com; s=20120113;
\r
26 h=from:to:cc:subject:in-reply-to:references:user-agent:date
\r
27 :message-id:mime-version:content-type:x-gm-message-state;
\r
28 bh=Yo7QO9QIIE+IY+Zi+Lo84vIkpBkjPVgJTzFkBRI8MpE=;
\r
29 b=d3izCQfMA7wNAKxMVY4406T0wOhDpWqKFBvsOlSs+wmZ8b59l5SF94Q7vakCf6GCdl
\r
30 9A2rXyp5zHvdms0elGLIHr8sT280J6wyNGjkzFot74nXZc85EKwfA+rjm4aZvctv17TT
\r
31 vrQfjAry9HU50tpSpgjCmJ64Uq/y5SyPVAI+yO6MmwKBpanT24vDUbIvPI/wY+ShavyV
\r
32 NlJggeG+9U41aC/BwnTj7voHyyOy2qZswwdYZNCGG47ojyIrfCxJuEjnU6jzIMk+SoDp
\r
33 7wjMbtTyU23v3RD2zqk1F1fV5dLtvWrOh7FfLNhF9GRQQeQ+HfsOx5Mn9oMRIyYxJzte
\r
35 Received: by 10.152.113.225 with SMTP id jb1mr2609763lab.23.1354312302746;
\r
36 Fri, 30 Nov 2012 13:51:42 -0800 (PST)
\r
37 Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi.
\r
39 by mx.google.com with ESMTPS id p9sm2526297lbc.3.2012.11.30.13.51.40
\r
40 (version=SSLv3 cipher=OTHER); Fri, 30 Nov 2012 13:51:41 -0800 (PST)
\r
41 From: Jani Nikula <jani@nikula.org>
\r
42 To: david@tethera.net, notmuch@notmuchmail.org
\r
43 Subject: Re: [Patch v2 02/17] test/hex-xcode: new test binary
\r
44 In-Reply-To: <1353792017-31459-3-git-send-email-david@tethera.net>
\r
45 References: <1353792017-31459-1-git-send-email-david@tethera.net>
\r
46 <1353792017-31459-3-git-send-email-david@tethera.net>
\r
47 User-Agent: Notmuch/0.14+124~g3b17402 (http://notmuchmail.org) Emacs/23.4.1
\r
49 Date: Fri, 30 Nov 2012 23:51:39 +0200
\r
50 Message-ID: <87txs6iwt0.fsf@nikula.org>
\r
52 Content-Type: text/plain; charset=us-ascii
\r
54 ALoCoQkPmeUYKyCUSSduZDNOpdAssUTBfBmVutbzbGdqEoegc6iVeR24v1Yf3oiNkYxKivWnyScJ
\r
55 Cc: David Bremner <bremner@debian.org>
\r
56 X-BeenThere: notmuch@notmuchmail.org
\r
57 X-Mailman-Version: 2.1.13
\r
59 List-Id: "Use and development of the notmuch mail system."
\r
60 <notmuch.notmuchmail.org>
\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
62 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
64 List-Post: <mailto:notmuch@notmuchmail.org>
\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
67 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
68 X-List-Received-Date: Fri, 30 Nov 2012 21:51:49 -0000
\r
70 On Sat, 24 Nov 2012, david@tethera.net wrote:
\r
71 > From: David Bremner <bremner@debian.org>
\r
73 > This program is used both as a test-bed/unit-tester for
\r
74 > ../util/hex-escape.c, and also as a utility in future tests of dump
\r
77 Should this have a mode for hex_decode_inplace()? It's silly from the
\r
78 tool perspective, but not from test coverage perspective.
\r
80 There'd be plenty to nitpick here, but it's only a test tool... so
\r
81 please just remove the extra/double newlines that seem to irritate me
\r
84 Otherwise, looks good.
\r
91 > test/.gitignore | 1 +
\r
92 > test/Makefile.local | 13 ++++++-
\r
94 > test/hex-xcode.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++
\r
95 > 4 files changed, 116 insertions(+), 2 deletions(-)
\r
96 > create mode 100644 test/hex-xcode.c
\r
98 > diff --git a/test/.gitignore b/test/.gitignore
\r
99 > index e63c689..be7ab5e 100644
\r
100 > --- a/test/.gitignore
\r
101 > +++ b/test/.gitignore
\r
102 > @@ -3,4 +3,5 @@ corpus.mail
\r
108 > diff --git a/test/Makefile.local b/test/Makefile.local
\r
109 > index 9ae130a..8da4c56 100644
\r
110 > --- a/test/Makefile.local
\r
111 > +++ b/test/Makefile.local
\r
112 > @@ -13,6 +13,9 @@ smtp_dummy_modules = $(smtp_dummy_srcs:.c=.o)
\r
113 > $(dir)/arg-test: $(dir)/arg-test.o command-line-arguments.o util/libutil.a
\r
114 > $(call quiet,CC) -I. $^ -o $@
\r
116 > +$(dir)/hex-xcode: $(dir)/hex-xcode.o command-line-arguments.o util/libutil.a
\r
117 > + $(call quiet,CC) -I. $^ -o $@ -ltalloc
\r
119 > $(dir)/smtp-dummy: $(smtp_dummy_modules)
\r
120 > $(call quiet,CC) $^ -o $@
\r
122 > @@ -24,8 +27,13 @@ $(dir)/parse-time: $(dir)/parse-time.o parse-time-string/parse-time-string.o
\r
124 > .PHONY: test check
\r
126 > -test-binaries: $(dir)/arg-test $(dir)/smtp-dummy $(dir)/symbol-test \
\r
127 > - $(dir)/parse-time
\r
128 > +TEST_BINARIES=$(dir)/arg-test \
\r
129 > + $(dir)/hex-xcode \
\r
130 > + $(dir)/parse-time \
\r
131 > + $(dir)/smtp-dummy \
\r
132 > + $(dir)/symbol-test
\r
134 > +test-binaries: $(TEST_BINARIES)
\r
136 > test: all test-binaries
\r
137 > @${dir}/notmuch-test $(OPTIONS)
\r
138 > @@ -36,5 +44,6 @@ SRCS := $(SRCS) $(smtp_dummy_srcs)
\r
139 > CLEAN := $(CLEAN) $(dir)/smtp-dummy $(dir)/smtp-dummy.o \
\r
140 > $(dir)/symbol-test $(dir)/symbol-test.o \
\r
141 > $(dir)/arg-test $(dir)/arg-test.o \
\r
142 > + $(dir)/hex-xcode $(dir)/hex-xcode.o \
\r
143 > $(dir)/parse-time $(dir)/parse-time.o \
\r
144 > $(dir)/corpus.mail $(dir)/test-results $(dir)/tmp.*
\r
145 > diff --git a/test/basic b/test/basic
\r
146 > index 1b842d2..2a571ac 100755
\r
149 > @@ -56,6 +56,7 @@ tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)
\r
150 > available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -perm +111 \
\r
151 > ! -name aggregate-results.sh \
\r
152 > ! -name arg-test \
\r
153 > + ! -name hex-xcode \
\r
154 > ! -name notmuch-test \
\r
155 > ! -name parse-time \
\r
156 > ! -name smtp-dummy \
\r
157 > diff --git a/test/hex-xcode.c b/test/hex-xcode.c
\r
158 > new file mode 100644
\r
159 > index 0000000..eec6541
\r
161 > +++ b/test/hex-xcode.c
\r
162 > @@ -0,0 +1,103 @@
\r
163 > +/* No, nothing to to with IDE from Apple Inc.
\r
164 > + testbed for ../util/hex-escape.c.
\r
167 > + hex-xcode [--direction=(encode|decode)] [--omit-newline] < file
\r
168 > + hex-xcode [--direction=(encode|decode)] [--omit-newline] arg1 arg2 arg3 ...
\r
172 > +#include "notmuch-client.h"
\r
173 > +#include "hex-escape.h"
\r
174 > +#include <assert.h>
\r
177 > +enum direction {
\r
183 > +xcode (void *ctx, enum direction dir, char *in, char **buf_p, size_t *size_p)
\r
185 > + hex_status_t status;
\r
187 > + if (dir == ENCODE)
\r
188 > + status = hex_encode (ctx, in, buf_p, size_p);
\r
190 > + status = hex_decode (ctx, in, buf_p, size_p);
\r
192 > + if (status == HEX_SUCCESS)
\r
193 > + fputs (*buf_p, stdout);
\r
200 > +main (int argc, char **argv)
\r
204 > + enum direction dir = DECODE;
\r
205 > + int omit_newline = FALSE;
\r
207 > + notmuch_opt_desc_t options[] = {
\r
208 > + { NOTMUCH_OPT_KEYWORD, &dir, "direction", 'd',
\r
209 > + (notmuch_keyword_t []){ { "encode", ENCODE },
\r
210 > + { "decode", DECODE },
\r
212 > + { NOTMUCH_OPT_BOOLEAN, &omit_newline, "omit-newline", 'n', 0 },
\r
213 > + { 0, 0, 0, 0, 0 }
\r
216 > + int opt_index = parse_arguments (argc, argv, options, 1);
\r
218 > + if (opt_index < 0)
\r
221 > + void *ctx = talloc_new (NULL);
\r
223 > + char *line = NULL;
\r
224 > + size_t line_size;
\r
225 > + ssize_t line_len;
\r
227 > + char *buffer = NULL;
\r
228 > + size_t buf_size = 0;
\r
230 > + notmuch_bool_t read_stdin = TRUE;
\r
232 > + for (; opt_index < argc; opt_index++) {
\r
234 > + if (xcode (ctx, dir, argv[opt_index],
\r
235 > + &buffer, &buf_size) != HEX_SUCCESS)
\r
238 > + if (!omit_newline)
\r
239 > + putchar ('\n');
\r
241 > + read_stdin = FALSE;
\r
244 > + if (!read_stdin)
\r
247 > + while ((line_len = getline (&line, &line_size, stdin)) != -1) {
\r
249 > + chomp_newline (line);
\r
251 > + if (xcode (ctx, dir, line, &buffer, &buf_size) != HEX_SUCCESS)
\r
254 > + if (!omit_newline)
\r
255 > + putchar ('\n');
\r
262 > + talloc_free (ctx);
\r
269 > _______________________________________________
\r
270 > notmuch mailing list
\r
271 > notmuch@notmuchmail.org
\r
272 > http://notmuchmail.org/mailman/listinfo/notmuch
\r