Re: [PATCH i-g-t 2/2] tests: add i915 query tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 16/01/18 21:38, Chris Wilson wrote:
Quoting Chris Wilson (2018-01-16 21:34:34)
Quoting Lionel Landwerlin (2018-01-16 16:07:28)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@xxxxxxxxx>
---
  tests/Makefile.sources |   1 +
  tests/meson.build      |   1 +
  tests/query.c          | 268 +++++++++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 270 insertions(+)
  create mode 100644 tests/query.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index e4e06d01..390cc82b 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -227,6 +227,7 @@ TESTS_progs = \
         prime_self_import \
         prime_udl \
         prime_vgem \
+       query \
         sw_sync \
         syncobj_basic \
         syncobj_wait \
diff --git a/tests/meson.build b/tests/meson.build
index 4c4bee1d..70df38f3 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -204,6 +204,7 @@ test_progs = [
         'prime_self_import',
         'prime_udl',
         'prime_vgem',
+       'query',
         'sw_sync',
         'syncobj_basic',
         'syncobj_wait',
diff --git a/tests/query.c b/tests/query.c
new file mode 100644
index 00000000..cb5aedd4
--- /dev/null
+++ b/tests/query.c
@@ -0,0 +1,268 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "igt.h"
+
+IGT_TEST_DESCRIPTION("Testing the query uAPI.");
+
+static bool has_query_supports(int fd)
+{
+       struct drm_i915_query query = {};
+
+       return igt_ioctl(fd, DRM_IOCTL_I915_QUERY, &query) == 0;
+}
+
+static void test_query_garbage(int fd)
+{
+       struct drm_i915_query query;
+       struct drm_i915_query_item items[2];
+
+       memset(&query, 0, sizeof(query));
+       query.num_items = 1;
+       query.items_ptr = 0xffffffff;
That might be legal on 64b. I think you mean -1.

For bonus points. .items_ptr = - num_items * sizeof(query) and variable
number of items.
There's also a fun one where you

query.items_ptr = mmap(0, 4096, PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
igt_assert(__i915_query(fd, &query) == 0);
munmap(query.items_ptr, 4096);
igt_assert(__i915_query(fd, &query) == -EFAULT);

Adjust for compilation :)
-Chris

Thanks, done.

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux