[Beignet] [PATCH] tests/core_getparams: Create new test core_getparams
jeff.mcgee at intel.com
jeff.mcgee at intel.com
Mon Mar 2 15:40:42 PST 2015
From: Jeff McGee <jeff.mcgee at intel.com>
New test core_getparams consists of 2 subtests, each one testing
the ability of userspace to query the correct value of a GT config
attribute: subslice total or EU total. drm/i915 implementation of
these queries is required for Cherryview and Gen9+ devices (non-
simulated).
For: VIZ-4636
Signed-off-by: Jeff McGee <jeff.mcgee at intel.com>
---
tests/.gitignore | 1 +
tests/Makefile.sources | 1 +
tests/core_getparams.c | 145 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 147 insertions(+)
create mode 100644 tests/core_getparams.c
diff --git a/tests/.gitignore b/tests/.gitignore
index 7b4dd94..39b4e28 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,6 +1,7 @@
# Please keep sorted alphabetically
core_get_client_auth
core_getclient
+core_getparams
core_getstats
core_getversion
drm_import_export
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 51e8376..999c8f8 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -15,6 +15,7 @@ NOUVEAU_TESTS_M = \
TESTS_progs_M = \
core_get_client_auth \
+ core_getparams \
drv_suspend \
drv_hangman \
gem_bad_reloc \
diff --git a/tests/core_getparams.c b/tests/core_getparams.c
new file mode 100644
index 0000000..37a4f63
--- /dev/null
+++ b/tests/core_getparams.c
@@ -0,0 +1,145 @@
+/*
+ * Copyright © 2014 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.
+ *
+ * Authors:
+ * Jeff McGee <jeff.mcgee at intel.com>
+ *
+ */
+
+#include <unistd.h>
+#include <errno.h>
+#include <xf86drm.h>
+#include "drmtest.h"
+#include "intel_chipset.h"
+#include "intel_bufmgr.h"
+
+int drm_fd;
+int devid;
+
+static void
+init(void)
+{
+ drm_fd = drm_open_any();
+ devid = intel_get_drm_devid(drm_fd);
+}
+
+static void
+deinit(void)
+{
+ close(drm_fd);
+}
+
+static void
+subslice_total(void)
+{
+ unsigned int subslice_total = 0;
+ int ret;
+
+ ret = drm_intel_get_subslice_total(drm_fd, &subslice_total);
+
+ if (ret) {
+ /*
+ * These devices are not required to implement the
+ * interface. If they do not, -ENODEV must be returned.
+ */
+ if ((intel_gen(devid) < 8) ||
+ IS_BROADWELL(devid) ||
+ igt_run_in_simulation()) {
+ igt_assert(ret == -ENODEV);
+ igt_info("subslice total: unknown\n");
+ /*
+ * All other devices must implement the interface, so
+ * fail them if we are here.
+ */
+ } else {
+ igt_assert(ret != EINVAL); /* request not recognized? */
+ igt_assert(ret != ENODEV); /* device not supported? */
+ igt_assert(ret == 0); /* other error? */
+ }
+ } else {
+ /*
+ * On success, just make sure the returned count value is
+ * non-zero. The validity of the count value for the given
+ * device is not checked.
+ */
+ igt_assert(subslice_total != 0);
+ igt_info("subslice total: %u\n", subslice_total);
+ }
+}
+
+static void
+eu_total(void)
+{
+ unsigned int eu_total = 0;
+ int ret;
+
+ ret = drm_intel_get_eu_total(drm_fd, &eu_total);
+
+ if (ret) {
+ /*
+ * These devices are not required to implement the
+ * interface. If they do not, -ENODEV must be returned.
+ */
+ if ((intel_gen(devid) < 8) ||
+ IS_BROADWELL(devid) ||
+ igt_run_in_simulation()) {
+ igt_assert(ret == -ENODEV);
+ igt_info("EU total: unknown\n");
+ /*
+ * All other devices must implement the interface, so
+ * fail them if we are here.
+ */
+ } else {
+ igt_assert(ret != EINVAL); /* request not recognized? */
+ igt_assert(ret != ENODEV); /* device not supported? */
+ igt_assert(ret == 0); /* other error? */
+ }
+ } else {
+ /*
+ * On success, just make sure the returned count value is
+ * non-zero. The validity of the count value for the given
+ * device is not checked.
+ */
+ igt_assert(eu_total != 0);
+ igt_info("EU total: %u\n", eu_total);
+ }
+}
+
+static void
+exit_handler(int sig)
+{
+ deinit();
+}
+
+igt_main
+{
+ igt_fixture {
+ igt_install_exit_handler(exit_handler);
+ init();
+ }
+
+ igt_subtest("subslice-total")
+ subslice_total();
+
+ igt_subtest("eu-total")
+ eu_total();
+}
--
2.3.0
More information about the Beignet
mailing list