[igt-dev] [PATCH] tests/xe/xe_query: Add subtest query-invalid-extension

Kumar, Janga Rahul janga.rahul.kumar at intel.com
Wed Apr 26 18:58:41 UTC 2023



> -----Original Message-----
> From: Kempczynski, Zbigniew <zbigniew.kempczynski at intel.com>
> Sent: 26 April 2023 15:43
> To: Kumar, Janga Rahul <janga.rahul.kumar at intel.com>
> Cc: igt-dev at lists.freedesktop.org; Gandi, Ramadevi
> <ramadevi.gandi at intel.com>
> Subject: Re: [igt-dev] [PATCH] tests/xe/xe_query: Add subtest query-invalid-
> extension
> 
> On Wed, Apr 26, 2023 at 12:10:03AM +0530, janga.rahul.kumar at intel.com
> wrote:
> > From: Janga Rahul Kumar <janga.rahul.kumar at intel.com>
> >
> > Check query with invalid extension returns expected error code.
> >
> > Signed-off-by: Janga Rahul Kumar <janga.rahul.kumar at intel.com>
> > ---
> >  tests/xe/xe_query.c | 20 ++++++++++++++++++++
> >  1 file changed, 20 insertions(+)
> >
> > diff --git a/tests/xe/xe_query.c b/tests/xe/xe_query.c index
> > 3f038225..6c35730c 100644
> > --- a/tests/xe/xe_query.c
> > +++ b/tests/xe/xe_query.c
> > @@ -435,6 +435,23 @@ test_query_invalid_size(int fd)
> >  	igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query), -
> 1);
> > }
> >
> > +/**
> > + * SUBTEST: query-invalid-extension
> > + * Description: Check query with invalid extension returns expected error
> code.
> > + */
> > +static void
> > +test_query_invalid_extension(int fd)
> > +{
> > +	struct drm_xe_device_query query = {
> > +		.extensions = -1,
> > +		.query = DRM_XE_DEVICE_QUERY_CONFIG,
> > +		.size = 0,
> > +		.data = 0,
> > +	};
> > +
> > +	igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query), -
> 1);
> > +}
> > +
> >  igt_main
> >  {
> >  	int xe;
> > @@ -468,6 +485,9 @@ igt_main
> >  	igt_subtest("query-invalid-size")
> >  		test_query_invalid_size(xe);
> >
> > +	igt_subtest("query-invalid-extension")
> > +		test_query_invalid_extension(xe);
> > +
> 
> We need to start fixing those tests as they are not properly validating uapi. See
> gem_mmap_offset at bad-extensions.
I think the best way here is to use the do_ioctl_err(..) wrapper. It will help in checking the expecting error as well.

-   igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query), -1);
+   do_ioctl_err(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query, EINVAL);
> 
> --
> Zbigniew
> 
> >  	igt_fixture {
> >  		xe_device_put(xe);
> >  		close(xe);
> > --
> > 2.25.1
> >


More information about the igt-dev mailing list