[PATCH i-g-t] tests/intel/xe_create: Check negative cases for exec_queue create/destroy ioctl

Kamil Konieczny kamil.konieczny at linux.intel.com
Tue Jan 21 14:32:28 UTC 2025


Hi Nakshtra,
On 2025-01-18 at 02:23:19 +0530, nakshtra.goyal at intel.com wrote:
> 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
> 
> Signed-off-by: Nakshtra Goyal <nakshtra.goyal at intel.com>
> ---
>  tests/intel/xe_create.c | 141 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 141 insertions(+)
> 
> diff --git a/tests/intel/xe_create.c b/tests/intel/xe_create.c
> index 07e11036d..edc2a6178 100644
> --- a/tests/intel/xe_create.c
> +++ b/tests/intel/xe_create.c
> @@ -59,6 +59,123 @@ static int __create_bo(int fd, uint32_t vm, uint64_t size, uint32_t placement,
>  	return ret;
>  }
>  
> +/**
> + * TEST: Negative test for exec-queue create/destroy ioctl
> + * Category: Core
> + * Mega feature: General Core features
> + * Sub-category: Synchronization
> + * Functionality: exec-queue create
> + * Test category: negative test
> + */

Remove this, do _not_ add a second 'TEST: ' section, there is one
at beginning of this test.

> +
> +/**
> + * SUBTEST: invalid-flag
> + * Description: Check ioctl with invalid flag returns expected error code

Add here:
 * Functionality: ioctl_input_validation

And use this in other subtests below.

Regards,
Kamil

> + *
> + * SUBTEST: exec-queue-create-invalid-reserved
> + * Description: Send query with invalid reserved value for exec_queue_destroy ioctl
> + *
> + * SUBTEST: invalid-width
> + * Description: Check query with invalid width returns expected error code
> + *
> + * SUBTEST: invalid-num-placements
> + * Description: Check query with invalid num-placements returns expected error code
> + *
> + * SUBTEST: invalid-extensions
> + * 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_width(int fd)
> +{
> +	struct drm_xe_exec_queue_create create = {
> +		.width = 1,
> +	};
> +
> +	do_ioctl_err(fd, DRM_IOCTL_XE_EXEC_QUEUE_CREATE, &create, EINVAL);
> +}
> +
> +static void invalid_num_placements(int fd)
> +{
> +	struct drm_xe_exec_queue_create create = {
> +		.num_placements = 1,
> +	};
> +
> +	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 = {
> +		.extensions = -1,
> +	};
> +
> +	do_ioctl_err(fd, DRM_IOCTL_XE_EXEC_QUEUE_CREATE, &create, EINVAL);
> +}
> +
> +/**
> + * SUBTEST: invalid-pad
> + * Description: Check query with invalid pad returns expected error code
> + *
> + * SUBTEST: exec-queue-destroy-invalid-reserved
> + * Description: Send query with invalid reserved value for exec_queue_destroy ioctl
> + *
> + * SUBTEST: invalid-exec-queue-id
> + * 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 +509,30 @@ 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-width")
> +		invalid_width(xe);
> +
> +	igt_subtest("invalid-num-placements")
> +		invalid_num_placements(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