Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dominik Grzegorzek <dominik.grzegorzek@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 4/8] xe/xe_eudebug: test open close events
Date: Tue, 16 May 2023 17:44:30 +0200	[thread overview]
Message-ID: <20230516154434.810356-5-dominik.grzegorzek@intel.com> (raw)
In-Reply-To: <20230516154434.810356-1-dominik.grzegorzek@intel.com>

Introduce basic tests which validate client create/destroy events
sent on xe drm client open/close.

Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek@intel.com>
---
 tests/xe/xe_eudebug.c | 88 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)

diff --git a/tests/xe/xe_eudebug.c b/tests/xe/xe_eudebug.c
index 7202da689..cf49a4bd4 100644
--- a/tests/xe/xe_eudebug.c
+++ b/tests/xe/xe_eudebug.c
@@ -4,8 +4,68 @@
  */
 
 #include <xe_drm_tmp.h>
+#include "xe/xe_eudebug.h"
 #include "igt.h"
 
+static void run_basic_client(struct xe_eudebug_client *c)
+{
+	int fd;
+
+	fd = xe_eudebug_client_open_driver(c);
+	xe_eudebug_client_close_driver(c, fd);
+}
+
+struct session {
+	unsigned int flags;
+	struct xe_eudebug_debugger *d;
+	struct xe_eudebug_client *c;
+};
+
+static struct session *session_create(int fd, xe_eudebug_client_work_fn work, unsigned int flags)
+{
+	struct session *s;
+
+	s = calloc(1, sizeof(*s));
+	igt_assert(s);
+
+	s->c = xe_eudebug_client_create(work, flags);
+	s->d = xe_eudebug_debugger_create(fd, flags);
+
+	return s;
+}
+
+static void session_run(struct session *s)
+{
+	struct xe_eudebug_debugger *debugger = s->d;
+	struct xe_eudebug_client *client = s->c;
+
+	igt_assert_eq(xe_eudebug_debugger_attach(debugger, client->pid), 0);
+
+	xe_eudebug_debugger_start_worker(debugger);
+
+	xe_eudebug_client_start(client);
+	xe_eudebug_client_wait_done(client);
+
+	xe_eudebug_debugger_stop_worker(debugger, 1);
+
+	xe_eudebug_event_log_print(debugger->log, true);
+	xe_eudebug_event_log_print(client->log, true);
+}
+
+static void session_check(struct session *s, bool match_opposite)
+{
+	xe_eudebug_event_log_compare(s->c->log, s->d->log);
+
+	if (match_opposite)
+		xe_eudebug_event_log_match_opposite(s->d->log);
+}
+
+static void session_destroy(struct session *s)
+{
+	xe_eudebug_debugger_destroy(s->d);
+	xe_eudebug_client_destroy(s->c);
+}
+
 static int __debug_connect(int fd, int *debugfd, struct drm_xe_eudebug_connect_param *param)
 {
 	int ret = 0;
@@ -114,6 +174,28 @@ static void test_close(int fd)
 	close(debug_fd1);
 }
 
+static void test_basic_sessions(int fd, unsigned int flags, int count)
+{
+	struct session **s;
+	int i;
+
+	s = calloc(count, sizeof(*s));
+
+	igt_assert(s);
+
+	for (i = 0; i < count; i++)
+		s[i] = session_create(fd, run_basic_client, flags);
+
+	for (i = 0; i < count; i++)
+		session_run(s[i]);
+
+	for (i = 0; i < count; i++)
+		session_check(s[i], true);
+
+	for (i = 0; i < count; i++)
+		session_destroy(s[i]);
+}
+
 igt_main
 {
 	int fd;
@@ -128,6 +210,12 @@ igt_main
 	igt_subtest("basic-close")
 		test_close(fd);
 
+	igt_subtest("basic-client")
+		test_basic_sessions(fd, 0, 1);
+
+	igt_subtest("multiple-sessions")
+		test_basic_sessions(fd, 0, 4);
+
 	igt_fixture
 		close(fd);
 }
-- 
2.34.1

  parent reply	other threads:[~2023-05-16 15:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-16 15:44 [igt-dev] [RFC i-g-t 0/8] Add initial eudebug coverage Dominik Grzegorzek
2023-05-16 15:44 ` [igt-dev] [PATCH i-g-t 1/8] xe: sync uapi headers Dominik Grzegorzek
2023-05-16 15:44 ` [igt-dev] [PATCH i-g-t 2/8] xe/xe_eudebug: test eudebug connection Dominik Grzegorzek
2023-05-16 15:44 ` [igt-dev] [PATCH i-g-t 3/8] xe/xe_eudebug: introduce eu debug testing framework Dominik Grzegorzek
2023-05-16 15:44 ` Dominik Grzegorzek [this message]
2023-05-16 15:44 ` [igt-dev] [PATCH i-g-t 5/8] xe/xe_eudebug: exercise read_event ioctl Dominik Grzegorzek
2023-05-16 15:44 ` [igt-dev] [PATCH i-g-t 6/8] xe/xe_eudebug: add vm events sanity check Dominik Grzegorzek
2023-05-16 15:44 ` [igt-dev] [PATCH i-g-t 7/8] xe/xe_eudebug: Race discovery against eudebug attach Dominik Grzegorzek
2023-05-16 15:44 ` [igt-dev] [PATCH i-g-t 8/8] xe/xe_eudebug: Add TEST/SUBTEST documentation Dominik Grzegorzek
2023-05-16 17:17 ` [igt-dev] ✗ GitLab.Pipeline: warning for Add initial eudebug coverage Patchwork
2023-05-16 17:41 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-05-17  2:11 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2023-05-17 18:56 ` [igt-dev] ✓ Fi.CI.BAT: success for Add initial eudebug coverage (rev2) Patchwork
2023-05-18  8:16 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230516154434.810356-5-dominik.grzegorzek@intel.com \
    --to=dominik.grzegorzek@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox