Message ID | 20230130125554.363481-1-mairacanal@riseup.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/format-helper: Use KUNIT_EXPECT_MEMEQ macro | expand |
On Mon, 30 Jan 2023 at 20:58, Maíra Canal <mairacanal@riseup.net> 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. Therefore, use KUNIT_EXPECT_MEMEQ to compare memory blocks in > replacement of the KUNIT_EXPECT_EQ macro. > > Signed-off-by: Maíra Canal <mairacanal@riseup.net> > --- Looks good to me! (I'd vaguely assumed we'd already updated these tests, but apparently not...) I expect this'll go in via one of the DRM trees, not the KUnit one (it doesn't apply to the kselftest/kunit tree as-is). Reviewed-by: David Gow <davidgow@google.com> Cheers, -- David > drivers/gpu/drm/tests/drm_format_helper_test.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c > index 34e80eb6d96e..9536829c6e3a 100644 > --- a/drivers/gpu/drm/tests/drm_format_helper_test.c > +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c > @@ -597,7 +597,7 @@ static void drm_test_fb_xrgb8888_to_xrgb1555(struct kunit *test) > > drm_fb_xrgb8888_to_xrgb1555(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); > buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); > - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static void drm_test_fb_xrgb8888_to_argb1555(struct kunit *test) > @@ -628,7 +628,7 @@ static void drm_test_fb_xrgb8888_to_argb1555(struct kunit *test) > > drm_fb_xrgb8888_to_argb1555(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); > buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); > - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static void drm_test_fb_xrgb8888_to_rgba5551(struct kunit *test) > @@ -659,7 +659,7 @@ static void drm_test_fb_xrgb8888_to_rgba5551(struct kunit *test) > > drm_fb_xrgb8888_to_rgba5551(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); > buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); > - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static void drm_test_fb_xrgb8888_to_rgb888(struct kunit *test) > @@ -724,7 +724,7 @@ static void drm_test_fb_xrgb8888_to_argb8888(struct kunit *test) > > drm_fb_xrgb8888_to_argb8888(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); > buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); > - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test) > @@ -786,7 +786,7 @@ static void drm_test_fb_xrgb8888_to_argb2101010(struct kunit *test) > > drm_fb_xrgb8888_to_argb2101010(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); > buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); > - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static struct kunit_case drm_format_helper_test_cases[] = { > -- > 2.39.1 >
Am 30.01.23 um 13:55 schrieb Maíra Canal: > 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. Therefore, use KUNIT_EXPECT_MEMEQ to compare memory blocks in > replacement of the KUNIT_EXPECT_EQ macro. > > Signed-off-by: Maíra Canal <mairacanal@riseup.net> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> > --- > drivers/gpu/drm/tests/drm_format_helper_test.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c > index 34e80eb6d96e..9536829c6e3a 100644 > --- a/drivers/gpu/drm/tests/drm_format_helper_test.c > +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c > @@ -597,7 +597,7 @@ static void drm_test_fb_xrgb8888_to_xrgb1555(struct kunit *test) > > drm_fb_xrgb8888_to_xrgb1555(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); > buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); > - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static void drm_test_fb_xrgb8888_to_argb1555(struct kunit *test) > @@ -628,7 +628,7 @@ static void drm_test_fb_xrgb8888_to_argb1555(struct kunit *test) > > drm_fb_xrgb8888_to_argb1555(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); > buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); > - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static void drm_test_fb_xrgb8888_to_rgba5551(struct kunit *test) > @@ -659,7 +659,7 @@ static void drm_test_fb_xrgb8888_to_rgba5551(struct kunit *test) > > drm_fb_xrgb8888_to_rgba5551(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); > buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); > - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static void drm_test_fb_xrgb8888_to_rgb888(struct kunit *test) > @@ -724,7 +724,7 @@ static void drm_test_fb_xrgb8888_to_argb8888(struct kunit *test) > > drm_fb_xrgb8888_to_argb8888(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); > buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); > - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test) > @@ -786,7 +786,7 @@ static void drm_test_fb_xrgb8888_to_argb2101010(struct kunit *test) > > drm_fb_xrgb8888_to_argb2101010(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); > buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); > - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static struct kunit_case drm_format_helper_test_cases[] = {
On 2/1/23 04:10, Thomas Zimmermann wrote: > > > Am 30.01.23 um 13:55 schrieb Maíra Canal: >> 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. Therefore, use KUNIT_EXPECT_MEMEQ to compare memory blocks in >> replacement of the KUNIT_EXPECT_EQ macro. >> >> Signed-off-by: Maíra Canal <mairacanal@riseup.net> > > Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Applied to drm-misc-next! Best Regards, - Maíra Canal > >> --- >> drivers/gpu/drm/tests/drm_format_helper_test.c | 10 +++++----- >> 1 file changed, 5 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c >> index 34e80eb6d96e..9536829c6e3a 100644 >> --- a/drivers/gpu/drm/tests/drm_format_helper_test.c >> +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c >> @@ -597,7 +597,7 @@ static void drm_test_fb_xrgb8888_to_xrgb1555(struct kunit *test) >> drm_fb_xrgb8888_to_xrgb1555(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); >> buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); >> - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); >> + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); >> } >> static void drm_test_fb_xrgb8888_to_argb1555(struct kunit *test) >> @@ -628,7 +628,7 @@ static void drm_test_fb_xrgb8888_to_argb1555(struct kunit *test) >> drm_fb_xrgb8888_to_argb1555(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); >> buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); >> - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); >> + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); >> } >> static void drm_test_fb_xrgb8888_to_rgba5551(struct kunit *test) >> @@ -659,7 +659,7 @@ static void drm_test_fb_xrgb8888_to_rgba5551(struct kunit *test) >> drm_fb_xrgb8888_to_rgba5551(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); >> buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); >> - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); >> + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); >> } >> static void drm_test_fb_xrgb8888_to_rgb888(struct kunit *test) >> @@ -724,7 +724,7 @@ static void drm_test_fb_xrgb8888_to_argb8888(struct kunit *test) >> drm_fb_xrgb8888_to_argb8888(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); >> buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); >> - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); >> + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); >> } >> static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test) >> @@ -786,7 +786,7 @@ static void drm_test_fb_xrgb8888_to_argb2101010(struct kunit *test) >> drm_fb_xrgb8888_to_argb2101010(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); >> buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); >> - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); >> + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); >> } >> static struct kunit_case drm_format_helper_test_cases[] = { >
diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c index 34e80eb6d96e..9536829c6e3a 100644 --- a/drivers/gpu/drm/tests/drm_format_helper_test.c +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c @@ -597,7 +597,7 @@ static void drm_test_fb_xrgb8888_to_xrgb1555(struct kunit *test) drm_fb_xrgb8888_to_xrgb1555(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } static void drm_test_fb_xrgb8888_to_argb1555(struct kunit *test) @@ -628,7 +628,7 @@ static void drm_test_fb_xrgb8888_to_argb1555(struct kunit *test) drm_fb_xrgb8888_to_argb1555(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } static void drm_test_fb_xrgb8888_to_rgba5551(struct kunit *test) @@ -659,7 +659,7 @@ static void drm_test_fb_xrgb8888_to_rgba5551(struct kunit *test) drm_fb_xrgb8888_to_rgba5551(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } static void drm_test_fb_xrgb8888_to_rgb888(struct kunit *test) @@ -724,7 +724,7 @@ static void drm_test_fb_xrgb8888_to_argb8888(struct kunit *test) drm_fb_xrgb8888_to_argb8888(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test) @@ -786,7 +786,7 @@ static void drm_test_fb_xrgb8888_to_argb2101010(struct kunit *test) drm_fb_xrgb8888_to_argb2101010(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); - KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } static struct kunit_case drm_format_helper_test_cases[] = {
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. Therefore, use KUNIT_EXPECT_MEMEQ to compare memory blocks in replacement of the KUNIT_EXPECT_EQ macro. Signed-off-by: Maíra Canal <mairacanal@riseup.net> --- drivers/gpu/drm/tests/drm_format_helper_test.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)