All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/tests: Split drm_framebuffer_create_test into parameterized tests
@ 2022-08-30 21:16 ` Maíra Canal
  0 siblings, 0 replies; 14+ messages in thread
From: Maíra Canal @ 2022-08-30 21:16 UTC (permalink / raw)
  To: Isabella Basso, magalilemes00, tales.aparecida, mwen,
	andrealmeid, siqueirajordao, Trevor Woerner, Daniel Vetter,
	David Airlie, Javier Martinez Canillas, David Gow,
	brendanhiggins, Arthur Grillo, michal.winiarski,
	José Expósito
  Cc: kunit-dev, linux-kselftest, dri-devel, linux-kernel, Maíra Canal

The igt_check_drm_framebuffer_create is based on a loop that executes
tests for all createbuffer_tests test cases. This could be better
represented by parameterized tests, provided by KUnit.

So, convert the igt_check_drm_framebuffer_create test into parameterized tests.

Signed-off-by: Maíra Canal <mairacanal@riseup.net>
---
 drivers/gpu/drm/tests/drm_framebuffer_test.c | 23 +++++++++-----------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/tests/drm_framebuffer_test.c b/drivers/gpu/drm/tests/drm_framebuffer_test.c
index ec7a08ba4056..3e46fd9f6615 100644
--- a/drivers/gpu/drm/tests/drm_framebuffer_test.c
+++ b/drivers/gpu/drm/tests/drm_framebuffer_test.c
@@ -25,7 +25,7 @@ struct drm_framebuffer_test {
 	const char *name;
 };
 
-static struct drm_framebuffer_test createbuffer_tests[] = {
+static const struct drm_framebuffer_test drm_framebuffer_create_cases[] = {
 { .buffer_created = 1, .name = "ABGR8888 normal sizes",
 	.cmd = { .width = 600, .height = 600, .pixel_format = DRM_FORMAT_ABGR8888,
 		 .handles = { 1, 0, 0 }, .pitches = { 4 * 600, 0, 0 },
@@ -340,28 +340,25 @@ static struct drm_device mock_drm_device = {
 	},
 };
 
-static int execute_drm_mode_fb_cmd2(struct drm_mode_fb_cmd2 *r)
+static void drm_framebuffer_create_test(struct kunit *test)
 {
+	const struct drm_framebuffer_test *params = test->param_value;
 	int buffer_created = 0;
 
 	mock_drm_device.dev_private = &buffer_created;
-	drm_internal_framebuffer_create(&mock_drm_device, r, NULL);
-	return buffer_created;
+	drm_internal_framebuffer_create(&mock_drm_device, &params->cmd, NULL);
+	KUNIT_EXPECT_EQ(test, params->buffer_created, buffer_created);
 }
 
-static void igt_check_drm_framebuffer_create(struct kunit *test)
+static void drm_framebuffer_to_desc(const struct drm_framebuffer_test *t, char *desc)
 {
-	int i = 0;
-
-	for (i = 0; i < ARRAY_SIZE(createbuffer_tests); i++) {
-		KUNIT_EXPECT_EQ_MSG(test, createbuffer_tests[i].buffer_created,
-				    execute_drm_mode_fb_cmd2(&createbuffer_tests[i].cmd),
-		     "Test %d: \"%s\" failed\n", i, createbuffer_tests[i].name);
-	}
+	strcpy(desc, t->name);
 }
 
+KUNIT_ARRAY_PARAM(drm_framebuffer_create, drm_framebuffer_create_cases, drm_framebuffer_to_desc);
+
 static struct kunit_case drm_framebuffer_tests[] = {
-	KUNIT_CASE(igt_check_drm_framebuffer_create),
+	KUNIT_CASE_PARAM(drm_framebuffer_create_test, drm_framebuffer_create_gen_params),
 	{ }
 };
 
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-09-02  7:52 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-30 21:16 [PATCH 1/2] drm/tests: Split drm_framebuffer_create_test into parameterized tests Maíra Canal
2022-08-30 21:16 ` Maíra Canal
2022-08-30 21:16 ` [PATCH 2/2] drm/tests: Change "igt_" prefix to "drm_" Maíra Canal
2022-08-30 21:16   ` Maíra Canal
2022-08-31  9:30   ` Jani Nikula
2022-08-31  9:30     ` Jani Nikula
2022-08-31 17:30     ` Maíra Canal
2022-08-31 17:30       ` Maíra Canal
2022-08-31 17:39       ` Jani Nikula
2022-08-31 17:39         ` Jani Nikula
2022-09-02  7:52   ` David Gow
2022-09-02  7:52     ` David Gow
2022-08-31 10:49 ` [PATCH 1/2] drm/tests: Split drm_framebuffer_create_test into parameterized tests Michał Winiarski
2022-08-31 10:49   ` Michał Winiarski

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.