public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] tests/i915/query: Test invalid TOPO_INFO flags
@ 2019-06-21 19:15 Stuart Summers
  2019-06-21 19:48 ` [igt-dev] ✗ Fi.CI.BAT: failure for " Patchwork
  0 siblings, 1 reply; 3+ messages in thread
From: Stuart Summers @ 2019-06-21 19:15 UTC (permalink / raw)
  To: igt-dev

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-21 22:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-21 19:15 [igt-dev] [PATCH i-g-t] tests/i915/query: Test invalid TOPO_INFO flags Stuart Summers
2019-06-21 19:48 ` [igt-dev] ✗ Fi.CI.BAT: failure for " Patchwork
2019-06-21 22:18   ` Summers, Stuart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox