lkml.org 
[lkml]   [2022]   [May]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subject[RFC PATCH 0/1] KUnit tests for drm_format_helper
Date
Hello everyone,

Recently Javier added a new task in the ToDo list [1] to create KUnit
tests for the functions present in "drm_format_helper".

This patch, marked as RFC to start the conversation, includes tests for
"drm_fb_xrgb8888_to_rgb332".

Since the conversion functions present in "drm_format_helper" convert
from XRGB8888 to another format, my plan is to create a set of XRGB8888
data to test all the available conversions.

To illustrate it with an example, the code present in this patch:

{
.name = "Single pixel source",
.pitch = 1 * 4,
.dst_pitch = 0,
.clip = CLIP(0, 0, 1, 1),
.xrgb8888 = { 0x01FF0000 },
.expected = { 0xE0 },
}

In a follow up patch, should look like:

{
.name = "Single pixel source",
.pitch = 1 * 4,
.clip = CLIP(0, 0, 1, 1),
.xrgb8888 = { 0x01FF0000 },
.expected = {
{
.dst_format = DRM_FORMAT_RGB332,
.dst_pitch = 0,
.conv_func = drm_fb_xrgb8888_to_rgb332,
.result = { 0xE0 },
},
{ ... },
},
}

What is tested?

- Different values for the X in XRGB8888 to make sure it is ignored
- Different clip values: Single pixel and full and partial buffer
- Well know colors: White, black, red, green, blue, magenta, yellow
and cyan
- Other colors: Randomly picked
- Destination pitch

What is NOT tested?

- NULL destination buffer: Because there is not validation in place
- Out of bounds destination buffer: The size of the buffer is not
checked. The conversion function could cause out of bound errors
- Out of bounds source buffer: Similary to the destination buffer, the
source buffer is read without checking its size
- Invalid clip values: Because there is no clip validation.
Example: clip out of or bigger than the source buffer
- Invalid destination pitch: A dst_pitch < (clip->width * dst_pixsize)
could cause issues.
- "Big" source buffers. I don't know if this kind of tests could be of
interest

How to run the tests?

My .kunitconfig:

CONFIG_KUNIT=y
CONFIG_DRM=y
CONFIG_DRM_FORMAR_HELPER_TEST=y

$ ./tools/testing/kunit/kunit.py run --arch=x86_64

Feedback?

It'd be great to know your ideas about what else we could test, if you
think that we should make the functions safer by checking the buffers
and clip sizes or anything else.

Thanks a lot,
José Expósito

[1] https://cgit.freedesktop.org/drm/drm-misc/commit/?id=596c35b1440e

José Expósito (1):
drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_rgb332()

drivers/gpu/drm/Kconfig | 12 ++
drivers/gpu/drm/Makefile | 3 +
drivers/gpu/drm/drm_format_helper_test.c | 166 +++++++++++++++++++++++
3 files changed, 181 insertions(+)
create mode 100644 drivers/gpu/drm/drm_format_helper_test.c

--
2.25.1

\
 
 \ /
  Last update: 2022-05-30 12:21    [W:0.105 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site