[PATCH i-g-t v3 3/6] tests/intel/xe_fault_injection: Add helper to start injecting fault after x iterations

Satyanarayana K V P satyanarayana.k.v.p at intel.com
Thu Mar 6 10:10:38 UTC 2025


As per the current implementation, the fault is injected on the first call
of the error injection function. Introduce an environment variable
IGT_FAULT_INJECT_ITERATION using which, an error can be injected at
specific function call.

Signed-off-by: Satyanarayana K V P <satyanarayana.k.v.p at intel.com>
Cc: Michał Wajdeczko <michal.wajdeczko at intel.com>
Cc: Francois Dugast <francois.dugast at intel.com>
---
 tests/intel/xe_fault_injection.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/tests/intel/xe_fault_injection.c b/tests/intel/xe_fault_injection.c
index 019ddfb7f..1bf8ef1d8 100644
--- a/tests/intel/xe_fault_injection.c
+++ b/tests/intel/xe_fault_injection.c
@@ -42,6 +42,18 @@ struct fault_injection_params {
 	uint32_t space;
 };
 
+/**
+ *  Introduce a new environmental variable IGT_FAULT_INJECT_ITERATION
+ *  using which an error can be injected at specific function call.
+ */
+static int get_fault_inject_iter(void)
+{
+	const char *env = getenv("IGT_FAULT_INJECT_ITERATION");
+
+	/* Return 0 if not exported / -ve value */
+	return env ? (atoi(env) > 0 ? atoi(env) : 0) : 0;
+}
+
 static int fail_function_open(void)
 {
 	int debugfs_fail_function_dir_fd;
-- 
2.35.3



More information about the igt-dev mailing list