mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sander Vanheule <sander@svanheule.net>
To: Yury Norov <yury.norov@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Valentin Schneider <vschneid@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Marco Elver <elver@google.com>,
	linux-kernel@vger.kernel.org,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: Re: [PATCH v2 1/4] lib/test: Introduce cpumask KUnit test suite
Date: Sun, 05 Jun 2022 08:21:35 +0200	[thread overview]
Message-ID: <5bfcbc7aeb3963c3672534513c64fbec5c31e83d.camel@svanheule.net> (raw)
In-Reply-To: <YpuzKLQdToIwBrSm@yury-laptop>

Hi Yury,

On Sat, 2022-06-04 at 12:31 -0700, Yury Norov wrote:
> On Sat, Jun 04, 2022 at 07:15:56PM +0200, Sander Vanheule wrote:
> > Add a basic suite of tests for cpumask, providing some tests for empty
> > and completely filled cpumasks.
> > 
> > Signed-off-by: Sander Vanheule <sander@svanheule.net>
> 
> The test must go after fix, so that it's doesn't cause regressions
> while bisecting.

OK, I'll change the order of the patches.

> 
> > ---
> >  lib/Kconfig.debug  |   9 ++++
> >  lib/Makefile       |   1 +
> >  lib/test_cpumask.c | 115 +++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 125 insertions(+)
> >  create mode 100644 lib/test_cpumask.c
> 
> [..]
> 
> > +#define FOR_EACH_ITER_EQ(_test, _iter, _expect, _loop)         \
> > +       do {                                                    \
> > +               (_iter) = 0;                                    \
> > +               _loop                                           \
> > +                       (_iter)++;                              \
> > +               KUNIT_EXPECT_EQ((_test), (_expect), (_iter));   \
> > +       } while (0)
> 
> This one is harder to use than it should be.

Perhaps I tried to hard to make one macro to cover all the cases.

>  Maybe like this? (not tested,
> just an idea)
> 
> #define TEST_FOR_EACH_CPU_EQ(test, mask)                                \
>         do {                                                            \
>                 cpumask_t *m = (mask);                                  \
>                 int iter = 0, cpu;                                      \
>                 for_each_cpu(cpu, m)                                    \
>                         iter++;                                         \
>                 KUNIT_EXPECT_EQ((test), cpumask_weight(m), iter);       \
>         } while (0)
> 
> static void test_cpumask_iterators(struct kunit *test)
> {
>         TEST_FOR_EACH_CPU(test, &mask_empty);
>         ...
> }
>  
> Similarly for NOT and WRAP.

Thanks for the suggestion, I forgot we don't have to declare all variables at the start of the
function. I'll send an update with a few more specific macros.

Best,
Sander

  reply	other threads:[~2022-06-05  6:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-04 17:15 [PATCH v2 0/4] cpumask: Fix invalid uniprocessor assumptions Sander Vanheule
2022-06-04 17:15 ` [PATCH v2 1/4] lib/test: Introduce cpumask KUnit test suite Sander Vanheule
2022-06-04 19:31   ` Yury Norov
2022-06-05  6:21     ` Sander Vanheule [this message]
2022-06-04 17:15 ` [PATCH v2 2/4] cpumask: Fix invalid uniprocessor mask assumption Sander Vanheule
2022-06-04 17:15 ` [PATCH v2 3/4] cpumask: Add UP optimised for_each_*_cpu versions Sander Vanheule
2022-06-04 17:15 ` [PATCH v2 4/4] cpumask: Update cpumask_next_wrap() signature Sander Vanheule

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=5bfcbc7aeb3963c3672534513c64fbec5c31e83d.camel@svanheule.net \
    --to=sander@svanheule.net \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=elver@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=vschneid@redhat.com \
    --cc=yury.norov@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®