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 11FC6431FD4
\r
6 for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 05:15:50 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
\r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
13 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id PtgvYZdRCvnO for <notmuch@notmuchmail.org>;
\r
17 Sat, 14 Apr 2012 05:15:47 -0700 (PDT)
\r
18 Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com
\r
19 [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id AD00D431FBD
\r
22 for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 05:15:44 -0700 (PDT)
\r
23 Received: by mail-lb0-f181.google.com with SMTP id b5so40243lbd.26
\r
24 for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 05:15:44 -0700 (PDT)
\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
26 d=google.com; s=20120113;
\r
27 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references
\r
28 :in-reply-to:references:x-gm-message-state;
\r
29 bh=Sa1X0bPHRHQiErxc62pbcrRL7R+yylPzZFHAcy3qFDg=;
\r
30 b=UQW/c/BT2H/4ZwbErZ1DnxE2z4eHKHI+xSfE7yjX7uR7cemkQYqeBFPf8/RI7vgmH3
\r
31 M9/wPtBKIRTVKHpC/oYS67MM9XY/YzoRAMZtObRzaFfHDXGDfJbgecCAnDp77Pi3H8fT
\r
32 6gZzJvktB3DDSo7lFaRuqJV09iUY6gaZfYH/Wpua8viDvzBXqFnMrq+9grOWhBFPNMHD
\r
33 9crvmyxMlYvcFTTAeDqzn8wNgyuRYfgmvcLnZ4W+JyEOGPKjVhR60OOUe2PffLIJ8m2R
\r
34 reeC8nU7I5TfkYpKHN0JLvWT85lnIa84YVHsk3GjYFI2Ld3kIG0NGCKaB56aUXDxZShz
\r
36 Received: by 10.112.37.134 with SMTP id y6mr2162112lbj.102.1334405744334;
\r
37 Sat, 14 Apr 2012 05:15:44 -0700 (PDT)
\r
38 Received: from localhost (dsl-hkibrasgw4-fe50dc00-68.dhcp.inet.fi.
\r
40 by mx.google.com with ESMTPS id fe6sm16009481lbb.9.2012.04.14.05.15.42
\r
41 (version=SSLv3 cipher=OTHER); Sat, 14 Apr 2012 05:15:43 -0700 (PDT)
\r
42 From: Jani Nikula <jani@nikula.org>
\r
43 To: notmuch@notmuchmail.org
\r
44 Subject: [PATCH v2 2/6] test/hex-xcode: new test binary
\r
45 Date: Sat, 14 Apr 2012 15:15:27 +0300
\r
47 <e40d095e6a5208d8e720d1f681bd172e28f3f112.1334404979.git.jani@nikula.org>
\r
48 X-Mailer: git-send-email 1.7.5.4
\r
49 In-Reply-To: <cover.1334404979.git.jani@nikula.org>
\r
50 References: <cover.1334404979.git.jani@nikula.org>
\r
51 In-Reply-To: <cover.1334404979.git.jani@nikula.org>
\r
52 References: <cover.1334404979.git.jani@nikula.org>
\r
54 ALoCoQmAJ8obfLHNsoFrwJw5pOpNhKThPzRJdHC4Cj28NqT9Xa1pxeEMnN7AAZ9yDS9scNWXWEeN
\r
55 X-BeenThere: notmuch@notmuchmail.org
\r
56 X-Mailman-Version: 2.1.13
\r
58 List-Id: "Use and development of the notmuch mail system."
\r
59 <notmuch.notmuchmail.org>
\r
60 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
61 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
62 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
63 List-Post: <mailto:notmuch@notmuchmail.org>
\r
64 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
65 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
66 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
67 X-List-Received-Date: Sat, 14 Apr 2012 12:15:50 -0000
\r
69 From: David Bremner <bremner@debian.org>
\r
71 This program is used both as a test-bed/unit-tester for
\r
72 ../util/hex-escape.c, and also as a utility in future tests of dump
\r
75 test/.gitignore | 1 +
\r
76 test/Makefile.local | 6 ++-
\r
78 test/hex-xcode.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++
\r
79 4 files changed, 110 insertions(+), 2 deletions(-)
\r
80 create mode 100644 test/hex-xcode.c
\r
82 diff --git a/test/.gitignore b/test/.gitignore
\r
83 index e63c689..be7ab5e 100644
\r
84 --- a/test/.gitignore
\r
85 +++ b/test/.gitignore
\r
86 @@ -3,4 +3,5 @@ corpus.mail
\r
92 diff --git a/test/Makefile.local b/test/Makefile.local
\r
93 index 4a6a4b1..9cecd28 100644
\r
94 --- a/test/Makefile.local
\r
95 +++ b/test/Makefile.local
\r
96 @@ -13,6 +13,9 @@ smtp_dummy_modules = $(smtp_dummy_srcs:.c=.o)
\r
97 $(dir)/arg-test: $(dir)/arg-test.o command-line-arguments.o util/libutil.a
\r
98 $(call quiet,CC) -I. $^ -o $@
\r
100 +$(dir)/hex-xcode: $(dir)/hex-xcode.o command-line-arguments.o util/libutil.a
\r
101 + $(call quiet,CC) -I. $^ -o $@ -ltalloc
\r
103 $(dir)/smtp-dummy: $(smtp_dummy_modules)
\r
104 $(call quiet,CC) $^ -o $@
\r
106 @@ -21,7 +24,8 @@ $(dir)/symbol-test: $(dir)/symbol-test.o
\r
110 -test-binaries: $(dir)/arg-test $(dir)/smtp-dummy $(dir)/symbol-test
\r
111 +test-binaries: $(dir)/arg-test $(dir)/hex-xcode \
\r
112 + $(dir)/smtp-dummy $(dir)/symbol-test
\r
114 test: all test-binaries
\r
115 @${dir}/notmuch-test $(OPTIONS)
\r
116 diff --git a/test/basic b/test/basic
\r
117 index d6aed24..af57026 100755
\r
120 @@ -54,7 +54,7 @@ test_begin_subtest 'Ensure that all available tests will be run by notmuch-test'
\r
121 eval $(sed -n -e '/^TESTS="$/,/^"$/p' $TEST_DIRECTORY/notmuch-test)
\r
122 tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)
\r
123 available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -executable -printf '%f\n' | \
\r
124 - sed -r -e "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test)$/d" | \
\r
125 + sed -r -e "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|hex-xcode)$/d" | \
\r
127 test_expect_equal "$tests_in_suite" "$available"
\r
129 diff --git a/test/hex-xcode.c b/test/hex-xcode.c
\r
130 new file mode 100644
\r
131 index 0000000..eec6541
\r
133 +++ b/test/hex-xcode.c
\r
135 +/* No, nothing to to with IDE from Apple Inc.
\r
136 + testbed for ../util/hex-escape.c.
\r
139 + hex-xcode [--direction=(encode|decode)] [--omit-newline] < file
\r
140 + hex-xcode [--direction=(encode|decode)] [--omit-newline] arg1 arg2 arg3 ...
\r
144 +#include "notmuch-client.h"
\r
145 +#include "hex-escape.h"
\r
146 +#include <assert.h>
\r
155 +xcode (void *ctx, enum direction dir, char *in, char **buf_p, size_t *size_p)
\r
157 + hex_status_t status;
\r
159 + if (dir == ENCODE)
\r
160 + status = hex_encode (ctx, in, buf_p, size_p);
\r
162 + status = hex_decode (ctx, in, buf_p, size_p);
\r
164 + if (status == HEX_SUCCESS)
\r
165 + fputs (*buf_p, stdout);
\r
172 +main (int argc, char **argv)
\r
176 + enum direction dir = DECODE;
\r
177 + int omit_newline = FALSE;
\r
179 + notmuch_opt_desc_t options[] = {
\r
180 + { NOTMUCH_OPT_KEYWORD, &dir, "direction", 'd',
\r
181 + (notmuch_keyword_t []){ { "encode", ENCODE },
\r
182 + { "decode", DECODE },
\r
184 + { NOTMUCH_OPT_BOOLEAN, &omit_newline, "omit-newline", 'n', 0 },
\r
185 + { 0, 0, 0, 0, 0 }
\r
188 + int opt_index = parse_arguments (argc, argv, options, 1);
\r
190 + if (opt_index < 0)
\r
193 + void *ctx = talloc_new (NULL);
\r
195 + char *line = NULL;
\r
196 + size_t line_size;
\r
197 + ssize_t line_len;
\r
199 + char *buffer = NULL;
\r
200 + size_t buf_size = 0;
\r
202 + notmuch_bool_t read_stdin = TRUE;
\r
204 + for (; opt_index < argc; opt_index++) {
\r
206 + if (xcode (ctx, dir, argv[opt_index],
\r
207 + &buffer, &buf_size) != HEX_SUCCESS)
\r
210 + if (!omit_newline)
\r
213 + read_stdin = FALSE;
\r
219 + while ((line_len = getline (&line, &line_size, stdin)) != -1) {
\r
221 + chomp_newline (line);
\r
223 + if (xcode (ctx, dir, line, &buffer, &buf_size) != HEX_SUCCESS)
\r
226 + if (!omit_newline)
\r
234 + talloc_free (ctx);
\r