[PATCH v2 i-g-t] tests/intel/xe_create: Check negative cases for exec_queue create/destroy ioctl
Cavitt, Jonathan
jonathan.cavitt at intel.com
Wed Jan 22 21:14:36 UTC 2025
-----Original Message-----
From: Goyal, Nakshtra <nakshtra.goyal at intel.com>
Sent: Wednesday, January 22, 2025 1:03 PM
To: igt-dev at lists.freedesktop.org; Gandi, Ramadevi <ramadevi.gandi at intel.com>
Cc: Cavitt, Jonathan <jonathan.cavitt at intel.com>; Konieczny, Kamil <kamil.konieczny at intel.com>
Subject: [PATCH v2 i-g-t] tests/intel/xe_create: Check negative cases for exec_queue create/destroy ioctl
>
> From: Nakshtra Goyal <nakshtra.goyal at intel.com>
>
> Negetive test cases to check expected errors using invalid
> flags, width, pad, reserved bits, num_placements, extensions, exec_queue_id
>
> v1: Combining width and numplacement test for len,
> adding width and numplacement in extension,
> change error type (Jonathan Cavitt)
>
> Adding functionality inside subtest description and
> removing new added TEST section (Kamil)
>
> Signed-off-by: Nakshtra Goyal <nakshtra.goyal at intel.com>
> Reviewed-by: Jonathan Cavitt <jonathan.cavitt at intel.com>
There's probably an argument to be made that we should add code comments to
the subcases in invalid-len and exec_queue_destroy_invalid_reserved, but I don't
think it's strictly necessary, so I won't block on it.
My reviewed-by still stands.
-Jonathan Cavitt
> ---
> tests/intel/xe_create.c | 137 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 137 insertions(+)
>
> diff --git a/tests/intel/xe_create.c b/tests/intel/xe_create.c
> index 07e11036d..e3be6b774 100644
> --- a/tests/intel/xe_create.c
> +++ b/tests/intel/xe_create.c
> @@ -59,6 +59,122 @@ static int __create_bo(int fd, uint32_t vm, uint64_t size, uint32_t placement,
> return ret;
> }
>
> +/**
> + * SUBTEST: invalid-flag
> + * Functionality: ioctl_input_validation
> + * Description: Check ioctl with invalid flag returns expected error code
> + *
> + * SUBTEST: exec-queue-create-invalid-reserved
> + * Functionality: ioctl_input_validation
> + * Description: Send query with invalid reserved value for exec_queue_destroy ioctl
> + *
> + * SUBTEST: invalid-len
> + * Functionality: ioctl_input_validation
> + * Description: Check query with invalid length returns expected error code
> + *
> + * SUBTEST: invalid-extensions
> + * Functionality: ioctl_input_validation
> + * Description: Check query with invalid extensions returns expected error code
> + */
> +
> +static void invalid_flag(int fd)
> +{
> + struct drm_xe_exec_queue_create create = {
> + .flags = -1,
> + };
> +
> + do_ioctl_err(fd, DRM_IOCTL_XE_EXEC_QUEUE_CREATE, &create, EINVAL);
> +}
> +
> +static void exec_queue_create_invalid_reserved(int fd)
> +{
> + struct drm_xe_exec_queue_create create = {
> + .reserved[0] = 0xffff,
> + };
> +
> + do_ioctl_err(fd, DRM_IOCTL_XE_EXEC_QUEUE_CREATE, &create, EINVAL);
> +
> + create.reserved[0] = 0;
> + create.reserved[1] = 0xffff;
> + do_ioctl_err(fd, DRM_IOCTL_XE_EXEC_QUEUE_CREATE, &create, EINVAL);
> +}
> +
> +static void invalid_len(int fd)
> +{
> + struct drm_xe_exec_queue_create create = {
> + .width = 1,
> + .num_placements = 1,
> + };
> +
> + create.width = 0;
> + do_ioctl_err(fd, DRM_IOCTL_XE_EXEC_QUEUE_CREATE, &create, EINVAL);
> + create.width = 1;
> +
> + create.num_placements = 0;
> + do_ioctl_err(fd, DRM_IOCTL_XE_EXEC_QUEUE_CREATE, &create, EINVAL);
> + create.num_placements = 1;
> +
> + create.width = 9;
> + create.num_placements = 9;
> + do_ioctl_err(fd, DRM_IOCTL_XE_EXEC_QUEUE_CREATE, &create, EINVAL);
> +}
> +
> +static void invalid_extensions(int fd)
> +{
> + struct drm_xe_exec_queue_create create = {
> + .width = 1,
> + .num_placements = 1,
> + .extensions = -1,
> + };
> +
> + do_ioctl_err(fd, DRM_IOCTL_XE_EXEC_QUEUE_CREATE, &create, EFAULT);
> +}
> +
> +/**
> + * SUBTEST: invalid-pad
> + * Functionality: ioctl_input_validation
> + * Description: Check query with invalid pad returns expected error code
> + *
> + * SUBTEST: exec-queue-destroy-invalid-reserved
> + * Functionality: ioctl_input_validation
> + * Description: Send query with invalid reserved value for exec_queue_destroy ioctl
> + *
> + * SUBTEST: invalid-exec-queue-id
> + * Functionality: ioctl_input_validation
> + * Description: Check query with invalid exec_queue_id returns expected error code
> + */
> +
> +static void invalid_pad(int fd)
> +{
> + struct drm_xe_exec_queue_destroy destroy = {
> + .pad = 1,
> + };
> +
> + do_ioctl_err(fd, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, &destroy, EINVAL);
> +}
> +
> +static void exec_queue_destroy_invalid_reserved(int fd)
> +{
> + struct drm_xe_exec_queue_destroy destroy = {
> + .reserved[0] = 0xffff,
> + };
> +
> + do_ioctl_err(fd, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, &destroy, EINVAL);
> +
> + destroy.reserved[0] = 0;
> + destroy.reserved[1] = 0xffff;
> + do_ioctl_err(fd, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, &destroy, EINVAL);
> +}
> +
> +static void invalid_exec_queue_id(int xe)
> +{
> + struct drm_xe_exec_queue_destroy args = {
> + .exec_queue_id = 0xffff,
> + };
> +
> + do_ioctl_err(xe, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, &args, ENOENT);
> +}
> +
> /**
> * SUBTEST: create-invalid-size
> * Functionality: ioctl
> @@ -392,6 +508,27 @@ igt_main_args("Q:p:", NULL, help_str, opt_handler, NULL)
> igt_fixture
> xe = drm_open_driver(DRIVER_XE);
>
> + igt_subtest("invalid-flag")
> + invalid_flag(xe);
> +
> + igt_subtest("exec-queue-create-invalid-reserved")
> + exec_queue_create_invalid_reserved(xe);
> +
> + igt_subtest("invalid-len")
> + invalid_len(xe);
> +
> + igt_subtest("invalid-extensions")
> + invalid_extensions(xe);
> +
> + igt_subtest("invalid-pad")
> + invalid_pad(xe);
> +
> + igt_subtest("exec-queue-destroy-invalid-reserved")
> + exec_queue_destroy_invalid_reserved(xe);
> +
> + igt_subtest("invalid-exec-queue-id")
> + invalid_exec_queue_id(xe);
> +
> igt_subtest("create-invalid-mbz")
> create_invalid_mbz(xe);
>
> --
> 2.34.1
>
>
More information about the igt-dev
mailing list