Re: [PATCH 1/2] Add Google Inc. to AUTHORS as a contributor.
[notmuch-archives.git] / bf / 8eb216089f511b00e1579609285d1e0d291b79
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 4831A429E31\r
6         for <notmuch@notmuchmail.org>; Sun, 18 Dec 2011 05:15:50 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] 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 Q--jq1hUts6w for <notmuch@notmuchmail.org>;\r
16         Sun, 18 Dec 2011 05:15:48 -0800 (PST)\r
17 Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21])\r
18         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 57442429E26\r
21         for <notmuch@notmuchmail.org>; Sun, 18 Dec 2011 05:15:43 -0800 (PST)\r
22 Received: from zancas.localnet\r
23         (fctnnbsc36w-156034079193.pppoe-dynamic.High-Speed.nb.bellaliant.net\r
24         [156.34.79.193]) (authenticated bits=0)\r
25         by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id pBIDFc0F017877\r
26         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);\r
27         Sun, 18 Dec 2011 09:15:39 -0400\r
28 Received: from bremner by zancas.localnet with local (Exim 4.77)\r
29         (envelope-from <bremner@tethera.net>)\r
30         id 1RcGaY-0008RG-Cd; Sun, 18 Dec 2011 09:15:38 -0400\r
31 From: David Bremner <david@tethera.net>\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH Draft 2 2/9] test/hex-xcode: new test binary\r
34 Date: Sun, 18 Dec 2011 09:15:04 -0400\r
35 Message-Id: <1324214111-32079-3-git-send-email-david@tethera.net>\r
36 X-Mailer: git-send-email 1.7.7.3\r
37 In-Reply-To: <1324214111-32079-1-git-send-email-david@tethera.net>\r
38 References: <id:87sjkmuck7.fsf@gmail.com>\r
39         <1324214111-32079-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
43 Precedence: list\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: Sun, 18 Dec 2011 13:15:50 -0000\r
54 \r
55 From: David Bremner <bremner@debian.org>\r
56 \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
59 and restore.\r
60 ---\r
61  test/.gitignore     |    1 +\r
62  test/Makefile.local |    6 +++-\r
63  test/basic          |    2 +-\r
64  test/hex-xcode.c    |   78 +++++++++++++++++++++++++++++++++++++++++++++++++++\r
65  4 files changed, 85 insertions(+), 2 deletions(-)\r
66  create mode 100644 test/hex-xcode.c\r
67 \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
73  smtp-dummy\r
74  symbol-test\r
75  arg-test\r
76 +hex-xcode\r
77  tmp.*\r
78 diff --git a/test/Makefile.local b/test/Makefile.local\r
79 index fa2df73..ec507c4 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
85  \r
86 +$(dir)/hex-xcode: $(dir)/hex-xcode.o util/libutil.a\r
87 +       $(call quiet,CC) -I. $^ -o $@ -ltalloc\r
88 +\r
89  $(dir)/smtp-dummy: $(smtp_dummy_modules)\r
90         $(call quiet,CC) $^ -o $@\r
91  \r
92 @@ -21,7 +24,8 @@ $(dir)/symbol-test: $(dir)/symbol-test.o\r
93  \r
94  .PHONY: test check\r
95  \r
96 -test-binaries: $(dir)/arg-test $(dir)/smtp-dummy $(dir)/symbol-test\r
97 +test-binaries: $(dir)/arg-test $(dir)/hex-xcode \\r
98 +        $(dir)/smtp-dummy $(dir)/symbol-test\r
99  \r
100  test:  all test-binaries\r
101         @${dir}/notmuch-test $(OPTIONS)\r
102 diff --git a/test/basic b/test/basic\r
103 index d6aed24..af57026 100755\r
104 --- a/test/basic\r
105 +++ b/test/basic\r
106 @@ -54,7 +54,7 @@ test_begin_subtest 'Ensure that all available tests will be run by notmuch-test'\r
107  eval $(sed -n -e '/^TESTS="$/,/^"$/p' $TEST_DIRECTORY/notmuch-test)\r
108  tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)\r
109  available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -executable -printf '%f\n' | \\r
110 -    sed -r -e "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test)$/d" | \\r
111 +    sed -r -e "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|hex-xcode)$/d" | \\r
112      sort)\r
113  test_expect_equal "$tests_in_suite" "$available"\r
114  \r
115 diff --git a/test/hex-xcode.c b/test/hex-xcode.c\r
116 new file mode 100644\r
117 index 0000000..20c1603\r
118 --- /dev/null\r
119 +++ b/test/hex-xcode.c\r
120 @@ -0,0 +1,78 @@\r
121 +/* No, nothing to to with IDE from Apple Inc.\r
122 +   testbed for ../util/hex-escape.c.\r
123 +\r
124 +   usage: hex-xcode (e|d) < foo\r
125 +\r
126 +   e is for encode\r
127 +   d is for decode\r
128 + */\r
129 +\r
130 +#include "notmuch-client.h"\r
131 +#include "hex-escape.h"\r
132 +#include <assert.h>\r
133 +\r
134 +static int\r
135 +xcode (void *ctx, char dir, char *in, char **buf_p, size_t *size_p)\r
136 +{\r
137 +    hex_status_t status;\r
138 +\r
139 +    if (dir == 'e')\r
140 +       status = hex_encode (ctx, in, buf_p, size_p);\r
141 +    else\r
142 +       status = hex_decode (ctx, in, buf_p, size_p);\r
143 +\r
144 +    if (status == HEX_SUCCESS)\r
145 +       puts (*buf_p);\r
146 +\r
147 +    return status;\r
148 +}\r
149 +\r
150 +\r
151 +int\r
152 +main (int argc, char **argv)\r
153 +{\r
154 +\r
155 +    assert (argc > 1 && argv[1]);\r
156 +\r
157 +    char dir = argv[1][0];\r
158 +\r
159 +    void *ctx = talloc_new (NULL);\r
160 +\r
161 +    char *line = NULL;\r
162 +    size_t line_size;\r
163 +    ssize_t line_len;\r
164 +\r
165 +    char *buffer = NULL;\r
166 +    size_t buf_size = 0;\r
167 +\r
168 +    int arg_index = 2;\r
169 +    notmuch_bool_t read_stdin = TRUE;\r
170 +\r
171 +    for (arg_index = 2; arg_index < argc; arg_index++) {\r
172 +\r
173 +       if (xcode (ctx, dir, argv[arg_index],\r
174 +                  &buffer, &buf_size) != HEX_SUCCESS)\r
175 +           return 1;\r
176 +\r
177 +       read_stdin = FALSE;\r
178 +    }\r
179 +\r
180 +    if (!read_stdin)\r
181 +       return 0;\r
182 +\r
183 +    while ((line_len = getline (&line, &line_size, stdin)) != -1) {\r
184 +\r
185 +       chomp_newline (line);\r
186 +\r
187 +       if (xcode (ctx, dir, line, &buffer, &buf_size) != HEX_SUCCESS)\r
188 +           return 1;\r
189 +\r
190 +    }\r
191 +\r
192 +    if (line)\r
193 +       free (line);\r
194 +\r
195 +    talloc_free (ctx);\r
196 +\r
197 +    return 0;\r
198 +}\r
199 -- \r
200 1.7.7.3\r
201 \r