From: Syed Nayyar Waris <syednwaris@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
William Breathitt Gray <vilhelm.gray@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/6] lib/test_bitmap.c: Add for_each_set_clump test cases
Date: Fri, 24 Apr 2020 23:56:11 +0530 [thread overview]
Message-ID: <CACG_h5oNkRbusS9Qa-KR35Q=LppQxx+ah7wHpkC1FvjLQ1wHgQ@mail.gmail.com> (raw)
In-Reply-To: <CAHp75VcWwHT1eWekAMheaaU0-M_-w41XvJ-iNdKSVC+GZY7JsQ@mail.gmail.com>
On Fri, Apr 24, 2020 at 6:41 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Fri, Apr 24, 2020 at 3:29 PM Syed Nayyar Waris <syednwaris@gmail.com> wrote:
> >
> > The introduction of the generic for_each_set_clump macro need test
> > cases to verify the implementation. This patch adds test cases for
> > scenarios in which clump sizes are 8 bits, 24 bits, 30 bits and 6 bits.
> > The cases contain situations where clump is getting split at the word
> > boundary and also when zeroes are present in the start and middle of
> > bitmap.
>
> ...
>
> > #define expect_eq_clump8(...) __expect_eq(clump8, ##__VA_ARGS__)
> > +#define expect_eq_clump(...) __expect_eq(clump, ##__VA_ARGS__)
>
> What the difference with clump8() ? Can either of them use another?
>
The difference is that generic (Non-8 version) expect_eq_clump(...)
expands to __check_eq_clump(...), which further uses clump_size
variable to check for the tests. Now this clump_size can have any
value signifying number of bits (less than or equal to BITS_PER_LONG).
While the clump8 version uses a fixed (hardcoded) value '8' for clump size.
I don't think either of them can use another.
> ...
>
> > #define CLUMP_EXP_NUMBITS 64
>
> > +static void __init test_for_each_set_clump_8(void) /* 8 bit clumps test using
> > + new for_each_set_clump */
> > +{
>
> > +#define CLUMP_EXP_NUMBITS 64
>
> Isn't it a redefinition? Shouldn't we undef all local definitions
> above and below?
>
> Also, can we derive it's size based on ARRAY_SIZE() and clump size?
Actually this macro is to create bitmap having a particular size. The
size doesn't need to be related to or derived from clump_size
necessarily. I believe I should hardcode it - as it is just a test
value. I will submit this change in next version. Let me know if you
think otherwise.
>
> > + DECLARE_BITMAP(bits, CLUMP_EXP_NUMBITS);
> > + unsigned long start, clump, clump_size = 8;
> > +
> > + /* set bitmap to test case */
> > + bitmap_zero(bits, CLUMP_EXP_NUMBITS);
> > + bitmap_set_value(bits, 0x38000201, 0, 32);
> > + bitmap_set_value(bits, 0x05ff0f38, 32, 32);
> > +
> > + for_each_set_clump(start, clump, bits, CLUMP_EXP_NUMBITS, clump_size)
> > + expect_eq_clump(start, CLUMP_EXP_NUMBITS, clump_exp1, &clump, clump_size);
> > +}
> > +
> > +static void __init test_for_each_set_clump_24(void) /* 24 bit clumps */
> > +{
> > +#define CLUMP_EXP_NUMBITS_2 256
> > + DECLARE_BITMAP(bits, CLUMP_EXP_NUMBITS_2);
> > + unsigned long start, clump, clump_size = 24;
> > + unsigned long size = clump_size * 10;
> > +
> > + /* set bitmap to test case */
> > + bitmap_zero(bits, CLUMP_EXP_NUMBITS_2);
> > + bitmap_set_value(bits, 0xeffedcba, 0, 32);
> > + bitmap_set_value(bits, 0xbbbbabcd, 32, 32);
> > + bitmap_set_value(bits, 0x000000aa, 64, 32);
> > + bitmap_set_value(bits, 0x000000aa, 96, 32);
> > + bitmap_set_value(bits, 0x00ff0000, 128, 32);
> > + bitmap_set_value(bits, 0xaaaaaa00, 160, 32);
> > + bitmap_set_value(bits, 0xff000000, 192, 32);
> > + bitmap_set_value(bits, 0x00aa0000, 224, 32);
> > +
> > + for_each_set_clump(start, clump, bits, size, clump_size)
> > + expect_eq_clump(start, size, clump_exp2, &clump, clump_size);
> > +}
> > +
> > +static void __init test_for_each_set_clump_30(void) /* 30 bit clumps */
> > +{
> > +#define CLUMP_EXP_NUMBITS_2 256
> > + DECLARE_BITMAP(bits, CLUMP_EXP_NUMBITS_2);
> > + unsigned long start, clump, clump_size = 30;
> > + unsigned long size = clump_size * 8;
> > +
> > + /* set bitmap to test case */
> > + bitmap_zero(bits, CLUMP_EXP_NUMBITS_2);
> > + bitmap_set_value(bits, 0x00000000, 0, 32);
> > + bitmap_set_value(bits, 0x00000000, 32, 32);
> > + bitmap_set_value(bits, 0x00000000, 64, 32);
> > + bitmap_set_value(bits, 0x0f000000, 96, 32);
> > + bitmap_set_value(bits, 0x00ff0000, 128, 32);
> > + bitmap_set_value(bits, 0xaaaaaa00, 160, 32);
> > + bitmap_set_value(bits, 0xff000000, 192, 32);
> > + bitmap_set_value(bits, 0x00aa0000, 224, 32);
> > +
> > + for_each_set_clump(start, clump, bits, size, clump_size)
> > + expect_eq_clump(start, size, clump_exp3, &clump, clump_size);
> > +}
> > +
> > +static void __init test_for_each_set_clump_6(void) /* 6 bit clumps */
> > +{
> > +#define CLUMP_EXP_NUMBITS_2 256
> > + DECLARE_BITMAP(bits, CLUMP_EXP_NUMBITS_2);
> > + unsigned long start, clump, clump_size = 6;
> > + unsigned long size = clump_size * 3;
> > +
> > + /* set bitmap to test case */
> > + bitmap_zero(bits, CLUMP_EXP_NUMBITS_2);
> > + bitmap_set_value(bits, 0x00000ac0, 0, 32);
> > + bitmap_set_value(bits, 0x00000000, 32, 32);
> > + bitmap_set_value(bits, 0x00000000, 64, 32);
> > + bitmap_set_value(bits, 0x0f000000, 96, 32);
> > + bitmap_set_value(bits, 0x00ff0000, 128, 32);
> > + bitmap_set_value(bits, 0xaaaaaa00, 160, 32);
> > + bitmap_set_value(bits, 0xff000000, 192, 32);
> > + bitmap_set_value(bits, 0x00aa0000, 224, 32);
> > +
> > + for_each_set_clump(start, clump, bits, size, clump_size)
> > + expect_eq_clump(start, size, clump_exp4, &clump, clump_size);
> > +}
>
> Can we unify all above and provide simple two test data sets:
> expected, input, clump size and other information as function
> parameter?
Yes I can do that. I will try it out in next version (v2).
>
> --
> With Best Regards,
> Andy Shevchenko
Thank You!
Syed Nayyar Waris
prev parent reply other threads:[~2020-04-24 18:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-24 12:26 [PATCH 2/6] lib/test_bitmap.c: Add for_each_set_clump test cases Syed Nayyar Waris
2020-04-24 13:11 ` Andy Shevchenko
2020-04-24 18:26 ` Syed Nayyar Waris [this message]
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='CACG_h5oNkRbusS9Qa-KR35Q=LppQxx+ah7wHpkC1FvjLQ1wHgQ@mail.gmail.com' \
--to=syednwaris@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy.shevchenko@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vilhelm.gray@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;
as well as URLs for NNTP newsgroup(s).