2020-03-16 13:13:41 +10:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
# vim: set expandtab shiftwidth=4:
|
|
|
|
|
# -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */
|
|
|
|
|
#
|
|
|
|
|
# Copyright © 2018 Red Hat, Inc.
|
|
|
|
|
#
|
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
# copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
# to deal in the Software without restriction, including without limitation
|
|
|
|
|
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
# and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
# Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
#
|
|
|
|
|
# The above copyright notice and this permission notice (including the next
|
|
|
|
|
# paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
# Software.
|
|
|
|
|
#
|
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
# DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
import resource
|
|
|
|
|
import sys
|
|
|
|
|
import subprocess
|
|
|
|
|
import logging
|
|
|
|
|
|
2020-03-20 16:16:48 +10:00
|
|
|
try:
|
|
|
|
|
import pytest
|
|
|
|
|
except ImportError:
|
2021-01-25 13:12:25 +10:00
|
|
|
print("Failed to import pytest. Skipping.", file=sys.stderr)
|
2020-03-20 16:16:48 +10:00
|
|
|
sys.exit(77)
|
|
|
|
|
|
|
|
|
|
|
2021-01-25 13:12:25 +10:00
|
|
|
logger = logging.getLogger("test")
|
2020-03-16 13:13:41 +10:00
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
|
|
2021-01-25 13:12:25 +10:00
|
|
|
if "@DISABLE_WARNING@" != "yes":
|
|
|
|
|
print("This is the source file, run the one in the meson builddir instead")
|
2020-03-16 13:13:41 +10:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _disable_coredump():
|
|
|
|
|
resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_command(args):
|
2021-01-25 13:12:25 +10:00
|
|
|
logger.debug("run command: {}".format(" ".join(args)))
|
|
|
|
|
with subprocess.Popen(
|
|
|
|
|
args,
|
|
|
|
|
preexec_fn=_disable_coredump,
|
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
|
stderr=subprocess.PIPE,
|
|
|
|
|
) as p:
|
2020-03-16 13:13:41 +10:00
|
|
|
try:
|
|
|
|
|
p.wait(0.7)
|
|
|
|
|
except subprocess.TimeoutExpired:
|
|
|
|
|
p.send_signal(3) # SIGQUIT
|
|
|
|
|
stdout, stderr = p.communicate(timeout=5)
|
|
|
|
|
if p.returncode == -3:
|
|
|
|
|
p.returncode = 0
|
2021-01-25 13:12:25 +10:00
|
|
|
return p.returncode, stdout.decode("UTF-8"), stderr.decode("UTF-8")
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class LibinputTool(object):
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_tool = "libinput"
|
2020-03-16 13:13:41 +10:00
|
|
|
subtool = None
|
|
|
|
|
|
|
|
|
|
def __init__(self, subtool=None):
|
|
|
|
|
self.libinput_tool = "@TOOL_PATH@"
|
|
|
|
|
self.subtool = subtool
|
|
|
|
|
|
|
|
|
|
def run_command(self, args):
|
|
|
|
|
args = [self.libinput_tool] + args
|
|
|
|
|
if self.subtool is not None:
|
|
|
|
|
args.insert(1, self.subtool)
|
|
|
|
|
|
|
|
|
|
return run_command(args)
|
|
|
|
|
|
|
|
|
|
def run_command_success(self, args):
|
|
|
|
|
rc, stdout, stderr = self.run_command(args)
|
|
|
|
|
# if we're running as user, we might fail the command but we should
|
|
|
|
|
# never get rc 2 (invalid usage)
|
|
|
|
|
assert rc in [0, 1], (stdout, stderr)
|
|
|
|
|
return stdout, stderr
|
|
|
|
|
|
|
|
|
|
def run_command_invalid(self, args):
|
|
|
|
|
rc, stdout, stderr = self.run_command(args)
|
|
|
|
|
assert rc == 2, (rc, stdout, stderr)
|
|
|
|
|
return rc, stdout, stderr
|
|
|
|
|
|
|
|
|
|
def run_command_unrecognized_option(self, args):
|
|
|
|
|
rc, stdout, stderr = self.run_command(args)
|
|
|
|
|
assert rc == 2, (rc, stdout, stderr)
|
2021-01-25 13:12:25 +10:00
|
|
|
assert stdout.startswith("Usage") or stdout == ""
|
|
|
|
|
assert "unrecognized option" in stderr
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
def run_command_missing_arg(self, args):
|
|
|
|
|
rc, stdout, stderr = self.run_command(args)
|
|
|
|
|
assert rc == 2, (rc, stdout, stderr)
|
2021-01-25 13:12:25 +10:00
|
|
|
assert stdout.startswith("Usage") or stdout == ""
|
|
|
|
|
assert "requires an argument" in stderr
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
def run_command_unrecognized_tool(self, args):
|
|
|
|
|
rc, stdout, stderr = self.run_command(args)
|
|
|
|
|
assert rc == 2, (rc, stdout, stderr)
|
2021-01-25 13:12:25 +10:00
|
|
|
assert stdout.startswith("Usage") or stdout == ""
|
|
|
|
|
assert "is not installed" in stderr
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class LibinputDebugGui(LibinputTool):
|
2021-01-25 13:12:25 +10:00
|
|
|
def __init__(self, subtool="debug-gui"):
|
|
|
|
|
assert subtool == "debug-gui"
|
2020-03-16 13:13:41 +10:00
|
|
|
super().__init__(subtool)
|
|
|
|
|
|
2021-01-25 13:12:25 +10:00
|
|
|
debug_gui_enabled = "@MESON_ENABLED_DEBUG_GUI@" == "True"
|
2020-03-16 13:13:41 +10:00
|
|
|
if not debug_gui_enabled:
|
|
|
|
|
pytest.skip()
|
|
|
|
|
|
2021-01-25 13:12:25 +10:00
|
|
|
if not os.getenv("DISPLAY") and not os.getenv("WAYLAND_DISPLAY"):
|
2020-03-16 13:13:41 +10:00
|
|
|
pytest.skip()
|
|
|
|
|
|
|
|
|
|
# 77 means gtk_init() failed, which is probably because you can't
|
|
|
|
|
# connect to the display server.
|
2021-01-25 13:12:25 +10:00
|
|
|
rc, _, _ = self.run_command(["--help"])
|
2020-03-16 13:13:41 +10:00
|
|
|
if rc == 77:
|
|
|
|
|
pytest.skip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_tool(subtool=None):
|
2021-01-25 13:12:25 +10:00
|
|
|
if subtool == "debug-gui":
|
2020-03-16 13:13:41 +10:00
|
|
|
return LibinputDebugGui()
|
|
|
|
|
else:
|
|
|
|
|
return LibinputTool(subtool)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def libinput():
|
|
|
|
|
return get_tool()
|
|
|
|
|
|
|
|
|
|
|
2021-01-25 13:12:25 +10:00
|
|
|
@pytest.fixture(params=["debug-events", "debug-gui"])
|
2020-03-16 13:13:41 +10:00
|
|
|
def libinput_debug_tool(request):
|
|
|
|
|
yield get_tool(request.param)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def libinput_debug_events():
|
2021-01-25 13:12:25 +10:00
|
|
|
return get_tool("debug-events")
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def libinput_debug_gui():
|
2021-01-25 13:12:25 +10:00
|
|
|
return get_tool("debug-gui")
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def libinput_record():
|
2021-01-25 13:12:25 +10:00
|
|
|
return get_tool("record")
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_help(libinput):
|
2021-01-25 13:12:25 +10:00
|
|
|
stdout, stderr = libinput.run_command_success(["--help"])
|
|
|
|
|
assert stdout.startswith("Usage:")
|
|
|
|
|
assert stderr == ""
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_version(libinput):
|
2021-01-25 13:12:25 +10:00
|
|
|
stdout, stderr = libinput.run_command_success(["--version"])
|
|
|
|
|
assert stdout.startswith("1")
|
|
|
|
|
assert stderr == ""
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
2021-01-25 13:12:25 +10:00
|
|
|
@pytest.mark.parametrize("argument", ["--banana", "--foo", "--quiet", "--verbose"])
|
2020-03-16 13:13:41 +10:00
|
|
|
def test_invalid_arguments(libinput, argument):
|
|
|
|
|
libinput.run_command_unrecognized_option([argument])
|
|
|
|
|
|
|
|
|
|
|
2021-01-25 13:12:25 +10:00
|
|
|
@pytest.mark.parametrize("tool", [["foo"], ["debug"], ["foo", "--quiet"]])
|
2020-03-16 13:13:41 +10:00
|
|
|
def test_invalid_tool(libinput, tool):
|
|
|
|
|
libinput.run_command_unrecognized_tool(tool)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_udev_seat(libinput_debug_tool):
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_debug_tool.run_command_missing_arg(["--udev"])
|
|
|
|
|
libinput_debug_tool.run_command_success(["--udev", "seat0"])
|
|
|
|
|
libinput_debug_tool.run_command_success(["--udev", "seat1"])
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
2021-01-25 13:12:25 +10:00
|
|
|
@pytest.mark.skipif(os.environ.get("UDEV_NOT_AVAILABLE"), reason="udev required")
|
2020-03-16 13:13:41 +10:00
|
|
|
def test_device_arg(libinput_debug_tool):
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_debug_tool.run_command_missing_arg(["--device"])
|
|
|
|
|
libinput_debug_tool.run_command_success(["--device", "/dev/input/event0"])
|
|
|
|
|
libinput_debug_tool.run_command_success(["--device", "/dev/input/event1"])
|
|
|
|
|
libinput_debug_tool.run_command_success(["/dev/input/event0"])
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
options = {
|
2021-01-25 13:12:25 +10:00
|
|
|
"pattern": ["sendevents"],
|
2020-03-16 13:13:41 +10:00
|
|
|
# enable/disable options
|
2021-01-25 13:12:25 +10:00
|
|
|
"enable-disable": [
|
|
|
|
|
"tap",
|
|
|
|
|
"drag",
|
|
|
|
|
"drag-lock",
|
|
|
|
|
"middlebutton",
|
|
|
|
|
"natural-scrolling",
|
|
|
|
|
"left-handed",
|
|
|
|
|
"dwt",
|
2022-03-08 01:33:40 +00:00
|
|
|
"dwtp",
|
2020-03-16 13:13:41 +10:00
|
|
|
],
|
|
|
|
|
# options with distinct values
|
2021-01-25 13:12:25 +10:00
|
|
|
"enums": {
|
|
|
|
|
"set-click-method": ["none", "clickfinger", "buttonareas"],
|
|
|
|
|
"set-scroll-method": ["none", "twofinger", "edge", "button"],
|
|
|
|
|
"set-profile": ["adaptive", "flat"],
|
|
|
|
|
"set-tap-map": ["lrm", "lmr"],
|
2020-03-16 13:13:41 +10:00
|
|
|
},
|
2023-04-27 11:12:17 +10:00
|
|
|
# options with a range (and increment)
|
2021-01-25 13:12:25 +10:00
|
|
|
"ranges": {
|
2023-04-27 11:12:17 +10:00
|
|
|
"set-speed": (-1.0, +1.0, 0.1),
|
2021-01-25 13:12:25 +10:00
|
|
|
},
|
2020-03-16 13:13:41 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Options that allow for glob patterns
|
2021-01-25 13:12:25 +10:00
|
|
|
@pytest.mark.parametrize("option", options["pattern"])
|
2020-03-16 13:13:41 +10:00
|
|
|
def test_options_pattern(libinput_debug_tool, option):
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_debug_tool.run_command_success(["--disable-{}".format(option), "*"])
|
|
|
|
|
libinput_debug_tool.run_command_success(["--disable-{}".format(option), "abc*"])
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
2021-01-25 13:12:25 +10:00
|
|
|
@pytest.mark.parametrize("option", options["enable-disable"])
|
2020-03-16 13:13:41 +10:00
|
|
|
def test_options_enable_disable(libinput_debug_tool, option):
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_debug_tool.run_command_success(["--enable-{}".format(option)])
|
|
|
|
|
libinput_debug_tool.run_command_success(["--disable-{}".format(option)])
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
2021-01-25 13:12:25 +10:00
|
|
|
@pytest.mark.parametrize("option", options["enums"].items())
|
2020-03-16 13:13:41 +10:00
|
|
|
def test_options_enums(libinput_debug_tool, option):
|
|
|
|
|
name, values = option
|
|
|
|
|
for v in values:
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_debug_tool.run_command_success(["--{}".format(name), v])
|
|
|
|
|
libinput_debug_tool.run_command_success(["--{}={}".format(name, v)])
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
2021-01-25 13:12:25 +10:00
|
|
|
@pytest.mark.parametrize("option", options["ranges"].items())
|
2020-03-16 13:13:41 +10:00
|
|
|
def test_options_ranges(libinput_debug_tool, option):
|
|
|
|
|
name, values = option
|
2023-04-27 11:12:17 +10:00
|
|
|
minimum, maximum, step = values
|
2020-03-16 13:13:41 +10:00
|
|
|
value = minimum
|
|
|
|
|
while value < maximum:
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_debug_tool.run_command_success(["--{}".format(name), str(value)])
|
|
|
|
|
libinput_debug_tool.run_command_success(["--{}={}".format(name, value)])
|
2020-03-16 13:13:41 +10:00
|
|
|
value += step
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_debug_tool.run_command_success(["--{}".format(name), str(maximum)])
|
|
|
|
|
libinput_debug_tool.run_command_success(["--{}={}".format(name, maximum)])
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_apply_to(libinput_debug_tool):
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_debug_tool.run_command_missing_arg(["--apply-to"])
|
|
|
|
|
libinput_debug_tool.run_command_success(["--apply-to", "*foo*"])
|
|
|
|
|
libinput_debug_tool.run_command_success(["--apply-to", "foobar"])
|
|
|
|
|
libinput_debug_tool.run_command_success(["--apply-to", "any"])
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
2021-01-25 13:12:25 +10:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
"args",
|
|
|
|
|
[["--verbose"], ["--quiet"], ["--verbose", "--quiet"], ["--quiet", "--verbose"]],
|
|
|
|
|
)
|
2020-03-16 13:13:41 +10:00
|
|
|
def test_debug_events_verbose_quiet(libinput_debug_events, args):
|
|
|
|
|
libinput_debug_events.run_command_success(args)
|
|
|
|
|
|
|
|
|
|
|
2021-01-25 13:12:25 +10:00
|
|
|
@pytest.mark.parametrize("arg", ["--banana", "--foo", "--version"])
|
2020-03-16 13:13:41 +10:00
|
|
|
def test_invalid_args(libinput_debug_tool, arg):
|
|
|
|
|
libinput_debug_tool.run_command_unrecognized_option([arg])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_libinput_debug_events_multiple_devices(libinput_debug_events):
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_debug_events.run_command_success(
|
|
|
|
|
["--device", "/dev/input/event0", "/dev/input/event1"]
|
|
|
|
|
)
|
2020-03-16 13:13:41 +10:00
|
|
|
# same event path multiple times? meh, your problem
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_debug_events.run_command_success(
|
|
|
|
|
["--device", "/dev/input/event0", "/dev/input/event0"]
|
|
|
|
|
)
|
|
|
|
|
libinput_debug_events.run_command_success(
|
|
|
|
|
["/dev/input/event0", "/dev/input/event1"]
|
|
|
|
|
)
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_libinput_debug_events_too_many_devices(libinput_debug_events):
|
|
|
|
|
# Too many arguments just bails with the usage message
|
2021-01-25 13:12:25 +10:00
|
|
|
rc, stdout, stderr = libinput_debug_events.run_command(["/dev/input/event0"] * 61)
|
2020-03-16 13:13:41 +10:00
|
|
|
assert rc == 2, (stdout, stderr)
|
|
|
|
|
|
|
|
|
|
|
2021-01-25 13:12:25 +10:00
|
|
|
@pytest.mark.parametrize("arg", ["--quiet"])
|
2020-03-16 13:13:41 +10:00
|
|
|
def test_libinput_debug_gui_invalid_arg(libinput_debug_gui, arg):
|
|
|
|
|
libinput_debug_gui.run_command_unrecognized_option([arg])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_libinput_debug_gui_verbose(libinput_debug_gui):
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_debug_gui.run_command_success(["--verbose"])
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
tools/record: add support for hidraw recording
New commandline switch --with-hidraw. This will open all hidraw devices
associated with this device and add any reports to the output in the
form:
events:
- hid:
time: [0, 0]
hidraw1: [0x01, 0x02, 0x03, 0x05, 0x06]
hidraw2: [0x07, 0x08, 0x09, 0x0a, 0x0b]
- evdev:
...
i.e. there's a nesting of `hid` with a list of reports, each with the hidraw
node as dictionary entry.
Because hidraw events do not have timestamps and always occur before the evdev
events, they are in a separate frame (as shown above). We could try to figure
out how to match them with the upcoming evdev frame but it's not worth it for
now.
The timestamp itself is a special key in the hidraw with the timestamp from
clock_gettime.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-18 14:20:22 +10:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
"arg", ["--help", "--show-keycodes", "--with-libinput", "--with-hidraw"]
|
|
|
|
|
)
|
2020-03-16 13:13:41 +10:00
|
|
|
def test_libinput_record_args(libinput_record, arg):
|
|
|
|
|
libinput_record.run_command_success([arg])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_libinput_record_multiple_arg(libinput_record):
|
|
|
|
|
# this arg is deprecated and a noop
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_record.run_command_success(["--multiple"])
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def recording(tmp_path):
|
2021-01-25 13:12:25 +10:00
|
|
|
return str((tmp_path / "record.out").resolve())
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_libinput_record_all(libinput_record, recording):
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_record.run_command_success(["--all", "-o", recording])
|
|
|
|
|
libinput_record.run_command_success(["--all", recording])
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_libinput_record_outfile(libinput_record, recording):
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_record.run_command_success(["-o", recording])
|
|
|
|
|
libinput_record.run_command_success(["--output-file", recording])
|
|
|
|
|
libinput_record.run_command_success(["--output-file={}".format(recording)])
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_libinput_record_single(libinput_record, recording):
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_record.run_command_success(["/dev/input/event0"])
|
|
|
|
|
libinput_record.run_command_success(["-o", recording, "/dev/input/event0"])
|
|
|
|
|
libinput_record.run_command_success(["/dev/input/event0", recording])
|
|
|
|
|
libinput_record.run_command_success([recording, "/dev/input/event0"])
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_libinput_record_multiple(libinput_record, recording):
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_record.run_command_success(
|
|
|
|
|
["-o", recording, "/dev/input/event0", "/dev/input/event1"]
|
|
|
|
|
)
|
|
|
|
|
libinput_record.run_command_success(
|
|
|
|
|
[recording, "/dev/input/event0", "/dev/input/event1"]
|
|
|
|
|
)
|
|
|
|
|
libinput_record.run_command_success(
|
|
|
|
|
["/dev/input/event0", "/dev/input/event1", recording]
|
|
|
|
|
)
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_libinput_record_autorestart(libinput_record, recording):
|
2021-01-25 13:12:25 +10:00
|
|
|
libinput_record.run_command_invalid(["--autorestart"])
|
|
|
|
|
libinput_record.run_command_invalid(["--autorestart=2"])
|
|
|
|
|
libinput_record.run_command_success(["-o", recording, "--autorestart=2"])
|
2020-03-16 13:13:41 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2021-01-25 13:12:25 +10:00
|
|
|
args = ["-m", "pytest"]
|
2020-03-16 13:13:41 +10:00
|
|
|
try:
|
|
|
|
|
import xdist # noqa
|
2021-01-25 13:12:25 +10:00
|
|
|
|
2023-03-20 09:18:30 +10:00
|
|
|
ncores = os.environ.get("FDO_CI_CONCURRENT", "auto")
|
|
|
|
|
args += ["-n", ncores]
|
2020-03-16 13:13:41 +10:00
|
|
|
except ImportError:
|
2021-01-25 13:12:25 +10:00
|
|
|
logger.info("python-xdist missing, this test will be slow")
|
2020-03-16 13:13:41 +10:00
|
|
|
pass
|
|
|
|
|
|
2021-01-25 13:12:25 +10:00
|
|
|
args += ["@MESON_BUILD_ROOT@"]
|
2020-03-16 13:13:41 +10:00
|
|
|
|
2021-01-25 13:12:25 +10:00
|
|
|
os.environ["LIBINPUT_RUNNING_TEST_SUITE"] = "1"
|
2020-07-03 09:55:37 +10:00
|
|
|
|
2020-03-16 13:13:41 +10:00
|
|
|
return subprocess.run([sys.executable] + args).returncode
|
|
|
|
|
|
|
|
|
|
|
2021-01-25 13:12:25 +10:00
|
|
|
if __name__ == "__main__":
|
2020-03-16 13:13:41 +10:00
|
|
|
raise SystemExit(main())
|