[PATCH 4/4] Update NEWS for user.other_name
[notmuch-archives.git] / 16 / bae731cb01caaa1d70bfd9169757a54baff896
1 Return-Path: <m.walters@qmul.ac.uk>\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 AAD89431FAF\r
6         for <notmuch@notmuchmail.org>; Sat,  4 Feb 2012 17:03:07 -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: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 cY34u9ZF5Svz for <notmuch@notmuchmail.org>;\r
17         Sat,  4 Feb 2012 17:03:06 -0800 (PST)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 7FD3E431FAE\r
22         for <notmuch@notmuchmail.org>; Sat,  4 Feb 2012 17:03:06 -0800 (PST)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1RtqVT-0004i3-Kf; Sun, 05 Feb 2012 01:03:04 +0000\r
27 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
28         helo=localhost)\r
29         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
30         (envelope-from <m.walters@qmul.ac.uk>)\r
31         id 1RtqVS-0001AM-Tw; Sun, 05 Feb 2012 01:03:03 +0000\r
32 From: Mark Walters <markwalters1009@gmail.com>\r
33 To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
34 Subject: Re: [PATCH v3 09/10] random-dump.c: new test-binary to generate dump\r
35         files\r
36 In-Reply-To: <1326591624-15493-10-git-send-email-david@tethera.net>\r
37 References: <874nwxbkhr.fsf@zancas.localnet>\r
38         <1326591624-15493-1-git-send-email-david@tethera.net>\r
39         <1326591624-15493-10-git-send-email-david@tethera.net>\r
40 User-Agent: Notmuch/0.11+154~ged6d37e (http://notmuchmail.org) Emacs/23.2.1\r
41         (i486-pc-linux-gnu)\r
42 Date: Sun, 05 Feb 2012 01:04:13 +0000\r
43 Message-ID: <87pqduozua.fsf@qmul.ac.uk>\r
44 MIME-Version: 1.0\r
45 Content-Type: text/plain; charset=us-ascii\r
46 X-Sender-Host-Address: 94.192.233.223\r
47 X-QM-SPAM-Info: Sender has good ham record.  :)\r
48 X-QM-Body-MD5: 3d9f4a4d652b1de39be6b3fa8d4da618 (of first 20000 bytes)\r
49 X-SpamAssassin-Score: -1.8\r
50 X-SpamAssassin-SpamBar: -\r
51 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
52         determine if it is\r
53         spam. We require at least 5.0 points to mark a message as spam.\r
54         This message scored -1.8 points.\r
55         Summary of the scoring: \r
56         * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
57         *      medium trust\r
58         *      [138.37.6.40 listed in list.dnswl.org]\r
59         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
60         provider *      (markwalters1009[at]gmail.com)\r
61         * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
62         *      domain\r
63         *  0.5 AWL AWL: From: address is in the auto white-list\r
64 X-QM-Scan-Virus: ClamAV says the message is clean\r
65 Cc: David Bremner <bremner@debian.org>\r
66 X-BeenThere: notmuch@notmuchmail.org\r
67 X-Mailman-Version: 2.1.13\r
68 Precedence: list\r
69 List-Id: "Use and development of the notmuch mail system."\r
70         <notmuch.notmuchmail.org>\r
71 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
72         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
73 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
74 List-Post: <mailto:notmuch@notmuchmail.org>\r
75 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
76 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
77         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
78 X-List-Received-Date: Sun, 05 Feb 2012 01:03:07 -0000\r
79 \r
80 On Sat, 14 Jan 2012 21:40:23 -0400, David Bremner <david@tethera.net> wrote:\r
81 > From: David Bremner <bremner@debian.org>\r
82\r
83 > This binary creates a "torture test" dump file for the new dump\r
84 > format.\r
85 > ---\r
86 >  test/Makefile.local |    4 ++\r
87 >  test/basic          |    2 +-\r
88 >  test/random-dump.c  |  144 +++++++++++++++++++++++++++++++++++++++++++++++++++\r
89 >  3 files changed, 149 insertions(+), 1 deletions(-)\r
90 >  create mode 100644 test/random-dump.c\r
91\r
92 > diff --git a/test/Makefile.local b/test/Makefile.local\r
93 > index ba697f4..b59f837 100644\r
94 > --- a/test/Makefile.local\r
95 > +++ b/test/Makefile.local\r
96 > @@ -16,6 +16,9 @@ $(dir)/arg-test: $(dir)/arg-test.o command-line-arguments.o util/libutil.a\r
97 >  $(dir)/hex-xcode: $(dir)/hex-xcode.o command-line-arguments.o util/libutil.a\r
98 >       $(call quiet,CC) -I. $^ -o $@ -ltalloc\r
99 >  \r
100 > +$(dir)/random-dump:  $(dir)/random-dump.o command-line-arguments.o util/libutil.a\r
101 > +     $(call quiet,CC) -I. $^ -o $@ -ltalloc -lm\r
102 > +\r
103 >  $(dir)/smtp-dummy: $(smtp_dummy_modules)\r
104 >       $(call quiet,CC) $^ -o $@\r
105 >  \r
106 > @@ -25,6 +28,7 @@ $(dir)/symbol-test: $(dir)/symbol-test.o\r
107 >  .PHONY: test check\r
108 >  \r
109 >  test-binaries: $(dir)/arg-test $(dir)/hex-xcode \\r
110 > +     $(dir)/random-dump \\r
111 >        $(dir)/smtp-dummy $(dir)/symbol-test\r
112 >  \r
113 >  test:        all test-binaries\r
114 > diff --git a/test/basic b/test/basic\r
115 > index af57026..e3a6cef 100755\r
116 > --- a/test/basic\r
117 > +++ b/test/basic\r
118 > @@ -54,7 +54,7 @@ test_begin_subtest 'Ensure that all available tests will be run by notmuch-test'\r
119 >  eval $(sed -n -e '/^TESTS="$/,/^"$/p' $TEST_DIRECTORY/notmuch-test)\r
120 >  tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)\r
121 >  available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -executable -printf '%f\n' | \\r
122 > -    sed -r -e "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|hex-xcode)$/d" | \\r
123 > +    sed -r -e "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|hex-xcode|random-dump)$/d" | \\r
124 >      sort)\r
125 >  test_expect_equal "$tests_in_suite" "$available"\r
126 >  \r
127 > diff --git a/test/random-dump.c b/test/random-dump.c\r
128 > new file mode 100644\r
129 > index 0000000..1949425\r
130 > --- /dev/null\r
131 > +++ b/test/random-dump.c\r
132 > @@ -0,0 +1,144 @@\r
133 > +/*\r
134 > +   Generate a random dump file in 'notmuch' format.\r
135 > +   Generated message-id's and tags are intentionally nasty.\r
136 > +\r
137 > +   We restrict ourselves to 7 bit message-ids, because generating\r
138 > +   random valid UTF-8 seems like work. And invalid UTF-8 can't be\r
139 > +   round-tripped via Xapian.\r
140 > +\r
141 > + */\r
142 > +\r
143 > +#include <stdlib.h>\r
144 > +#include <assert.h>\r
145 > +#include <talloc.h>\r
146 > +#include <string.h>\r
147 > +#include "math.h"\r
148 > +#include "hex-escape.h"\r
149 > +#include "command-line-arguments.h"\r
150 > +\r
151 > +static void\r
152 > +hex_out (void *ctx, char *buf)\r
153 > +{\r
154 > +    static char *encoded_buf = NULL;\r
155 > +    static size_t encoded_buf_size = 0;\r
156 > +\r
157 > +    if (hex_encode (ctx, buf, &encoded_buf, &encoded_buf_size) != HEX_SUCCESS) {\r
158 > +     fprintf (stderr, "Hex encoding failed");\r
159 > +     exit (1);\r
160 > +    }\r
161 > +\r
162 > +    fputs (encoded_buf, stdout);\r
163 > +}\r
164 > +\r
165 > +static void\r
166 > +random_chars (char *buf, int from, int stop, int max_char,\r
167 > +           const char *blacklist)\r
168 > +{\r
169 > +    int i;\r
170 > +\r
171 > +    for (i = from; i < stop; i++) {\r
172 > +     do {\r
173 > +         buf[i] = ' ' + (random () % (max_char - ' '));\r
174 > +     } while (blacklist && strchr (blacklist, buf[i]));\r
175 > +    }\r
176 > +}\r
177 > +\r
178 > +static void\r
179 > +random_tag (void *ctx, size_t len)\r
180 > +{\r
181 > +    static char *buf = NULL;\r
182 > +    static size_t buf_len = 0;\r
183 > +\r
184 > +    int use = (random () % (len - 1)) + 1;\r
185 > +\r
186 > +    if (len > buf_len) {\r
187 > +     buf = talloc_realloc (ctx, buf, char, len);\r
188 > +     buf_len = len;\r
189 > +    }\r
190 > +\r
191 > +    random_chars (buf, 0, use, 255, NULL);\r
192 > +\r
193 > +    buf[use] = '\0';\r
194 > +\r
195 > +    hex_out (ctx, buf);\r
196 > +}\r
197 > +\r
198 > +static void\r
199 > +random_message_id (void *ctx, size_t len)\r
200 > +{\r
201 > +    static char *buf = NULL;\r
202 > +    static size_t buf_len = 0;\r
203 > +\r
204 > +    int lhs_len = (random () % (len / 2 - 1)) + 1;\r
205 > +\r
206 > +    int rhs_len = (random () % len / 2) + 1;\r
207 > +\r
208 > +    const char *blacklist = "\n\r@<>[]()";\r
209 > +\r
210 > +    if (len > buf_len) {\r
211 > +     buf = talloc_realloc (ctx, buf, char, len);\r
212 > +     buf_len = len;\r
213 > +    }\r
214 > +\r
215 > +    random_chars (buf, 0, lhs_len, 127, blacklist);\r
216 > +\r
217 > +    buf[lhs_len] = '@';\r
218 > +\r
219 > +    random_chars (buf, lhs_len + 1, lhs_len + rhs_len + 1, 127, blacklist);\r
220 > +\r
221 > +    hex_out (ctx, buf);\r
222 > +}\r
223 > +\r
224 > +int\r
225 > +main (int argc, char **argv)\r
226 > +{\r
227 > +\r
228 > +    void *ctx = talloc_new (NULL);\r
229 > +    int num_lines = 500;\r
230 > +    int max_tags = 10;\r
231 > +    int message_id_len = 100;\r
232 > +    int tag_len = 50;\r
233 > +    int seed = 734569;\r
234 > +\r
235 > +    int pad_tag = 0, pad_mid = 0;\r
236 > +\r
237 > +    notmuch_opt_desc_t options[] = {\r
238 > +     { NOTMUCH_OPT_INT, &num_lines, "num-lines", 'n', 0 },\r
239 > +     { NOTMUCH_OPT_INT, &max_tags, "max-tags", 'm', 0 },\r
240 > +     { NOTMUCH_OPT_INT, &message_id_len, "message-id-len", 'M', 0 },\r
241 > +     { NOTMUCH_OPT_INT, &tag_len, "tag-len", 't', 0 },\r
242 > +     { NOTMUCH_OPT_INT, &seed, "tag-len", 't', 0 },\r
243 > +     { 0, 0, 0, 0, 0 }\r
244 > +    };\r
245 > +\r
246 > +    int opt_index = parse_arguments (argc, argv, options, 1);\r
247 > +\r
248 > +    if (opt_index < 0)\r
249 > +     exit (1);\r
250 > +\r
251 > +    pad_mid = ((int) log10 (num_lines) + 1);\r
252 > +    pad_tag = ((int) log10 (max_tags)) + 1;\r
253 > +\r
254 > +    srandom (seed);\r
255 > +\r
256 > +    int line;\r
257 > +    for (line = 0; line < num_lines; line++) {\r
258 > +\r
259 > +     printf ("%0*d-", pad_mid, line);\r
260 > +\r
261 > +     random_message_id (ctx, message_id_len);\r
262 > +\r
263 > +     int num_tags = random () % (max_tags + 1);\r
264 > +\r
265 > +     int j;\r
266 > +     for (j = 0; j < num_tags; j++) {\r
267 > +         printf (" %0*d-", pad_tag, j);\r
268 > +         random_tag (ctx, tag_len);\r
269 > +     }\r
270 > +     putchar ('\n');\r
271 > +    }\r
272 > +\r
273 > +    talloc_free (ctx);\r
274 > +\r
275 > +    return 0;\r
276 > +}\r
277 \r
278 Hi\r
279 \r
280 Just a thought on this and the next test. Could you add messages with\r
281 the random ids and tags from the above code to the Xapian database\r
282 directly by calling whatever notmuch-new calls. Then test by doing dump,\r
283 restore and dump and check the two dumps are equal? It might avoid your\r
284 gmime concern from the next patch and you could have arbitrary\r
285 (non-null) strings including all sorts of malformed utf-8.\r
286 \r
287 I guess Xapian might do bizarre things on the malformed utf-8 but, if it\r
288 does, it might mean the correct place to fix it is in notmuch-new.\r
289 \r
290 Best wishes\r
291 \r
292 Mark\r