[igt-dev] [PATCH i-g-t] tests: Check and skip tests when driver don't have display enabled
José Roberto de Souza
jose.souza at intel.com
Tue Sep 11 23:42:52 UTC 2018
Right now i915 is not doing the full job to complete disable display
when i915.disable_display parameters is set, when that is completed
it will cause several tests to fail, so here skiping all the tests
that depends on modeset or display block when those are not
available.
v2: Not skipping all tests in debugfs_test, perf_pmu and perf_pmu,
now skiping only the required subtests
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Jani Nikula <jani.nikula at intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
Signed-off-by: José Roberto de Souza <jose.souza at intel.com>
---
lib/igt_kms.c | 20 +++++++++
lib/igt_kms.h | 1 +
tests/debugfs_test.c | 13 +++++-
tests/gem_exec_nop.c | 1 +
tests/kms_3d.c | 1 +
tests/kms_addfb_basic.c | 4 +-
tests/kms_atomic.c | 1 +
tests/kms_atomic_interruptible.c | 1 +
tests/kms_available_modes_crc.c | 1 +
tests/kms_busy.c | 1 +
tests/kms_ccs.c | 1 +
tests/kms_chamelium.c | 1 +
tests/kms_chv_cursor_fail.c | 1 +
tests/kms_color.c | 1 +
tests/kms_concurrent.c | 1 +
tests/kms_crtc_background_color.c | 1 +
tests/kms_cursor_crc.c | 1 +
tests/kms_cursor_legacy.c | 1 +
tests/kms_draw_crc.c | 1 +
tests/kms_fbcon_fbt.c | 1 +
tests/kms_fence_pin_leak.c | 1 +
tests/kms_flip.c | 1 +
tests/kms_flip_event_leak.c | 1 +
tests/kms_flip_tiling.c | 1 +
tests/kms_force_connector_basic.c | 1 +
tests/kms_frontbuffer_tracking.c | 1 +
tests/kms_getfb.c | 4 +-
tests/kms_hdmi_inject.c | 1 +
tests/kms_invalid_dotclock.c | 1 +
tests/kms_legacy_colorkey.c | 1 +
tests/kms_mmap_write_crc.c | 1 +
tests/kms_panel_fitting.c | 1 +
tests/kms_pipe_b_c_ivb.c | 1 +
tests/kms_pipe_crc_basic.c | 1 +
tests/kms_plane.c | 1 +
tests/kms_plane_lowres.c | 1 +
tests/kms_plane_multiple.c | 1 +
tests/kms_plane_scaling.c | 1 +
tests/kms_properties.c | 1 +
tests/kms_psr.c | 1 +
tests/kms_pwrite_crc.c | 1 +
tests/kms_rmfb.c | 1 +
tests/kms_rotation_crc.c | 1 +
tests/kms_setmode.c | 1 +
tests/kms_sysfs_edid_timing.c | 5 +++
tests/kms_tv_load_detect.c | 1 +
tests/kms_universal_plane.c | 1 +
tests/kms_vblank.c | 1 +
tests/perf_pmu.c | 13 +++---
tests/pm_backlight.c | 5 ++-
tests/pm_lpsp.c | 1 +
tests/pm_rpm.c | 69 ++++++++++++++++++++++++-------
tests/prime_vgem.c | 2 +
tests/testdisplay.c | 1 +
54 files changed, 155 insertions(+), 25 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 4563bfd9..a12d4b79 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2018,6 +2018,26 @@ int igt_display_get_n_pipes(igt_display_t *display)
return display->n_pipes;
}
+/**
+ * igt_display_require_output:
+ * @drm_fd: a drm file descriptor
+ *
+ * Checks if driver supports modeset and have display enabled.
+ */
+void igt_require_display(int fd)
+{
+ drmModeRes *resources;
+ int pipes;
+
+ resources = drmModeGetResources(fd);
+ igt_require_f(resources, "drm driver do not support modeset\n");
+
+ pipes = resources->count_crtcs;
+ drmModeFreeResources(resources);
+
+ igt_require_f(pipes > 0, "drm driver without display hardware\n");
+}
+
/**
* igt_display_require_output:
* @display: A pointer to an #igt_display_t structure
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 3862efa2..0c6a7b1c 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -388,6 +388,7 @@ void igt_display_commit_atomic(igt_display_t *display, uint32_t flags, void *use
int igt_display_try_commit2(igt_display_t *display, enum igt_commit_style s);
int igt_display_drop_events(igt_display_t *display);
int igt_display_get_n_pipes(igt_display_t *display);
+void igt_require_display(int fd);
void igt_display_require_output(igt_display_t *display);
void igt_display_require_output_on_pipe(igt_display_t *display, enum pipe pipe);
diff --git a/tests/debugfs_test.c b/tests/debugfs_test.c
index 2e87e442..041027c5 100644
--- a/tests/debugfs_test.c
+++ b/tests/debugfs_test.c
@@ -102,10 +102,16 @@ igt_main
debugfs = igt_debugfs_dir(fd);
kmstest_set_vt_graphics_mode();
- igt_display_init(&display, fd);
+
+ memset(&display, 0, sizeof(igt_display_t));
}
igt_subtest("read_all_entries") {
+ if (!display.n_pipes) {
+ igt_require_display(fd);
+ igt_display_init(&display, fd);
+ }
+
/* try to light all pipes */
for_each_pipe(&display, pipe) {
igt_output_t *output;
@@ -140,6 +146,11 @@ igt_main
igt_output_t *output;
igt_plane_t *plane;
+ if (!display.n_pipes) {
+ igt_require_display(fd);
+ igt_display_init(&display, fd);
+ }
+
for_each_connected_output(&display, output)
igt_output_set_pipe(output, PIPE_NONE);
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index 74d27522..1cd3d70d 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -279,6 +279,7 @@ static void headless(int fd, uint32_t handle)
drmModeRes *res;
double n_display, n_headless;
+ igt_require_display(fd);
res = drmModeGetResources(fd);
igt_assert(res);
diff --git a/tests/kms_3d.c b/tests/kms_3d.c
index bfc981ee..830b3321 100644
--- a/tests/kms_3d.c
+++ b/tests/kms_3d.c
@@ -36,6 +36,7 @@ igt_simple_main
int mode_count, connector_id;
drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(drm_fd);
res = drmModeGetResources(drm_fd);
igt_assert(drmSetClientCap(drm_fd, DRM_CLIENT_CAP_STEREO_3D, 1) >= 0);
diff --git a/tests/kms_addfb_basic.c b/tests/kms_addfb_basic.c
index ce48d24f..ce4caa5e 100644
--- a/tests/kms_addfb_basic.c
+++ b/tests/kms_addfb_basic.c
@@ -671,8 +671,10 @@ int fd;
igt_main
{
- igt_fixture
+ igt_fixture {
fd = drm_open_driver_master(DRIVER_ANY);
+ igt_require_display(fd);
+ }
invalid_tests(fd);
diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
index ac02baf0..6998a116 100644
--- a/tests/kms_atomic.c
+++ b/tests/kms_atomic.c
@@ -868,6 +868,7 @@ igt_main
igt_fixture {
display.drm_fd = drm_open_driver_master(DRIVER_ANY);
+ igt_require_display(display.drm_fd);
kmstest_set_vt_graphics_mode();
diff --git a/tests/kms_atomic_interruptible.c b/tests/kms_atomic_interruptible.c
index 64a00559..d3182d62 100644
--- a/tests/kms_atomic_interruptible.c
+++ b/tests/kms_atomic_interruptible.c
@@ -276,6 +276,7 @@ igt_main
igt_fixture {
display.drm_fd = drm_open_driver_master(DRIVER_ANY);
+ igt_require_display(display.drm_fd);
kmstest_set_vt_graphics_mode();
diff --git a/tests/kms_available_modes_crc.c b/tests/kms_available_modes_crc.c
index b67b4f83..f7eb8214 100644
--- a/tests/kms_available_modes_crc.c
+++ b/tests/kms_available_modes_crc.c
@@ -493,6 +493,7 @@ igt_main
igt_fixture {
data.gfx_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(data.gfx_fd);
kmstest_set_vt_graphics_mode();
igt_display_init(&data.display, data.gfx_fd);
igt_require_pipe_crc(data.gfx_fd);
diff --git a/tests/kms_busy.c b/tests/kms_busy.c
index abf39828..b25b1853 100644
--- a/tests/kms_busy.c
+++ b/tests/kms_busy.c
@@ -321,6 +321,7 @@ igt_main
igt_require_gem(fd);
gem_require_mmap_wc(fd);
+ igt_require_display(fd);
kmstest_set_vt_graphics_mode();
igt_display_init(&display, fd);
diff --git a/tests/kms_ccs.c b/tests/kms_ccs.c
index e1ee5880..5774b14b 100644
--- a/tests/kms_ccs.c
+++ b/tests/kms_ccs.c
@@ -521,6 +521,7 @@ igt_main
igt_fixture {
data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(data.drm_fd);
igt_require(intel_gen(intel_get_drm_devid(data.drm_fd)) >= 9);
kmstest_set_vt_graphics_mode();
igt_require_pipe_crc(data.drm_fd);
diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 2bc34d07..b8876f49 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -736,6 +736,7 @@ igt_main
igt_skip_on_simulation();
data.drm_fd = drm_open_driver_master(DRIVER_ANY);
+ igt_require_display(data.drm_fd);
data.chamelium = chamelium_init(data.drm_fd);
igt_require(data.chamelium);
diff --git a/tests/kms_chv_cursor_fail.c b/tests/kms_chv_cursor_fail.c
index 7138e549..683b08a9 100644
--- a/tests/kms_chv_cursor_fail.c
+++ b/tests/kms_chv_cursor_fail.c
@@ -316,6 +316,7 @@ int main(int argc, char **argv)
int ret;
data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(data.drm_fd);
data.devid = intel_get_drm_devid(data.drm_fd);
diff --git a/tests/kms_color.c b/tests/kms_color.c
index bb106dd0..86100e46 100644
--- a/tests/kms_color.c
+++ b/tests/kms_color.c
@@ -1159,6 +1159,7 @@ igt_main
igt_fixture {
data.drm_fd = drm_open_driver_master(DRIVER_INTEL | DRIVER_AMDGPU);
+ igt_require_display(data.drm_fd);
if (is_i915_device(data.drm_fd))
data.devid = intel_get_drm_devid(data.drm_fd);
kmstest_set_vt_graphics_mode();
diff --git a/tests/kms_concurrent.c b/tests/kms_concurrent.c
index 283acf8c..90476ad2 100644
--- a/tests/kms_concurrent.c
+++ b/tests/kms_concurrent.c
@@ -406,6 +406,7 @@ int main(int argc, char *argv[])
igt_fixture {
data.drm_fd = drm_open_driver_master(DRIVER_ANY);
+ igt_require_display(data.drm_fd);
kmstest_set_vt_graphics_mode();
igt_display_init(&data.display, data.drm_fd);
igt_require(data.display.n_pipes > 0);
diff --git a/tests/kms_crtc_background_color.c b/tests/kms_crtc_background_color.c
index 6407e19b..61edf3b2 100644
--- a/tests/kms_crtc_background_color.c
+++ b/tests/kms_crtc_background_color.c
@@ -179,6 +179,7 @@ igt_simple_main
igt_skip_on_simulation();
data.gfx_fd = drm_open_driver(DRIVER_INTEL);
+ igt_require_display(data.gfx_fd);
igt_require_pipe_crc(data.gfx_fd);
igt_display_init(&data.display, data.gfx_fd);
diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c
index 99946b1a..daa825d9 100644
--- a/tests/kms_cursor_crc.c
+++ b/tests/kms_cursor_crc.c
@@ -661,6 +661,7 @@ igt_main
igt_fixture {
data.drm_fd = drm_open_driver_master(DRIVER_ANY);
+ igt_require_display(data.drm_fd);
ret = drmGetCap(data.drm_fd, DRM_CAP_CURSOR_WIDTH, &cursor_width);
igt_assert(ret == 0 || errno == EINVAL);
diff --git a/tests/kms_cursor_legacy.c b/tests/kms_cursor_legacy.c
index 82ceebcb..3d64d8c8 100644
--- a/tests/kms_cursor_legacy.c
+++ b/tests/kms_cursor_legacy.c
@@ -1363,6 +1363,7 @@ igt_main
igt_fixture {
display.drm_fd = drm_open_driver_master(DRIVER_ANY);
+ igt_require_display(display.drm_fd);
kmstest_set_vt_graphics_mode();
igt_display_init(&display, display.drm_fd);
diff --git a/tests/kms_draw_crc.c b/tests/kms_draw_crc.c
index 86dcf392..18a60131 100644
--- a/tests/kms_draw_crc.c
+++ b/tests/kms_draw_crc.c
@@ -251,6 +251,7 @@ static void setup_environment(void)
drm_fd = drm_open_driver_master(DRIVER_INTEL);
igt_require(drm_fd >= 0);
+ igt_require_display(drm_fd);
drm_res = drmModeGetResources(drm_fd);
igt_assert(drm_res->count_connectors <= MAX_CONNECTORS);
diff --git a/tests/kms_fbcon_fbt.c b/tests/kms_fbcon_fbt.c
index 138eda9b..a13968d3 100644
--- a/tests/kms_fbcon_fbt.c
+++ b/tests/kms_fbcon_fbt.c
@@ -293,6 +293,7 @@ static void setup_environment(void)
drm_fd = drm_open_driver_master(DRIVER_INTEL);
igt_require(drm_fd >= 0);
+ igt_require_display(drm_fd);
igt_assert(close(drm_fd) == 0);
}
diff --git a/tests/kms_fence_pin_leak.c b/tests/kms_fence_pin_leak.c
index 8bbd5563..d2d5c236 100644
--- a/tests/kms_fence_pin_leak.c
+++ b/tests/kms_fence_pin_leak.c
@@ -201,6 +201,7 @@ igt_simple_main
igt_skip_on_simulation();
data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(data.drm_fd);
data.devid = intel_get_drm_devid(data.drm_fd);
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 393d690a..b94c068b 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -1574,6 +1574,7 @@ int main(int argc, char **argv)
igt_fixture {
drm_fd = drm_open_driver_master(DRIVER_ANY);
+ igt_require_display(drm_fd);
igt_enable_connectors();
diff --git a/tests/kms_flip_event_leak.c b/tests/kms_flip_event_leak.c
index f1a8abd8..42b3a703 100644
--- a/tests/kms_flip_event_leak.c
+++ b/tests/kms_flip_event_leak.c
@@ -101,6 +101,7 @@ igt_simple_main
igt_skip_on_simulation();
data.drm_fd = drm_open_driver_master(DRIVER_ANY);
+ igt_require_display(data.drm_fd);
kmstest_set_vt_graphics_mode();
igt_display_init(&data.display, data.drm_fd);
diff --git a/tests/kms_flip_tiling.c b/tests/kms_flip_tiling.c
index beeb111b..54258e2f 100644
--- a/tests/kms_flip_tiling.c
+++ b/tests/kms_flip_tiling.c
@@ -146,6 +146,7 @@ igt_main
igt_fixture {
data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(data.drm_fd);
data.gen = intel_gen(intel_get_drm_devid(data.drm_fd));
kmstest_set_vt_graphics_mode();
diff --git a/tests/kms_force_connector_basic.c b/tests/kms_force_connector_basic.c
index 89431232..06c1a0cb 100644
--- a/tests/kms_force_connector_basic.c
+++ b/tests/kms_force_connector_basic.c
@@ -89,6 +89,7 @@ int main(int argc, char **argv)
unsigned vga_connector_id = 0;
drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(drm_fd);
res = drmModeGetResources(drm_fd);
igt_assert(res);
diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index b33f3128..16fd6599 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -1281,6 +1281,7 @@ static void init_crcs(enum pixel_format format,
static void setup_drm(void)
{
drm.fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(drm.fd);
drm.debugfs = igt_debugfs_dir(drm.fd);
kmstest_set_vt_graphics_mode();
diff --git a/tests/kms_getfb.c b/tests/kms_getfb.c
index 81d796a4..94fd0fea 100644
--- a/tests/kms_getfb.c
+++ b/tests/kms_getfb.c
@@ -198,8 +198,10 @@ igt_main
{
int fd;
- igt_fixture
+ igt_fixture {
fd = drm_open_driver_master(DRIVER_ANY);
+ igt_require_display(fd);
+ }
igt_subtest_group
test_handle_input(fd);
diff --git a/tests/kms_hdmi_inject.c b/tests/kms_hdmi_inject.c
index 22570a4b..eedc282b 100644
--- a/tests/kms_hdmi_inject.c
+++ b/tests/kms_hdmi_inject.c
@@ -254,6 +254,7 @@ igt_main
igt_fixture {
drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(drm_fd);
res = drmModeGetResources(drm_fd);
connector = get_connector(drm_fd, res);
diff --git a/tests/kms_invalid_dotclock.c b/tests/kms_invalid_dotclock.c
index e6e72f52..8c5ebab5 100644
--- a/tests/kms_invalid_dotclock.c
+++ b/tests/kms_invalid_dotclock.c
@@ -130,6 +130,7 @@ igt_simple_main
data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
igt_require_intel(data.drm_fd);
+ igt_require_display(data.drm_fd);
igt_enable_connectors();
kmstest_set_vt_graphics_mode();
diff --git a/tests/kms_legacy_colorkey.c b/tests/kms_legacy_colorkey.c
index 150520ce..e1cc33b6 100644
--- a/tests/kms_legacy_colorkey.c
+++ b/tests/kms_legacy_colorkey.c
@@ -48,6 +48,7 @@ igt_simple_main
igt_skip_on_simulation();
drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(drm_fd);
kmstest_set_vt_graphics_mode();
diff --git a/tests/kms_mmap_write_crc.c b/tests/kms_mmap_write_crc.c
index 279d0f67..802d5a37 100644
--- a/tests/kms_mmap_write_crc.c
+++ b/tests/kms_mmap_write_crc.c
@@ -274,6 +274,7 @@ int main(int argc, char **argv)
igt_fixture {
data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(data.drm_fd);
data.devid = intel_get_drm_devid(data.drm_fd);
diff --git a/tests/kms_panel_fitting.c b/tests/kms_panel_fitting.c
index 7df8104e..bb11399d 100644
--- a/tests/kms_panel_fitting.c
+++ b/tests/kms_panel_fitting.c
@@ -241,6 +241,7 @@ igt_main
igt_skip_on_simulation();
data.drm_fd = drm_open_driver(DRIVER_ANY);
+ igt_require_display(data.drm_fd);
igt_display_init(&data.display, data.drm_fd);
igt_display_require_output(&data.display);
}
diff --git a/tests/kms_pipe_b_c_ivb.c b/tests/kms_pipe_b_c_ivb.c
index 64086915..1854ff68 100644
--- a/tests/kms_pipe_b_c_ivb.c
+++ b/tests/kms_pipe_b_c_ivb.c
@@ -259,6 +259,7 @@ igt_main
igt_fixture {
data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(data.drm_fd);
devid = intel_get_drm_devid(data.drm_fd);
igt_skip_on(!IS_IVYBRIDGE(devid));
diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
index 852f1697..4a6e950b 100644
--- a/tests/kms_pipe_crc_basic.c
+++ b/tests/kms_pipe_crc_basic.c
@@ -180,6 +180,7 @@ igt_main
{
igt_fixture {
data.drm_fd = drm_open_driver_master(DRIVER_ANY);
+ igt_require_display(data.drm_fd);
igt_enable_connectors();
diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 3999dde8..385d475e 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -581,6 +581,7 @@ igt_main
igt_fixture {
data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(data.drm_fd);
kmstest_set_vt_graphics_mode();
diff --git a/tests/kms_plane_lowres.c b/tests/kms_plane_lowres.c
index 5e83ef56..1a531f3c 100644
--- a/tests/kms_plane_lowres.c
+++ b/tests/kms_plane_lowres.c
@@ -297,6 +297,7 @@ igt_main
igt_fixture {
data.drm_fd = drm_open_driver_master(DRIVER_ANY);
+ igt_require_display(data.drm_fd);
kmstest_set_vt_graphics_mode();
diff --git a/tests/kms_plane_multiple.c b/tests/kms_plane_multiple.c
index a53be001..017d791a 100644
--- a/tests/kms_plane_multiple.c
+++ b/tests/kms_plane_multiple.c
@@ -391,6 +391,7 @@ int main(int argc, char *argv[])
igt_fixture {
data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(data.drm_fd);
kmstest_set_vt_graphics_mode();
igt_require_pipe_crc(data.drm_fd);
igt_display_init(&data.display, data.drm_fd);
diff --git a/tests/kms_plane_scaling.c b/tests/kms_plane_scaling.c
index 7c64ed14..3b7b41db 100644
--- a/tests/kms_plane_scaling.c
+++ b/tests/kms_plane_scaling.c
@@ -543,6 +543,7 @@ igt_main
igt_fixture {
data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(data.drm_fd);
igt_require_pipe_crc(data.drm_fd);
igt_display_init(&data.display, data.drm_fd);
data.devid = intel_get_drm_devid(data.drm_fd);
diff --git a/tests/kms_properties.c b/tests/kms_properties.c
index 68c0518f..41e90e5f 100644
--- a/tests/kms_properties.c
+++ b/tests/kms_properties.c
@@ -675,6 +675,7 @@ igt_main
igt_fixture {
display.drm_fd = drm_open_driver_master(DRIVER_ANY);
+ igt_require_display(display.drm_fd);
kmstest_set_vt_graphics_mode();
diff --git a/tests/kms_psr.c b/tests/kms_psr.c
index fcc04770..73bbab6b 100644
--- a/tests/kms_psr.c
+++ b/tests/kms_psr.c
@@ -410,6 +410,7 @@ int main(int argc, char *argv[])
igt_fixture {
data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(data.drm_fd);
data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
kmstest_set_vt_graphics_mode();
data.devid = intel_get_drm_devid(data.drm_fd);
diff --git a/tests/kms_pwrite_crc.c b/tests/kms_pwrite_crc.c
index ee895db6..71aa093d 100644
--- a/tests/kms_pwrite_crc.c
+++ b/tests/kms_pwrite_crc.c
@@ -178,6 +178,7 @@ igt_simple_main
igt_fixture {
data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(data.drm_fd);
data.devid = intel_get_drm_devid(data.drm_fd);
diff --git a/tests/kms_rmfb.c b/tests/kms_rmfb.c
index f3461cc9..abb854cc 100644
--- a/tests/kms_rmfb.c
+++ b/tests/kms_rmfb.c
@@ -143,6 +143,7 @@ igt_main
igt_fixture {
data.drm_fd = drm_open_driver_master(DRIVER_ANY);
+ igt_require_display(data.drm_fd);
kmstest_set_vt_graphics_mode();
diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index f73c6a39..fd30f3b5 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -525,6 +525,7 @@ igt_main
igt_fixture {
data.gfx_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(data.gfx_fd);
data.devid = intel_get_drm_devid(data.gfx_fd);
gen = intel_gen(data.devid);
diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
index 47d04fb5..4ad4740b 100644
--- a/tests/kms_setmode.c
+++ b/tests/kms_setmode.c
@@ -854,6 +854,7 @@ int main(int argc, char **argv)
igt_fixture {
drm_fd = drm_open_driver_master(DRIVER_ANY);
+ igt_require_display(drm_fd);
if (!dry_run)
kmstest_set_vt_graphics_mode();
diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
index 12013881..ecdfea37 100644
--- a/tests/kms_sysfs_edid_timing.c
+++ b/tests/kms_sysfs_edid_timing.c
@@ -41,6 +41,11 @@ igt_simple_main
{
DIR *dirp;
struct dirent *de;
+ int drm_fd;
+
+ drm_fd = drm_open_driver_master(DRIVER_ANY);
+ igt_require_display(drm_fd);
+ close(drm_fd);
dirp = opendir("/sys/class/drm");
igt_assert(dirp != NULL);
diff --git a/tests/kms_tv_load_detect.c b/tests/kms_tv_load_detect.c
index 5684b267..6c9da3ea 100644
--- a/tests/kms_tv_load_detect.c
+++ b/tests/kms_tv_load_detect.c
@@ -37,6 +37,7 @@ int main(int argc, char **argv)
igt_fixture {
drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(drm_fd);
res = drmModeGetResources(drm_fd);
igt_assert(res);
diff --git a/tests/kms_universal_plane.c b/tests/kms_universal_plane.c
index 58f329e6..1c03fad9 100644
--- a/tests/kms_universal_plane.c
+++ b/tests/kms_universal_plane.c
@@ -793,6 +793,7 @@ igt_main
igt_fixture {
data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ igt_require_display(data.drm_fd);
data.gen = intel_gen(intel_get_drm_devid(data.drm_fd));
kmstest_set_vt_graphics_mode();
diff --git a/tests/kms_vblank.c b/tests/kms_vblank.c
index 1c0771c6..90dd6e4a 100644
--- a/tests/kms_vblank.c
+++ b/tests/kms_vblank.c
@@ -506,6 +506,7 @@ igt_main
igt_fixture {
fd = drm_open_driver_master(DRIVER_ANY);
+ igt_require_display(fd);
kmstest_set_vt_graphics_mode();
igt_display_init(&data.display, fd);
igt_display_require_output(&data.display);
diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index 6ab2595b..759eca6b 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -809,6 +809,7 @@ event_wait(int gem_fd, const struct intel_execution_engine2 *e)
devid = intel_get_drm_devid(gem_fd);
igt_require(intel_gen(devid) >= 7);
igt_skip_on(IS_VALLEYVIEW(devid) || IS_CHERRYVIEW(devid));
+ igt_require_display(gem_fd);
kmstest_set_vt_graphics_mode();
igt_display_init(&data.display, gem_fd);
@@ -1398,12 +1399,12 @@ test_rc6(int gem_fd, unsigned int flags)
drmModeRes *res;
res = drmModeGetResources(gem_fd);
- igt_assert(res);
-
- /* force all connectors off */
- kmstest_set_vt_graphics_mode();
- kmstest_unset_all_crtcs(gem_fd, res);
- drmModeFreeResources(res);
+ if (res) {
+ /* force all connectors off */
+ kmstest_set_vt_graphics_mode();
+ kmstest_unset_all_crtcs(gem_fd, res);
+ drmModeFreeResources(res);
+ }
igt_require(igt_setup_runtime_pm());
igt_require(igt_wait_for_pm_status(IGT_RUNTIME_PM_STATUS_SUSPENDED));
diff --git a/tests/pm_backlight.c b/tests/pm_backlight.c
index 32808cdf..ac556b3d 100644
--- a/tests/pm_backlight.c
+++ b/tests/pm_backlight.c
@@ -204,6 +204,7 @@ igt_main
char *name;
drmModeModeInfo *mode;
igt_plane_t *primary;
+ int drm_fd;
/* Get the max value and skip the whole test if sysfs interface not available */
igt_skip_on(backlight_read(&old, "brightness"));
@@ -213,8 +214,10 @@ igt_main
* Backlight tests requires the output to be enabled,
* try to enable all.
*/
+ drm_fd = drm_open_driver(DRIVER_INTEL);
+ igt_require_display(drm_fd);
kmstest_set_vt_graphics_mode();
- igt_display_init(&display, drm_open_driver(DRIVER_INTEL));
+ igt_display_init(&display, drm_fd);
/* should be ../../cardX-$output */
igt_assert_lt(12, readlink(BACKLIGHT_PATH "/device", full_name, sizeof(full_name) - 1));
diff --git a/tests/pm_lpsp.c b/tests/pm_lpsp.c
index a741cb78..d4f96d25 100644
--- a/tests/pm_lpsp.c
+++ b/tests/pm_lpsp.c
@@ -195,6 +195,7 @@ igt_main
drm_fd = drm_open_driver_master(DRIVER_INTEL);
igt_require(drm_fd >= 0);
+ igt_require_display(drm_fd);
devid = intel_get_drm_devid(drm_fd);
diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c
index c24fd95b..f5534ef7 100644
--- a/tests/pm_rpm.c
+++ b/tests/pm_rpm.c
@@ -222,6 +222,9 @@ static void disable_all_screens_dpms(struct mode_set_data *data)
{
int i;
+ if (!data->res)
+ return;
+
for (i = 0; i < data->res->count_connectors; i++) {
drmModeConnectorPtr c = data->connectors[i];
@@ -231,6 +234,9 @@ static void disable_all_screens_dpms(struct mode_set_data *data)
static void disable_all_screens(struct mode_set_data *data)
{
+ if (!data->res)
+ return;
+
kmstest_unset_all_crtcs(drm_fd, data->res);
}
@@ -329,6 +335,8 @@ static bool enable_one_screen_with_type(struct mode_set_data *data,
{
struct modeset_params *params = NULL;
+ igt_require_display(drm_fd);
+
switch (type) {
case SCREEN_TYPE_ANY:
params = default_mode_params;
@@ -388,8 +396,12 @@ static void init_mode_set_data(struct mode_set_data *data)
{
int i;
+ data->devid = intel_get_drm_devid(drm_fd);
+
data->res = drmModeGetResources(drm_fd);
- igt_assert(data->res);
+ if (!data->res)
+ return;
+
igt_assert(data->res->count_connectors <= MAX_CONNECTORS);
for (i = 0; i < data->res->count_connectors; i++) {
@@ -398,8 +410,6 @@ static void init_mode_set_data(struct mode_set_data *data)
data->edids[i] = get_connector_edid(data->connectors[i], i);
}
- data->devid = intel_get_drm_devid(drm_fd);
-
kmstest_set_vt_graphics_mode();
init_modeset_cached_params(&ms_data);
@@ -409,6 +419,9 @@ static void fini_mode_set_data(struct mode_set_data *data)
{
int i;
+ if (!data->res)
+ return;
+
for (i = 0; i < data->res->count_connectors; i++) {
drmModeFreeConnector(data->connectors[i]);
drmModeFreePropertyBlob(data->edids[i]);
@@ -574,6 +587,9 @@ static int count_drm_valid_edids(struct mode_set_data *data)
{
int i, ret = 0;
+ if (!data->res)
+ return ret;
+
for (i = 0; i < data->res->count_connectors; i++)
if (data->edids[i] && edid_is_valid(data->edids[i]->data))
ret++;
@@ -637,6 +653,9 @@ static int count_vga_outputs(struct mode_set_data *data)
{
int i, count = 0;
+ if (!data->res)
+ return count;
+
for (i = 0; i < data->res->count_connectors; i++)
if (data->connectors[i]->connector_type ==
DRM_MODE_CONNECTOR_VGA)
@@ -730,7 +749,8 @@ static bool setup_environment(void)
igt_info("Runtime PM support: %d\n", has_runtime_pm);
igt_info("PC8 residency support: %d\n", has_pc8);
igt_require(has_runtime_pm);
- igt_require(dmc_loaded());
+ if (ms_data.res)
+ igt_require(dmc_loaded());
out:
disable_all_screens(&ms_data);
@@ -773,6 +793,9 @@ static void pc8_residency_subtest(void)
"Machine is not reaching PC8+ states, please check its "
"configuration.\n");
+ if (!ms_data.res)
+ return;
+
/* Make sure PC8+ residencies stop! */
enable_one_screen(&ms_data);
igt_assert_f(!pc8_plus_residency_changed(10),
@@ -783,6 +806,8 @@ static void modeset_subtest(enum screen_type type, int rounds, int wait_flags)
{
int i;
+ igt_require_display(drm_fd);
+
if (wait_flags & WAIT_PC8_RES)
igt_require(has_pc8);
@@ -864,6 +889,7 @@ static void i2c_subtest_check_environment(void)
/* Try to use raw I2C, which also needs interrupts. */
static void i2c_subtest(void)
{
+ igt_require_display(drm_fd);
i2c_subtest_check_environment();
enable_one_screen_and_wait(&ms_data);
@@ -967,7 +993,8 @@ static void gem_mmap_subtest(bool gtt_mmap)
uint8_t *gem_buf;
/* Create, map and set data while the device is active. */
- enable_one_screen_and_wait(&ms_data);
+ if (ms_data.res)
+ enable_one_screen_and_wait(&ms_data);
handle = gem_create(drm_fd, buf_size);
@@ -998,7 +1025,8 @@ static void gem_mmap_subtest(bool gtt_mmap)
igt_assert(wait_for_suspended());
/* Now resume and see if it's still there. */
- enable_one_screen_and_wait(&ms_data);
+ if (ms_data.res)
+ enable_one_screen_and_wait(&ms_data);
for (i = 0; i < buf_size; i++)
igt_assert(gem_buf[i] == (~i & 0xFF));
@@ -1027,7 +1055,8 @@ static void gem_mmap_subtest(bool gtt_mmap)
igt_assert(wait_for_suspended());
/* Resume and check if it's still there. */
- enable_one_screen_and_wait(&ms_data);
+ if (ms_data.res)
+ enable_one_screen_and_wait(&ms_data);
for (i = 0; i < buf_size; i++)
igt_assert(gem_buf[i] == (i & 0xFF));
@@ -1050,7 +1079,8 @@ static void gem_pread_subtest(void)
memset(read_buf, 0, buf_size);
/* Create and set data while the device is active. */
- enable_one_screen_and_wait(&ms_data);
+ if (ms_data.res)
+ enable_one_screen_and_wait(&ms_data);
handle = gem_create(drm_fd, buf_size);
@@ -1080,7 +1110,8 @@ static void gem_pread_subtest(void)
igt_assert(wait_for_suspended());
/* Now resume and see if it's still there. */
- enable_one_screen_and_wait(&ms_data);
+ if (ms_data.res)
+ enable_one_screen_and_wait(&ms_data);
memset(read_buf, 0, buf_size);
gem_read(drm_fd, handle, 0, read_buf, buf_size);
@@ -1187,7 +1218,8 @@ static void gem_execbuf_subtest(void)
uint32_t color;
/* Create and set data while the device is active. */
- enable_one_screen_and_wait(&ms_data);
+ if (ms_data.res)
+ enable_one_screen_and_wait(&ms_data);
handle = gem_create(drm_fd, dst_size);
@@ -1219,7 +1251,8 @@ static void gem_execbuf_subtest(void)
}
/* Now resume and check for it again. */
- enable_one_screen_and_wait(&ms_data);
+ if (ms_data.res)
+ enable_one_screen_and_wait(&ms_data);
memset(cpu_buf, 0, dst_size);
gem_read(drm_fd, handle, 0, cpu_buf, dst_size);
@@ -1388,8 +1421,10 @@ static void pci_d3_state_subtest(void)
disable_all_screens_and_wait(&ms_data);
igt_assert(igt_wait(device_in_pci_d3(), 2000, 100));
- enable_one_screen_and_wait(&ms_data);
- igt_assert(!device_in_pci_d3());
+ if (ms_data.res) {
+ enable_one_screen_and_wait(&ms_data);
+ igt_assert(!device_in_pci_d3());
+ }
}
static void __attribute__((noreturn)) stay_subtest(void)
@@ -1453,7 +1488,8 @@ static void system_suspend_modeset_subtest(void)
igt_system_suspend_autoresume(SUSPEND_STATE_MEM, SUSPEND_TEST_NONE);
igt_assert(wait_for_suspended());
- enable_one_screen_and_wait(&ms_data);
+ if (ms_data.res)
+ enable_one_screen_and_wait(&ms_data);
disable_all_screens_and_wait(&ms_data);
}
@@ -1461,6 +1497,8 @@ static void system_suspend_modeset_subtest(void)
* produced WARNs on this case. */
static void dpms_mode_unset_subtest(enum screen_type type)
{
+ igt_require_display(drm_fd);
+
disable_all_screens_and_wait(&ms_data);
igt_require(enable_one_screen_with_type(&ms_data, type));
@@ -1783,7 +1821,8 @@ static void pm_test_tiling(void)
igt_assert(tiling_modes[i] == ti);
}
- enable_one_screen_and_wait(&ms_data);
+ if (ms_data.res)
+ enable_one_screen_and_wait(&ms_data);
for (j = 0, k = 1 << off_bit;
k <= gtt_obj_max_size; k <<= 1, j++) {
diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
index b821fbb8..a99cd8a9 100644
--- a/tests/prime_vgem.c
+++ b/tests/prime_vgem.c
@@ -747,6 +747,8 @@ static void test_flip(int i915, int vgem, unsigned hang)
struct vgem_bo bo[2];
uint32_t fb_id[2], handle[2], crtc_id;
+ igt_require_display(i915);
+
signal(SIGHUP, sighandler);
for (int i = 0; i < 2; i++) {
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 0ff98a2b..a770b29f 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -716,6 +716,7 @@ int main(int argc, char **argv)
test_all_modes = 1;
drm_fd = drm_open_driver(DRIVER_ANY);
+ igt_require_display(drm_fd);
if (test_stereo_modes &&
drmSetClientCap(drm_fd, DRM_CLIENT_CAP_STEREO_3D, 1) < 0) {
--
2.18.0
More information about the igt-dev
mailing list