[igt-dev] [PATCH i-g-t] igt: Check drmModeGetResources()
Chris Wilson
chris at chris-wilson.co.uk
Wed Oct 3 19:43:49 UTC 2018
If KMS is not supported on the device, drmModeGetResources() will return
NULL, often this is an indication that we should not attempt to run the
test. Although it would be preferred to use something like
igt_require_display() as the canonical check and assert that
drmModeGetResources() did not hit an error, it is not always practical
as the tests do not utilize the common igt_display abstraction.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
tests/gem_exec_nop.c | 2 +-
tests/kms_3d.c | 2 ++
tests/kms_chamelium.c | 2 +-
tests/kms_draw_crc.c | 1 +
tests/kms_fbcon_fbt.c | 1 +
tests/kms_flip.c | 4 ++--
tests/kms_force_connector_basic.c | 3 ++-
tests/kms_hdmi_inject.c | 2 ++
tests/kms_invalid_dotclock.c | 3 +++
tests/kms_setmode.c | 2 +-
tests/kms_tv_load_detect.c | 3 ++-
tests/kms_universal_plane.c | 1 +
tests/perf_pmu.c | 2 +-
tests/pm_lpsp.c | 1 +
tests/testdisplay.c | 9 ++++++---
15 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index 74d27522..59a08ad0 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -280,7 +280,7 @@ static void headless(int fd, uint32_t handle)
double n_display, n_headless;
res = drmModeGetResources(fd);
- igt_assert(res);
+ igt_require(res);
/* require at least one connected connector for the test */
for (int i = 0; i < res->count_connectors; i++) {
diff --git a/tests/kms_3d.c b/tests/kms_3d.c
index bfc981ee..df8185ab 100644
--- a/tests/kms_3d.c
+++ b/tests/kms_3d.c
@@ -36,7 +36,9 @@ igt_simple_main
int mode_count, connector_id;
drm_fd = drm_open_driver_master(DRIVER_INTEL);
+
res = drmModeGetResources(drm_fd);
+ igt_require(res);
igt_assert(drmSetClientCap(drm_fd, DRM_CLIENT_CAP_STEREO_3D, 1) >= 0);
diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index cf7e3c9a..5ebac8dc 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -420,7 +420,7 @@ prepare_output(data_t *data,
enum pipe pipe;
bool found = false;
- igt_assert(res = drmModeGetResources(data->drm_fd));
+ igt_require(res = drmModeGetResources(data->drm_fd));
/* The chamelium's default EDID has a lot of resolutions, way more then
* we need to test
diff --git a/tests/kms_draw_crc.c b/tests/kms_draw_crc.c
index 90904714..ea14db9a 100644
--- a/tests/kms_draw_crc.c
+++ b/tests/kms_draw_crc.c
@@ -254,6 +254,7 @@ static void setup_environment(void)
igt_require(drm_fd >= 0);
drm_res = drmModeGetResources(drm_fd);
+ igt_require(drm_res);
igt_assert(drm_res->count_connectors <= MAX_CONNECTORS);
for (i = 0; i < drm_res->count_connectors; i++)
diff --git a/tests/kms_fbcon_fbt.c b/tests/kms_fbcon_fbt.c
index 8de3da83..24d3ad90 100644
--- a/tests/kms_fbcon_fbt.c
+++ b/tests/kms_fbcon_fbt.c
@@ -63,6 +63,7 @@ static void setup_drm(struct drm_info *drm)
drm->debugfs_fd = igt_debugfs_dir(drm->fd);
drm->res = drmModeGetResources(drm->fd);
+ igt_require(drm->res);
igt_assert(drm->res->count_connectors <= MAX_CONNECTORS);
for (i = 0; i < drm->res->count_connectors; i++)
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 44a82053..f28272dd 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -1355,7 +1355,7 @@ static int run_test(int duration, int flags)
igt_require(igt_setup_runtime_pm());
resources = drmModeGetResources(drm_fd);
- igt_assert(resources);
+ igt_require(resources);
/* Count output configurations to scale test runtime. */
for (i = 0; i < resources->count_connectors; i++) {
@@ -1412,7 +1412,7 @@ static int run_pair(int duration, int flags)
igt_require((flags & TEST_HANG) == 0 || !is_wedged(drm_fd));
resources = drmModeGetResources(drm_fd);
- igt_assert(resources);
+ igt_require(resources);
/* Find a pair of connected displays */
for (i = 0; i < resources->count_connectors; i++) {
diff --git a/tests/kms_force_connector_basic.c b/tests/kms_force_connector_basic.c
index 89431232..e9325dec 100644
--- a/tests/kms_force_connector_basic.c
+++ b/tests/kms_force_connector_basic.c
@@ -89,8 +89,9 @@ int main(int argc, char **argv)
unsigned vga_connector_id = 0;
drm_fd = drm_open_driver_master(DRIVER_INTEL);
+
res = drmModeGetResources(drm_fd);
- igt_assert(res);
+ igt_require(res);
/* find the vga connector */
for (int i = 0; i < res->count_connectors; i++) {
diff --git a/tests/kms_hdmi_inject.c b/tests/kms_hdmi_inject.c
index 22570a4b..699bad5b 100644
--- a/tests/kms_hdmi_inject.c
+++ b/tests/kms_hdmi_inject.c
@@ -254,7 +254,9 @@ igt_main
igt_fixture {
drm_fd = drm_open_driver_master(DRIVER_INTEL);
+
res = drmModeGetResources(drm_fd);
+ igt_require(res);
connector = get_connector(drm_fd, res);
igt_require(connector);
diff --git a/tests/kms_invalid_dotclock.c b/tests/kms_invalid_dotclock.c
index 568889a9..8c4c3122 100644
--- a/tests/kms_invalid_dotclock.c
+++ b/tests/kms_invalid_dotclock.c
@@ -133,8 +133,11 @@ igt_simple_main
igt_enable_connectors(data.drm_fd);
kmstest_set_vt_graphics_mode();
+
igt_display_require(&data.display, data.drm_fd);
data.res = drmModeGetResources(data.drm_fd);
+ igt_assert(data.res);
+
kmstest_unset_all_crtcs(data.drm_fd, data.res);
data.max_dotclock = i915_max_dotclock(&data);
diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
index 47d04fb5..68149604 100644
--- a/tests/kms_setmode.c
+++ b/tests/kms_setmode.c
@@ -858,7 +858,7 @@ int main(int argc, char **argv)
kmstest_set_vt_graphics_mode();
drm_resources = drmModeGetResources(drm_fd);
- igt_assert(drm_resources);
+ igt_require(drm_resources);
}
for (i = 0; i < ARRAY_SIZE(tests); i++) {
diff --git a/tests/kms_tv_load_detect.c b/tests/kms_tv_load_detect.c
index 5684b267..012d0629 100644
--- a/tests/kms_tv_load_detect.c
+++ b/tests/kms_tv_load_detect.c
@@ -37,8 +37,9 @@ int main(int argc, char **argv)
igt_fixture {
drm_fd = drm_open_driver_master(DRIVER_INTEL);
+
res = drmModeGetResources(drm_fd);
- igt_assert(res);
+ igt_require(res);
/* find the TV connector */
for (int i = 0; i < res->count_connectors; i++) {
diff --git a/tests/kms_universal_plane.c b/tests/kms_universal_plane.c
index cb5070b1..30c03bbb 100644
--- a/tests/kms_universal_plane.c
+++ b/tests/kms_universal_plane.c
@@ -333,6 +333,7 @@ sanity_test_init(sanity_test_t *test, igt_output_t *output, enum pipe pipe)
&test->undersized_fb);
test->moderes = drmModeGetResources(data->drm_fd);
+ igt_assert(test->moderes);
}
static void
diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index 6ab2595b..b34bc66c 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -1398,7 +1398,7 @@ test_rc6(int gem_fd, unsigned int flags)
drmModeRes *res;
res = drmModeGetResources(gem_fd);
- igt_assert(res);
+ igt_require(res);
/* force all connectors off */
kmstest_set_vt_graphics_mode();
diff --git a/tests/pm_lpsp.c b/tests/pm_lpsp.c
index a741cb78..b319dbe9 100644
--- a/tests/pm_lpsp.c
+++ b/tests/pm_lpsp.c
@@ -199,6 +199,7 @@ igt_main
devid = intel_get_drm_devid(drm_fd);
drm_res = drmModeGetResources(drm_fd);
+ igt_require(drm_res);
igt_assert(drm_res->count_connectors <= MAX_CONNECTORS);
for (i = 0; i < drm_res->count_connectors; i++)
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 0ff98a2b..b13c3d70 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -156,12 +156,15 @@ static void dump_connectors_fd(int drmfd)
static void dump_crtcs_fd(int drmfd)
{
- int i;
- drmModeRes *mode_resources = drmModeGetResources(drmfd);
+ drmModeRes *mode_resources;
+
+ mode_resources = drmModeGetResources(drmfd);
+ if (!mode_resources)
+ return;
igt_info("CRTCs:\n");
igt_info("id\tfb\tpos\tsize\n");
- for (i = 0; i < mode_resources->count_crtcs; i++) {
+ for (int i = 0; i < mode_resources->count_crtcs; i++) {
drmModeCrtc *crtc;
crtc = drmModeGetCrtc(drmfd, mode_resources->crtcs[i]);
--
2.19.0
More information about the igt-dev
mailing list