[PATCH i-g-t] tests/intel/gem_ctx_persistence: Wait for context termination

Krzysztof Niemiec krzysztof.niemiec at intel.com
Mon Oct 28 12:56:42 UTC 2024


In the smoketest subtest, there is a race condition - if a
non-persistent context is not terminated by the driver before the
associated spinner is ended and probed for status, the status will be
incorrectly reported as completed.

Add a check before the spinner end to ensure this does not happen.

Signed-off-by: Krzysztof Niemiec <krzysztof.niemiec at intel.com>
---
 tests/intel/gem_ctx_persistence.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/intel/gem_ctx_persistence.c b/tests/intel/gem_ctx_persistence.c
index 974444cf1..f21920fc5 100644
--- a/tests/intel/gem_ctx_persistence.c
+++ b/tests/intel/gem_ctx_persistence.c
@@ -1173,6 +1173,10 @@ static void __smoker(int i915, const intel_ctx_cfg_t *cfg,
 	drm_close_driver(fd);
 	flush_delayed_fput(i915);
 
+	/* Give the kernel time to terminate the non-persistent context */
+	igt_assert_eq(wait_for_status(spin->out_fence, timeout * 2),
+		      expected < 0 ? expected : -ETIME);
+
 	igt_spin_end(spin);
 
 	igt_assert_eq(wait_for_status(spin->out_fence, timeout), expected);
-- 
2.45.2



More information about the igt-dev mailing list