Skip to contentSkip to conversation

tests/kms_lease: IGT test Cleanup

PATCH Superseded Mohammed Thasleem 2 participants 4 messages Aug 18, 2022

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v6 cover tests/kms_lease: IGT test Cleanup

Convert all possible subtests to dynamic and sanitize the system state before starting/exiting the subtest.

Mohammed Thasleem (2):
tests/kms_lease: Create dynamic subtests
tests/kms_lease: Test Cleanup

 tests/kms_lease.c | 257 ++++++++++++++++++++--------------------------
 1 file changed, 110 insertions(+), 147 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v6 1/2 tests/kms_lease: Create dynamic subtests

Modified tests/kms_lease to include dynamic test cases.

v2: Updated dynamic test cases to all test cases.
v3: Removed dynamic test for which it's not required.
v4: Moved content of for loop in to igt_dynamic.
v5: Minor changes.
v6: Removed run_test which is not required.

---
 tests/kms_lease.c | 55 ++++++++++++++---------------------------------
 1 file changed, 16 insertions(+), 39 deletions(-)
tests/kms_lease.c +16 -39
index 0bf102a6..d36f56aa 100644
@@ -808,42 +808,6 @@ static void lease_invalid_plane(data_t *data)
 	assert_unleased(ret);
 }
 
