Re: [PATCH v3 09/10] random-dump.c: new test-binary to generate dump files
authorJani Nikula <jani@nikula.org>
Sun, 15 Jan 2012 08:05:15 +0000 (10:05 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:42:11 +0000 (09:42 -0800)
77/4a6eac040e80ee3c60fb58b3eda496cbbb4fc2 [new file with mode: 0644]

diff --git a/77/4a6eac040e80ee3c60fb58b3eda496cbbb4fc2 b/77/4a6eac040e80ee3c60fb58b3eda496cbbb4fc2
new file mode 100644 (file)
index 0000000..272f61b
--- /dev/null
@@ -0,0 +1,529 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id BC35F431FAF\r
+       for <notmuch@notmuchmail.org>; Sun, 15 Jan 2012 00:05:18 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.699\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
+       tests=[HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id m9UHXtLjTjfT for <notmuch@notmuchmail.org>;\r
+       Sun, 15 Jan 2012 00:05:17 -0800 (PST)\r
+Received: from mail-pz0-f53.google.com (mail-pz0-f53.google.com\r
+       [209.85.210.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 49D2A431FAE\r
+       for <notmuch@notmuchmail.org>; Sun, 15 Jan 2012 00:05:17 -0800 (PST)\r
+Received: by dalz17 with SMTP id z17so2743369dal.26\r
+       for <notmuch@notmuchmail.org>; Sun, 15 Jan 2012 00:05:15 -0800 (PST)\r
+MIME-Version: 1.0\r
+Received: by 10.68.213.38 with SMTP id np6mr16285599pbc.37.1326614715150; Sun,\r
+       15 Jan 2012 00:05:15 -0800 (PST)\r
+Received: by 10.68.58.234 with HTTP; Sun, 15 Jan 2012 00:05:15 -0800 (PST)\r
+Received: by 10.68.58.234 with HTTP; Sun, 15 Jan 2012 00:05:15 -0800 (PST)\r
+In-Reply-To: <1326591624-15493-10-git-send-email-david@tethera.net>\r
+References: <874nwxbkhr.fsf@zancas.localnet>\r
+       <1326591624-15493-1-git-send-email-david@tethera.net>\r
+       <1326591624-15493-10-git-send-email-david@tethera.net>\r
+Date: Sun, 15 Jan 2012 10:05:15 +0200\r
+Message-ID:\r
+ <CAB+hUn9Eas_4DRc8FDk+S88JiWhcOipHc_ePn4pHe89B72=JiA@mail.gmail.com>\r
+Subject: Re: [PATCH v3 09/10] random-dump.c: new test-binary to generate dump\r
+       files\r
+From: Jani Nikula <jani@nikula.org>\r
+To: David Bremner <david@tethera.net>\r
+Content-Type: multipart/alternative; boundary=e89a8ff1c322d9b16904b68c8ec8\r
+Cc: notmuch@notmuchmail.org, David Bremner <bremner@debian.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 15 Jan 2012 08:05:18 -0000\r
+\r
+--e89a8ff1c322d9b16904b68c8ec8\r
+Content-Type: text/plain; charset=UTF-8\r
+\r
+On Jan 15, 2012 3:41 AM, "David Bremner" <david@tethera.net> wrote:\r
+>\r
+> From: David Bremner <bremner@debian.org>\r
+>\r
+> This binary creates a "torture test" dump file for the new dump\r
+> format.\r
+> ---\r
+>  test/Makefile.local |    4 ++\r
+>  test/basic          |    2 +-\r
+>  test/random-dump.c  |  144\r
++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+>  3 files changed, 149 insertions(+), 1 deletions(-)\r
+>  create mode 100644 test/random-dump.c\r
+>\r
+> diff --git a/test/Makefile.local b/test/Makefile.local\r
+> index ba697f4..b59f837 100644\r
+> --- a/test/Makefile.local\r
+> +++ b/test/Makefile.local\r
+> @@ -16,6 +16,9 @@ $(dir)/arg-test: $(dir)/arg-test.o\r
+command-line-arguments.o util/libutil.a\r
+>  $(dir)/hex-xcode: $(dir)/hex-xcode.o command-line-arguments.o\r
+util/libutil.a\r
+>        $(call quiet,CC) -I. $^ -o $@ -ltalloc\r
+>\r
+> +$(dir)/random-dump:  $(dir)/random-dump.o command-line-arguments.o\r
+util/libutil.a\r
+> +       $(call quiet,CC) -I. $^ -o $@ -ltalloc -lm\r
+> +\r
+>  $(dir)/smtp-dummy: $(smtp_dummy_modules)\r
+>        $(call quiet,CC) $^ -o $@\r
+>\r
+> @@ -25,6 +28,7 @@ $(dir)/symbol-test: $(dir)/symbol-test.o\r
+>  .PHONY: test check\r
+>\r
+>  test-binaries: $(dir)/arg-test $(dir)/hex-xcode \\r
+> +       $(dir)/random-dump \\r
+>         $(dir)/smtp-dummy $(dir)/symbol-test\r
+>\r
+>  test:  all test-binaries\r
+> diff --git a/test/basic b/test/basic\r
+> index af57026..e3a6cef 100755\r
+> --- a/test/basic\r
+> +++ b/test/basic\r
+> @@ -54,7 +54,7 @@ test_begin_subtest 'Ensure that all available tests\r
+will be run by notmuch-test'\r
+>  eval $(sed -n -e '/^TESTS="$/,/^"$/p' $TEST_DIRECTORY/notmuch-test)\r
+>  tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)\r
+>  available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -executable\r
+-printf '%f\n' | \\r
+> -    sed -r -e\r
+"/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|hex-xcode)$/d"\r
+| \\r
+> +    sed -r -e\r
+"/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|hex-xcode|random-dump)$/d"\r
+| \\r
+>     sort)\r
+>  test_expect_equal "$tests_in_suite" "$available"\r
+>\r
+> diff --git a/test/random-dump.c b/test/random-dump.c\r
+> new file mode 100644\r
+> index 0000000..1949425\r
+> --- /dev/null\r
+> +++ b/test/random-dump.c\r
+> @@ -0,0 +1,144 @@\r
+> +/*\r
+> +   Generate a random dump file in 'notmuch' format.\r
+> +   Generated message-id's and tags are intentionally nasty.\r
+> +\r
+> +   We restrict ourselves to 7 bit message-ids, because generating\r
+> +   random valid UTF-8 seems like work. And invalid UTF-8 can't be\r
+> +   round-tripped via Xapian.\r
+> +\r
+> + */\r
+> +\r
+> +#include <stdlib.h>\r
+> +#include <assert.h>\r
+> +#include <talloc.h>\r
+> +#include <string.h>\r
+> +#include "math.h"\r
+> +#include "hex-escape.h"\r
+> +#include "command-line-arguments.h"\r
+> +\r
+> +static void\r
+> +hex_out (void *ctx, char *buf)\r
+> +{\r
+> +    static char *encoded_buf = NULL;\r
+> +    static size_t encoded_buf_size = 0;\r
+> +\r
+> +    if (hex_encode (ctx, buf, &encoded_buf, &encoded_buf_size) !=\r
+HEX_SUCCESS) {\r
+> +       fprintf (stderr, "Hex encoding failed");\r
+> +       exit (1);\r
+> +    }\r
+> +\r
+> +    fputs (encoded_buf, stdout);\r
+> +}\r
+> +\r
+> +static void\r
+> +random_chars (char *buf, int from, int stop, int max_char,\r
+> +             const char *blacklist)\r
+> +{\r
+> +    int i;\r
+> +\r
+> +    for (i = from; i < stop; i++) {\r
+> +       do {\r
+> +           buf[i] = ' ' + (random () % (max_char - ' '));\r
+> +       } while (blacklist && strchr (blacklist, buf[i]));\r
+> +    }\r
+> +}\r
+> +\r
+> +static void\r
+> +random_tag (void *ctx, size_t len)\r
+> +{\r
+> +    static char *buf = NULL;\r
+> +    static size_t buf_len = 0;\r
+> +\r
+> +    int use = (random () % (len - 1)) + 1;\r
+> +\r
+> +    if (len > buf_len) {\r
+> +       buf = talloc_realloc (ctx, buf, char, len);\r
+> +       buf_len = len;\r
+> +    }\r
+> +\r
+> +    random_chars (buf, 0, use, 255, NULL);\r
+> +\r
+> +    buf[use] = '\0';\r
+> +\r
+> +    hex_out (ctx, buf);\r
+> +}\r
+> +\r
+> +static void\r
+> +random_message_id (void *ctx, size_t len)\r
+> +{\r
+> +    static char *buf = NULL;\r
+> +    static size_t buf_len = 0;\r
+> +\r
+> +    int lhs_len = (random () % (len / 2 - 1)) + 1;\r
+> +\r
+> +    int rhs_len = (random () % len / 2) + 1;\r
+> +\r
+> +    const char *blacklist = "\n\r@<>[]()";\r
+> +\r
+> +    if (len > buf_len) {\r
+> +       buf = talloc_realloc (ctx, buf, char, len);\r
+> +       buf_len = len;\r
+> +    }\r
+> +\r
+> +    random_chars (buf, 0, lhs_len, 127, blacklist);\r
+> +\r
+> +    buf[lhs_len] = '@';\r
+> +\r
+> +    random_chars (buf, lhs_len + 1, lhs_len + rhs_len + 1, 127,\r
+blacklist);\r
+> +\r
+> +    hex_out (ctx, buf);\r
+> +}\r
+> +\r
+> +int\r
+> +main (int argc, char **argv)\r
+> +{\r
+> +\r
+> +    void *ctx = talloc_new (NULL);\r
+> +    int num_lines = 500;\r
+> +    int max_tags = 10;\r
+> +    int message_id_len = 100;\r
+> +    int tag_len = 50;\r
+> +    int seed = 734569;\r
+> +\r
+> +    int pad_tag = 0, pad_mid = 0;\r
+> +\r
+> +    notmuch_opt_desc_t options[] = {\r
+> +       { NOTMUCH_OPT_INT, &num_lines, "num-lines", 'n', 0 },\r
+> +       { NOTMUCH_OPT_INT, &max_tags, "max-tags", 'm', 0 },\r
+> +       { NOTMUCH_OPT_INT, &message_id_len, "message-id-len", 'M', 0 },\r
+> +       { NOTMUCH_OPT_INT, &tag_len, "tag-len", 't', 0 },\r
+> +       { NOTMUCH_OPT_INT, &seed, "tag-len", 't', 0 },\r
+\r
+s/tag-len/seed/\r
+\r
+> +       { 0, 0, 0, 0, 0 }\r
+> +    };\r
+> +\r
+> +    int opt_index = parse_arguments (argc, argv, options, 1);\r
+> +\r
+> +    if (opt_index < 0)\r
+> +       exit (1);\r
+> +\r
+> +    pad_mid = ((int) log10 (num_lines) + 1);\r
+> +    pad_tag = ((int) log10 (max_tags)) + 1;\r
+> +\r
+> +    srandom (seed);\r
+> +\r
+> +    int line;\r
+> +    for (line = 0; line < num_lines; line++) {\r
+> +\r
+> +       printf ("%0*d-", pad_mid, line);\r
+> +\r
+> +       random_message_id (ctx, message_id_len);\r
+> +\r
+> +       int num_tags = random () % (max_tags + 1);\r
+> +\r
+> +       int j;\r
+> +       for (j = 0; j < num_tags; j++) {\r
+> +           printf (" %0*d-", pad_tag, j);\r
+> +           random_tag (ctx, tag_len);\r
+> +       }\r
+> +       putchar ('\n');\r
+> +    }\r
+> +\r
+> +    talloc_free (ctx);\r
+> +\r
+> +    return 0;\r
+> +}\r
+> --\r
+> 1.7.7.3\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r
+\r
+--e89a8ff1c322d9b16904b68c8ec8\r
+Content-Type: text/html; charset=UTF-8\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+<p><br>\r
+On Jan 15, 2012 3:41 AM, &quot;David Bremner&quot; &lt;<a href=3D"mailto:da=\r
+vid@tethera.net">david@tethera.net</a>&gt; wrote:<br>\r
+&gt;<br>\r
+&gt; From: David Bremner &lt;<a href=3D"mailto:bremner@debian.org">bremner@=\r
+debian.org</a>&gt;<br>\r
+&gt;<br>\r
+&gt; This binary creates a &quot;torture test&quot; dump file for the new d=\r
+ump<br>\r
+&gt; format.<br>\r
+&gt; ---<br>\r
+&gt; =C2=A0test/Makefile.local | =C2=A0 =C2=A04 ++<br>\r
+&gt; =C2=A0test/basic =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A02 +-=\r
+<br>\r
+&gt; =C2=A0test/random-dump.c =C2=A0| =C2=A0144 +++++++++++++++++++++++++++=\r
+++++++++++++++++++++++++<br>\r
+&gt; =C2=A03 files changed, 149 insertions(+), 1 deletions(-)<br>\r
+&gt; =C2=A0create mode 100644 test/random-dump.c<br>\r
+&gt;<br>\r
+&gt; diff --git a/test/Makefile.local b/test/Makefile.local<br>\r
+&gt; index ba697f4..b59f837 100644<br>\r
+&gt; --- a/test/Makefile.local<br>\r
+&gt; +++ b/test/Makefile.local<br>\r
+&gt; @@ -16,6 +16,9 @@ $(dir)/arg-test: $(dir)/arg-test.o command-line-argu=\r
+ments.o util/libutil.a<br>\r
+&gt; =C2=A0$(dir)/hex-xcode: $(dir)/hex-xcode.o command-line-arguments.o ut=\r
+il/libutil.a<br>\r
+&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0$(call quiet,CC) -I. $^ -o $@ -ltalloc<br>\r
+&gt;<br>\r
+&gt; +$(dir)/random-dump: =C2=A0$(dir)/random-dump.o command-line-arguments=\r
+.o util/libutil.a<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 $(call quiet,CC) -I. $^ -o $@ -ltalloc -lm<br>\r
+&gt; +<br>\r
+&gt; =C2=A0$(dir)/smtp-dummy: $(smtp_dummy_modules)<br>\r
+&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0$(call quiet,CC) $^ -o $@<br>\r
+&gt;<br>\r
+&gt; @@ -25,6 +28,7 @@ $(dir)/symbol-test: $(dir)/symbol-test.o<br>\r
+&gt; =C2=A0.PHONY: test check<br>\r
+&gt;<br>\r
+&gt; =C2=A0test-binaries: $(dir)/arg-test $(dir)/hex-xcode \<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 $(dir)/random-dump \<br>\r
+&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 $(dir)/smtp-dummy $(dir)/symbol-test<br>\r
+&gt;<br>\r
+&gt; =C2=A0test: =C2=A0all test-binaries<br>\r
+&gt; diff --git a/test/basic b/test/basic<br>\r
+&gt; index af57026..e3a6cef 100755<br>\r
+&gt; --- a/test/basic<br>\r
+&gt; +++ b/test/basic<br>\r
+&gt; @@ -54,7 +54,7 @@ test_begin_subtest &#39;Ensure that all available te=\r
+sts will be run by notmuch-test&#39;<br>\r
+&gt; =C2=A0eval $(sed -n -e &#39;/^TESTS=3D&quot;$/,/^&quot;$/p&#39; $TEST_=\r
+DIRECTORY/notmuch-test)<br>\r
+&gt; =C2=A0tests_in_suite=3D$(for i in $TESTS; do echo $i; done | sort)<br>\r
+&gt; =C2=A0available=3D$(find &quot;$TEST_DIRECTORY&quot; -maxdepth 1 -type=\r
+ f -executable -printf &#39;%f\n&#39; | \<br>\r
+&gt; - =C2=A0 =C2=A0sed -r -e &quot;/^(aggregate-results.sh|notmuch-test|sm=\r
+tp-dummy|test-verbose|symbol-test|arg-test|hex-xcode)$/d&quot; | \<br>\r
+&gt; + =C2=A0 =C2=A0sed -r -e &quot;/^(aggregate-results.sh|notmuch-test|sm=\r
+tp-dummy|test-verbose|symbol-test|arg-test|hex-xcode|random-dump)$/d&quot; =\r
+| \<br>\r
+&gt; =C2=A0 =C2=A0 sort)<br>\r
+&gt; =C2=A0test_expect_equal &quot;$tests_in_suite&quot; &quot;$available&q=\r
+uot;<br>\r
+&gt;<br>\r
+&gt; diff --git a/test/random-dump.c b/test/random-dump.c<br>\r
+&gt; new file mode 100644<br>\r
+&gt; index 0000000..1949425<br>\r
+&gt; --- /dev/null<br>\r
+&gt; +++ b/test/random-dump.c<br>\r
+&gt; @@ -0,0 +1,144 @@<br>\r
+&gt; +/*<br>\r
+&gt; + =C2=A0 Generate a random dump file in &#39;notmuch&#39; format.<br>\r
+&gt; + =C2=A0 Generated message-id&#39;s and tags are intentionally nasty.<=\r
+br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 We restrict ourselves to 7 bit message-ids, because generatin=\r
+g<br>\r
+&gt; + =C2=A0 random valid UTF-8 seems like work. And invalid UTF-8 can&#39=\r
+;t be<br>\r
+&gt; + =C2=A0 round-tripped via Xapian.<br>\r
+&gt; +<br>\r
+&gt; + */<br>\r
+&gt; +<br>\r
+&gt; +#include &lt;stdlib.h&gt;<br>\r
+&gt; +#include &lt;assert.h&gt;<br>\r
+&gt; +#include &lt;talloc.h&gt;<br>\r
+&gt; +#include &lt;string.h&gt;<br>\r
+&gt; +#include &quot;math.h&quot;<br>\r
+&gt; +#include &quot;hex-escape.h&quot;<br>\r
+&gt; +#include &quot;command-line-arguments.h&quot;<br>\r
+&gt; +<br>\r
+&gt; +static void<br>\r
+&gt; +hex_out (void *ctx, char *buf)<br>\r
+&gt; +{<br>\r
+&gt; + =C2=A0 =C2=A0static char *encoded_buf =3D NULL;<br>\r
+&gt; + =C2=A0 =C2=A0static size_t encoded_buf_size =3D 0;<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0if (hex_encode (ctx, buf, &amp;encoded_buf, &amp;encode=\r
+d_buf_size) !=3D HEX_SUCCESS) {<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 fprintf (stderr, &quot;Hex encoding failed&quot=\r
+;);<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 exit (1);<br>\r
+&gt; + =C2=A0 =C2=A0}<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0fputs (encoded_buf, stdout);<br>\r
+&gt; +}<br>\r
+&gt; +<br>\r
+&gt; +static void<br>\r
+&gt; +random_chars (char *buf, int from, int stop, int max_char,<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 const char *blacklist)<br>\r
+&gt; +{<br>\r
+&gt; + =C2=A0 =C2=A0int i;<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0for (i =3D from; i &lt; stop; i++) {<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 do {<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 buf[i] =3D &#39; &#39; + (random =\r
+() % (max_char - &#39; &#39;));<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 } while (blacklist &amp;&amp; strchr (blacklist=\r
+, buf[i]));<br>\r
+&gt; + =C2=A0 =C2=A0}<br>\r
+&gt; +}<br>\r
+&gt; +<br>\r
+&gt; +static void<br>\r
+&gt; +random_tag (void *ctx, size_t len)<br>\r
+&gt; +{<br>\r
+&gt; + =C2=A0 =C2=A0static char *buf =3D NULL;<br>\r
+&gt; + =C2=A0 =C2=A0static size_t buf_len =3D 0;<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0int use =3D (random () % (len - 1)) + 1;<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0if (len &gt; buf_len) {<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 buf =3D talloc_realloc (ctx, buf, char, len);<b=\r
+r>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 buf_len =3D len;<br>\r
+&gt; + =C2=A0 =C2=A0}<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0random_chars (buf, 0, use, 255, NULL);<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0buf[use] =3D &#39;\0&#39;;<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0hex_out (ctx, buf);<br>\r
+&gt; +}<br>\r
+&gt; +<br>\r
+&gt; +static void<br>\r
+&gt; +random_message_id (void *ctx, size_t len)<br>\r
+&gt; +{<br>\r
+&gt; + =C2=A0 =C2=A0static char *buf =3D NULL;<br>\r
+&gt; + =C2=A0 =C2=A0static size_t buf_len =3D 0;<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0int lhs_len =3D (random () % (len / 2 - 1)) + 1;<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0int rhs_len =3D (random () % len / 2) + 1;<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0const char *blacklist =3D &quot;\n\r@&lt;&gt;[]()&quot;=\r
+;<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0if (len &gt; buf_len) {<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 buf =3D talloc_realloc (ctx, buf, char, len);<b=\r
+r>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 buf_len =3D len;<br>\r
+&gt; + =C2=A0 =C2=A0}<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0random_chars (buf, 0, lhs_len, 127, blacklist);<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0buf[lhs_len] =3D &#39;@&#39;;<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0random_chars (buf, lhs_len + 1, lhs_len + rhs_len + 1, =\r
+127, blacklist);<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0hex_out (ctx, buf);<br>\r
+&gt; +}<br>\r
+&gt; +<br>\r
+&gt; +int<br>\r
+&gt; +main (int argc, char **argv)<br>\r
+&gt; +{<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0void *ctx =3D talloc_new (NULL);<br>\r
+&gt; + =C2=A0 =C2=A0int num_lines =3D 500;<br>\r
+&gt; + =C2=A0 =C2=A0int max_tags =3D 10;<br>\r
+&gt; + =C2=A0 =C2=A0int message_id_len =3D 100;<br>\r
+&gt; + =C2=A0 =C2=A0int tag_len =3D 50;<br>\r
+&gt; + =C2=A0 =C2=A0int seed =3D 734569;<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0int pad_tag =3D 0, pad_mid =3D 0;<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0notmuch_opt_desc_t options[] =3D {<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 { NOTMUCH_OPT_INT, &amp;num_lines, &quot;num-li=\r
+nes&quot;, &#39;n&#39;, 0 },<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 { NOTMUCH_OPT_INT, &amp;max_tags, &quot;max-tag=\r
+s&quot;, &#39;m&#39;, 0 },<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 { NOTMUCH_OPT_INT, &amp;message_id_len, &quot;m=\r
+essage-id-len&quot;, &#39;M&#39;, 0 },<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 { NOTMUCH_OPT_INT, &amp;tag_len, &quot;tag-len&=\r
+quot;, &#39;t&#39;, 0 },<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 { NOTMUCH_OPT_INT, &amp;seed, &quot;tag-len&quo=\r
+t;, &#39;t&#39;, 0 },</p>\r
+<p>s/tag-len/seed/</p>\r
+<p>&gt; + =C2=A0 =C2=A0 =C2=A0 { 0, 0, 0, 0, 0 }<br>\r
+&gt; + =C2=A0 =C2=A0};<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0int opt_index =3D parse_arguments (argc, argv, options,=\r
+ 1);<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0if (opt_index &lt; 0)<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 exit (1);<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0pad_mid =3D ((int) log10 (num_lines) + 1);<br>\r
+&gt; + =C2=A0 =C2=A0pad_tag =3D ((int) log10 (max_tags)) + 1;<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0srandom (seed);<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0int line;<br>\r
+&gt; + =C2=A0 =C2=A0for (line =3D 0; line &lt; num_lines; line++) {<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 printf (&quot;%0*d-&quot;, pad_mid, line);<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 random_message_id (ctx, message_id_len);<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 int num_tags =3D random () % (max_tags + 1);<br=\r
+>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 int j;<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 for (j =3D 0; j &lt; num_tags; j++) {<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf (&quot; %0*d-&quot;, pad_t=\r
+ag, j);<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 random_tag (ctx, tag_len);<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 }<br>\r
+&gt; + =C2=A0 =C2=A0 =C2=A0 putchar (&#39;\n&#39;);<br>\r
+&gt; + =C2=A0 =C2=A0}<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0talloc_free (ctx);<br>\r
+&gt; +<br>\r
+&gt; + =C2=A0 =C2=A0return 0;<br>\r
+&gt; +}<br>\r
+&gt; --<br>\r
+&gt; 1.7.7.3<br>\r
+&gt;<br>\r
+&gt; _______________________________________________<br>\r
+&gt; notmuch mailing list<br>\r
+&gt; <a href=3D"mailto:notmuch@notmuchmail.org">notmuch@notmuchmail.org</a>=\r
+<br>\r
+&gt; <a href=3D"http://notmuchmail.org/mailman/listinfo/notmuch">http://not=\r
+muchmail.org/mailman/listinfo/notmuch</a><br>\r
+</p>\r
+\r
+--e89a8ff1c322d9b16904b68c8ec8--\r