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

Thomas Wood thomas.wood at intel.com
Tue Feb 24 08:12:48 PST 2015


On 24 February 2015 at 00:03, Daniel Vetter <daniel at ffwll.ch> wrote:
> On Thu, Feb 19, 2015 at 04:38:43PM -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>
>> ---
>>  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;
>
> -1 collides with the negative errno space. Imo it's clearer to just return
> KD_GRAPHICS since a system without vt is kinda always in gfx mode. This
> means we'll run the exit handler but that will again be a noop because
> there's still no tty.
>
> With that change the patch looks good I think.

It seems that missing tty0 isn't a major cause for concern, so the
igt_warn can be changed back to igt_debug as well.

> -Daniel
>
>> +     }
>>
>> -     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 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
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx


More information about the Intel-gfx mailing list