tests/xe/xe_query: Add subtest query-invalid-extension
PATCH 1/1 tests/xe/xe_query: Add subtest query-invalid-extension
From: Janga Rahul Kumar <[email protected]>
Check query with invalid extension returns expected error code.
--- tests/xe/xe_query.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
tests/xe/xe_query.c +20 -0
@@ -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); + igt_fixture {xe_device_put (xe);close (xe);
Signature · 1 line
2.25.1
Quoted 38 lines · On Wed, Apr 26, 2023 at 12:10:03AM +0530, [email protected] wrote:
From: Janga Rahul Kumar <[email protected]>
Check query with invalid extension returns expected error code.
Signed-off-by Janga Rahul Kumar <[email protected]>--- tests/xe/xe_query.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)tests/xe/xe_query.c +17
-0@@ -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;
tests/xe/xe_query.c igt_main · line 490
Quoted 6 lines
tests/xe/xe_query.c +3
-0@@ -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@bad-extensions.
--
Zbigniew
Quoted 6 lines
tests/xe/xe_query.c +0
-0igt_fixture {xe_device_put (xe);close (xe);Signature · 1 line
2.25.1
Quoted 57 lines
-----Original Message-----
From: Kempczynski, Zbigniew <[email protected]>
Sent: 26 April 2023 15:43
To: Kumar, Janga Rahul <[email protected]>
Cc: [email protected]; Gandi, Ramadevi <[email protected]>
Subject: Re: [igt-dev] [PATCH] tests/xe/xe_query: Add subtest query-invalid- extensionQuoted 14 lines · On Wed, Apr 26, 2023 at 12:10:03AM +0530, [email protected] wrote:
From: Janga Rahul Kumar <[email protected]>
Check query with invalid extension returns expected error code.
Signed-off-by Janga Rahul Kumar <[email protected]>--- tests/xe/xe_query.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)tests/xe/xe_query.c index renamed from tests/xe/xe_query.c +0
-0
3f038225..6c35730c100644tests/xe/xe_query.c test_query_invalid_size(int fd) · line 435
Quoted 1 line
tests/xe/xe_query.c +0
-0@@ -435,6 +435,23 @@ test_query_invalid_size(int fd) igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query), -1);
tests/xe/xe_query.c test_query_invalid_size(int fd)
Quoted 5 lines
tests/xe/xe_query.c +3
-0} +/** +* SUBTEST: query-invalid-extension +* Description: Check query with invalid extension returns expected error code.
tests/xe/xe_query.c test_query_invalid_size(int fd)
Quoted 12 lines
tests/xe/xe_query.c +12
-0+*/ +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);
Quoted 9 lines
tests/xe/xe_query.c +2
-0+} + igt_main {int xe;@@ -468,6 +485,9 @@ igt_main igt_subtest("query-invalid-size")test_query_invalid_size (xe);
Quoted 6 lines
tests/xe/xe_query.c igt_main · line 490
Quoted 3 lines
tests/xe/xe_query.c +3
-0+ 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@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);
Quoted 10 lines
--
ZbigniewQuoted 6 lines
tests/xe/xe_query.c +0
-1igt_fixture {xe_device_put (xe);close (xe); --2.25.1
On Wed, Apr 26, 2023 at 08:58:41PM +0200, Kumar, Janga Rahul wrote:
<cut>
Review
Quoted 7 lines
Quoted 3 lines
We need to start fixing those tests as they are not properly validating uapi. See gem_mmap_offset@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.(quoted diff) +1
-1- igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query), -1); + do_ioctl_err(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query, EINVAL);
Sure, we didn't use this broadly in i915 igt but looks good for me.
--
Zbigniew
Quoted 10 lines
Quoted 10 lines
--
ZbigniewQuoted 6 lines
tests/xe/xe_query.c +0
-1igt_fixture {xe_device_put (xe);close (xe); --2.25.1
Quoted 22 lines · On Wed, Apr 26, 2023 at 12:10:03AM +0530, [email protected] wrote:
From: Janga Rahul Kumar <[email protected]>
Check query with invalid extension returns expected error code.
Signed-off-by Janga Rahul Kumar <[email protected]>--- tests/xe/xe_query.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)tests/xe/xe_query.c +5
-0@@ -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
tests/xe/xe_query.c test_query_invalid_size(int fd) · line 452
Quoted 10 lines
tests/xe/xe_query.c +10
-0+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 );
I forget to comment this value, -1 is not valid error code we should validate in this test.
--
Zbigniew
Quoted 18 lines
tests/xe/xe_query.c +5
-0+} + 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); + igt_fixture {xe_device_put (xe);close (xe);Signature · 1 line
2.25.1