[PATCH] tests/intel/xe_vm_create: Check negative cases for vm_create ioctl

Gurram, Pravalika pravalika.gurram at intel.com
Fri Dec 13 12:15:32 UTC 2024



> -----Original Message-----
> From: Auld, Matthew <matthew.auld at intel.com>
> Sent: Friday, December 13, 2024 4:02 PM
> To: Gurram, Pravalika <pravalika.gurram at intel.com>; igt-
> dev at lists.freedesktop.org
> Subject: Re: [PATCH] tests/intel/xe_vm_create: Check negative cases for
> vm_create ioctl
> 
> On 13/12/2024 07:57, Pravalika Gurram wrote:
> > Negative test to check vm_create ioctl returns expected error when
> > invalid flags, extensions, reserved  param is used.
> 
> Would be good to also do the same for the vm_destroy ioctl. It has pad and
> reserved also which should be zero, plus would be good to also try to destroy an
> invalid vm id.
> 

Thanks for reply I will also add for vm_destroy ioctl waiting for input 
is it okay to add new lib? or not

> >
> > Signed-off-by: Pravalika Gurram <pravalika.gurram at intel.com>
> > ---
> >   tests/intel/xe_vm_create.c | 104
> +++++++++++++++++++++++++++++++++++++
> >   tests/meson.build          |   1 +
> >   2 files changed, 105 insertions(+)
> >   create mode 100644 tests/intel/xe_vm_create.c
> >
> > diff --git a/tests/intel/xe_vm_create.c b/tests/intel/xe_vm_create.c
> > new file mode 100644 index 000000000..2430e6739
> > --- /dev/null
> > +++ b/tests/intel/xe_vm_create.c
> > @@ -0,0 +1,104 @@
> > +// SPDX-License-Identifier: MIT
> > +/*
> > + * Copyright © 2024 Intel Corporation  */
> > +
> > +#include "igt.h"
> > +#include "xe_drm.h"
> > +
> > +/**
> > + * TEST: Negative test for vm create ioctl
> > + * Category: Core
> > + * Mega feature: General Core features
> > + * Sub-category: Synchronization
> > + * Functionality: vm create
> > + * Test category: negative test
> > + */
> > +
> > +/**
> > + * SUBTEST: invalid-flag-%s
> > + * Description:  function %arg[1] used in vm create IOCTL to make it
> > +fail
> > + * Functionality: fault
> > + *
> > + * arg[1]:
> > + * @xe_vm_create_fault:  xe_vm_create_fault
> > + * @xe_vm_create_scrach_fault: xe_vm_create_scrach_fault
> > + * @xe_vm_create_scrach_fault_lr:    xe_vm_create_scrach_fault_lr
> > + */
> > +
> > +static void invalid_flag(int fd, __u32 flags) {
> > +	struct drm_xe_vm_create create = {
> > +		.flags = flags,
> > +	};
> > +
> > +	do_ioctl_err(fd, DRM_IOCTL_XE_VM_CREATE, &create, EINVAL);
> > +
> > +}
> > +
> > +/**
> > + * SUBTEST: invalid-extensions
> > + * Description: Check query with invalid extensions returns expected
> > +error code
> > + *
> > + * SUBTEST: invalid-reserved
> > + * Description: Check query with invalid reserved value returns
> > +expected error code  */
> > +
> > +static void inavlid_extensions(int fd) {
> > +	struct drm_xe_vm_create create = {
> > +		.extensions = -1,
> > +	};
> > +
> > +	do_ioctl_err(fd, DRM_IOCTL_XE_VM_CREATE, &create, EINVAL);
> > +
> > +}
> > +
> > +static void inavlid_reserved(int fd)
> > +{
> > +	struct drm_xe_vm_create create = {
> > +		.reserved[0] = 0xffff,
> > +	};
> > +
> > +	do_ioctl_err(fd, DRM_IOCTL_XE_VM_CREATE, &create, EINVAL);
> > +
> > +}
> > +
> > +igt_main
> > +{
> > +	int fd;
> > +
> > +	const struct section {
> > +		const char *name;
> > +		__u32 flags;
> > +	} vm_create_flags_fail_functions[] = {
> > +		{ "xe_vm_create_fault",
> DRM_XE_VM_CREATE_FLAG_FAULT_MODE },
> > +		{ "xe_vm_create_scrach_fault",
> > +			DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE |
> > +			DRM_XE_VM_CREATE_FLAG_FAULT_MODE },
> > +		{ "xe_vm_create_scrach_fault_lr",
> > +			~(DRM_XE_VM_CREATE_FLAG_LR_MODE |
> > +			DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE |
> > +			DRM_XE_VM_CREATE_FLAG_FAULT_MODE) },
> > +		{ }
> > +	};
> > +
> > +	igt_fixture
> > +		fd = drm_open_driver(DRIVER_XE);
> > +
> > +	for (const struct section *s = vm_create_flags_fail_functions; s->name;
> s++) {
> > +		igt_subtest_f("invalid-flag-%s", s->name)
> > +			invalid_flag(fd, s->flags);
> > +	}
> > +
> > +	igt_subtest("invalid-extensions")
> > +			inavlid_extensions(fd);
> > +
> > +	igt_subtest("invalid-reserved")
> > +			inavlid_reserved(fd);
> > +
> > +	igt_fixture {
> > +		drm_close_driver(fd);
> > +	}
> > +
> > +}
> > diff --git a/tests/meson.build b/tests/meson.build index
> > 2724c7a9a..fb9fc75d8 100644
> > --- a/tests/meson.build
> > +++ b/tests/meson.build
> > @@ -321,6 +321,7 @@ intel_xe_progs = [
> >   	'xe_sysfs_scheduler',
> >           'xe_sysfs_timeslice_duration',
> >           'xe_tlb',
> > +        'xe_vm_create',
> >   ]
> >
> >   intel_xe_eudebug_progs = [



More information about the igt-dev mailing list