* [PATCH] HID: uclogic: Use KUNIT_EXPECT_MEMEQ
@ 2022-12-26 12:57 José Expósito
2022-12-26 13:22 ` Maíra Canal
2023-01-18 8:47 ` Jiri Kosina
0 siblings, 2 replies; 3+ messages in thread
From: José Expósito @ 2022-12-26 12:57 UTC (permalink / raw)
To: jikos
Cc: benjamin.tissoires, mcanal, mairacanal, linux-input,
linux-kernel, José Expósito
Commit b8a926bea8b1 ("kunit: Introduce KUNIT_EXPECT_MEMEQ and
KUNIT_EXPECT_MEMNEQ macros") introduced a new macro to compare blocks of
memory and, if the test fails, print the result in a human friendly
format. For example, this is the output of a test failure:
Expected res == params->expected, but
res ==
01 02 aa 00 00 00 03 bb 00 <00> 00 04 05
params->expected ==
01 02 aa 00 00 00 03 bb 00 <01> 00 04 05
Use this new macro to replace KUNIT_EXPECT_EQ + memcmp.
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/hid/hid-uclogic-rdesc-test.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/hid/hid-uclogic-rdesc-test.c b/drivers/hid/hid-uclogic-rdesc-test.c
index b429c541bf2f..90bf4e586e01 100644
--- a/drivers/hid/hid-uclogic-rdesc-test.c
+++ b/drivers/hid/hid-uclogic-rdesc-test.c
@@ -197,8 +197,7 @@ static void hid_test_uclogic_template(struct kunit *test)
params->param_list,
params->param_num);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, res);
- KUNIT_EXPECT_EQ(test, 0,
- memcmp(res, params->expected, params->template_size));
+ KUNIT_EXPECT_MEMEQ(test, res, params->expected, params->template_size);
kfree(res);
}
--
2.38.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] HID: uclogic: Use KUNIT_EXPECT_MEMEQ
2022-12-26 12:57 [PATCH] HID: uclogic: Use KUNIT_EXPECT_MEMEQ José Expósito
@ 2022-12-26 13:22 ` Maíra Canal
2023-01-18 8:47 ` Jiri Kosina
1 sibling, 0 replies; 3+ messages in thread
From: Maíra Canal @ 2022-12-26 13:22 UTC (permalink / raw)
To: José Expósito, jikos
Cc: benjamin.tissoires, mairacanal, linux-input, linux-kernel
On 12/26/22 09:57, José Expósito wrote:
> Commit b8a926bea8b1 ("kunit: Introduce KUNIT_EXPECT_MEMEQ and
> KUNIT_EXPECT_MEMNEQ macros") introduced a new macro to compare blocks of
> memory and, if the test fails, print the result in a human friendly
> format. For example, this is the output of a test failure:
>
> Expected res == params->expected, but
> res ==
> 01 02 aa 00 00 00 03 bb 00 <00> 00 04 05
> params->expected ==
> 01 02 aa 00 00 00 03 bb 00 <01> 00 04 05
>
> Use this new macro to replace KUNIT_EXPECT_EQ + memcmp.
>
> Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Reviewed-by: Maíra Canal <mairacanal@riseup.net>
Best Regards,
- Maíra Canal
> ---
> drivers/hid/hid-uclogic-rdesc-test.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/hid/hid-uclogic-rdesc-test.c b/drivers/hid/hid-uclogic-rdesc-test.c
> index b429c541bf2f..90bf4e586e01 100644
> --- a/drivers/hid/hid-uclogic-rdesc-test.c
> +++ b/drivers/hid/hid-uclogic-rdesc-test.c
> @@ -197,8 +197,7 @@ static void hid_test_uclogic_template(struct kunit *test)
> params->param_list,
> params->param_num);
> KUNIT_ASSERT_NOT_ERR_OR_NULL(test, res);
> - KUNIT_EXPECT_EQ(test, 0,
> - memcmp(res, params->expected, params->template_size));
> + KUNIT_EXPECT_MEMEQ(test, res, params->expected, params->template_size);
> kfree(res);
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] HID: uclogic: Use KUNIT_EXPECT_MEMEQ
2022-12-26 12:57 [PATCH] HID: uclogic: Use KUNIT_EXPECT_MEMEQ José Expósito
2022-12-26 13:22 ` Maíra Canal
@ 2023-01-18 8:47 ` Jiri Kosina
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Kosina @ 2023-01-18 8:47 UTC (permalink / raw)
To: José Expósito
Cc: benjamin.tissoires, mcanal, mairacanal, linux-input, linux-kernel
On Mon, 26 Dec 2022, José Expósito wrote:
> Commit b8a926bea8b1 ("kunit: Introduce KUNIT_EXPECT_MEMEQ and
> KUNIT_EXPECT_MEMNEQ macros") introduced a new macro to compare blocks of
> memory and, if the test fails, print the result in a human friendly
> format. For example, this is the output of a test failure:
>
> Expected res == params->expected, but
> res ==
> 01 02 aa 00 00 00 03 bb 00 <00> 00 04 05
> params->expected ==
> 01 02 aa 00 00 00 03 bb 00 <01> 00 04 05
>
> Use this new macro to replace KUNIT_EXPECT_EQ + memcmp.
>
> Signed-off-by: José Expósito <jose.exposito89@gmail.com>
> ---
> drivers/hid/hid-uclogic-rdesc-test.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/hid/hid-uclogic-rdesc-test.c b/drivers/hid/hid-uclogic-rdesc-test.c
> index b429c541bf2f..90bf4e586e01 100644
> --- a/drivers/hid/hid-uclogic-rdesc-test.c
> +++ b/drivers/hid/hid-uclogic-rdesc-test.c
> @@ -197,8 +197,7 @@ static void hid_test_uclogic_template(struct kunit *test)
> params->param_list,
> params->param_num);
> KUNIT_ASSERT_NOT_ERR_OR_NULL(test, res);
> - KUNIT_EXPECT_EQ(test, 0,
> - memcmp(res, params->expected, params->template_size));
> + KUNIT_EXPECT_MEMEQ(test, res, params->expected, params->template_size);
> kfree(res);
Applied, thanks.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-18 9:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-26 12:57 [PATCH] HID: uclogic: Use KUNIT_EXPECT_MEMEQ José Expósito
2022-12-26 13:22 ` Maíra Canal
2023-01-18 8:47 ` Jiri Kosina
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.