-
-static void run_test(data_t *data, void (*testfunc)(data_t *))
-{
-	lease_t *master = &data->master;
-	igt_display_t *display = &master->display;
-	igt_output_t *output;
-	enum pipe p;
-	unsigned int valid_tests = 0;
-
-	for_each_pipe_with_valid_output(display, p, output) {
-		igt_info("Beginning %s on pipe %s, connector %s\n",
-			 igt_subtest_name(),
-			 kmstest_pipe_name(p),
-			 igt_output_name(output));
-
-		data->pipe = p;
-		data->crtc_id = pipe_to_crtc_id(display, p);
-		data->connector_id = output->id;
-		data->plane_id =
-			igt_pipe_get_plane_type(&data->master.display.pipes[data->pipe],
-						DRM_PLANE_TYPE_PRIMARY)->drm_plane->plane_id;
-
-		testfunc(data);
-
-		igt_info("\n%s on pipe %s, connector %s: PASSED\n\n",
-			 igt_subtest_name(),
-			 kmstest_pipe_name(p),
-			 igt_output_name(output));
-
-		valid_tests++;
-	}
-
-	igt_require_f(valid_tests,
-		      "no valid crtc/connector combinations found\n");
-}
-
 #define assert_double_id_err(ret) \
 	igt_assert_f((ret) == -EBUSY || (ret) == -ENOSPC, \
 		     "wrong return code %i, %s\n", ret, \
@@ -1218,6 +1182,9 @@ static void lease_uevent(data_t *data)
 igt_main
 {
 	data_t data;
+	igt_output_t *output;
+	igt_display_t *display = &data.master.display;
+
 	const struct {
 		const char *name;
 		void (*func)(data_t *);
@@ -1249,14 +1216,24 @@ igt_main
 	igt_fixture {
 		data.master.fd = drm_open_driver_master(DRIVER_ANY);
 		kmstest_set_vt_graphics_mode();
-		igt_display_require(&data.master.display, data.master.fd);
+		igt_display_require(display, data.master.fd);
 	}
 
 	for (f = funcs; f->name; f++) {
 
 		igt_describe(f->desc);
-		igt_subtest_f("%s", f->name) {
-			run_test(&data, f->func);
+		igt_subtest_with_dynamic_f("%s", f->name) {
+			for_each_pipe_with_valid_output(display, data.pipe, data->output) {
+				igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(data.pipe),
+					      igt_output_name(output)) {
+					data.crtc_id = pipe_to_crtc_id(display, data.pipe);
+					data.connector_id = output->id;
+					data.plane_id =
+						igt_pipe_get_plane_type(&data.master.display.pipes[data.pipe],
+								DRM_PLANE_TYPE_PRIMARY)->drm_plane->plane_id;
+					f->func(&data);
+				}
+			}
 		}
 	}
 
Signature · 1 line
2.25.1
#2 lore raw

PATCH v6 2/2 tests/kms_lease: Test Cleanup

In reply to Mohammed Thasleem

Sanitize the system state before starting the subtest.

v2: Minor changes.
v3: Moved display reset and commit in to igt_subtest_with_dynamic_f.
v4: Separated display and non-display subsets.
v5: Minor changes.
v6: Removed connector_id_to_output,crtc_id_to_pipe & pipe_to_crtc_id
function calls.

---
 tests/kms_lease.c | 224 ++++++++++++++++++++++------------------------
 1 file changed, 105 insertions(+), 119 deletions(-)
tests/kms_lease.c +105 -119
index d36f56aa..758c0297 100644
@@ -64,36 +64,12 @@ typedef struct {
 	uint32_t plane_id;
 } data_t;
 
-static uint32_t pipe_to_crtc_id(igt_display_t *display, enum pipe pipe)
-{
-	return display->pipes[pipe].crtc_id;
-}
-
-static enum pipe crtc_id_to_pipe(igt_display_t *display, uint32_t crtc_id)
-{
-	enum pipe pipe;
-
-	for_each_pipe(display, pipe) {
-		if(display->pipes[pipe].crtc_id == crtc_id)
-			return pipe;
-	}
-	return -1;
-}
-
-static igt_output_t *connector_id_to_output(igt_display_t *display, uint32_t connector_id)
-{
-	drmModeConnector		connector;
-
-	connector.connector_id = connector_id;
-	return igt_output_from_connector(display, &connector);
-}
-
-static int prepare_crtc(lease_t *lease, uint32_t connector_id, uint32_t crtc_id)
+static int prepare_crtc(lease_t *lease, data_t *data)
 {
 	drmModeModeInfo *mode;
 	igt_display_t *display = &lease->display;
-	igt_output_t *output = connector_id_to_output(display, connector_id);
-	enum pipe pipe = crtc_id_to_pipe(display, crtc_id);
+	igt_output_t *output = data->output;
+	enum pipe pipe = data->pipe;
 	igt_plane_t *primary;
 	int ret;
 
@@ -136,7 +112,7 @@ static void cleanup_crtc(lease_t *lease, igt_output_t *output)
 	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
 	igt_plane_set_fb(primary, NULL);
 
-	igt_output_set_pipe(output, PIPE_ANY);
+	igt_output_set_pipe(output, PIPE_NONE);
 	igt_display_commit(display);
 }
 
@@ -238,14 +214,13 @@ static void simple_lease(data_t *data)
 	igt_display_require(&lease.display, lease.fd);
 
 	/* Set a mode on the leased output */
-	igt_assert_eq(0, prepare_crtc(&lease, data->connector_id, data->crtc_id));
+	igt_assert_eq(0, prepare_crtc(&lease, data));
 
 	/* Paint something attractive */
 	paint_fb(lease.fd, &lease.primary_fb, "simple_lease",
 		 lease.mode->name, igt_output_name(lease.output), kmstest_pipe_name(data->pipe));
 	igt_debug_wait_for_keypress("lease");
-	cleanup_crtc(&lease,
-		     connector_id_to_output(&lease.display, data->connector_id));
+	cleanup_crtc(&lease, data->output);
 
 	terminate_lease(&lease);
 }
@@ -292,7 +267,7 @@ static void page_flip_implicit_plane(data_t *data)
 	drmSetClientCap(data->master.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
 
 	/* Set a mode on the leased output */
-	igt_assert_eq(0, prepare_crtc(&data->master, data->connector_id, data->crtc_id));
+	igt_assert_eq(0, prepare_crtc(&data->master, data));
 
 	/* sanity check */
 	do_or_die(drmModePageFlip(data->master.fd, data->crtc_id,
@@ -300,10 +275,9 @@ static void page_flip_implicit_plane(data_t *data)
 			      0, NULL));
 
 	display = &data->master.display;
-	pipe = crtc_id_to_pipe(display, data->crtc_id);
 
 	igt_wait_for_vblank(data->master.fd,
-			display->pipes[pipe].crtc_offset);
+			display->pipes[data->pipe].crtc_offset);
 
 	do_or_die(drmModePageFlip(mcl.fd, data->crtc_id,
 			      data->master.primary_fb.fb_id,
@@ -313,10 +287,8 @@ static void page_flip_implicit_plane(data_t *data)
 	object_ids[mcl.object_count++] = wrong_plane_id;
 	do_or_die(create_lease(data->master.fd, &mcl));
 
-	pipe = crtc_id_to_pipe(display, data->crtc_id);
-
 	igt_wait_for_vblank(data->master.fd,
-			display->pipes[pipe].crtc_offset);
+			display->pipes[data->pipe].crtc_offset);
 
 	igt_assert_eq(drmModePageFlip(mcl.fd, data->crtc_id,
 				      data->master.primary_fb.fb_id,
@@ -324,8 +296,7 @@ static void page_flip_implicit_plane(data_t *data)
 		      -EACCES);
 	close(mcl.fd);
 
-	cleanup_crtc(&data->master,
-		     connector_id_to_output(&data->master.display, data->connector_id));
+	cleanup_crtc(&data->master, data->output);
 }
 
 static void setcrtc_implicit_plane(data_t *data)
@@ -334,9 +305,7 @@ static void setcrtc_implicit_plane(data_t *data)
 	struct drm_mode_create_lease mcl;
 	drmModePlaneRes *plane_resources;
 	uint32_t wrong_plane_id = 0;
-	igt_output_t *output =
-		connector_id_to_output(&data->master.display,
-				       data->connector_id);
+	igt_output_t *output = data->output;
 	drmModeModeInfo *mode = igt_output_get_mode(output);
 	int i;
 
@@ -363,7 +332,7 @@ static void setcrtc_implicit_plane(data_t *data)
 	drmSetClientCap(data->master.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
 
 	/* Set a mode on the leased output */
-	igt_assert_eq(0, prepare_crtc(&data->master, data->connector_id, data->crtc_id));
+	igt_assert_eq(0, prepare_crtc(&data->master, data));
 
 	/* sanity check */
 	do_or_die(drmModeSetCrtc(data->master.fd, data->crtc_id, -1,
@@ -383,8 +352,7 @@ static void setcrtc_implicit_plane(data_t *data)
 				 0, 0, 0, NULL, 0, NULL));
 	close(mcl.fd);
 
-	cleanup_crtc(&data->master,
-		     connector_id_to_output(&data->master.display, data->connector_id));
+	cleanup_crtc(&data->master, data->output);
 }
 
 static void cursor_implicit_plane(data_t *data)
@@ -404,7 +372,7 @@ static void cursor_implicit_plane(data_t *data)
 	drmSetClientCap(data->master.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
 
 	/* Set a mode on the leased output */
-	igt_assert_eq(0, prepare_crtc(&data->master, data->connector_id, data->crtc_id));
+	igt_assert_eq(0, prepare_crtc(&data->master, data));
 
 	/* sanity check */
 	do_or_die(drmModeSetCursor(data->master.fd, data->crtc_id, 0, 0, 0));
@@ -419,8 +387,7 @@ static void cursor_implicit_plane(data_t *data)
 		      -EACCES);
 	close(mcl.fd);
 
-	cleanup_crtc(&data->master,
-		     connector_id_to_output(&data->master.display, data->connector_id));
+	cleanup_crtc(&data->master, data->output);
 }
 
 static void atomic_implicit_crtc(data_t *data)
@@ -642,8 +609,8 @@ static void lease_unleased_crtc(data_t *data)
 	for_each_pipe(&data->master.display, p) {
 		if (bad_crtc_id != 0)
 			break;
-		if (pipe_to_crtc_id(&data->master.display, p) != data->crtc_id)
-			bad_crtc_id = pipe_to_crtc_id(&data->master.display, p);
+		if (data->master.display.pipes[p].crtc_id != data->crtc_id)
+			bad_crtc_id = data->master.display.pipes[p].crtc_id;
 	}
 
 	/* Give up if there isn't another crtc */
@@ -729,7 +696,7 @@ static void lease_revoke(data_t *data)
 	igt_assert_eq(revoke_lease(data->master.fd, &mrl), 0);
 
 	/* Try to use the leased objects */
-	ret = prepare_crtc(&lease, data->connector_id, data->crtc_id);
+	ret = prepare_crtc(&lease, data);
 
 	/* Ensure that the expected error is returned */
 	igt_assert_eq(ret, -ENOENT);
@@ -1185,83 +1152,102 @@ igt_main
 	igt_output_t *output;
 	igt_display_t *display = &data.master.display;
 
-	const struct {
-		const char *name;
-		void (*func)(data_t *);
-		const char *desc;
-	} funcs[] = {
-		{ "simple_lease", simple_lease, "Check if create lease ioctl call works" },
-		{ "empty_lease", empty_lease, "Check that creating an empty lease works" },
-		{ "lessee_list", lessee_list, "Check if listed lease is same as created one" },
-		{ "lease_get", lease_get, "Tests getting the required contents of a lease" },
-		{ "lease_unleased_connector", lease_unleased_connector, "Negative test by trying to"
-			" use an unleased connector " },
-		{ "lease_unleased_crtc", lease_unleased_crtc, "Negative test by trying to use an unleased crtc" },
-		{ "lease_revoke", lease_revoke, "Tests revocation of lease" },
-		{ "lease_again", lease_again, "Tests leasing objects more than once" },
-		{ "lease_invalid_connector", lease_invalid_connector, "Tests leasing an invalid connector" },
-		{ "lease_invalid_crtc", lease_invalid_crtc, "Tests leasing an invalid crtc" },
-		{ "lease_invalid_plane", lease_invalid_plane, "Tests leasing an invalid plane" },
-		{ "page_flip_implicit_plane", page_flip_implicit_plane, "Negative test by using a "
-			"non-primary plane with the page flip ioctl" },
-		{ "setcrtc_implicit_plane", setcrtc_implicit_plane, "Negative test by using a "
-			"non-primary plane with the setcrtc ioctl" },
-		{ "cursor_implicit_plane", cursor_implicit_plane, "Negative test by using a non-primary"
-			" plane with setcursor ioctl" },
-		{ "atomic_implicit_crtc", atomic_implicit_crtc, "Negative test by using a different"
-			" crtc with atomic ioctl" },
-		{ }
-	}, *f;
-
 	igt_fixture {
 		data.master.fd = drm_open_driver_master(DRIVER_ANY);
 		kmstest_set_vt_graphics_mode();
 		igt_display_require(display, data.master.fd);
 	}
 
-	for (f = funcs; f->name; f++) {
-
-		igt_describe(f->desc);
-		igt_subtest_with_dynamic_f("%s", f->name) {
-			for_each_pipe_with_valid_output(display, data.pipe, data->output) {
-				igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(data.pipe),
-					      igt_output_name(output)) {
-					data.crtc_id = pipe_to_crtc_id(display, data.pipe);
-					data.connector_id = output->id;
-					data.plane_id =
-						igt_pipe_get_plane_type(&data.master.display.pipes[data.pipe],
-								DRM_PLANE_TYPE_PRIMARY)->drm_plane->plane_id;
-					f->func(&data);
+	/*Display dependent subtests*/
+	igt_subtest_group {
+
+		const struct {
+			const char *name;
+			void (*func)(data_t *);
+			const char *desc;
+		} funcs[] = {
+			{ "simple_lease", simple_lease, "Check if create lease ioctl call works" },
+			{ "empty_lease", empty_lease, "Check that creating an empty lease works" },
+			{ "lessee_list", lessee_list, "Check if listed lease is same as created one" },
+			{ "lease_get", lease_get, "Tests getting the required contents of a lease" },
+			{ "lease_unleased_connector", lease_unleased_connector, "Negative test by trying to"
+				" use an unleased connector " },
+			{ "lease_unleased_crtc", lease_unleased_crtc, "Negative test by trying to use an unleased crtc" },
+			{ "lease_revoke", lease_revoke, "Tests revocation of lease" },
+			{ "lease_again", lease_again, "Tests leasing objects more than once" },
+			{ "lease_invalid_connector", lease_invalid_connector, "Tests leasing an invalid connector" },
+			{ "lease_invalid_crtc", lease_invalid_crtc, "Tests leasing an invalid crtc" },
+			{ "lease_invalid_plane", lease_invalid_plane, "Tests leasing an invalid plane" },
+			{ "page_flip_implicit_plane", page_flip_implicit_plane, "Negative test by using a "
+				"non-primary plane with the page flip ioctl" },
+			{ "setcrtc_implicit_plane", setcrtc_implicit_plane, "Negative test by using a "
+				"non-primary plane with the setcrtc ioctl" },
+			{ "cursor_implicit_plane", cursor_implicit_plane, "Negative test by using a non-primary"
+				" plane with setcursor ioctl" },
+			{ "atomic_implicit_crtc", atomic_implicit_crtc, "Negative test by using a different"
+				" crtc with atomic ioctl" },
+			{ }
+		}, *f;
+
+		igt_fixture
+			igt_display_require_output(display);
+
+		for (f = funcs; f->name; f++) {
+
+			igt_describe(f->desc);
+			igt_subtest_with_dynamic_f("%s", f->name) {
+				for_each_pipe_with_valid_output(display, data.pipe, data->output) {
+					igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(data.pipe),
+						      igt_output_name(output)) {
+						igt_display_reset(display);
+						igt_display_commit(display);
+						data.crtc_id = display->pipes[data.pipe].crtc_id;
+						data.connector_id = output->id;
+						data.master.output = output;
+						data.plane_id =
+							igt_pipe_get_plane_type(&data.master.display.pipes[data.pipe],
+									DRM_PLANE_TYPE_PRIMARY)->drm_plane->plane_id;
+						f->func(&data);
+					}
 				}
 			}
 		}
 	}
 
-	igt_describe("Tests error handling while creating invalid corner-cases for "
-		     "create-lease ioctl");
-	igt_subtest("invalid-create-leases")
-		invalid_create_leases(&data);
-
-	igt_describe("Tests that  possible_crtcs logically match between master and "
-		     "lease, and that the values are correctly renumbered on the lease side.");
-	igt_subtest("possible-crtcs-filtering")
-		possible_crtcs_filtering(&data);
-
-	igt_describe("Tests the drop/set_master interactions.");
-	igt_subtest("master-vs-lease")
-		master_vs_lease(&data);
-
-	igt_describe("Tests that the 2nd master can only create leases while being active "
-		     "master, and that leases on the first master don't prevent lease creation "
-		     "for the 2nd master.");
-	igt_subtest("multimaster-lease")
-		multimaster_lease(&data);
-
-	igt_describe("Tests the implicitly added planes.");
-	igt_subtest("implicit-plane-lease")
-		implicit_plane_lease(&data);
-
-	igt_describe("Tests all the uevent cases");
-	igt_subtest("lease-uevent")
-		lease_uevent(&data);
+	/*Non-Display dependent subtests*/
+	igt_subtest_group {
+
+		igt_describe("Tests error handling while creating invalid corner-cases for "
+			     "create-lease ioctl");
+		igt_subtest("invalid-create-leases")
+			invalid_create_leases(&data);
+
+		igt_describe("Tests that  possible_crtcs logically match between master and "
+			     "lease, and that the values are correctly renumbered on the lease side.");
+		igt_subtest("possible-crtcs-filtering")
+			possible_crtcs_filtering(&data);
+
+		igt_describe("Tests the drop/set_master interactions.");
+		igt_subtest("master-vs-lease")
+			master_vs_lease(&data);
+
+		igt_describe("Tests that the 2nd master can only create leases while being active "
+			     "master, and that leases on the first master don't prevent lease creation "
+			     "for the 2nd master.");
+		igt_subtest("multimaster-lease")
+			multimaster_lease(&data);
+
+		igt_describe("Tests the implicitly added planes.");
+		igt_subtest("implicit-plane-lease")
+			implicit_plane_lease(&data);
+
+		igt_describe("Tests all the uevent cases");
+		igt_subtest("lease-uevent")
+			lease_uevent(&data);
+	}
+
+	igt_fixture {
+		igt_display_fini(display);
+		close(data.master.fd);
+	}
 }
Signature · 1 line
2.25.1
#3 lore raw

[igt-dev] ✗ Fi.CI.BUILD: failure for tests/kms_lease: IGT test Cleanup

In reply to Mohammed Thasleem
== Series Details ==

== Series Details ==

Series: tests/kms_lease: IGT test Cleanup
URL : https://patchwork.freedesktop.org/series/107439/
State : failure

== Summary ==

IGT patchset build failed on latest successful build b5e2222c9a988015bdf237e6ebb9f5b6d87ac7e1 tools/intel_vbt_decode: Extract dp_vswing()/dp_preemph()

../tests/kms_lease.c: In function ‘cursor_implicit_plane’:
../tests/kms_lease.c:390:34: error: ‘data_t’ {aka ‘struct <anonymous>’} has no member named ‘output’

  cleanup_crtc(&data->master, data->output);
                                  ^~
In file included from ../lib/igt.h:38,
                 from ../tests/kms_lease.c:30:
../tests/kms_lease.c: In function ‘__igt_unique____real_main1149’:
../tests/kms_lease.c:1199:61: error: invalid type argument of ‘->’ (have ‘data_t’ {aka ‘struct <anonymous>’})
     for_each_pipe_with_valid_output(display, data.pipe, data->output) {
                                                             ^~
../lib/igt_kms.h:544:38: note: in definition of macro ‘for_each_if’
 #define for_each_if(condition) if (!(condition)) {} else
                                      ^~~~~~~~~
../tests/kms_lease.c:1199:5: note: in expansion of macro ‘for_each_pipe_with_valid_output’
     for_each_pipe_with_valid_output(display, data.pipe, data->output) {
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../tests/kms_lease.c:1199:61: error: invalid type argument of ‘->’ (have ‘data_t’ {aka ‘struct <anonymous>’})
     for_each_pipe_with_valid_output(display, data.pipe, data->output) {
                                                             ^~
../lib/igt_kms.h:544:38: note: in definition of macro ‘for_each_if’
 #define for_each_if(condition) if (!(condition)) {} else
                                      ^~~~~~~~~
../lib/igt_kms.h:604:7: note: in expansion of macro ‘igt_pipe_connector_valid’
       igt_pipe_connector_valid((pipe), (output))))
       ^~~~~~~~~~~~~~~~~~~~~~~~
../tests/kms_lease.c:1199:5: note: in expansion of macro ‘for_each_pipe_with_valid_output’
     for_each_pipe_with_valid_output(display, data.pipe, data->output) {
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../tests/kms_lease.c:1199:61: error: invalid type argument of ‘->’ (have ‘data_t’ {aka ‘struct <anonymous>’})
     for_each_pipe_with_valid_output(display, data.pipe, data->output) {
                                                             ^~
../lib/igt_kms.h:544:38: note: in definition of macro ‘for_each_if’
 #define for_each_if(condition) if (!(condition)) {} else
                                      ^~~~~~~~~
../lib/igt_kms.h:604:7: note: in expansion of macro ‘igt_pipe_connector_valid’
       igt_pipe_connector_valid((pipe), (output))))
       ^~~~~~~~~~~~~~~~~~~~~~~~
../tests/kms_lease.c:1199:5: note: in expansion of macro ‘for_each_pipe_with_valid_output’
     for_each_pipe_with_valid_output(display, data.pipe, data->output) {
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../lib/igt_kms.h:603:57: warning: left-hand operand of comma expression has no effect [-Wunused-value]
    for_each_if ((((output) = &(display)->outputs[con__]), \
                                                         ^
../lib/igt_kms.h:544:38: note: in definition of macro ‘for_each_if’
 #define for_each_if(condition) if (!(condition)) {} else
                                      ^~~~~~~~~
../tests/kms_lease.c:1199:5: note: in expansion of macro ‘for_each_pipe_with_valid_output’
     for_each_pipe_with_valid_output(display, data.pipe, data->output) {
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ninja: build stopped: subcommand failed.