[PATCH i-g-t v2 02/66] tests/xe_eudebug: Test eudebug connection
Piatkowski, Dominik Karol
dominik.karol.piatkowski at intel.com
Thu Aug 1 09:30:11 UTC 2024
On top of copyright year issue noticed by Dominik Grzegorzek, please fix the typo mentioned below. When both issues fixed:
Reviewed-by: Dominik Karol Piątkowski <dominik.karol.piatkowski at intel.com>
> -----Original Message-----
> From: Manszewski, Christoph <christoph.manszewski at intel.com>
> Sent: Tuesday, July 30, 2024 1:44 PM
> To: igt-dev at lists.freedesktop.org
> Cc: Kempczynski, Zbigniew <zbigniew.kempczynski at intel.com>; Kamil
> Konieczny <kamil.konieczny at linux.intel.com>; Grzegorzek, Dominik
> <dominik.grzegorzek at intel.com>; Patelczyk, Maciej
> <maciej.patelczyk at intel.com>; Piatkowski, Dominik Karol
> <dominik.karol.piatkowski at intel.com>; Sikora, Pawel
> <pawel.sikora at intel.com>; Hajda, Andrzej <andrzej.hajda at intel.com>;
> Kolanupaka Naveena <kolanupaka.naveena at intel.com>; Kuoppala, Mika
> <mika.kuoppala at intel.com>; Mun, Gwan-gyeong <gwan-
> gyeong.mun at intel.com>
> Subject: [PATCH i-g-t v2 02/66] tests/xe_eudebug: Test eudebug connection
>
> From: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
>
> Add basic tests checking xe eudebug connection capability.
>
> Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
> Signed-off-by: Mika Kuoppala <mika.kuoppala at linux.intel.com>
> Cc: Christoph Manszewski <christoph.manszewski at intel.com>
> ---
> tests/intel/xe_eudebug.c | 135
> +++++++++++++++++++++++++++++++++++++++
> tests/meson.build | 1 +
> 2 files changed, 136 insertions(+)
> create mode 100644 tests/intel/xe_eudebug.c
>
> diff --git a/tests/intel/xe_eudebug.c b/tests/intel/xe_eudebug.c new file mode
> 100644 index 000000000..44a491319
> --- /dev/null
> +++ b/tests/intel/xe_eudebug.c
> @@ -0,0 +1,135 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2023 Intel Corporation
> + */
> +
> +/**
> + * TEST: Test EU Debugger functionality
> + * Category: Core
> + * Mega feature: EUdebug
> + * Sub-category: EUdebug tests
> + * Functionality: eu debugger framework
> + * Test category: functionality test
> + */
> +
> +#include <xe_drm.h>
> +#include "igt.h"
> +
> +static int __debug_connect(int fd, int *debugfd, struct
> +drm_xe_eudebug_connect *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;
> +}
> +
> +/**
> + * SUBTEST: basic-connect
> + * Description:
> + * Exercise XE_EUDEBG_CONNECT ioctl with passing
Typo in XE_EUDEBUG_CONNECT
> + * valid and invalid params.
> + */
> +static void test_connect(int fd)
> +{
> + struct drm_xe_eudebug_connect 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);
> +
> + 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.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);
> +}
> +
> +/**
> + * SUBTEST: basic-close
> + * Description:
> + * Test whether eudebug can be reattached after closure.
> + */
> +static void test_close(int fd)
> +{
> + struct drm_xe_eudebug_connect 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
> + drm_close_driver(fd);
> +}
> diff --git a/tests/meson.build b/tests/meson.build index
> e649466be..35bf8ed35 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -279,6 +279,7 @@ intel_xe_progs = [
> 'xe_dma_buf_sync',
> 'xe_debugfs',
> 'xe_drm_fdinfo',
> + 'xe_eudebug',
> 'xe_evict',
> 'xe_evict_ccs',
> 'xe_exec_atomic',
> --
> 2.34.1
More information about the igt-dev
mailing list