[PATCH 40/66] tests/xe_exec_sip: Check usercoredump for attentions
Christoph Manszewski
christoph.manszewski at intel.com
Mon Jul 29 16:01:33 UTC 2024
From: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
Check for attentions within usercoredump in tests that raise attentions.
Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
Cc: Christoph Manszewski <christoph.manszewski at intel.com>
---
tests/intel/xe_exec_sip.c | 64 +++++++++++++++++++++++++++++++++++++--
1 file changed, 61 insertions(+), 3 deletions(-)
diff --git a/tests/intel/xe_exec_sip.c b/tests/intel/xe_exec_sip.c
index 1b0accb3b..a315bd3a9 100644
--- a/tests/intel/xe_exec_sip.c
+++ b/tests/intel/xe_exec_sip.c
@@ -145,7 +145,7 @@ static void check_fill_buf(uint8_t *ptr, const int width, const int x,
color, val, x, y);
}
-static void check_buf(int fd, uint32_t handle, int width, int height,
+static int check_buf(int fd, uint32_t handle, int width, int height,
int siptype, uint8_t poison_c)
{
unsigned int sz = ALIGN(width * height, 4096);
@@ -188,6 +188,63 @@ static void check_buf(int fd, uint32_t handle, int width, int height,
igt_assert(sip_count == 0);
munmap(ptr, sz);
+
+ return sip_count;
+}
+
+#define USERCOREDUMP_FORMAT "usercoredumps/%d/%d"
+static char *get_latest_usercoredump(int dir)
+{
+ char tmp[256];
+ int i = 1;
+
+ do {
+ snprintf(tmp, sizeof(tmp), USERCOREDUMP_FORMAT, getpid(), i++);
+ } while (igt_sysfs_has_attr(dir, tmp));
+
+ snprintf(tmp, sizeof(tmp), USERCOREDUMP_FORMAT, getpid(), i-2);
+ return igt_sysfs_get(dir, tmp);
+}
+
+static void check_usercoredump(int fd, int sip, int dispatched)
+{
+ int dir = igt_debugfs_dir(fd);
+ char *usercoredump, *str;
+ unsigned int before, after;
+ char match[256];
+
+ if (sip != SIP_WAIT)
+ return;
+
+ /* XXX reinstate when offline coredumps are implemented */
+#ifndef XXX_ATTENTIONS_THROUGH_COREDUMPS
+ return;
+#endif
+ usercoredump = get_latest_usercoredump(dir);
+ igt_assert(usercoredump);
+ igt_debug("%s\n", usercoredump);
+
+ snprintf(match, sizeof(match), "PID: %d", getpid());
+ str = strstr(usercoredump, match);
+ igt_assert(str);
+
+ snprintf(match, sizeof(match), "Comm: %s", igt_test_name());
+ str = strstr(str, match);
+ igt_assert(str);
+
+ str = strstr(str, "TD_ATT");
+ igt_assert(str);
+ igt_assert_eq(sscanf(str, "TD_ATT before (%d):", &before), 1);
+ str = strstr(str + 1, "TD_ATT");
+ igt_assert_eq(sscanf(str, "TD_ATT after (%d):", &after), 1);
+
+ igt_info("attentions %d before, %d after\n", before, after);
+
+ igt_assert_eq(before, dispatched);
+ igt_assert_eq(after, dispatched);
+
+ free(usercoredump);
+ close(dir);
}
static uint64_t
@@ -232,7 +289,7 @@ static void test_sip(int shader, int sip, struct drm_xe_engine_class_instance *e
uint32_t exec_queue_id, handle, vm_id;
struct intel_bb *ibb;
uint64_t timeout;
- int fd;
+ int dispatched, fd;
igt_debug("Using %s\n", xe_engine_class_string(eci->engine_class));
@@ -258,7 +315,8 @@ static void test_sip(int shader, int sip, struct drm_xe_engine_class_instance *e
intel_bb_sync(ibb);
igt_assert_lt_u64(igt_nsec_elapsed(&ts), timeout);
- check_buf(fd, handle, width, height, sip, COLOR_C4);
+ dispatched = check_buf(fd, handle, width, height, sip, COLOR_C4);
+ check_usercoredump(fd, sip, dispatched);
gem_close(fd, handle);
intel_bb_destroy(ibb);
--
2.34.1
More information about the igt-dev
mailing list