[PATCH libinput] test: call K_OFF when run on the vt

Peter Hutterer peter.hutterer at who-t.net
Fri Apr 6 02:31:45 UTC 2018


On Thu, Apr 05, 2018 at 12:53:45PM +0300, Pekka Paalanen wrote:
> On Thu, 5 Apr 2018 15:18:08 +1000
> Peter Hutterer <peter.hutterer at who-t.net> wrote:
> 
> > Slight disadvantage: this breaks Ctrl+C to cancel the test suite when run
> > from the VT. Still potentially better than injecting semi-random events.
> > 
> > Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> > ---
> > Pekka noticed this yesterday. This approach is the simplest solution,
> > allowing the test suite to be run as-is but but as soon as any options are
> > specified we don't touch things. This saves us the need for rollbacks in
> > case of failures (we usually fork everything except in the below cases).
> > 
> > It's a bit of a niche case IMO so not sure we need to put a lot more effort
> > in. I'm not even that happy with this patch, so unless there's a real need
> > for it...
> > 
> >  test/litest.c | 22 +++++++++++++++++++++-
> >  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> Hi,
> 
> Tested-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> 
> and the code looks reasonable to me, so Reviewed-by as well fwiw.
> 
> While running this, I noticed the tests printing some ^@ on the VT
> still, and a few ยง and maybe some others.

yeah, saw those too but not sure yet where those come from.
 
> Another thing is, running Xorg 1.19.5 in an inactive VT at the same
> time but without the libinput config snippet to ignore the test
> devices, the Xorg log fills up with the test device messages. Is Xorg
> intended to react to input devices even when inactive?

yes, it still gets the udev notifications so it initialises the devices. But
while vt-switched away events from the devices are ignored, so other than
spamming your log files (which they'd do anyway) nothing should happen.

> Here's an example:
> 
> [3182708.368] (II) config/udev: Adding input device litest Wheel Click Angle Mouse (/dev/input/event19)
> [3182708.368] (**) litest Wheel Click Angle Mouse: Applying InputClass "evdev pointer catchall"
> [3182708.368] (**) litest Wheel Click Angle Mouse: Applying InputClass "libinput pointer catchall"
> [3182708.368] (II) Using input driver 'libinput' for 'litest Wheel Click Angle Mouse'
> [3182708.368] (II) systemd-logind: got fd for /dev/input/event19 13:83 fd 88 paused 1
> [3182708.368] (II) systemd-logind: releasing fd for 13:83
> 
> 
> I'm mostly curious, and I appreciate the right way is to have that Xorg
> config snippet in place, so there's no pressing need from my side to
> have this patch. However, would you not need this for CI?

CI is ... tricky. It only works on VMs, not containers, so things like
CircleCI only test build combinations. For running the full test suite I
don't have automated CI.

Instead, I usually clone into a fresh directory and run my magic script that
I've accumulated over the years:
    https://gist.github.com/whot/0fa8e0ab40e294b4dbf9d62de97d7794

This usually works fine while you have a normal session going as libinput
test devices are ignored by the libinput you have in your compositor.

I also had minimal VMs but on those I usually ran under screen. So running
the test suite on the VT is rarely needed.

Cheers,
   Peter

> 
> > 
> > diff --git a/test/litest.c b/test/litest.c
> > index 9f4681bb..03e19a81 100644
> > --- a/test/litest.c
> > +++ b/test/litest.c
> > @@ -56,6 +56,8 @@
> >  #include "litest-int.h"
> >  #include "libinput-util.h"
> >  
> > +#include <linux/kd.h>
> > +
> >  #define UDEV_RULES_D "/run/udev/rules.d"
> >  #define UDEV_RULE_PREFIX "99-litest-"
> >  #define UDEV_HWDB_D "/etc/udev/hwdb.d"
> > @@ -3722,6 +3724,8 @@ main(int argc, char **argv)
> >  {
> >  	const struct rlimit corelimit = { 0, 0 };
> >  	enum litest_mode mode;
> > +	int tty_mode = -1;
> > +	int failed_tests;
> >  
> >  	if (getuid() != 0) {
> >  		fprintf(stderr,
> > @@ -3762,6 +3766,22 @@ main(int argc, char **argv)
> >  	if (setrlimit(RLIMIT_CORE, &corelimit) != 0)
> >  		perror("WARNING: Core dumps not disabled. Reason");
> >  
> > -	return litest_run(argc, argv);
> > +	/* If we're running 'normally' on the VT, disable the keyboard to
> > +	 * avoid messing up our host. But if we're inside gdb or running
> > +	 * without forking, leave it as-is.
> > +	 */
> > +	if (jobs > 1 &&
> > +	    !in_debugger &&
> > +	    getenv("CK_FORK") == NULL &&
> > +	    isatty(STDIN_FILENO) &&
> > +	    ioctl(STDIN_FILENO, KDGKBMODE, &tty_mode) == 0)
> > +		ioctl(STDIN_FILENO, KDSKBMODE, K_OFF);
> > +
> > +	failed_tests = litest_run(argc, argv);
> > +
> > +	if (tty_mode != -1)
> > +		ioctl(STDIN_FILENO, KDSKBMODE, tty_mode);
> > +
> > +	return failed_tests;
> >  }
> >  #endif
> 




More information about the wayland-devel mailing list