[PATCH i-g-t 2/2] tests/core_getversion: Added raw-cards subtest

Kamil Konieczny kamil.konieczny at linux.intel.com
Wed Dec 18 19:04:18 UTC 2024


Created new subtest raw-card for checking all cards without
loading any driver, so it could show what is loaded on a system
after booting.

Signed-off-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
---
 tests/core_getversion.c | 39 ++++++++++++++++++++++++++++++++-------
 1 file changed, 32 insertions(+), 7 deletions(-)

diff --git a/tests/core_getversion.c b/tests/core_getversion.c
index 0842b7db6..989ed2aba 100644
--- a/tests/core_getversion.c
+++ b/tests/core_getversion.c
@@ -25,6 +25,7 @@
  *
  */
 
+#include <fcntl.h>
 #include <string.h>
 #include <sys/ioctl.h>
 
@@ -45,6 +46,9 @@
  *
  * SUBTEST: all-cards
  * Description: Tests GET_VERSION ioctl for all drm devices.
+ *
+ * SUBTEST: raw-cards
+ * Description: Test GET_VERSION ioctl for all present drm devices without loading any driver.
  */
 
 IGT_TEST_DESCRIPTION("Tests the DRM_IOCTL_GET_VERSION ioctl and libdrm's "
@@ -83,26 +87,47 @@ static void check_all_drm(void)
 	}
 }
 
-igt_main
+static void check_raw_drm_cards(void)
 {
+	char fname[32];
 	char info[256];
-	int fd;
+	int fd2, count;
 
-	igt_fixture {
-		fd = __drm_open_driver(DRIVER_ANY);
-		igt_assert_fd(fd);
+	count = 0;
+	for (int i = 0; i < 128; i++) {
+		snprintf(fname, ARRAY_SIZE(fname), "/dev/dri/card%d", i);
+		fd2 = open(fname, O_RDWR);
+		if (fd2 == -1)
+			continue;
+
+		++count;
+		check(fd2, info, sizeof(info));
+		igt_info("%d: %s\n", i, info);
+		close(fd2);
 	}
 
+	igt_info("Tested %d drm devices\n", count);
+}
+
+igt_main
+{
+	char info[256];
+	int fd;
+
 	igt_describe("Check GET_VERSION ioctl of the first drm device.");
 	igt_subtest("basic") {
+		fd = __drm_open_driver(DRIVER_ANY);
+		igt_assert_fd(fd);
 		check(fd, info, sizeof(info));
 		igt_info("0: %s\n", info);
+		__drm_close_driver(fd);
 	}
 
 	igt_describe("Check GET_VERSION ioctl for all drm devices.");
 	igt_subtest("all-cards")
 		check_all_drm();
 
-	igt_fixture
-		__drm_close_driver(fd);
+	igt_describe("Check GET_VERSION ioctl for all present drm devices without loading any driver.");
+	igt_subtest("raw-cards")
+		check_raw_drm_cards();
 }
-- 
2.47.1



More information about the igt-dev mailing list