Skip to contentSkip to conversation

xe: Add test for engines_allowed in configfs

PATCH Superseded Lucas De Marchi 1 participant 3 messages May 28, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover xe: Add test for engines_allowed in configfs

Tested with the pending patch series:
https://lore.kernel.org/intel-xe/[email protected]/

---
Lucas De Marchi (2):
tests/intel/xe_configfs: Use openat to simplify check tests/intel/xe_configfs: Test engines_allowed

 tests/intel/xe_configfs.c | 41 +++++++++++++++++++++++++++++++++++++----
 1 file changed, 37 insertions(+), 4 deletions(-)

base-commit: f564652c85f6bf5e6e076526fe0de7c96dbbe0b2
change-id: 20250528-engines-allowed-75d546df45ae

Lucas De Marchi

#1 lore raw

PATCH 1/2 tests/intel/xe_configfs: Use openat to simplify check

No need to create the path again. Just make sure there's such attribute relative to the fd passed.

---
 tests/intel/xe_configfs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
tests/intel/xe_configfs.c +1 -4
index e5701b7d1..074cd04d9 100644
@@ -43,16 +43,13 @@ static void set_survivability_mode(int configfs_device_fd, bool value)
  */
 static void test_survivability_mode(int configfs_device_fd)
 {
-	char path[PATH_MAX];
 	int fd;
 
 	/* Enable survivability mode */
 	set_survivability_mode(configfs_device_fd, true);
 
 	/* check presence of survivability mode sysfs */
-	snprintf(path, PATH_MAX, "/sys/bus/pci/devices/%s/survivability_mode", bus_addr);
-
-	fd = open(path, O_RDONLY);
+	fd = openat(configfs_device_fd, "survivability_mode", O_RDONLY);
 	igt_assert_f(fd >= 0, "Survivability mode not set\n");
 	close(fd);
 }
Signature · 1 line
2.49.0
#2 lore raw

PATCH 2/2 tests/intel/xe_configfs: Test engines_allowed

In reply to Lucas De Marchi

Add tests for the parsing of engines_allowed configfs. This doesn't try to bind the driver and ensure only those engines are available. That's because the engine uapi instance doesn't necessarily match what is used for configfs configuration. Maybe we will need an engine map in debugfs for covering that.

---
 tests/intel/xe_configfs.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
tests/intel/xe_configfs.c +36 -0
index 074cd04d9..c559b4974 100644
@@ -10,6 +10,7 @@
 #include "igt_fs.h"
 #include "igt_kmod.h"
 #include "igt_sysfs.h"
+#include "xe/xe_query.h"
 
 /**
  * TEST: Check configfs userspace API
@@ -54,6 +55,29 @@ static void test_survivability_mode(int configfs_device_fd)
 	close(fd);
 }
 
+/**
+ * SUBTEST: engines-allowed-invalid
+ * Description: Validate engines_allowed attribute for invalid values
+ */
+static void test_engines_allowed_invalid(int configfs_device_fd)
+{
+	static const char *values[] = {
+		"xcs0",
+		"abcsdcs0",
+		"rcs0,abcsdcs0",
+		"rcs9",
+		"rcs10",
+		"rcs0asdf",
+	};
+
+	for (size_t i = 0; i < ARRAY_SIZE(values); i++) {
+		const char *v = values[i];
+
+		igt_debug("Writing '%s' to engines_allowed\n", v);
+		igt_assert(!igt_sysfs_set(configfs_device_fd, "engines_allowed", v));
+	}
+}
+
 static int create_device_configfs_group(int configfs_fd, int fd)
 {
 	int configfs_device_fd;
@@ -88,6 +112,18 @@ igt_main
 		test_survivability_mode(configfs_device_fd);
 	}
 
+	igt_describe("Validate engines_allowed with invalid options");
+	igt_subtest("engines-allowed-invalid") {
+		igt_install_exit_handler(restore);
+		test_engines_allowed_invalid(configfs_device_fd);
+	}
+
+	igt_describe("Validate engines_allowed");
+	igt_subtest("engines-allowed") {
+		igt_install_exit_handler(restore);
+		test_engines_allowed(configfs_device_fd);
+	}
+
 	igt_fixture {
 		igt_fs_remove_dir(configfs_fd, bus_addr);
 		close(configfs_device_fd);
Signature · 1 line
2.49.0