summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2020-05-19 15:04:35 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2020-05-19 19:02:23 +0100
commite770178c9e8a6792ea6459e6ec7c79b283b268e1 (patch)
treee2b69b34e808ec165aa7d98b0f703c29ac630d25 /tests
parentbf43e3e45a17c16094fb3a47b363ccf1c95c28b9 (diff)
i915: Add test to assert that the PCI-ID is known
We do want to ensure that the igt identification table is kept up to date, and so would like to be warned if being run on an unknown chipset. Instead of refusing to run any test, have a specific test for the unknown chipset. Suggested-by: Mika Kuoppala <mika.kuoppala@linux.intel.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com> Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.sources3
-rw-r--r--tests/i915/i915_pciid.c62
-rw-r--r--tests/meson.build1
3 files changed, 66 insertions, 0 deletions
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index c450fa0e..f1df1346 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -475,6 +475,9 @@ i915_hangman_SOURCES = i915/i915_hangman.c
TESTS_progs += i915_module_load
i915_module_load_SOURCES = i915/i915_module_load.c
+TESTS_progs += i915_pciid
+i915_pciid_SOURCES = i915/i915_pciid.c
+
TESTS_progs += i915_pm_backlight
i915_pm_backlight_SOURCES = i915/i915_pm_backlight.c
diff --git a/tests/i915/i915_pciid.c b/tests/i915/i915_pciid.c
new file mode 100644
index 00000000..97502fb3
--- /dev/null
+++ b/tests/i915/i915_pciid.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright © 2020 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 <sys/ioctl.h>
+
+#include "drm.h"
+#include "drmtest.h"
+#include "i915_drm.h"
+#include "intel_chipset.h"
+
+IGT_TEST_DESCRIPTION("Check that igt/i915 know about this PCI-ID");
+
+static bool has_known_intel_chipset(int fd)
+{
+ int devid = 0;
+ struct drm_i915_getparam gp = {
+ .param = I915_PARAM_CHIPSET_ID,
+ .value = &devid,
+ };
+ const struct intel_device_info *info;
+
+ if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)))
+ return false;
+
+ info = intel_get_device_info(devid);
+ if (!info) {
+ igt_warn("Unrecognised PCI-ID: %04x\n", devid);
+ return false;
+ }
+
+ igt_info("PCI-ID: %#04x, gen %d, %s\n",
+ devid, ffs(info->gen), info->codename);
+ return true;
+}
+
+igt_simple_main
+{
+ int intel = drm_open_driver(DRIVER_INTEL);
+
+ igt_assert(has_known_intel_chipset(intel));
+}
diff --git a/tests/meson.build b/tests/meson.build
index 88e4875b..d021af68 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -218,6 +218,7 @@ i915_progs = [
'i915_getparams_basic',
'i915_hangman',
'i915_module_load',
+ 'i915_pciid',
'i915_pm_backlight',
'i915_pm_lpsp',
'i915_pm_rpm',