From: Stuart Summers <stuart.summers@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t] tests/i915/query: Test invalid TOPO_INFO flags
Date: Fri, 21 Jun 2019 12:15:50 -0700 [thread overview]
Message-ID: <20190621191550.12290-1-stuart.summers@intel.com> (raw)
Current tests only check for invalid flags in the i915_query_ioctl
itself. A user might add invalid flags in the actual TOPO_INFO data,
though, so adding a test cast to confirm the kernel appropriately
rejects this.
Signed-off-by: Stuart Summers <stuart.summers@intel.com>
---
tests/i915/i915_query.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/tests/i915/i915_query.c b/tests/i915/i915_query.c
index ecbec3ae..8a84d867 100644
--- a/tests/i915/i915_query.c
+++ b/tests/i915/i915_query.c
@@ -33,6 +33,8 @@ IGT_TEST_DESCRIPTION("Testing the i915 query uAPI.");
*/
#define MIN_TOPOLOGY_ITEM_SIZE (sizeof(struct drm_i915_query_topology_info) + 3)
+#define INVALID_FLAGS 42
+
static int
__i915_query(int fd, struct drm_i915_query *q)
{
@@ -80,7 +82,7 @@ static void test_query_garbage(int fd)
* change in the future.
*/
memset(&query, 0, sizeof(query));
- query.flags = 42;
+ query.flags = INVALID_FLAGS;
igt_assert_eq(__i915_query(fd, &query), -EINVAL);
/* Test a couple of invalid pointers. */
@@ -96,6 +98,7 @@ static void test_query_garbage_items(int fd)
{
struct drm_i915_query_item items[2];
struct drm_i915_query_item *items_ptr;
+ struct drm_i915_query_topology_info *topo_info;
int i, n_items;
/*
@@ -104,9 +107,24 @@ static void test_query_garbage_items(int fd)
*/
memset(items, 0, sizeof(items));
items[0].query_id = DRM_I915_QUERY_TOPOLOGY_INFO;
- items[0].flags = 42;
+ items[0].flags = INVALID_FLAGS;
+ i915_query_items(fd, items, 1);
+ igt_assert_eq(items[0].length, -EINVAL);
+
+ /*
+ * Currently no TopologyInfo item flags are valid.
+ * Subject to change in the future.
+ */
+ memset(items, 0, sizeof(items));
+ items[0].query_id = DRM_I915_QUERY_TOPOLOGY_INFO;
+ items[0].flags = 0;
+ i915_query_items(fd, items, 1);
+ topo_info = calloc(1, items[0].length);
+ topo_info->flags = INVALID_FLAGS;
+ items[0].data_ptr = to_user_pointer(topo_info);
i915_query_items(fd, items, 1);
igt_assert_eq(items[0].length, -EINVAL);
+ free(topo_info);
/*
* Test an invalid query id in the second item and verify that the first
--
2.21.0.5.gaeb582a983
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next reply other threads:[~2019-06-21 19:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-21 19:15 Stuart Summers [this message]
2019-06-21 19:48 ` [igt-dev] ✗ Fi.CI.BAT: failure for tests/i915/query: Test invalid TOPO_INFO flags Patchwork
2019-06-21 22:18 ` Summers, Stuart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190621191550.12290-1-stuart.summers@intel.com \
--to=stuart.summers@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox