lkml.org 
[lkml]   [2022]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v3 2/4] lib/test: Introduce cpumask KUnit test suite
From
Date
Hi Andy,

On Mon, 2022-06-06 at 13:36 +0300, Andy Shevchenko wrote:
> On Sun, Jun 05, 2022 at 08:22:39AM +0200, Sander Vanheule wrote:
> > Add a basic suite of tests for cpumask, providing some tests for empty
> > and completely filled cpumasks.
>
> Always in favour of a new test!
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Thanks!

>
> > Signed-off-by: Sander Vanheule <sander@svanheule.net>
> > ---
> >
> > +#define EXPECT_FOR_EACH_CPU_BUILTIN_EQ(test, name)             \
> > +       do {                                                    \
> > +               const cpumask_t *m = cpu_##name##_mask;         \
> > +               int mask_weight = cpumask_weight(m);            \

Given the documentation for num_online_cpus(), I've replaced this with

int mask_weight = num_##name##_cpus();

and added guards around the test for the dynamic builtin masks.

> > +               int cpu, iter = 0;                              \
> > +               for_each_##name##_cpu(cpu)                      \
> > +                       iter++;                                 \
> > +               KUNIT_EXPECT_EQ((test), mask_weight, iter);     \
> > +       } while (0)
> >


> > +static void test_cpumask_iterators_builtin(struct kunit *test)
> > +{
> > +       EXPECT_FOR_EACH_CPU_BUILTIN_EQ(test, possible);

cpu_hotplug_disable();

> > +       EXPECT_FOR_EACH_CPU_BUILTIN_EQ(test, online);
> > +       EXPECT_FOR_EACH_CPU_BUILTIN_EQ(test, present);

cpu_hotplug_enable();

> > +}

This should ensure the tests will not randomly fail, if they happen to run while a CPU is going
online/offline.

Best,
Sander
\
 
 \ /
  Last update: 2022-06-06 14:25    [W:0.083 / U:1.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site