Required to run on any recent, freon-based and X11-free ChromeOS release. Signed-off-by: Marc Herbert <marc.herbert@xxxxxxxxx> --- lib/igt_kms.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index d0c3690..27cff86 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -299,12 +299,24 @@ int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id) return pfci.pipe; } +static unsigned long orig_vt_mode = -1UL; + static signed long set_vt_mode(unsigned long mode) { int fd; unsigned long prev_mode; + static const char TTY0[] = "/dev/tty0"; + + if (access(TTY0, F_OK)) { + /* errno message should be "No such file". Do not + hardcode but ask strerror() in the very unlikely + case something else happened. */ + igt_warn("VT: %s: %s, cannot change its mode\n", + TTY0, strerror(errno)); + return orig_vt_mode; + } - fd = open("/dev/tty0", O_RDONLY); + fd = open(TTY0, O_RDONLY); if (fd < 0) return -errno; @@ -323,8 +335,6 @@ err: return -errno; } -static unsigned long orig_vt_mode = -1UL; - /** * kmstest_restore_vt_mode: * @@ -363,6 +373,10 @@ void kmstest_set_vt_graphics_mode(void) ret = set_vt_mode(KD_GRAPHICS); igt_enable_exit_handler(); + /* Return if set_vt_mode has successfully not changed anything */ + if (ret == orig_vt_mode) + return; + igt_assert(ret >= 0); orig_vt_mode = ret; -- 1.9.3 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx