All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: Eric Sandeen <sandeen@redhat.com>, xfs <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH] xfs_io: add crc32 self test
Date: Mon, 29 Oct 2018 12:09:28 -0700	[thread overview]
Message-ID: <20181029190928.GD4135@magnolia> (raw)
In-Reply-To: <a9f99690-418e-9fcd-ecd0-bbed071b0a6f@sandeen.net>

On Mon, Oct 29, 2018 at 01:30:32PM -0500, Eric Sandeen wrote:
> On 10/29/18 1:11 PM, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Add a self test for crc32 into xfs_io so that xfstests can check the
> > operation of the (potentially cross-compiled) package binaries by
> > isolating the self test code to a header file that can be included by
> > the build system self test and xfs_io.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  include/crc32selftest.h |  706 +++++++++++++++++++++++++++++++++++++++++++++++
> >  io/Makefile             |    8 -
> >  io/crc32selftest.c      |   51 +++
> >  io/init.c               |    1 
> >  io/io.h                 |    1 
> >  libfrog/crc32.c         |  669 ---------------------------------------------
> 
> needs a manpage change as well I think.

Dangit, I forgot to port that over when I moved the command.

> >  6 files changed, 764 insertions(+), 672 deletions(-)
> >  create mode 100644 include/crc32selftest.h
> >  create mode 100644 io/crc32selftest.c
> > 
> 
> ...
> 
> > diff --git a/io/crc32selftest.c b/io/crc32selftest.c
> > new file mode 100644
> > index 00000000..c0b4b2f4
> > --- /dev/null
> > +++ b/io/crc32selftest.c
> > @@ -0,0 +1,51 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright (c) 2018 Oracle, Inc.
> > + * All Rights Reserved.
> > + */
> > +
> > +#include "platform_defs.h"
> > +#include "command.h"
> > +#include "init.h"
> > +#include "io.h"
> > +#include "crc32c.h"
> > +#include "crc32selftest.h"
> > +
> > +static int
> > +crc32selftest_f(
> > +	int		argc,
> > +	char		**argv)
> > +{
> > +	int		c;
> > +	int		errors;
> > +
> > +	while ((c = getopt(argc, argv, "")) != EOF) {
> > +		switch (c) {
> > +		default:
> > +			fprintf(stderr,
> > +_("Bad option for crc32selftest command.\n"));
> > +			return 0;
> > +		}
> > +	}
> 
> I think we can drop the getopt bits altogether because:
> 
> > +	errors = crc32c_test();
> > +	return errors == 0 ? 0 : 1;
> > +}
> > +
> > +static const cmdinfo_t	crc32selftest_cmd = {
> > +	.name		= "crc32selftest",
> > +	.cfunc		= crc32selftest_f,
> > +	.argmin		= 0,
> > +	.argmax		= 0,
> 
> This command structure doesn't even let us get there:
> 
> # io/xfs_io -c "crc32selftest foo"
> bad argument count 1 to crc32selftest, expected 0 arguments
> # io/xfs_io -c "crc32selftest -f"
> bad argument count 1 to crc32selftest, expected 0 arguments
> 
> and other "argmax" functions (freeze, thaw, close, munmap...) don't bother
> with getopt at all.

ok.

> > +	.canpush	= 0,
> > +	.args		= "",
> 
> drop this I think, otherwise we get a weird space in usage:
> 
> crc32selftest  -- crc32c self test
> 
> vs
> 
> crc32selftest -- crc32c self test
> 
> because
> 
>         if (ct->args)
>                 printf("%s ", ct->args);
>         printf("-- %s\n", ct->oneline);
> 

Aha, that's why it does that...

> > +	.flags		= CMD_FLAG_ONESHOT | CMD_FLAG_FOREIGN_OK |
> > +			  CMD_NOFILE_OK | CMD_NOMAP_OK,
> > +	.oneline	= N_("crc32c self test"),
> 
> > +};
> > +
> > +void
> > +crc32selftest_init(void)
> > +{
> > +	add_command(&crc32selftest_cmd);
> > +}
> 
> ok is it better to call this crc32c selftest or crc32 selftest?  Seems a little inconsistent in the naming.

crc32cselftest it is then.

--D

> > diff --git a/io/init.c b/io/init.c
> > index b5eade39..53b754e4 100644
> > --- a/io/init.c
> > +++ b/io/init.c
> > @@ -85,6 +85,7 @@ init_commands(void)
> >  	sync_range_init();
> >  	truncate_init();
> >  	utimes_init();
> > +	crc32selftest_init();
> >  }
> >  
> >  /*
> > diff --git a/io/io.h b/io/io.h
> > index 9278ad00..847b4759 100644
> > --- a/io/io.h
> > +++ b/io/io.h
> > @@ -182,3 +182,4 @@ extern void		log_writes_init(void);
> >  
> >  extern void		scrub_init(void);
> >  extern void		repair_init(void);
> > +extern void		crc32selftest_init(void);
> 
> 

  reply	other threads:[~2018-10-30  3:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-29 18:11 [PATCH] xfs_io: add crc32 self test Darrick J. Wong
2018-10-29 18:30 ` Eric Sandeen
2018-10-29 19:09   ` Darrick J. Wong [this message]
2018-10-29 19:10 ` [PATCH v2] " Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181029190928.GD4135@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=sandeen@sandeen.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.