From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id B53F6431FAF for ; Fri, 30 Nov 2012 13:51:49 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3mqo3KSlCGQ6 for ; Fri, 30 Nov 2012 13:51:44 -0800 (PST) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 78D7F431FAE for ; Fri, 30 Nov 2012 13:51:44 -0800 (PST) Received: by mail-lb0-f181.google.com with SMTP id ge1so916432lbb.26 for ; Fri, 30 Nov 2012 13:51:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type:x-gm-message-state; bh=Yo7QO9QIIE+IY+Zi+Lo84vIkpBkjPVgJTzFkBRI8MpE=; b=d3izCQfMA7wNAKxMVY4406T0wOhDpWqKFBvsOlSs+wmZ8b59l5SF94Q7vakCf6GCdl 9A2rXyp5zHvdms0elGLIHr8sT280J6wyNGjkzFot74nXZc85EKwfA+rjm4aZvctv17TT vrQfjAry9HU50tpSpgjCmJ64Uq/y5SyPVAI+yO6MmwKBpanT24vDUbIvPI/wY+ShavyV NlJggeG+9U41aC/BwnTj7voHyyOy2qZswwdYZNCGG47ojyIrfCxJuEjnU6jzIMk+SoDp 7wjMbtTyU23v3RD2zqk1F1fV5dLtvWrOh7FfLNhF9GRQQeQ+HfsOx5Mn9oMRIyYxJzte C+wQ== Received: by 10.152.113.225 with SMTP id jb1mr2609763lab.23.1354312302746; Fri, 30 Nov 2012 13:51:42 -0800 (PST) Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi. [80.223.81.27]) by mx.google.com with ESMTPS id p9sm2526297lbc.3.2012.11.30.13.51.40 (version=SSLv3 cipher=OTHER); Fri, 30 Nov 2012 13:51:41 -0800 (PST) From: Jani Nikula To: david@tethera.net, notmuch@notmuchmail.org Subject: Re: [Patch v2 02/17] test/hex-xcode: new test binary In-Reply-To: <1353792017-31459-3-git-send-email-david@tethera.net> References: <1353792017-31459-1-git-send-email-david@tethera.net> <1353792017-31459-3-git-send-email-david@tethera.net> User-Agent: Notmuch/0.14+124~g3b17402 (http://notmuchmail.org) Emacs/23.4.1 (i686-pc-linux-gnu) Date: Fri, 30 Nov 2012 23:51:39 +0200 Message-ID: <87txs6iwt0.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Gm-Message-State: ALoCoQkPmeUYKyCUSSduZDNOpdAssUTBfBmVutbzbGdqEoegc6iVeR24v1Yf3oiNkYxKivWnyScJ Cc: David Bremner X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Nov 2012 21:51:49 -0000 On Sat, 24 Nov 2012, david@tethera.net wrote: > From: David Bremner > > This program is used both as a test-bed/unit-tester for > ../util/hex-escape.c, and also as a utility in future tests of dump > and restore. Should this have a mode for hex_decode_inplace()? It's silly from the tool perspective, but not from test coverage perspective. There'd be plenty to nitpick here, but it's only a test tool... so please just remove the extra/double newlines that seem to irritate me most. ;) Otherwise, looks good. BR, Jani. > --- > test/.gitignore | 1 + > test/Makefile.local | 13 ++++++- > test/basic | 1 + > test/hex-xcode.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++ > 4 files changed, 116 insertions(+), 2 deletions(-) > create mode 100644 test/hex-xcode.c > > diff --git a/test/.gitignore b/test/.gitignore > index e63c689..be7ab5e 100644 > --- a/test/.gitignore > +++ b/test/.gitignore > @@ -3,4 +3,5 @@ corpus.mail > smtp-dummy > symbol-test > arg-test > +hex-xcode > tmp.* > diff --git a/test/Makefile.local b/test/Makefile.local > index 9ae130a..8da4c56 100644 > --- a/test/Makefile.local > +++ b/test/Makefile.local > @@ -13,6 +13,9 @@ smtp_dummy_modules = $(smtp_dummy_srcs:.c=.o) > $(dir)/arg-test: $(dir)/arg-test.o command-line-arguments.o util/libutil.a > $(call quiet,CC) -I. $^ -o $@ > > +$(dir)/hex-xcode: $(dir)/hex-xcode.o command-line-arguments.o util/libutil.a > + $(call quiet,CC) -I. $^ -o $@ -ltalloc > + > $(dir)/smtp-dummy: $(smtp_dummy_modules) > $(call quiet,CC) $^ -o $@ > > @@ -24,8 +27,13 @@ $(dir)/parse-time: $(dir)/parse-time.o parse-time-string/parse-time-string.o > > .PHONY: test check > > -test-binaries: $(dir)/arg-test $(dir)/smtp-dummy $(dir)/symbol-test \ > - $(dir)/parse-time > +TEST_BINARIES=$(dir)/arg-test \ > + $(dir)/hex-xcode \ > + $(dir)/parse-time \ > + $(dir)/smtp-dummy \ > + $(dir)/symbol-test > + > +test-binaries: $(TEST_BINARIES) > > test: all test-binaries > @${dir}/notmuch-test $(OPTIONS) > @@ -36,5 +44,6 @@ SRCS := $(SRCS) $(smtp_dummy_srcs) > CLEAN := $(CLEAN) $(dir)/smtp-dummy $(dir)/smtp-dummy.o \ > $(dir)/symbol-test $(dir)/symbol-test.o \ > $(dir)/arg-test $(dir)/arg-test.o \ > + $(dir)/hex-xcode $(dir)/hex-xcode.o \ > $(dir)/parse-time $(dir)/parse-time.o \ > $(dir)/corpus.mail $(dir)/test-results $(dir)/tmp.* > diff --git a/test/basic b/test/basic > index 1b842d2..2a571ac 100755 > --- a/test/basic > +++ b/test/basic > @@ -56,6 +56,7 @@ tests_in_suite=$(for i in $TESTS; do echo $i; done | sort) > available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -perm +111 \ > ! -name aggregate-results.sh \ > ! -name arg-test \ > + ! -name hex-xcode \ > ! -name notmuch-test \ > ! -name parse-time \ > ! -name smtp-dummy \ > diff --git a/test/hex-xcode.c b/test/hex-xcode.c > new file mode 100644 > index 0000000..eec6541 > --- /dev/null > +++ b/test/hex-xcode.c > @@ -0,0 +1,103 @@ > +/* No, nothing to to with IDE from Apple Inc. > + testbed for ../util/hex-escape.c. > + > + usage: > + hex-xcode [--direction=(encode|decode)] [--omit-newline] < file > + hex-xcode [--direction=(encode|decode)] [--omit-newline] arg1 arg2 arg3 ... > + > + */ > + > +#include "notmuch-client.h" > +#include "hex-escape.h" > +#include > + > + > +enum direction { > + ENCODE, > + DECODE > +}; > + > +static int > +xcode (void *ctx, enum direction dir, char *in, char **buf_p, size_t *size_p) > +{ > + hex_status_t status; > + > + if (dir == ENCODE) > + status = hex_encode (ctx, in, buf_p, size_p); > + else > + status = hex_decode (ctx, in, buf_p, size_p); > + > + if (status == HEX_SUCCESS) > + fputs (*buf_p, stdout); > + > + return status; > +} > + > + > +int > +main (int argc, char **argv) > +{ > + > + > + enum direction dir = DECODE; > + int omit_newline = FALSE; > + > + notmuch_opt_desc_t options[] = { > + { NOTMUCH_OPT_KEYWORD, &dir, "direction", 'd', > + (notmuch_keyword_t []){ { "encode", ENCODE }, > + { "decode", DECODE }, > + { 0, 0 } } }, > + { NOTMUCH_OPT_BOOLEAN, &omit_newline, "omit-newline", 'n', 0 }, > + { 0, 0, 0, 0, 0 } > + }; > + > + int opt_index = parse_arguments (argc, argv, options, 1); > + > + if (opt_index < 0) > + exit (1); > + > + void *ctx = talloc_new (NULL); > + > + char *line = NULL; > + size_t line_size; > + ssize_t line_len; > + > + char *buffer = NULL; > + size_t buf_size = 0; > + > + notmuch_bool_t read_stdin = TRUE; > + > + for (; opt_index < argc; opt_index++) { > + > + if (xcode (ctx, dir, argv[opt_index], > + &buffer, &buf_size) != HEX_SUCCESS) > + return 1; > + > + if (!omit_newline) > + putchar ('\n'); > + > + read_stdin = FALSE; > + } > + > + if (!read_stdin) > + return 0; > + > + while ((line_len = getline (&line, &line_size, stdin)) != -1) { > + > + chomp_newline (line); > + > + if (xcode (ctx, dir, line, &buffer, &buf_size) != HEX_SUCCESS) > + return 1; > + > + if (!omit_newline) > + putchar ('\n'); > + > + } > + > + if (line) > + free (line); > + > + talloc_free (ctx); > + > + return 0; > +} > -- > 1.7.10.4 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch