diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2022-05-23 13:43:30 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2022-05-26 08:28:39 +1000 |
commit | 6fd9efcd269e7bd879c62044d176007df8d659d8 (patch) | |
tree | 81d5e81d52a43a8d978a254c6c75983cc872d3bc | |
parent | 00473a30a0c5a6558a3c0491fc5808baaf711702 (diff) | |
download | xf86-input-wacom-6fd9efcd269e7bd879c62044d176007df8d659d8.tar.gz |
test: ignore test devices, or real devices during test suite runs
Set an option on all our created uinput devices, and an environment
variable when we're running the test suite. If both of these are set we
process the device, otherwise ignore the device during PreInit.
This stops the driver picking up events from test suite runs
(potentially clicking around on the desktop) and it stops the test suite
from false positives by locally connected devices.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | src/wcmConfig.c | 21 | ||||
-rw-r--r-- | test/__init__.py | 1 | ||||
-rw-r--r-- | test/conftest.py | 6 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/wcmConfig.c b/src/wcmConfig.c index 973728a..f1d058b 100644 --- a/src/wcmConfig.c +++ b/src/wcmConfig.c @@ -694,6 +694,22 @@ static inline WacomType getType(const char *type) return wtype; } +static inline Bool filter_test_suite(WacomDevicePtr priv) +{ + bool is_test_device = wcmOptGetBool(priv, "_testdevice", FALSE); + bool is_test_suite_run = getenv("WACOM_RUNNING_TEST_SUITE") != NULL; + + if (is_test_device == is_test_suite_run) + return FALSE; + + if (is_test_device) + wcmLog(priv, W_INFO, "Ignoring test device '%s'\n", priv->name); + else if (is_test_suite_run) + wcmLog(priv, W_INFO, "Ignoring device '%s' during test suite run\n", priv->name); + + return TRUE; +} + /* wcmPreInit - called for each input devices with the driver set to * "wacom" */ int wcmPreInit(WacomDevicePtr priv) @@ -704,6 +720,11 @@ int wcmPreInit(WacomDevicePtr priv) int need_hotplug = 0, is_dependent = 0; int fd = -1; + /* Ignore real devices during test suite runs, or test devices during + * normal operation */ + if (filter_test_suite(priv)) + goto SetupProc_fail; + /* Init process: - if no device is given, auto-probe for one (find a wacom device diff --git a/test/__init__.py b/test/__init__.py index 5d9b8ed..7a10f16 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -233,6 +233,7 @@ class Monitor: pytest.skip("Insufficient permissions to open event node") opts["Device"] = uidev.devnode + opts["_testdevice"] = "true" wacom_options = wacom.Options() for name, value in opts.items(): wacom_options.set(name, value) diff --git a/test/conftest.py b/test/conftest.py index c68a1d0..d934143 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,3 +1,4 @@ +import os import pytest # We set up hooks to count how many tests actually ran. Since we need uinput @@ -29,3 +30,8 @@ def pytest_sessionfinish(session, exitstatus): reporter = session.config.pluginmanager.get_plugin("terminalreporter") reporter.section("Session errors", sep="-", red=True, bold=True) reporter.line(f"{session.count_skipped} tests were skipped, none were run") + + +@pytest.fixture(autouse=True) +def set_environment(): + os.environ["WACOM_RUNNING_TEST_SUITE"] = "1" |