[PATCH i-g-t 1/2] tests/intel/xe_fault_injection: Return probe result from inject_fault_probe

Marcin Bernatowicz marcin.bernatowicz at linux.intel.com
Thu Apr 17 13:13:11 UTC 2025


Refactor inject_fault_probe() to return the result of the probe instead
of asserting internally. This defers the decision of whether to assert
or how to handle the result to the caller.

This change allows more flexibility for test cases that may expect the
probe to succeed despite an injected fault. If strict checking is still
desired, a wrapper such as:

  static void assert_inject_fault_probe(...) {
      igt_assert_eq(INJECT_ERRNO, inject_fault_probe(...));
  }

can be introduced to preserve the old behavior.

Follow-up patches will demonstrate use cases where fault injection does
not cause the probe to fail, justifying this change in behavior.

Cc: Francois Dugast <francois.dugast at intel.com>
Cc: Satyanarayana K V P <satyanarayana.k.v.p at intel.com>
Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz at linux.intel.com>
---
 tests/intel/xe_fault_injection.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/tests/intel/xe_fault_injection.c b/tests/intel/xe_fault_injection.c
index 24d3df572..dc8005dc8 100644
--- a/tests/intel/xe_fault_injection.c
+++ b/tests/intel/xe_fault_injection.c
@@ -186,9 +186,11 @@ static void set_retval(const char function_name[], long long retval)
  * @xe_wa_init:				xe_wa_init
  * @xe_wopcm_init:			xe_wopcm_init
  */
-static void
+static int
 inject_fault_probe(int fd, char pci_slot[], const char function_name[])
 {
+	int err = 0;
+
 	igt_info("Injecting error \"%s\" (%d) in function \"%s\"\n",
 		 strerror(-INJECT_ERRNO), INJECT_ERRNO, function_name);
 
@@ -197,9 +199,10 @@ inject_fault_probe(int fd, char pci_slot[], const char function_name[])
 	set_retval(function_name, INJECT_ERRNO);
 
 	igt_kmod_bind("xe", pci_slot);
-
-	igt_assert_eq(-errno, INJECT_ERRNO);
+	err = -errno;
 	injection_list_remove(function_name);
+
+	return err;
 }
 
 /**
@@ -478,7 +481,7 @@ igt_main
 
 	for (const struct section *s = probe_fail_functions; s->name; s++)
 		igt_subtest_f("inject-fault-probe-function-%s", s->name)
-			inject_fault_probe(fd, pci_slot, s->name);
+			igt_assert_eq(INJECT_ERRNO, inject_fault_probe(fd, pci_slot, s->name));
 
 	igt_fixture {
 		close(sysfs);
-- 
2.31.1



More information about the igt-dev mailing list