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 3E344431FAF
\r
6 for <notmuch@notmuchmail.org>; Sat, 31 Mar 2012 15:17:57 -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 F2PfLJubUezv for <notmuch@notmuchmail.org>;
\r
17 Sat, 31 Mar 2012 15:17:54 -0700 (PDT)
\r
18 Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com
\r
19 [209.85.214.53]) (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 6911B429E3D
\r
22 for <notmuch@notmuchmail.org>; Sat, 31 Mar 2012 15:17:51 -0700 (PDT)
\r
23 Received: by mail-bk0-f53.google.com with SMTP id j4so1547751bkw.26
\r
24 for <notmuch@notmuchmail.org>; Sat, 31 Mar 2012 15:17:51 -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=JC6KNwbJQR6KzZDqDhHQEVnkhsRjSz9DQaRuFetQiZt0cfjh/m+85oD0R3blyL4v38
\r
31 ayp7DjW1WN4DiYnt2aZAukZuLWrukrznVYQJhXXIML5OHb8grlpJvn5VeNdKm2yOsiG2
\r
32 Kl2YPKKAPIXTQwV0ZuoM3A5vzwd2nRsusT64Z+H3jKkRuvRHXvhlICeffbjYatKSag8Y
\r
33 iiIqgs9o9iEVE9EzSPejvaV0k/uj56Ea3ibYQ8nAdyIvIxj7apRaPc8iOmny37rqMHu3
\r
34 Lv8B4JHnyRaAYZOLZjrM3PJtxyafOMU6th7+lpnk7iTFulufG6VVBYkk/e7rolCjJtFy
\r
36 Received: by 10.204.136.219 with SMTP id s27mr1255237bkt.116.1333232270945;
\r
37 Sat, 31 Mar 2012 15:17:50 -0700 (PDT)
\r
38 Received: from localhost (dsl-hkibrasgw4-fe50f800-253.dhcp.inet.fi.
\r
39 [84.248.80.253]) by mx.google.com with ESMTPS id
\r
40 jr13sm28511474bkb.14.2012.03.31.15.17.49
\r
41 (version=SSLv3 cipher=OTHER); Sat, 31 Mar 2012 15:17:50 -0700 (PDT)
\r
42 From: Jani Nikula <jani@nikula.org>
\r
43 To: notmuch@notmuchmail.org
\r
44 Subject: [PATCH 4/8] test/hex-xcode: new test binary
\r
45 Date: Sun, 1 Apr 2012 01:17:24 +0300
\r
47 <a984626045b59100ec7f2d9f9b14a9a48252d8d0.1333231401.git.jani@nikula.org>
\r
48 X-Mailer: git-send-email 1.7.5.4
\r
49 In-Reply-To: <cover.1333231401.git.jani@nikula.org>
\r
50 References: <cover.1333231401.git.jani@nikula.org>
\r
51 In-Reply-To: <cover.1333231401.git.jani@nikula.org>
\r
52 References: <cover.1333231401.git.jani@nikula.org>
\r
54 ALoCoQlp3EAad/+4OnM9MZSlyGy8TLYv9wTpr9LGHQkCtbTcmug5H9e/9/e8ZZpaLQoyrNcHEfe7
\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, 31 Mar 2012 22:17:57 -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