From: Dominik Grzegorzek <dominik.grzegorzek@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 2/8] xe/xe_eudebug: test eudebug connection
Date: Tue, 16 May 2023 17:44:28 +0200 [thread overview]
Message-ID: <20230516154434.810356-3-dominik.grzegorzek@intel.com> (raw)
In-Reply-To: <20230516154434.810356-1-dominik.grzegorzek@intel.com>
Add basic tests checking xe eudebug connection capability.
Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek@intel.com>
Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
tests/meson.build | 1 +
tests/xe/xe_eudebug.c | 133 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 134 insertions(+)
create mode 100644 tests/xe/xe_eudebug.c
diff --git a/tests/meson.build b/tests/meson.build
index 38f080f7c..6f6b39e56 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -247,6 +247,7 @@ xe_progs = [
'xe_compute',
'xe_dma_buf_sync',
'xe_debugfs',
+ 'xe_eudebug',
'xe_evict',
'xe_exec_balancer',
'xe_exec_basic',
diff --git a/tests/xe/xe_eudebug.c b/tests/xe/xe_eudebug.c
new file mode 100644
index 000000000..7202da689
--- /dev/null
+++ b/tests/xe/xe_eudebug.c
@@ -0,0 +1,133 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#include <xe_drm_tmp.h>
+#include "igt.h"
+
+static int __debug_connect(int fd, int *debugfd, struct drm_xe_eudebug_connect_param *param)
+{
+ int ret = 0;
+
+ *debugfd = igt_ioctl(fd, DRM_IOCTL_XE_EUDEBUG_CONNECT, param);
+
+ if (*debugfd < 0) {
+ ret = -errno;
+ igt_assume(ret != 0);
+ }
+
+ errno = 0;
+ return ret;
+}
+
+static void test_connect(int fd)
+{
+ struct drm_xe_eudebug_connect_param param = {};
+ int debugfd, ret;
+ pid_t *pid;
+
+ pid = mmap(NULL, sizeof(pid_t), PROT_WRITE,
+ MAP_SHARED | MAP_ANON, -1, 0);
+
+ /* get fresh unrelated pid */
+ igt_fork(child, 1)
+ *pid = getpid();
+
+ igt_waitchildren();
+ param.pid = *pid;
+ munmap(pid, sizeof(pid_t));
+
+ ret = __debug_connect(fd, &debugfd, ¶m);
+ igt_assert(debugfd == -1);
+ igt_assert_eq(ret, param.pid ? -ENOENT : -EINVAL);
+
+ param.pid = 0;
+ ret = __debug_connect(fd, &debugfd, ¶m);
+ igt_assert(debugfd == -1);
+ igt_assert_eq(ret, -EINVAL);
+
+ igt_fork(child, 1) {
+ int newfd = drm_open_driver(DRIVER_XE);
+
+ igt_drop_root();
+
+ param.pid = 1;
+ ret = __debug_connect(newfd, &debugfd, ¶m);
+ igt_assert(debugfd == -1);
+ igt_assert_eq(ret, -EACCES);
+ }
+ igt_waitchildren();
+
+ param.pid = getpid();
+ param.version = -1;
+ ret = __debug_connect(fd, &debugfd, ¶m);
+ igt_assert(debugfd == -1);
+ igt_assert_eq(ret, -EINVAL);
+
+ param.version = 0;
+ param.flags = ~0;
+ ret = __debug_connect(fd, &debugfd, ¶m);
+ igt_assert(debugfd == -1);
+ igt_assert_eq(ret, -EINVAL);
+
+ param.flags = 0;
+ param.events = ~0;
+ ret = __debug_connect(fd, &debugfd, ¶m);
+ igt_assert(debugfd == -1);
+ igt_assert_eq(ret, -EINVAL);
+
+ param.events = 0;
+ param.extensions = ~0;
+ ret = __debug_connect(fd, &debugfd, ¶m);
+ igt_assert(debugfd == -1);
+ igt_assert_eq(ret, -EINVAL);
+
+ param.extensions = 0;
+ ret = __debug_connect(fd, &debugfd, ¶m);
+ igt_assert_neq(debugfd, -1);
+ igt_assert_eq(ret, 0);
+
+ close(debugfd);
+}
+
+static void test_close(int fd)
+{
+ struct drm_xe_eudebug_connect_param param = { 0, };
+ int debug_fd1, debug_fd2;
+ int fd2;
+
+ param.pid = getpid();
+
+ igt_assert_eq(__debug_connect(fd, &debug_fd1, ¶m), 0);
+ igt_assert(debug_fd1 >= 0);
+ igt_assert_eq(__debug_connect(fd, &debug_fd2, ¶m), -EBUSY);
+ igt_assert_eq(debug_fd2, -1);
+
+ close(debug_fd1);
+ fd2 = drm_open_driver(DRIVER_XE);
+
+ igt_assert_eq(__debug_connect(fd2, &debug_fd2, ¶m), 0);
+ igt_assert(debug_fd2 >= 0);
+ close(fd2);
+ close(debug_fd2);
+ close(debug_fd1);
+}
+
+igt_main
+{
+ int fd;
+
+ igt_fixture {
+ fd = drm_open_driver(DRIVER_XE);
+ }
+
+ igt_subtest("basic-connect")
+ test_connect(fd);
+
+ igt_subtest("basic-close")
+ test_close(fd);
+
+ igt_fixture
+ close(fd);
+}
--
2.34.1
next prev 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 ` Dominik Grzegorzek [this message]
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 ` [igt-dev] [PATCH i-g-t 4/8] xe/xe_eudebug: test open close events Dominik Grzegorzek
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-3-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