[Intel-gfx] [PATCH v2] lib/igt_kms.c: remove tests dependency on VT /dev/tty0

Daniel Vetter daniel at ffwll.ch
Tue Feb 24 14:39:13 PST 2015


On Tue, Feb 24, 2015 at 12:29:22PM -0800, Marc Herbert wrote:
> Required to run on any recent, freon-based and X11-free ChromeOS release.
> 
> Signed-off-by: Marc Herbert <marc.herbert at intel.com>
> ---
> 
> Changes from v1:
> - igt_debug() instead of igt_warn()
> - return KD_GRAPHICS instead of -1UL
> - print previous mode in debug statements. Among others this help a tiny
>   bit with the now confusing debug output ("cannot change" immediately
>   followed by a misleading "mode changed").

Thanks for the patch, merged to igt.
-Daniel

> 
> Note: a naive "mv /dev/tty0 /dev/tty0.orig" is typically enough to test
> this patch.
> 
>  lib/igt_kms.c | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index d0c3690..9c131f0 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -299,12 +299,26 @@ int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id)
>  	return pfci.pipe;
>  }
>  
> +/*
> + * Returns: the previous mode, or KD_GRAPHICS if no /dev/tty0 was
> + * found and nothing was done.
> + */
>  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_debug("VT: %s: %s, cannot change its mode\n",
> +			  TTY0, strerror(errno));
> +		return KD_GRAPHICS;
> +	}
>  
> -	fd = open("/dev/tty0", O_RDONLY);
> +	fd = open(TTY0, O_RDONLY);
>  	if (fd < 0)
>  		return -errno;
>  
> @@ -336,10 +350,10 @@ void kmstest_restore_vt_mode(void)
>  
>  	if (orig_vt_mode != -1UL) {
>  		ret = set_vt_mode(orig_vt_mode);
> -		orig_vt_mode = -1UL;
>  
>  		igt_assert(ret >= 0);
> -		igt_debug("VT: original mode restored\n");
> +		igt_debug("VT: original mode 0x%lx restored\n", orig_vt_mode);
> +		orig_vt_mode = -1UL;
>  	}
>  }
>  
> @@ -366,7 +380,7 @@ void kmstest_set_vt_graphics_mode(void)
>  	igt_assert(ret >= 0);
>  	orig_vt_mode = ret;
>  
> -	igt_debug("VT: graphics mode set\n");
> +	igt_debug("VT: graphics mode set (mode was 0x%lx)\n", ret);
>  }
>  
>  
> -- 
> 1.9.3
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


More information about the Intel-gfx mailing list