summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2020-02-04 13:20:29 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2020-12-13 12:01:31 +0000
commit461f9f1828c1fd2cf6ab5ff259ac64d56632643b (patch)
treef37b9f7349ac0779ff4b0e2e77eae668661db122
parent84786ef748a4ccb0165620075b1e502d0db0399b (diff)
ctx-traceHEADmaster
-rw-r--r--tests/Makefile.sources3
-rw-r--r--tests/i915/gem_ctx_trace.c95
-rw-r--r--tests/meson.build1
3 files changed, 99 insertions, 0 deletions
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 8b23237a..94e9beb2 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -206,6 +206,9 @@ gem_ctx_switch_SOURCES = i915/gem_ctx_switch.c
TESTS_progs += gem_ctx_thrash
gem_ctx_thrash_SOURCES = i915/gem_ctx_thrash.c
+TESTS_progs += gem_ctx_trace
+gem_ctx_trace_SOURCES = i915/gem_ctx_trace.c
+
TESTS_progs += gem_eio
gem_eio_SOURCES = i915/gem_eio.c
diff --git a/tests/i915/gem_ctx_trace.c b/tests/i915/gem_ctx_trace.c
new file mode 100644
index 00000000..ed3f05de
--- /dev/null
+++ b/tests/i915/gem_ctx_trace.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright © 2019 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 <unistd.h>
+
+#include "drmtest.h"
+#include "i915_drm.h"
+#include "i915/gem.h"
+#include "i915/gem_context.h"
+#include "i915/gem_submission.h"
+#include "igt_core.h"
+#include "ioctl_wrappers.h"
+
+#define I915_CONTEXT_PARAM_TRACE 0xc
+
+static int get_trace(int i915)
+{
+ struct drm_i915_gem_context_param p = {
+ .param = I915_CONTEXT_PARAM_TRACE,
+ };
+ int trace = -1;
+
+ if (__gem_context_get_param(i915, &p) == 0)
+ trace = p.value;
+
+ return trace;
+}
+
+static bool has_trace(int i915)
+{
+ int trace;
+
+ i915 = gem_reopen_driver(i915);
+ trace = get_trace(i915);
+ close(i915);
+
+ close(trace);
+ errno = 0;
+
+ return trace != -1;
+}
+
+igt_main
+{
+ int i915;
+
+ igt_fixture {
+ i915 = drm_open_driver(DRIVER_INTEL);
+ igt_require_gem(i915);
+
+ igt_require(has_trace(i915));
+ }
+
+ igt_subtest("hello-world") {
+ char buf[256];
+ int tr, len;
+
+ i915 = gem_reopen_driver(i915);
+ tr = get_trace(i915);
+
+ gem_context_create(i915);
+
+ len = read(tr, buf, sizeof(buf) - 1);
+ igt_assert(len > 0);
+ buf[len] = '\0';
+ igt_info("gem_context_create trace: '%s'\n", buf);
+
+ close(tr);
+ close(i915);
+ }
+
+ igt_fixture {
+ close(i915);
+ }
+}
diff --git a/tests/meson.build b/tests/meson.build
index b77627e8..6a949811 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -139,6 +139,7 @@ i915_progs = [
'gem_ctx_shared',
'gem_ctx_switch',
'gem_ctx_thrash',
+ 'gem_ctx_trace',
'gem_evict_alignment',
'gem_evict_everything',
'gem_exec_alignment',