drm/panic: Add kunit tests for drm_panic
Subsystems (3)
Jocelyn Falempe
maintainerv4 cover drm/panic: Add kunit tests for drm_panic
This series adds some kunit tests to drm_panic, and a debugfs interface to easily test the panic screen rendering at different resolutions/pixel format.
The kunit tests draws the panic screens to different framebuffer size and format, and ensure it doesn't crash or draw outside of the buffer. However it doesn't check the resulting image, because it depends on other Kconfig options, like logo, fonts, or panic colors.
v2:
* Use debugfs instead of sending the framebuffer through the kunit logs. (Thomas Zimmermann).
* Add a few checks, and more comments in the kunit tests. (Maxime Ripard).
v3:
* Check the framebuffer content in drm_test_panic_screen_user_page().
* Fix memory leaks, when the test fails (Maxime Ripard).
v4:
* Run QR code test only if QR code panic screen is built.
* Drop the last patch to add a draw_test debugfs.
Jocelyn Falempe (2):
drm/panic: Rename draw_panic_static_* to draw_panic_screen_* drm/panic: Add kunit tests for drm_panic
MAINTAINERS | 1 + drivers/gpu/drm/drm_panic.c | 22 ++- drivers/gpu/drm/tests/drm_panic_test.c | 220 +++++++++++++++++++++++++ 3 files changed, 234 insertions(+), 9 deletions(-) create mode 100644 drivers/gpu/drm/tests/drm_panic_test.c
base-commit: 20de1b0080b9889094d703927871da8f21fb624e
Signature · 1 line
2.52.0
Jocelyn Falempe
maintainerPATCH v4 1/2 drm/panic: Rename draw_panic_static_* to draw_panic_screen_*
I called them "static" because the panic screen is drawn only once, but this can be confused with the static meaning in C. Also remove some unnecessary braces in draw_panic_dispatch(). No functionnal change.
--- drivers/gpu/drm/drm_panic.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_panic.c +9 -9
@@ -476,7 +476,7 @@ static void drm_panic_logo_draw(struct drm_scanout_buffer *sb, struct drm_rect * fg_color); } -static void draw_panic_static_user (struct drm_scanout_buffer *sb) +static void draw_panic_screen_user (struct drm_scanout_buffer *sb) {u32 fg_color =drm_draw_color_from_xrgb8888 (CONFIG_DRM_PANIC_FOREGROUND_COLOR , sb->format->format);
@@ -545,7 +545,7 @@ static int draw_line_with_wrap(struct drm_scanout_buffer *sb, const struct font_* Draw the kmsg buffer to the screen, starting from the youngest message at the bottom, * and going up until reaching the top of the screen. */ -static void draw_panic_static_kmsg (struct drm_scanout_buffer *sb) +static void draw_panic_screen_kmsg (struct drm_scanout_buffer *sb) {u32 fg_color =drm_draw_color_from_xrgb8888 (CONFIG_DRM_PANIC_FOREGROUND_COLOR , sb->format->format);
@@ -733,7 +733,7 @@ static int drm_panic_get_qr_code(u8 **qr_image)/* * Draw the panic message at the center of the screen, with a QR Code */ -static int _draw_panic_static_qr_code (struct drm_scanout_buffer *sb) +static int _draw_panic_screen_qr_code (struct drm_scanout_buffer *sb) {u32 fg_color =drm_draw_color_from_xrgb8888 (CONFIG_DRM_PANIC_FOREGROUND_COLOR , sb->format->format);
@@ -801,10 +801,10 @@ static int _draw_panic_static_qr_code(struct drm_scanout_buffer *sb) return 0; } -static void draw_panic_static_qr_code (struct drm_scanout_buffer *sb) +static void draw_panic_screen_qr_code (struct drm_scanout_buffer *sb) { -if (_draw_panic_static_qr_code (sb)) -draw_panic_static_user (sb); +if (_draw_panic_screen_qr_code (sb)) +draw_panic_screen_user (sb); }#else static void drm_panic_qr_init (void ) {};
@@ -879,18 +879,18 @@ static void draw_panic_dispatch(struct drm_scanout_buffer *sb) {switch (drm_panic_type) {case DRM_PANIC_TYPE_KMSG : -draw_panic_static_kmsg (sb); +draw_panic_screen_kmsg (sb);break ;#if IS_ENABLED (CONFIG_DRM_PANIC_SCREEN_QR_CODE )case DRM_PANIC_TYPE_QR : -draw_panic_static_qr_code (sb); +draw_panic_screen_qr_code (sb);break ;#endif case DRM_PANIC_TYPE_USER :default : -draw_panic_static_user (sb); +draw_panic_screen_user (sb); } }
Signature · 1 line
2.52.0
Re: [PATCH v4 1/2] drm/panic: Rename draw_panic_static_* to draw_panic_screen_*
Jocelyn Falempe <[email protected]> writes:
Hello Jocelyn,
Quoted 7 lines
I called them "static" because the panic screen is drawn only once, but this can be confused with the static meaning in C. Also remove some unnecessary braces in
draw_panic_dispatch(). No functionnal change.Signed-off-by Jocelyn Falempe <[email protected]>---
Makes sense.
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Jocelyn Falempe
maintainerPATCH v4 2/2 drm/panic: Add kunit tests for drm_panic
In reply to Jocelyn FalempeAdd kunit tests for drm_panic.
They check that drawing the panic screen doesn't crash, but they don't check the correctness of the resulting image.
---
v3:
* Check the framebuffer content in drm_test_panic_screen_user_page().
* Fix memory leaks, when the test fails (Maxime Ripard).
v4:
* Run QR code test only if QR code panic screen is built.
MAINTAINERS | 1 + drivers/gpu/drm/drm_panic.c | 4 + drivers/gpu/drm/tests/drm_panic_test.c | 220 +++++++++++++++++++++++++ 3 files changed, 225 insertions(+) create mode 100644 drivers/gpu/drm/tests/drm_panic_test.c
MAINTAINERS +1 -0
@@ -8749,6 +8749,7 @@ T: git https://gitlab.freedesktop.org/drm/misc/kernel.git F: drivers/gpu/drm/drm_draw.c F: drivers/gpu/drm/drm_draw_internal.h F: drivers/gpu/drm/drm_panic*.c +F: drivers/gpu/drm/tests/drm_panic_test.c F: include/drm/drm_panic* DRM PANIC QR CODE
drivers/gpu/drm/drm_panic.c +4 -0
@@ -1084,3 +1084,7 @@ void drm_panic_exit(void) {drm_panic_qr_exit (); } + +#ifdef CONFIG_DRM_KUNIT_TEST +#include "tests/drm_panic_test.c" +#endif
drivers/gpu/drm/tests/drm_panic_test.c new file +220 -0
220 lines not on this page · raw message
Signature · 1 line
2.52.0
Quoted 5 lines · Jocelyn Falempe
Add kunit tests for
drm_panic.
They check that drawing the panic screen doesn't crash, but they don't check the correctness of the resulting image.Signed-off-by Jocelyn Falempe <[email protected]>
Maxime