summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* test: add a test for the artpen/airbrush wheel updatesPeter Hutterer2022-06-132-0/+85
| | | | | | | | | | | | | | | | | | | | | | This was slightly too complicated to add to the existing test_axis_updates test, so that test is duplicated here, only testing what we see as "wheel" axis in the driver. The test is run for all three pens Because the X driver unconditionally sets ds->abswheel from the kernel events, we must take care only to send the kernel axis that matters for our current tool - otherwise we overwrite ds->abswheel with whichever one of ABS_Z or ABS_WHEEL is sent last in the evdev frame. In other words, we cannot test that artpen ignores ABS_WHEEL and airbrush ignores ABS_Z because ... they don't. For the generic pen that doesn't matter since we're supposed to ignore both axes anyway. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Ping Cheng <ping.cheng@wacom.com> Tested-by: Ping Cheng <ping.cheng@wacom.com>
* Added vim modelines to python files.Greenscreener2022-06-133-0/+9
|
* test: raise an InputError with better info if modules are missingPeter Hutterer2022-06-131-4/+12
| | | | | | | | The tests need to run as root (for uinput/evdev) so pip-installing a package as user gets past the build check but then fails at runtime. Let's make this bit easier to debug. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: Ensure standard pen does not report the "wheel" axisPeter Hutterer2022-06-012-5/+29
| | | | | | | | | | | | | | | | The event data has a mask field that specifies which fields are actually present (zero may be a valid value for an axis after all). Let's check that mask for each event and ensure that if the pen supports the axis, the axis is also present in the event. We still send kernel events for all axes to ensure the unsupported ones are correctly ignored by the driver. This allows us to parametrize the test with different stylus types and re-use the rest. Here we add a standard Cintiq pen and make sure the wheel axis is never set. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: ignore test devices, or real devices during test suite runsPeter Hutterer2022-05-262-0/+7
| | | | | | | | | | | | 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>
* test: fix a typoPeter Hutterer2022-05-261-1/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: add a test for the artpen rotationPeter Hutterer2022-05-102-3/+14
| | | | | | | | | | | | | | | The artpen has a physical rotation property, sent by the kernel driver as ABS_Z (historical reasons). In the driver this is mapped to the ds->abswheel state because this axis is shared with the airbrush wheel - both are sent through the same XI valuator (historical reasons, as usual). We can rather easily test this by ensuring we have an artpen device id and then send something through ABS_Z, that should update the wheel axis. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Aaron Skomra <aaron.skomra@wacom.com>
* test: ensure a device prox out after our eventsPeter Hutterer2022-05-101-0/+8
| | | | | | | | | This avoids a potential stuck button by leaving the tablet in proximity. Shouldn't happen since removing the device should release all buttons but... Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Aaron Skomra <aaron.skomra@wacom.com>
* test: swap the axis checks for an iterator-based approachPeter Hutterer2022-05-101-4/+6
| | | | | | | | | This ensures we get a StopIteration exception if we don't have the events we expect - previously we'd get a false positive on this test if we had no motion events after the first one. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Aaron Skomra <aaron.skomra@wacom.com>
* test: increase the count of events for axis update testsPeter Hutterer2022-05-101-1/+1
| | | | | | | | Make it 30% of the axis in 2% step increments, this gets past the issue of tilt not updating significantly and getting filtered. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Aaron Skomra <aaron.skomra@wacom.com>
* test: fix the ID assignment when parsing a device filePeter Hutterer2022-05-101-1/+6
| | | | | | | | | | Because InputId didn't have the same field order as the recording (to allow for default bustype, vid and version), we ended up with an erroneous vendor ID, causing some code paths in the driver to go the non-wacom path. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Aaron Skomra <aaron.skomra@wacom.com>
* test: add a helper script to set up the environmentPeter Hutterer2022-05-102-0/+24
| | | | | | | | | | | $ sudo ./test/wacom-test-env.sh $ pytest A lot easier this way than having to manually set the environment variables. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Aaron Skomra <aaron.skomra@wacom.com>
* autotools: Use the same set of CFLAGS as Meson buildsJason Gerecke2022-02-221-2/+2
| | | | | | | | | When building with Meson, a number of CFLAGS are automatically used if supported by the compiler. Lets copy them over so that the same behavior will occur for autotools users. While we're at it, update the other target-specific flags to also better match Meson. Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
* test: add a test for the single-axis updatesPeter Hutterer2022-02-221-0/+57
| | | | | | Just a test that if we change x, only x changes in the events. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: add a test for the relative motion issuePeter Hutterer2022-02-221-0/+74
|
* test: add a pytest test suitePeter Hutterer2022-02-225-0/+540
| | | | | | | | | | | | | | | | | | This test suite makes use of the gwacom library and its GObject bindings, allowing us to write the actual tests in python. Real devices can be specified as a YAML file in test/devices. In the tests we can either create custom device or load the correct Pen/Finger/Pad component from the real device. Devices are then created as uinput devices [1], with a Monitor class set up to capture any events. The test needs to initialize that device and monitor, then play events through the device and analyze the output. [1] This unfortunately won't work in containers, like the github CI... Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: skip the wacom tests if we can't open the .so filePeter Hutterer2022-02-151-1/+2
| | | | | | | | | | | | | Distribution package builds that use -Wl,-z,relro -Wl,-z,now will attempt to resolve all symbols on dlopen(). This is explicitly what we do not want because we don't link in the whole X server. It's a bit hard to override this for a single executable (my attempts didn't go far so there may be some other flag that influences this too) so for now just skip the whole test - this is better than failing the test suite. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: remove a superfluous filePeter Hutterer2022-02-111-48/+0
| | | | | | | Accidentally added during development, renamed later to wacom-tests.c but not removed correctly Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: mark the test section entries as no_sanitize_addressPeter Hutterer2022-02-091-0/+9
| | | | | | | | | | | | | | | | | | | This works around an issue running our test suite through clang with asan. Specifically, the asan test fails with: ERROR: AddressSanitizer: global-buffer-overflow on address #0 0x7f31314a1b57 in wcm_run_tests [...] wacom-test-suite.c:44:3 ... 0x7f31314ff150 is located 48 bytes to the left of global variable '_decl_test_get_wheel_button' defined in '../src/wcmCommon.c:1802:1' (0x7f31314ff180) of size 16 0x7f31314ff150 is located 0 bytes to the right of global variable '_decl_test_get_scroll_delta' defined in '../src/wcmCommon.c:1754:1' (0x7f31314ff140) of size 16 The C standard doesn't guarantee that sections are immediately next to each other, so our expected behavior could break in the future. Since this is a test suite, we don't really care for now. And I rather suspect there's plenty of code out there that too would break if clang ever changed this. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Replace our unit-test suite with something more magic and easierPeter Hutterer2022-02-047-1139/+183
| | | | | | | | | | | | | | | | | | | | | The previous approach, written 11 years ago, relied on providing all symbols the driver needs as stubs (see fake-symbols.c). Most of these symbols just needed to be there so we could compile the test, they didn't actually get utilized by the tests. Dropping this and instead add something roughly similar to Rust: the test function can be in the same file as the source function. The TEST_CASE() macro uses __attribute__((section)) to push the test cases in custom ELF section. This section we can iterate on and call all tests one-by-one. The test runner only needs to dlopen + dlsym the driver module and run the entry point function. The test-suite part of this is minimal: tests can assert on failure and everything stops. Adding things like fnmatch for test case names is possible when/if we ever need it. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Split the various logging functions into several callsPeter Hutterer2021-12-201-0/+6
| | | | | | | | | | | We have driver and device logging, and each as a normal log function, a sigsafe log path and a debug message log path. So 6 functions overall. This doesn't matter for the X driver which routes sigsafe to LogMessageVerbSigSafe but for other frontends it's useful to keep these apart. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Pass the context to two helper functionsPeter Hutterer2021-12-201-3/+4
| | | | | | | In both cases we'll use that context in a follow-up patch to hook into the logging functions. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Abstract the pInfo pointer as a generic frontend void pointerPeter Hutterer2021-12-201-2/+2
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Switch the type handling to an enumPeter Hutterer2021-12-201-10/+6
| | | | | | | | The init code remains largely as-is but as soon as sensible, change this to an enum value and keep it in the device. The X driver layer can convert that into the type_name as required. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Split type name and flag assignmentPeter Hutterer2021-12-201-7/+7
| | | | | | | These are just lumped in for convenience, let's split them and move the type name to the X driver layer. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add an emulation of the X server's option handlingPeter Hutterer2021-12-201-0/+12
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add a copy of xf86ScaleAxis for our usePeter Hutterer2021-12-201-28/+0
| | | | | | | This is a simple helper function, easier to have this locally than rely on the X server API here. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add a custom log handlerPeter Hutterer2021-12-201-0/+12
| | | | | | | | This wraps the X-specific xf86IDrvMsg/LogMessageVerbSigSafe into a wcmLog() function. That then calls the X functions, depending on whether we have context as first argument or not. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Use WacomDevicePtr as primary context argumentPeter Hutterer2021-12-201-16/+14
| | | | | | | | | | | | | This changes all functions (wherever possible) to take a WacomDevicePtr instead of an InputInfoPtr as context argument, with the InputInfoPtr either assigned to priv->pInfo or removed where now superfluous. This should have no functional changes. Remaining functions are those required by the X server to have a certain signature. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* tests: make sure priv->pInfo is initialized correctlyPeter Hutterer2021-11-291-0/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Require xserver 1.13Peter Hutterer2021-11-292-44/+22
| | | | | | | | Released 9 years ago and available in e.g. RHEL6.4 and later, this is plenty old an X server to support. ABI version 18.0 so we can get rid of most of our ifdefs. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Unifdef HAVE_CONFIG_HPeter Hutterer2021-11-291-2/+0
| | | | | | There's no case where this is not defined Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Use strcasecmp instead of xf86NameCmpPeter Hutterer2021-11-231-6/+0
| | | | | | | The latter skips over '_ \t' but none of the options we parse will have any of those characters in it. Let's use strcasecmp() directly. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Replace xf86ReadSerial and xf86WriteSerial with libc callsPeter Hutterer2021-11-221-13/+0
| | | | | | | | That's all the server does anyway for these calls. That and some debugging printf of the data but that would require the server to be build with those debugging flags enabled. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: always build the testsPeter Hutterer2021-11-191-3/+3
| | | | | | | They don't test much but it's still better to always build them so we don't have to chase down compilation errors after the fact. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Use xf86IDrvMsg wherever possiblePeter Hutterer2021-11-191-0/+6
| | | | | | | This function was added in server 1.10, released in Feb 2011. Bump the requirements accordingly. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Require xserver 1.10 as minimum versionPeter Hutterer2021-11-191-47/+4
| | | | | | | | Released in 2011 and available in RHEL6.2 and later, this should be conservative enough. It allows us to drop a bunch of code that requires older ABIs (anything ABI_XINPUT_VERSION < 12). Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: Update test_normalize_pressure to work with maxCurveJason Gerecke2017-06-191-18/+25
| | | | | | | | | | | | | | | Commit d958ab79d2 changes the driver's pressure normalization functions to use a variable "maxCurve" which defines the upper limit of pressure values to be emitted by the driver, rather than using FILTER_PRESSURE_RES directly. The tests were never updated to take this into account and fail due to maxCurve never being set. This patch has the normalize_pressure test set the value of maxCurve. While we're at it, we have the test verify that multiple values of maxCurve work as expected. Fixes: d958ab79d2 (Introduce "Pressure2K" config option for incompatible software) Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
* test: add TimerCancel to fake symbolsPeter Hutterer2017-03-091-0/+4
| | | | | | Fixes distcheck Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* tests: Fix compilation under ABI 25 and greaterJason Gerecke2017-01-201-0/+10
| | | | | | | | | | | | The X server recently deprecated xf86BlockSIGIO and xf86UnblockSIGIO and simultaneously defined them inline within xf86.h. The new inline definition causes problems both because fake-symbols.c will end up redefining them, and because the function bodies reference a symbol that does not get included when building the tests. To fix these errors, update fake-symbols.c with updated include guards and a definition of the undefined symbols. Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
* Replace multitude of "old state" vars with a _WacomDeviceStateJason Gerecke2014-05-091-2/+2
| | | | | | | Reducing clutter. Signed-off-by: Jason Gerecke <killertofu@gmail.com> Reviewed-by: Ping Cheng <pingc@wacom.com>
* Add an option to disable pressure recalibrationEgbert Eich2014-03-191-0/+1
| | | | | | | | | | | | | If the initial pressure of a device is != 0 the driver recalibrates the pressure range. This is to account for worn out devices. The downside is that when the user hits the tablet very hard the initial pressure reading may be unequal to zero even for a perfectly good pen. If the consecutive pressure readings are not higher than the initial pressure by a threshold no button event will be generated. This option allows to disable the recalibration. Signed-off-by: Egbert Eich <eich@suse.com> Reviewed-by: Jason Gerecke <killertofu@gmail.com>
* Attempt to not lose events to pressure recalibrationEgbert Eich2014-03-191-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Worn out devices send a non-zero pressure even when not in contact with the tablet. To compensate for this the driver detects if the pressure sent by the device immediately after indicating proximity is non-zero. It subtracts this value from any pressure value sent later and rescales the pressure range to the full device range. If it later on sees the pressure value fall below this initial value it will readjust it this lower value. The downside of this is that when the pen is pushed onto the tablet really fast the initial pressure reading may be non-zero also the pen isn't worn. This can lead to lost events. This patch tries to address this: If the first pressure reading is != 0 it is recorded. If the recorded maximum value is >0 but a later pressure reading is higher the maximum value is replaced. If no button press event is generated the 'normal' way it is checked of the recorded maximum would trigger one when minPressure decreases. Once a 'normal' button event is generated or an 'alternative' button event is generated and minPressure doesn't decrease any more the recorded maximum is set to 0 which will disable the checks until the next prox in. Signed-off-by: Egbert Eich <eich@suse.com> Reviewed-by: Jason Gerecke <killertofu@gmail.com>
* Fix spurious '-Wshadow' warningEgbert Eich2014-02-191-1/+1
| | | | | | Signed-off-by: Egbert Eich <eich@suse.com> Reviewed-by: Jason Gerecke <killertofu@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
* Fix '-Wuninitialized' warningsEgbert Eich2014-02-191-1/+3
| | | | | | | | | Pinning variables to some value to fix warning about uninitialized variable. Signed-off-by: Egbert Eich <eich@suse.com> Reviewed-by: Jason Gerecke <killertofu@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
* Fix warning about discarding 'const' qualifierEgbert Eich2014-02-191-1/+1
| | | | | Signed-off-by: Egbert Eich <eich@suse.com> Reviewed-by: Jason Gerecke <killertofu@gmail.com>
* Make tested static functions non-static for test suiteEgbert Eich2014-02-191-1/+2
| | | | | | | | | | | | | | This gets rid of the hack which redefines 'static' to make every static function in the driver non-static for the test suite. Instead we use a macro instead of 'static' in the function definition of each function used in the test suite which we can set to empty when compiling the test suite. At the same time we create a declaration for each of those functions which gets us rind of about a bazillion compiler warnings. Signed-off-by: Egbert Eich <eich@suse.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add missing symbol xf86PrintChipsets() for test suiteEgbert Eich2014-02-141-0/+5
| | | | | | Signed-off-by: Egbert Eich <eich@suse.com> Reviewed-by: Jason Gerecke <killertofu@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
* Fix loads of 'redundand declaration' warnings in test suiteEgbert Eich2014-02-142-198/+31
| | | | | | | | | | | | | | | | | | Most symbols in fake-symbols.h were already declared in the Xserver header files from the SDK which are also included. These produce loads of compiler warnings. The few remaining ones can be added by including xf86_OSproc.h and exevents.h. Then then all function declarations for the stub functions can be deleted. Relying on SDK provided headers makes providing stub functions cumbersome due to frequent non-atomic API/ABI changes. To work around this one would have to avoid SDK headers completely, though. Signed-off-by: Egbert Eich <eich@suse.com> Reviewed-by: Jason Gerecke <killertofu@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
* Fix type mismatch in test suiteEgbert Eich2014-02-142-2/+2
| | | | | | | | | | Add CONST which expands to either 'const' or nothing depending on ABI version. This eliminates a compiler error. Signed-off-by: Egbert Eich <eich@suse.com> Reviewed-by: Jason Gerecke <killertofu@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>