All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Syed Nayyar Waris <syednwaris@gmail.com>
Cc: akpm@linux-foundation.org, vilhelm.gray@gmail.com,
	linus.walleij@linaro.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 2/4] lib/test_bitmap.c: Add for_each_set_clump test cases
Date: Mon, 4 May 2020 14:38:04 +0300	[thread overview]
Message-ID: <20200504113804.GD185537@smile.fi.intel.com> (raw)
In-Reply-To: <3eeb13d101db69be8eca739522bbf303527339bd.1588460322.git.syednwaris@gmail.com>

On Sun, May 03, 2020 at 04:41:42AM +0530, Syed Nayyar Waris 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.


> +static const unsigned long bitmap_test_data[] __initconst = {
> +	0x38000201,
> +	0x05ff0f38,
> +	0xeffedcba,
> +	0xbbbbabcd,
> +	0x000000aa,
> +	0x000000aa,
> +	0x00ff0000,
> +	0xaaaaaa00,
> +	0xff000000,
> +	0x00aa0000,
> +	0x00000000,
> +	0x00000000,
> +	0x00000000,
> +	0x0f000000,
> +	0x00000ac0,
> +};
> +
> +static const unsigned long clump_exp1[] __initconst = {
> +	0x01,	/* 1 bit set */
> +	0x02,	/* non-edge 1 bit set */
> +	0x00,	/* zero bits set */
> +	0x38,	/* 3 bits set across 4-bit boundary */
> +	0x38,	/* Repeated clump */
> +	0x0F,	/* 4 bits set */
> +	0xFF,	/* all bits set */
> +	0x05,	/* non-adjacent 2 bits set */
> +};
> +
> +static const unsigned long clump_exp2[] __initconst = {
> +	0xfedcba,	/* 24 bits */
> +	0xabcdef,
> +	0xaabbbb,	/* Clump split between 2 words */
> +	0x000000,	/* zeroes in between */
> +	0x0000aa,
> +	0x000000,
> +	0x0000ff,
> +	0xaaaaaa,
> +	0x000000,
> +	0x0000ff,
> +};
> +
> +static const unsigned long clump_exp3[] __initconst = {
> +	0x00000000,	/* starting with 0s*/
> +	0x00000000,	/* All 0s */
> +	0x00000000,
> +	0x00000000,
> +	0x3f00000f,     /* Non zero set */
> +	0x2aa80003,
> +	0x00000aaa,
> +	0x00003fc0,
> +};
> +
> +static const unsigned long clump_exp4[] __initconst = {
> +	0x00,
> +	0x2b,
> +};
> +

One more struct here, like

struct clump_test_data {
	unsigned long *data; // with offset implied
	unsigned long count;
	unsigned long size;
	unsigned long limit;
	unsigned long *exp;
};

> +static const unsigned long * const clump_data[] __initconst = {
> +	clump_exp1,
> +	clump_exp2,
> +	clump_exp3,
> +	clump_exp4,
> +};
> +
>  static void __init test_for_each_set_clump8(void)
>  {
>  #define CLUMP_EXP_NUMBITS 64
> @@ -610,6 +708,48 @@ static void __init test_for_each_set_clump8(void)
>  		expect_eq_clump8(start, CLUMP_EXP_NUMBITS, clump_exp, &clump);
>  }
>  
> +static void __init execute_for_each_set_clump_test(unsigned long *bits,
> +				unsigned long size,
> +				unsigned long clump_size,
> +				const unsigned long *clump_exp)
> +{
> +	unsigned long start, clump;
> +
> +	for_each_set_clump(start, clump, bits, size, clump_size)
> +		expect_eq_clump(start, size, clump_exp, &clump, clump_size);
> +}
> +

> +static void __init prepare_test_data(unsigned long * bits,
> +				const unsigned long * test_data,
> +				int start, int count)

... prepare_test_data(struct clump_test_data *data)
{
	...
}

> +{
> +	int i;
> +	unsigned long position = 0;
> +
> +	for(i = 0; i < count; i++)
> +	{
> +		bitmap_set_value(bits, test_data[start++], position, 32);
> +		position += 32;
> +	}
> +}
> +
> +static void __init test_for_each_set_clump(void)
> +{
> +	int i;
> +	int count[] = {2, 8, 4, 1};
> +	int offset[] = {0, 2, 10, 14};
> +	unsigned long limit[] = {64, 240, 240, 18};
> +	unsigned long clump_size[] = {8, 24, 30, 6};
> +	DECLARE_BITMAP(bits, 256);
> +
> +	for(i = 0; i < 4; i++)
> +	{
> +		prepare_test_data(bits, bitmap_test_data, offset[i], count[i]);
> +		execute_for_each_set_clump_test(bits, limit[i],
> +					clump_size[i], clump_data[i]);
> +	}

As I told you it should be as simple as

	unsigned int i;

	for (i < ARRAY_SIZE(clump_test_data)) {
		prepare()
		execute()
	}

> +}


-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2020-05-04 11:38 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-02 23:08 [PATCH v5 0/4] Introduce the for_each_set_clump macro Syed Nayyar Waris
2020-05-02 23:08 ` Syed Nayyar Waris
2020-05-02 23:10 ` [PATCH v5 1/4] bitops: Introduce the " Syed Nayyar Waris
2020-05-02 23:11 ` [PATCH v5 2/4] lib/test_bitmap.c: Add for_each_set_clump test cases Syed Nayyar Waris
2020-05-04 11:38   ` Andy Shevchenko [this message]
2020-05-14 23:30     ` Syed Nayyar Waris
2020-05-02 23:16 ` [PATCH v5 3/4] gpio: thunderx: Utilize for_each_set_clump macro Syed Nayyar Waris
2020-05-02 23:19 ` [PATCH v5 4/4] gpio: xilinx: " Syed Nayyar Waris
2020-05-02 23:19   ` Syed Nayyar Waris
2020-05-04 11:41 ` [PATCH v5 0/4] Introduce the " Andy Shevchenko
2020-05-04 11:41   ` Andy Shevchenko
2020-05-04 14:36   ` William Breathitt Gray
2020-05-04 14:36     ` William Breathitt Gray
2020-05-05 13:51     ` Andy Shevchenko
2020-05-05 13:51       ` Andy Shevchenko
2020-05-05 14:53       ` William Breathitt Gray
2020-05-05 14:53         ` William Breathitt Gray
2020-05-05 14:53         ` William Breathitt Gray
2020-05-05 14:53         ` William Breathitt Gray
2020-05-09 16:36         ` Syed Nayyar Waris
2020-05-09 16:36           ` Syed Nayyar Waris
2020-05-10 19:05           ` Andy Shevchenko
2020-05-10 19:05             ` Andy Shevchenko

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=20200504113804.GD185537@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syednwaris@gmail.com \
    --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 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.