[igt-dev] [PATCH i-g-t 1/5] xe/xe_sysfs: Updated tests to use xe_sysfs_gt_open

priyanka.dandamudi at intel.com priyanka.dandamudi at intel.com
Fri Aug 4 05:10:11 UTC 2023


From: Priyanka Dandamudi <priyanka.dandamudi at intel.com>

Tests have been updated to use xe_sysfs_gt_open function.

Cc: Tejas Upadhyay <tejas.upadhyay at intel.com>
Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi at intel.com>
Reviewed-by: Tejas Upadhyay <tejas.upadhyay at intel.com>
---
 tests/xe/xe_sysfs_defaults.c  | 10 ++++++----
 tests/xe/xe_sysfs_scheduler.c | 10 ++++++----
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/tests/xe/xe_sysfs_defaults.c b/tests/xe/xe_sysfs_defaults.c
index 5c9de43e9..ff958161b 100644
--- a/tests/xe/xe_sysfs_defaults.c
+++ b/tests/xe/xe_sysfs_defaults.c
@@ -65,25 +65,27 @@ igt_main
 
 		sys_fd = igt_sysfs_open(xe);
 		igt_require(sys_fd != -1);
+		close(sys_fd);
 	}
 
 	igt_subtest_with_dynamic("engine-defaults") {
 		xe_for_each_gt(xe, gt) {
 			int engines_fd = -1;
-			char buf[100];
+			int gt_fd = -1;
 
-			sprintf(buf, "device/gt%d/engines", gt);
-			engines_fd = openat(sys_fd, buf, O_RDONLY);
+			gt_fd = xe_sysfs_gt_open(xe, gt);
+			igt_require(gt_fd != -1);
+			engines_fd = openat(gt_fd, "engines", O_RDONLY);
 			igt_require(engines_fd != -1);
 
 			igt_sysfs_engines(xe, engines_fd, NULL, test_defaults);
 
 			close(engines_fd);
+			 close(gt_fd);
 		}
 	}
 
 	igt_fixture {
-		close(sys_fd);
 		xe_device_put(xe);
 		close(xe);
 	}
diff --git a/tests/xe/xe_sysfs_scheduler.c b/tests/xe/xe_sysfs_scheduler.c
index 1da0f541a..2a113ea0f 100644
--- a/tests/xe/xe_sysfs_scheduler.c
+++ b/tests/xe/xe_sysfs_scheduler.c
@@ -184,6 +184,7 @@ igt_main
 
 		sys_fd = igt_sysfs_open(xe);
 		igt_require(sys_fd != -1);
+		close(sys_fd);
 	}
 
 	for (int i = 0; i < count; i++) {
@@ -191,20 +192,21 @@ igt_main
 			igt_subtest_with_dynamic_f("%s-%s", property[i][0], t->name) {
 				xe_for_each_gt(xe, gt) {
 					int engines_fd = -1;
-					char buf[100];
+					int gt_fd = -1;
 
-					sprintf(buf, "device/gt%d/engines", gt);
-					engines_fd = openat(sys_fd, buf, O_RDONLY);
+					gt_fd = xe_sysfs_gt_open(xe, gt);
+					igt_require(gt_fd != -1);
+					engines_fd = openat(gt_fd, "engines", O_RDONLY);
 					igt_require(engines_fd != -1);
 
 					igt_sysfs_engines(xe, engines_fd, property[i], t->fn);
 					close(engines_fd);
+					close(gt_fd);
 				}
 			}
 		}
 	}
 	igt_fixture {
-		close(sys_fd);
 		xe_device_put(xe);
 		close(xe);
 	}
-- 
2.25.1



More information about the igt-dev mailing list