Add a device test suite
A rather large commit, copied from a similar (almost identical) suite in
libtouchpad and ported for libinput.
The goal here is to make testing for various devices easy, so the litest
("libinput test") wrappers do that. The idea is that each device has some
features, and tests are likely to exercise some features or won't work with
other features.
Each test case takes a list of required features and a list of excluded
features. The test suite will create a new test case for each device in the
suite that matches that set.
For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would
run on clickpads only, not on touchpads with buttons.
check supports suites and test cases, both named. We wrap that so that each
named set of cases we add are a test suite, with the set of devices being the
test cases. i.e.
litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY);
adds a suite named "foo:bar" and test cases for both devices given, with their
shortnames as test case name, resulting in:
"foo:bar", "trackpoint"
"foo:bar", "clickpad"
...
Multiple test functions can be added to a suite. For tests without a device
requirement there is litest_add_no_device_test(...).
The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow
the set of test cases. The test suite detects when run inside a debugger and
disables fork mode (the default).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 15:02:11 +10:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2013 Red Hat, Inc.
|
|
|
|
|
*
|
2015-06-11 12:09:18 +10:00
|
|
|
* 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:
|
Add a device test suite
A rather large commit, copied from a similar (almost identical) suite in
libtouchpad and ported for libinput.
The goal here is to make testing for various devices easy, so the litest
("libinput test") wrappers do that. The idea is that each device has some
features, and tests are likely to exercise some features or won't work with
other features.
Each test case takes a list of required features and a list of excluded
features. The test suite will create a new test case for each device in the
suite that matches that set.
For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would
run on clickpads only, not on touchpads with buttons.
check supports suites and test cases, both named. We wrap that so that each
named set of cases we add are a test suite, with the set of devices being the
test cases. i.e.
litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY);
adds a suite named "foo:bar" and test cases for both devices given, with their
shortnames as test case name, resulting in:
"foo:bar", "trackpoint"
"foo:bar", "clickpad"
...
Multiple test functions can be added to a suite. For tests without a device
requirement there is litest_add_no_device_test(...).
The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow
the set of test cases. The test suite detects when run inside a debugger and
disables fork mode (the default).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 15:02:11 +10:00
|
|
|
*
|
2015-06-11 12:09:18 +10:00
|
|
|
* 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.
|
Add a device test suite
A rather large commit, copied from a similar (almost identical) suite in
libtouchpad and ported for libinput.
The goal here is to make testing for various devices easy, so the litest
("libinput test") wrappers do that. The idea is that each device has some
features, and tests are likely to exercise some features or won't work with
other features.
Each test case takes a list of required features and a list of excluded
features. The test suite will create a new test case for each device in the
suite that matches that set.
For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would
run on clickpads only, not on touchpads with buttons.
check supports suites and test cases, both named. We wrap that so that each
named set of cases we add are a test suite, with the set of devices being the
test cases. i.e.
litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY);
adds a suite named "foo:bar" and test cases for both devices given, with their
shortnames as test case name, resulting in:
"foo:bar", "trackpoint"
"foo:bar", "clickpad"
...
Multiple test functions can be added to a suite. For tests without a device
requirement there is litest_add_no_device_test(...).
The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow
the set of test cases. The test suite detects when run inside a debugger and
disables fork mode (the default).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 15:02:11 +10:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
2025-07-01 16:30:11 +10:00
|
|
|
|
2019-03-06 13:43:00 +10:00
|
|
|
#include "litest-config.h"
|
Add a device test suite
A rather large commit, copied from a similar (almost identical) suite in
libtouchpad and ported for libinput.
The goal here is to make testing for various devices easy, so the litest
("libinput test") wrappers do that. The idea is that each device has some
features, and tests are likely to exercise some features or won't work with
other features.
Each test case takes a list of required features and a list of excluded
features. The test suite will create a new test case for each device in the
suite that matches that set.
For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would
run on clickpads only, not on touchpads with buttons.
check supports suites and test cases, both named. We wrap that so that each
named set of cases we add are a test suite, with the set of devices being the
test cases. i.e.
litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY);
adds a suite named "foo:bar" and test cases for both devices given, with their
shortnames as test case name, resulting in:
"foo:bar", "trackpoint"
"foo:bar", "clickpad"
...
Multiple test functions can be added to a suite. For tests without a device
requirement there is litest_add_no_device_test(...).
The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow
the set of test cases. The test suite detects when run inside a debugger and
disables fork mode (the default).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 15:02:11 +10:00
|
|
|
|
|
|
|
|
#ifndef LITEST_H
|
|
|
|
|
#define LITEST_H
|
|
|
|
|
|
|
|
|
|
#include <libevdev/libevdev-uinput.h>
|
|
|
|
|
#include <libevdev/libevdev.h>
|
|
|
|
|
#include <libinput.h>
|
2015-05-04 09:13:22 +10:00
|
|
|
#include <math.h>
|
2017-12-01 09:31:07 +10:00
|
|
|
#include <stdarg.h>
|
Add a device test suite
A rather large commit, copied from a similar (almost identical) suite in
libtouchpad and ported for libinput.
The goal here is to make testing for various devices easy, so the litest
("libinput test") wrappers do that. The idea is that each device has some
features, and tests are likely to exercise some features or won't work with
other features.
Each test case takes a list of required features and a list of excluded
features. The test suite will create a new test case for each device in the
suite that matches that set.
For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would
run on clickpads only, not on touchpads with buttons.
check supports suites and test cases, both named. We wrap that so that each
named set of cases we add are a test suite, with the set of devices being the
test cases. i.e.
litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY);
adds a suite named "foo:bar" and test cases for both devices given, with their
shortnames as test case name, resulting in:
"foo:bar", "trackpoint"
"foo:bar", "clickpad"
...
Multiple test functions can be added to a suite. For tests without a device
requirement there is litest_add_no_device_test(...).
The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow
the set of test cases. The test suite detects when run inside a debugger and
disables fork mode (the default).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 15:02:11 +10:00
|
|
|
#include <stdbool.h>
|
2015-05-04 09:13:22 +10:00
|
|
|
|
2021-05-27 19:19:49 +02:00
|
|
|
#include "libinput-private-config.h"
|
2017-03-23 14:54:00 +10:00
|
|
|
#include "libinput-util.h"
|
2024-10-12 10:31:42 +10:00
|
|
|
#include "litest-runner.h"
|
2018-05-24 16:52:42 +10:00
|
|
|
#include "quirks.h"
|
2024-10-12 10:31:42 +10:00
|
|
|
|
|
|
|
|
#define START_TEST(func_) \
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
static enum litest_runner_result func_(const struct litest_runner_test_env *test_env) { \
|
2025-04-07 15:18:55 +10:00
|
|
|
int _i _unused_ = test_env->rangeval;
|
2024-10-12 10:31:42 +10:00
|
|
|
|
|
|
|
|
#define END_TEST \
|
|
|
|
|
return LITEST_PASS; \
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-21 09:25:04 +10:00
|
|
|
struct test_device {
|
|
|
|
|
const char *name;
|
|
|
|
|
struct litest_test_device *device;
|
|
|
|
|
} __attribute__((aligned(16)));
|
|
|
|
|
|
2025-03-12 10:27:08 +10:00
|
|
|
#define TEST_DEVICE(which, ...) \
|
2017-09-21 09:25:04 +10:00
|
|
|
static struct litest_test_device _device; \
|
|
|
|
|
\
|
|
|
|
|
static void _setup(void) { \
|
|
|
|
|
struct litest_device *d = litest_create_device(_device.type); \
|
|
|
|
|
litest_set_current_device(d); \
|
|
|
|
|
} \
|
|
|
|
|
\
|
|
|
|
|
static const struct test_device _test_device \
|
|
|
|
|
__attribute__ ((used)) \
|
2024-10-13 19:20:57 +10:00
|
|
|
__attribute__ ((section ("test_device_section"))) = { \
|
2025-03-12 10:27:08 +10:00
|
|
|
#which, &_device \
|
2017-09-21 09:25:04 +10:00
|
|
|
}; \
|
|
|
|
|
static struct litest_test_device _device = { \
|
|
|
|
|
.setup = _setup, \
|
2025-03-12 10:27:08 +10:00
|
|
|
.shortname = #which, \
|
|
|
|
|
.type = which, \
|
2017-09-21 09:25:04 +10:00
|
|
|
__VA_ARGS__ \
|
|
|
|
|
};
|
|
|
|
|
|
2018-03-21 12:54:10 +10:00
|
|
|
struct test_collection {
|
|
|
|
|
const char *name;
|
|
|
|
|
void (*setup)(void);
|
|
|
|
|
} __attribute__((aligned(16)));
|
|
|
|
|
|
2024-10-17 19:25:39 +10:00
|
|
|
#define TEST_COLLECTION(name_) \
|
|
|
|
|
static void (CONCAT(name_ , __LINE__))(void); \
|
|
|
|
|
static const struct test_collection CONCAT(_test_collection_, __LINE__) \
|
2018-03-21 12:54:10 +10:00
|
|
|
__attribute__ ((used)) \
|
|
|
|
|
__attribute__ ((section ("test_collection_section"))) = { \
|
2024-10-17 19:25:39 +10:00
|
|
|
#name_, CONCAT(name_, __LINE__) \
|
2018-03-21 12:54:10 +10:00
|
|
|
}; \
|
2024-10-17 19:25:39 +10:00
|
|
|
static void (CONCAT(name_, __LINE__))(void)
|
2018-03-21 12:54:10 +10:00
|
|
|
|
2025-03-14 15:53:13 +10:00
|
|
|
#define litest_mark_test_start() \
|
|
|
|
|
litest_checkpoint("==================== BOILERPLATE END. TEST CONTENT STARTING NOW ====================");
|
|
|
|
|
|
2024-09-12 13:40:44 +10:00
|
|
|
__attribute__((format(printf, 3, 0))) void
|
|
|
|
|
_litest_checkpoint(const char *func,
|
|
|
|
|
int line,
|
2025-03-12 10:38:12 +10:00
|
|
|
const char *color,
|
2024-09-12 13:40:44 +10:00
|
|
|
const char *format,
|
|
|
|
|
...);
|
|
|
|
|
#define litest_checkpoint(...) \
|
2025-03-12 10:38:12 +10:00
|
|
|
_litest_checkpoint(__func__, __LINE__, ANSI_GREEN, __VA_ARGS__)
|
2021-02-12 07:55:21 +10:00
|
|
|
|
2025-06-03 11:43:49 +10:00
|
|
|
#define litest_log_group(...) \
|
|
|
|
|
for (bool i_ = ({ \
|
|
|
|
|
litest_checkpoint("🭋🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂 %s:%3d 🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🭀", __func__, __LINE__); \
|
|
|
|
|
litest_checkpoint(" " __VA_ARGS__); true; }); \
|
|
|
|
|
i_; \
|
|
|
|
|
i_ = ({litest_checkpoint("🭦🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭 %s:%3d 🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🭛", __func__, __LINE__); \
|
|
|
|
|
false; }))
|
|
|
|
|
|
2021-02-12 07:55:21 +10:00
|
|
|
/**
|
|
|
|
|
* litest itself needs the user_data to store some test-suite-specific
|
|
|
|
|
* information. Tests must not override this pointer, any data they need
|
|
|
|
|
* they can hang off the private pointer in this struct.
|
|
|
|
|
*/
|
|
|
|
|
struct litest_user_data {
|
|
|
|
|
void *private;
|
|
|
|
|
};
|
|
|
|
|
|
2015-12-21 10:52:08 +10:00
|
|
|
void
|
|
|
|
|
litest_fail_condition(const char *file,
|
|
|
|
|
int line,
|
|
|
|
|
const char *func,
|
|
|
|
|
const char *condition,
|
|
|
|
|
const char *message,
|
|
|
|
|
...);
|
|
|
|
|
void
|
|
|
|
|
litest_fail_comparison_int(const char *file,
|
|
|
|
|
int line,
|
|
|
|
|
const char *func,
|
|
|
|
|
const char *operator,
|
|
|
|
|
int a,
|
|
|
|
|
int b,
|
|
|
|
|
const char *astr,
|
|
|
|
|
const char *bstr);
|
|
|
|
|
void
|
2019-06-12 14:11:00 +10:00
|
|
|
litest_fail_comparison_double(const char *file,
|
|
|
|
|
int line,
|
|
|
|
|
const char *func,
|
|
|
|
|
const char *operator,
|
|
|
|
|
double a,
|
|
|
|
|
double b,
|
|
|
|
|
const char *astr,
|
|
|
|
|
const char *bstr);
|
|
|
|
|
void
|
2015-12-21 10:52:08 +10:00
|
|
|
litest_fail_comparison_ptr(const char *file,
|
|
|
|
|
int line,
|
|
|
|
|
const char *func,
|
|
|
|
|
const char *comparison);
|
|
|
|
|
|
2024-09-16 16:13:44 +10:00
|
|
|
void
|
|
|
|
|
litest_fail_comparison_str(const char *file,
|
|
|
|
|
int line,
|
|
|
|
|
const char *func,
|
|
|
|
|
const char *comparison,
|
|
|
|
|
const char *operator,
|
|
|
|
|
const char * astr,
|
|
|
|
|
const char *bstr);
|
|
|
|
|
|
2015-05-04 09:13:22 +10:00
|
|
|
#define litest_assert(cond) \
|
|
|
|
|
do { \
|
|
|
|
|
if (!(cond)) \
|
|
|
|
|
litest_fail_condition(__FILE__, __LINE__, __func__, \
|
|
|
|
|
#cond, NULL); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_msg(cond, ...) \
|
|
|
|
|
do { \
|
|
|
|
|
if (!(cond)) \
|
|
|
|
|
litest_fail_condition(__FILE__, __LINE__, __func__, \
|
|
|
|
|
#cond, __VA_ARGS__); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
2025-05-07 11:55:51 +10:00
|
|
|
#define litest_assert_not_reached() \
|
|
|
|
|
litest_abort_msg("Triggered unreachable code\n")
|
|
|
|
|
|
2025-03-31 14:10:26 +10:00
|
|
|
#define _litest_abort_msg(file_, line_, func_, ...) do {\
|
|
|
|
|
litest_fail_condition(file_, line_, func_, \
|
2015-05-04 09:13:22 +10:00
|
|
|
"aborting", __VA_ARGS__); \
|
2024-12-22 16:15:12 +10:00
|
|
|
abort(); \
|
2025-03-31 14:10:26 +10:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
#define litest_abort_msg(...) \
|
|
|
|
|
_litest_abort_msg(__FILE__, __LINE__, __func__, __VA_ARGS__)
|
2015-05-04 09:13:22 +10:00
|
|
|
|
|
|
|
|
#define litest_assert_notnull(cond) \
|
|
|
|
|
do { \
|
|
|
|
|
if ((cond) == NULL) \
|
|
|
|
|
litest_fail_condition(__FILE__, __LINE__, __func__, \
|
2024-12-21 10:39:07 +10:00
|
|
|
#cond " != NULL", "\n"); \
|
2015-05-04 09:13:22 +10:00
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_comparison_int_(a_, op_, b_) \
|
|
|
|
|
do { \
|
|
|
|
|
__typeof__(a_) _a = a_; \
|
|
|
|
|
__typeof__(b_) _b = b_; \
|
|
|
|
|
if (trunc(_a) != _a || trunc(_b) != _b) \
|
|
|
|
|
litest_abort_msg("litest_assert_int_* used for non-integer value\n"); \
|
|
|
|
|
if (!((_a) op_ (_b))) \
|
|
|
|
|
litest_fail_comparison_int(__FILE__, __LINE__, __func__,\
|
|
|
|
|
#op_, _a, _b, \
|
|
|
|
|
#a_, #b_); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
2024-03-14 12:07:29 +10:00
|
|
|
#define litest_assert_neg_errno_success(a_) \
|
|
|
|
|
do { \
|
|
|
|
|
__typeof__(a_) _a = a_; \
|
|
|
|
|
if (_a < 0) \
|
|
|
|
|
litest_abort_msg("Unexpected negative errno: %d (%s)", _a, strerror(-_a)); \
|
|
|
|
|
} while(0);
|
|
|
|
|
|
|
|
|
|
#define litest_assert_errno_success(a_) \
|
|
|
|
|
do { \
|
|
|
|
|
__typeof__(a_) _a = a_; \
|
|
|
|
|
__typeof__(a_) _e = errno; \
|
|
|
|
|
if (_a < 0) \
|
|
|
|
|
litest_abort_msg("Unexpected errno: %d (%s)", _e, strerror(_e)); \
|
|
|
|
|
} while(0);
|
|
|
|
|
|
2024-09-16 16:30:40 +10:00
|
|
|
#define litest_assert_comparison_enum_(a_, op_, b_) \
|
|
|
|
|
do { \
|
|
|
|
|
__typeof__(a_) _a = a_; \
|
|
|
|
|
__typeof__(a_) _b = b_; \
|
|
|
|
|
if (!((_a) op_ (_b))) \
|
|
|
|
|
litest_fail_comparison_int(__FILE__, __LINE__, __func__,\
|
|
|
|
|
#op_, (int)_a, (int)_b, \
|
|
|
|
|
#a_, #b_); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_enum_eq(a_, b_) \
|
|
|
|
|
litest_assert_comparison_enum_(a_, ==, b_)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_enum_ne(a_, b_) \
|
|
|
|
|
litest_assert_comparison_enum_(a_, !=, b_)
|
|
|
|
|
|
2015-05-04 09:13:22 +10:00
|
|
|
#define litest_assert_int_eq(a_, b_) \
|
|
|
|
|
litest_assert_comparison_int_(a_, ==, b_)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_int_ne(a_, b_) \
|
|
|
|
|
litest_assert_comparison_int_(a_, !=, b_)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_int_lt(a_, b_) \
|
|
|
|
|
litest_assert_comparison_int_(a_, <, b_)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_int_le(a_, b_) \
|
|
|
|
|
litest_assert_comparison_int_(a_, <=, b_)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_int_ge(a_, b_) \
|
|
|
|
|
litest_assert_comparison_int_(a_, >=, b_)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_int_gt(a_, b_) \
|
|
|
|
|
litest_assert_comparison_int_(a_, >, b_)
|
Add a device test suite
A rather large commit, copied from a similar (almost identical) suite in
libtouchpad and ported for libinput.
The goal here is to make testing for various devices easy, so the litest
("libinput test") wrappers do that. The idea is that each device has some
features, and tests are likely to exercise some features or won't work with
other features.
Each test case takes a list of required features and a list of excluded
features. The test suite will create a new test case for each device in the
suite that matches that set.
For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would
run on clickpads only, not on touchpads with buttons.
check supports suites and test cases, both named. We wrap that so that each
named set of cases we add are a test suite, with the set of devices being the
test cases. i.e.
litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY);
adds a suite named "foo:bar" and test cases for both devices given, with their
shortnames as test case name, resulting in:
"foo:bar", "trackpoint"
"foo:bar", "clickpad"
...
Multiple test functions can be added to a suite. For tests without a device
requirement there is litest_add_no_device_test(...).
The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow
the set of test cases. The test suite detects when run inside a debugger and
disables fork mode (the default).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 15:02:11 +10:00
|
|
|
|
2015-05-08 08:16:39 +10:00
|
|
|
#define litest_assert_comparison_ptr_(a_, op_, b_) \
|
|
|
|
|
do { \
|
|
|
|
|
__typeof__(a_) _a = a_; \
|
|
|
|
|
__typeof__(b_) _b = b_; \
|
|
|
|
|
if (!((_a) op_ (_b))) \
|
|
|
|
|
litest_fail_comparison_ptr(__FILE__, __LINE__, __func__,\
|
|
|
|
|
#a_ " " #op_ " " #b_); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_ptr_eq(a_, b_) \
|
|
|
|
|
litest_assert_comparison_ptr_(a_, ==, b_)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_ptr_ne(a_, b_) \
|
|
|
|
|
litest_assert_comparison_ptr_(a_, !=, b_)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_ptr_null(a_) \
|
|
|
|
|
litest_assert_comparison_ptr_(a_, ==, NULL)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_ptr_notnull(a_) \
|
|
|
|
|
litest_assert_comparison_ptr_(a_, !=, NULL)
|
Add a device test suite
A rather large commit, copied from a similar (almost identical) suite in
libtouchpad and ported for libinput.
The goal here is to make testing for various devices easy, so the litest
("libinput test") wrappers do that. The idea is that each device has some
features, and tests are likely to exercise some features or won't work with
other features.
Each test case takes a list of required features and a list of excluded
features. The test suite will create a new test case for each device in the
suite that matches that set.
For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would
run on clickpads only, not on touchpads with buttons.
check supports suites and test cases, both named. We wrap that so that each
named set of cases we add are a test suite, with the set of devices being the
test cases. i.e.
litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY);
adds a suite named "foo:bar" and test cases for both devices given, with their
shortnames as test case name, resulting in:
"foo:bar", "trackpoint"
"foo:bar", "clickpad"
...
Multiple test functions can be added to a suite. For tests without a device
requirement there is litest_add_no_device_test(...).
The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow
the set of test cases. The test suite detects when run inside a debugger and
disables fork mode (the default).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 15:02:11 +10:00
|
|
|
|
2024-09-16 16:13:44 +10:00
|
|
|
#define litest_assert_str_eq(a_, b_) \
|
|
|
|
|
do { \
|
|
|
|
|
const char *_a = a_; \
|
|
|
|
|
const char *_b = b_; \
|
|
|
|
|
if (!streq(_a, _b)) \
|
|
|
|
|
litest_fail_comparison_str(__FILE__, __LINE__, __func__,\
|
|
|
|
|
#a_ " == " #b_, \
|
|
|
|
|
"==", \
|
|
|
|
|
_a, _b); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_str_ne(a_, b_) \
|
|
|
|
|
do { \
|
|
|
|
|
const char *_a = a_; \
|
|
|
|
|
const char *_b = b_; \
|
|
|
|
|
if (streq(_a, _b)) \
|
|
|
|
|
litest_fail_comparison_str(__FILE__, __LINE__, __func__,\
|
|
|
|
|
#a_ " != " #b_, \
|
|
|
|
|
"!=", \
|
|
|
|
|
_a, _b); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
2025-05-07 15:55:23 +10:00
|
|
|
#define litest_assert_str_in(needle_, haystack_) \
|
|
|
|
|
do { \
|
|
|
|
|
const char *_needle = needle_; \
|
|
|
|
|
const char *_haystack = haystack_; \
|
|
|
|
|
if (!strstr(_haystack, _needle)) \
|
|
|
|
|
litest_fail_comparison_str(__FILE__, __LINE__, __func__,\
|
|
|
|
|
"'" #needle_ "' in: '" #haystack_ "'", \
|
|
|
|
|
"in", \
|
|
|
|
|
_needle, _haystack); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
2025-07-21 10:04:23 +10:00
|
|
|
#define litest_assert_str_not_in(needle_, haystack_) \
|
2025-05-07 15:55:23 +10:00
|
|
|
do { \
|
|
|
|
|
const char *_needle = needle_; \
|
|
|
|
|
const char *_haystack = haystack_; \
|
2025-07-21 10:04:23 +10:00
|
|
|
if (strstr(_haystack, _needle)) \
|
2025-05-07 15:55:23 +10:00
|
|
|
litest_fail_comparison_str(__FILE__, __LINE__, __func__,\
|
|
|
|
|
"'" #needle_ "' not in: '" #haystack_ "'", \
|
|
|
|
|
"not in", \
|
|
|
|
|
_needle, _haystack); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
2024-09-16 16:05:11 +10:00
|
|
|
#define LITEST_DEFAULT_EPSILON 0.001
|
|
|
|
|
|
|
|
|
|
#define litest_assert_double_eq_epsilon(a_, b_, epsilon_)\
|
|
|
|
|
do { \
|
|
|
|
|
__typeof__(a_) _a = a_; \
|
|
|
|
|
__typeof__(b_) _b = b_; \
|
|
|
|
|
if (!(fabs((_a) - (_b)) < epsilon_)) \
|
|
|
|
|
litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
|
|
|
|
|
"==", _a, _b, \
|
|
|
|
|
#a_, #b_); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_double_ne_epsilon(a_, b_, epsilon_)\
|
|
|
|
|
do { \
|
|
|
|
|
__typeof__(a_) _a = a_; \
|
|
|
|
|
__typeof__(b_) _b = b_; \
|
|
|
|
|
if (!(fabs((_a) - (_b)) > epsilon_)) \
|
|
|
|
|
litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
|
|
|
|
|
"!=", _a, _b, \
|
|
|
|
|
#a_, #b_); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_double_gt_epsilon(a_, b_, epsilon_)\
|
2024-09-16 16:08:02 +10:00
|
|
|
do { \
|
|
|
|
|
__typeof__(a_) _a = a_; \
|
|
|
|
|
__typeof__(b_) _b = b_; \
|
2024-09-16 16:05:11 +10:00
|
|
|
if (!(_a - (epsilon_) > _b)) \
|
2024-09-16 16:08:02 +10:00
|
|
|
litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
|
2024-09-16 16:05:11 +10:00
|
|
|
">", _a, _b, \
|
2024-09-16 16:08:02 +10:00
|
|
|
#a_, #b_); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
2024-09-16 16:05:11 +10:00
|
|
|
#define litest_assert_double_ge_epsilon(a_, b_, epsilon_)\
|
|
|
|
|
do { \
|
|
|
|
|
__typeof__(a_) _a = a_; \
|
|
|
|
|
__typeof__(b_) _b = b_; \
|
|
|
|
|
if (!(_a > _b || fabs((_a) - (_b)) < epsilon_)) \
|
|
|
|
|
litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
|
|
|
|
|
">=", _a, _b, \
|
|
|
|
|
#a_, #b_); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_double_lt_epsilon(a_, b_, epsilon_)\
|
|
|
|
|
do { \
|
|
|
|
|
__typeof__(a_) _a = a_; \
|
|
|
|
|
__typeof__(b_) _b = b_; \
|
|
|
|
|
if (!(_a < _b - (epsilon_))) \
|
|
|
|
|
litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
|
|
|
|
|
"<", _a, _b, \
|
|
|
|
|
#a_, #b_); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_double_le_epsilon(a_, b_, epsilon_)\
|
|
|
|
|
do { \
|
|
|
|
|
__typeof__(a_) _a = a_; \
|
|
|
|
|
__typeof__(b_) _b = b_; \
|
|
|
|
|
if (!(_a < _b || fabs((_a) - (_b)) < epsilon_)) \
|
|
|
|
|
litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
|
|
|
|
|
"<=", _a, _b, \
|
|
|
|
|
#a_, #b_); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#define litest_assert_comparison_double_(a_, op_, b_) \
|
|
|
|
|
litest_assert_comparison_double_epsilon_(a_, op_, b_, LITEST_DEFAULT_EPSILON)
|
|
|
|
|
|
2015-12-21 10:52:08 +10:00
|
|
|
#define litest_assert_double_eq(a_, b_)\
|
2024-09-16 16:05:11 +10:00
|
|
|
litest_assert_double_eq_epsilon((a_), (b_), LITEST_DEFAULT_EPSILON)
|
2015-12-21 10:52:08 +10:00
|
|
|
|
|
|
|
|
#define litest_assert_double_ne(a_, b_)\
|
2024-09-16 16:05:11 +10:00
|
|
|
litest_assert_double_ne_epsilon((a_), (b_),LITEST_DEFAULT_EPSILON)
|
2015-12-21 10:52:08 +10:00
|
|
|
|
|
|
|
|
#define litest_assert_double_lt(a_, b_)\
|
2024-09-16 16:05:11 +10:00
|
|
|
litest_assert_double_lt_epsilon((a_), (b_),LITEST_DEFAULT_EPSILON)
|
2015-12-21 10:52:08 +10:00
|
|
|
|
|
|
|
|
#define litest_assert_double_le(a_, b_)\
|
2024-09-16 16:05:11 +10:00
|
|
|
litest_assert_double_le_epsilon((a_), (b_),LITEST_DEFAULT_EPSILON)
|
2015-12-21 10:52:08 +10:00
|
|
|
|
|
|
|
|
#define litest_assert_double_gt(a_, b_)\
|
2024-09-16 16:05:11 +10:00
|
|
|
litest_assert_double_gt_epsilon((a_), (b_),LITEST_DEFAULT_EPSILON)
|
2015-12-21 10:52:08 +10:00
|
|
|
|
|
|
|
|
#define litest_assert_double_ge(a_, b_)\
|
2024-09-16 16:05:11 +10:00
|
|
|
litest_assert_double_ge_epsilon((a_), (b_),LITEST_DEFAULT_EPSILON)
|
2015-12-21 10:52:08 +10:00
|
|
|
|
2025-06-12 12:37:08 +10:00
|
|
|
void
|
|
|
|
|
_litest_assert_strv_substring(char **strv,
|
|
|
|
|
char *substring,
|
|
|
|
|
const char *file,
|
|
|
|
|
const char *func,
|
|
|
|
|
int line);
|
|
|
|
|
|
|
|
|
|
#define litest_assert_strv_substring(strv_, substring_) \
|
|
|
|
|
_litest_assert_strv_substring(strv_, substring_, __FILE__, __func__, __LINE__)
|
|
|
|
|
|
2025-03-14 09:51:01 +10:00
|
|
|
void
|
|
|
|
|
litest_backtrace(const char *func);
|
2024-10-12 10:35:29 +10:00
|
|
|
|
Add a device test suite
A rather large commit, copied from a similar (almost identical) suite in
libtouchpad and ported for libinput.
The goal here is to make testing for various devices easy, so the litest
("libinput test") wrappers do that. The idea is that each device has some
features, and tests are likely to exercise some features or won't work with
other features.
Each test case takes a list of required features and a list of excluded
features. The test suite will create a new test case for each device in the
suite that matches that set.
For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would
run on clickpads only, not on touchpads with buttons.
check supports suites and test cases, both named. We wrap that so that each
named set of cases we add are a test suite, with the set of devices being the
test cases. i.e.
litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY);
adds a suite named "foo:bar" and test cases for both devices given, with their
shortnames as test case name, resulting in:
"foo:bar", "trackpoint"
"foo:bar", "clickpad"
...
Multiple test functions can be added to a suite. For tests without a device
requirement there is litest_add_no_device_test(...).
The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow
the set of test cases. The test suite detects when run inside a debugger and
disables fork mode (the default).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 15:02:11 +10:00
|
|
|
enum litest_device_type {
|
|
|
|
|
LITEST_NO_DEVICE = -1,
|
2023-09-28 09:36:02 +10:00
|
|
|
/* Touchpads and associated devices */
|
|
|
|
|
LITEST_ACER_HAWAII_TOUCHPAD = -1000,
|
|
|
|
|
LITEST_AIPTEK,
|
|
|
|
|
LITEST_ALPS_3FG,
|
|
|
|
|
LITEST_ALPS_DUALPOINT,
|
2016-04-18 13:45:47 +10:00
|
|
|
LITEST_ALPS_SEMI_MT,
|
2023-09-28 09:36:02 +10:00
|
|
|
LITEST_APPLETOUCH,
|
|
|
|
|
LITEST_ATMEL_HOVER,
|
|
|
|
|
LITEST_BCM5974,
|
|
|
|
|
LITEST_ELANTECH_TOUCHPAD,
|
|
|
|
|
LITEST_GENERIC_PRESSUREPAD,
|
|
|
|
|
LITEST_MAGIC_TRACKPAD,
|
|
|
|
|
LITEST_SYNAPTICS_CLICKPAD_X220,
|
2016-04-18 13:45:47 +10:00
|
|
|
LITEST_SYNAPTICS_HOVER_SEMI_MT,
|
2023-09-28 09:36:02 +10:00
|
|
|
LITEST_SYNAPTICS_I2C,
|
|
|
|
|
LITEST_SYNAPTICS_PHANTOMCLICKS,
|
|
|
|
|
LITEST_SYNAPTICS_PRESSUREPAD,
|
|
|
|
|
LITEST_SYNAPTICS_RMI4,
|
|
|
|
|
LITEST_SYNAPTICS_TOPBUTTONPAD,
|
|
|
|
|
LITEST_SYNAPTICS_TOUCHPAD,
|
2023-09-27 09:41:21 +10:00
|
|
|
LITEST_TOUCHPAD_PALMPRESSURE_ZERO,
|
2025-03-12 09:34:47 +10:00
|
|
|
LITEST_WACOM_INTUOS5_FINGER,
|
2023-09-28 09:36:02 +10:00
|
|
|
|
|
|
|
|
/* Touchscreens */
|
|
|
|
|
LITEST_CALIBRATED_TOUCHSCREEN,
|
2016-04-18 13:45:47 +10:00
|
|
|
LITEST_GENERIC_MULTITOUCH_SCREEN,
|
2023-09-28 09:36:02 +10:00
|
|
|
LITEST_GENERIC_SINGLETOUCH,
|
|
|
|
|
LITEST_MS_SURFACE_COVER,
|
|
|
|
|
LITEST_MULTITOUCH_FUZZ_SCREEN,
|
2016-04-18 13:45:47 +10:00
|
|
|
LITEST_NEXUS4_TOUCH_SCREEN,
|
2023-09-28 09:36:02 +10:00
|
|
|
LITEST_PROTOCOL_A_SCREEN,
|
|
|
|
|
LITEST_TOUCHSCREEN_INVALID_RANGE,
|
|
|
|
|
LITEST_TOUCHSCREEN_MT_TOOL_TYPE,
|
2025-03-12 09:34:47 +10:00
|
|
|
LITEST_WACOM_ISDV4_E6_FINGER,
|
2023-09-28 09:36:02 +10:00
|
|
|
|
|
|
|
|
/* Pointing devices and keyboards */
|
|
|
|
|
LITEST_MOUSE,
|
2025-07-16 11:48:09 +10:00
|
|
|
LITEST_MOUSE_PS2,
|
2023-09-28 09:36:02 +10:00
|
|
|
LITEST_KEYBOARD,
|
|
|
|
|
LITEST_TRACKPOINT,
|
|
|
|
|
LITEST_ABSINFO_OVERRIDE,
|
|
|
|
|
LITEST_ACER_HAWAII_KEYBOARD,
|
2016-04-18 13:45:47 +10:00
|
|
|
LITEST_ANKER_MOUSE_KBD,
|
2023-09-28 09:36:02 +10:00
|
|
|
LITEST_APPLE_KEYBOARD,
|
2016-04-18 13:45:47 +10:00
|
|
|
LITEST_CYBORG_RAT,
|
2023-09-28 09:36:02 +10:00
|
|
|
LITEST_HP_WMI_HOTKEYS,
|
|
|
|
|
LITEST_IGNORED_MOUSE,
|
2016-05-10 12:22:40 +10:00
|
|
|
LITEST_KEYBOARD_ALL_CODES,
|
2023-09-28 09:36:02 +10:00
|
|
|
LITEST_KEYBOARD_BLACKWIDOW,
|
|
|
|
|
LITEST_KEYBOARD_BLADE_STEALTH,
|
|
|
|
|
LITEST_KEYBOARD_BLADE_STEALTH_VIDEOSWITCH,
|
|
|
|
|
LITEST_KEYBOARD_LOGITECH_MEDIA_KEYBOARD_ELITE,
|
|
|
|
|
LITEST_KEYBOARD_QUIRKED,
|
|
|
|
|
LITEST_LENOVO_SCROLLPOINT,
|
|
|
|
|
LITEST_LOGITECH_TRACKBALL,
|
2016-06-15 19:36:56 +10:00
|
|
|
LITEST_MAGICMOUSE,
|
2023-09-28 09:36:02 +10:00
|
|
|
LITEST_MOUSE_FORMAT_STRING,
|
|
|
|
|
LITEST_MOUSE_GLADIUS,
|
|
|
|
|
LITEST_MOUSE_LOW_DPI,
|
|
|
|
|
LITEST_MOUSE_ROCCAT,
|
2025-06-08 01:29:33 -04:00
|
|
|
LITEST_MOUSE_VIRTUAL,
|
2023-09-28 09:36:02 +10:00
|
|
|
LITEST_MOUSE_WHEEL_CLICK_ANGLE,
|
2016-10-28 15:08:32 +10:00
|
|
|
LITEST_MOUSE_WHEEL_CLICK_COUNT,
|
2016-11-28 11:08:01 +10:00
|
|
|
LITEST_MOUSE_WHEEL_TILT,
|
2025-07-21 14:00:14 +10:00
|
|
|
LITEST_MOUSE_WHEEL_HIRES_DISABLED,
|
2023-09-28 09:36:02 +10:00
|
|
|
LITEST_MS_NANO_TRANSCEIVER_MOUSE,
|
|
|
|
|
LITEST_SONY_VAIO_KEYS,
|
|
|
|
|
LITEST_SYNAPTICS_TRACKPOINT_BUTTONS,
|
|
|
|
|
LITEST_THINKPAD_EXTRABUTTONS,
|
|
|
|
|
LITEST_VMWARE_VIRTMOUSE,
|
|
|
|
|
LITEST_WHEEL_ONLY,
|
|
|
|
|
LITEST_XEN_VIRTUAL_POINTER,
|
|
|
|
|
|
|
|
|
|
/* Switches */
|
2017-01-20 16:54:16 +11:00
|
|
|
LITEST_LID_SWITCH,
|
2017-01-30 12:58:37 +10:00
|
|
|
LITEST_LID_SWITCH_SURFACE3,
|
2023-09-28 09:36:02 +10:00
|
|
|
LITEST_TABLET_MODE_UNRELIABLE,
|
|
|
|
|
|
|
|
|
|
/* Special devices */
|
|
|
|
|
LITEST_DELL_CANVAS_TOTEM,
|
|
|
|
|
LITEST_DELL_CANVAS_TOTEM_TOUCH,
|
2017-07-25 09:38:46 +10:00
|
|
|
LITEST_GPIO_KEYS,
|
2023-09-28 09:36:02 +10:00
|
|
|
LITEST_YUBIKEY,
|
|
|
|
|
|
|
|
|
|
/* Tablets */
|
|
|
|
|
LITEST_ELAN_TABLET,
|
|
|
|
|
LITEST_HUION_TABLET,
|
2024-01-30 14:43:59 +10:00
|
|
|
LITEST_HUION_Q620M_DIAL,
|
2025-07-09 11:07:21 +10:00
|
|
|
LITEST_PLOOPY_PAVONIS_STYLUS,
|
2025-07-09 11:06:53 +10:00
|
|
|
LITEST_QEMU_TABLET,
|
2024-01-30 14:43:59 +10:00
|
|
|
LITEST_TABLET_DOUBLEDIAL_PAD,
|
|
|
|
|
LITEST_TABLET_REL_DIAL_PAD,
|
2017-09-11 10:32:42 +10:00
|
|
|
LITEST_UCLOGIC_TABLET,
|
2025-03-12 09:34:47 +10:00
|
|
|
LITEST_WACOM_BAMBOO_16FG_PEN,
|
2023-09-28 09:36:02 +10:00
|
|
|
LITEST_WACOM_BAMBOO_2FG_FINGER,
|
2017-10-20 10:39:37 +10:00
|
|
|
LITEST_WACOM_BAMBOO_2FG_PAD,
|
|
|
|
|
LITEST_WACOM_BAMBOO_2FG_PEN,
|
2025-03-12 09:34:47 +10:00
|
|
|
LITEST_WACOM_CALIBRATED_TABLET_PEN,
|
|
|
|
|
LITEST_WACOM_CINTIQ_12WX_PEN,
|
2023-09-28 09:36:02 +10:00
|
|
|
LITEST_WACOM_CINTIQ_13HDT_FINGER,
|
|
|
|
|
LITEST_WACOM_CINTIQ_13HDT_PAD,
|
|
|
|
|
LITEST_WACOM_CINTIQ_13HDT_PEN,
|
|
|
|
|
LITEST_WACOM_CINTIQ_24HDT_PAD,
|
2025-07-09 11:06:53 +10:00
|
|
|
LITEST_WACOM_CINTIQ_24HD_PEN,
|
2023-09-28 09:36:02 +10:00
|
|
|
LITEST_WACOM_CINTIQ_PRO16_FINGER,
|
|
|
|
|
LITEST_WACOM_CINTIQ_PRO16_PAD,
|
|
|
|
|
LITEST_WACOM_CINTIQ_PRO16_PEN,
|
|
|
|
|
LITEST_WACOM_EKR,
|
|
|
|
|
LITEST_WACOM_HID4800_PEN,
|
|
|
|
|
LITEST_WACOM_INTUOS3_PAD,
|
|
|
|
|
LITEST_WACOM_INTUOS5_PAD,
|
2025-03-12 09:34:47 +10:00
|
|
|
LITEST_WACOM_INTUOS5_PEN,
|
2019-06-17 13:25:59 +10:00
|
|
|
LITEST_WACOM_ISDV4_4200_PEN,
|
2021-11-17 14:29:35 +10:00
|
|
|
LITEST_WACOM_ISDV4_524C_PEN,
|
2025-07-09 11:06:53 +10:00
|
|
|
LITEST_WACOM_ISDV4_E6_PEN,
|
2023-09-28 09:36:02 +10:00
|
|
|
LITEST_WACOM_MOBILESTUDIO_PRO_16_PAD,
|
|
|
|
|
LITEST_WALTOP,
|
Add a device test suite
A rather large commit, copied from a similar (almost identical) suite in
libtouchpad and ported for libinput.
The goal here is to make testing for various devices easy, so the litest
("libinput test") wrappers do that. The idea is that each device has some
features, and tests are likely to exercise some features or won't work with
other features.
Each test case takes a list of required features and a list of excluded
features. The test suite will create a new test case for each device in the
suite that matches that set.
For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would
run on clickpads only, not on touchpads with buttons.
check supports suites and test cases, both named. We wrap that so that each
named set of cases we add are a test suite, with the set of devices being the
test cases. i.e.
litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY);
adds a suite named "foo:bar" and test cases for both devices given, with their
shortnames as test case name, resulting in:
"foo:bar", "trackpoint"
"foo:bar", "clickpad"
...
Multiple test functions can be added to a suite. For tests without a device
requirement there is litest_add_no_device_test(...).
The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow
the set of test cases. The test suite detects when run inside a debugger and
disables fork mode (the default).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 15:02:11 +10:00
|
|
|
};
|
|
|
|
|
|
2019-07-01 16:12:26 +10:00
|
|
|
#define LITEST_DEVICELESS -2
|
|
|
|
|
#define LITEST_DISABLE_DEVICE -1
|
|
|
|
|
#define LITEST_ANY 0
|
|
|
|
|
#define LITEST_TOUCHPAD bit(0)
|
|
|
|
|
#define LITEST_CLICKPAD bit(1)
|
|
|
|
|
#define LITEST_BUTTON bit(2)
|
|
|
|
|
#define LITEST_KEYS bit(3)
|
|
|
|
|
#define LITEST_RELATIVE bit(4)
|
|
|
|
|
#define LITEST_WHEEL bit(5)
|
|
|
|
|
#define LITEST_TOUCH bit(6)
|
|
|
|
|
#define LITEST_SINGLE_TOUCH bit(7)
|
|
|
|
|
#define LITEST_APPLE_CLICKPAD bit(8)
|
|
|
|
|
#define LITEST_TOPBUTTONPAD bit(9)
|
|
|
|
|
#define LITEST_SEMI_MT bit(10)
|
|
|
|
|
#define LITEST_POINTINGSTICK bit(11)
|
|
|
|
|
#define LITEST_FAKE_MT bit(12)
|
|
|
|
|
#define LITEST_ABSOLUTE bit(13)
|
|
|
|
|
#define LITEST_PROTOCOL_A bit(14)
|
|
|
|
|
#define LITEST_HOVER bit(15)
|
|
|
|
|
#define LITEST_ELLIPSE bit(16)
|
|
|
|
|
#define LITEST_TABLET bit(17)
|
|
|
|
|
#define LITEST_DISTANCE bit(18)
|
|
|
|
|
#define LITEST_TOOL_SERIAL bit(19)
|
|
|
|
|
#define LITEST_TILT bit(20)
|
|
|
|
|
#define LITEST_TABLET_PAD bit(21)
|
|
|
|
|
#define LITEST_RING bit(22)
|
|
|
|
|
#define LITEST_STRIP bit(23)
|
|
|
|
|
#define LITEST_TRACKBALL bit(24)
|
|
|
|
|
#define LITEST_LEDS bit(25)
|
|
|
|
|
#define LITEST_SWITCH bit(26)
|
|
|
|
|
#define LITEST_IGNORED bit(27)
|
|
|
|
|
#define LITEST_NO_DEBOUNCE bit(28)
|
|
|
|
|
#define LITEST_TOOL_MOUSE bit(29)
|
|
|
|
|
#define LITEST_DIRECT bit(30)
|
|
|
|
|
#define LITEST_TOTEM bit(31)
|
2020-02-06 18:51:09 +10:00
|
|
|
#define LITEST_FORCED_PROXOUT bit(32)
|
2023-05-11 14:47:20 +10:00
|
|
|
#define LITEST_PRECALIBRATED bit(33)
|
2024-01-30 14:43:59 +10:00
|
|
|
#define LITEST_DIAL bit(34)
|
2019-02-06 15:35:08 +10:00
|
|
|
|
2017-01-19 15:58:13 +10:00
|
|
|
/* this is a semi-mt device, so we keep track of the touches that the tests
|
|
|
|
|
* send and modify them so that the first touch is always slot 0 and sends
|
|
|
|
|
* the top-left of the bounding box, the second is always slot 1 and sends
|
|
|
|
|
* the bottom-right of the bounding box.
|
|
|
|
|
* Lifting any of two fingers terminates slot 1
|
|
|
|
|
*/
|
|
|
|
|
struct litest_semi_mt {
|
|
|
|
|
bool is_semi_mt;
|
|
|
|
|
|
|
|
|
|
int tracking_id;
|
|
|
|
|
/* The actual touches requested by the test for the two slots
|
|
|
|
|
* in the 0..100 range used by litest */
|
|
|
|
|
struct {
|
|
|
|
|
double x, y;
|
|
|
|
|
} touches[2];
|
|
|
|
|
};
|
|
|
|
|
|
Add a device test suite
A rather large commit, copied from a similar (almost identical) suite in
libtouchpad and ported for libinput.
The goal here is to make testing for various devices easy, so the litest
("libinput test") wrappers do that. The idea is that each device has some
features, and tests are likely to exercise some features or won't work with
other features.
Each test case takes a list of required features and a list of excluded
features. The test suite will create a new test case for each device in the
suite that matches that set.
For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would
run on clickpads only, not on touchpads with buttons.
check supports suites and test cases, both named. We wrap that so that each
named set of cases we add are a test suite, with the set of devices being the
test cases. i.e.
litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY);
adds a suite named "foo:bar" and test cases for both devices given, with their
shortnames as test case name, resulting in:
"foo:bar", "trackpoint"
"foo:bar", "clickpad"
...
Multiple test functions can be added to a suite. For tests without a device
requirement there is litest_add_no_device_test(...).
The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow
the set of test cases. The test suite detects when run inside a debugger and
disables fork mode (the default).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 15:02:11 +10:00
|
|
|
struct litest_device {
|
2019-01-04 14:44:38 +10:00
|
|
|
enum litest_device_type which;
|
Add a device test suite
A rather large commit, copied from a similar (almost identical) suite in
libtouchpad and ported for libinput.
The goal here is to make testing for various devices easy, so the litest
("libinput test") wrappers do that. The idea is that each device has some
features, and tests are likely to exercise some features or won't work with
other features.
Each test case takes a list of required features and a list of excluded
features. The test suite will create a new test case for each device in the
suite that matches that set.
For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would
run on clickpads only, not on touchpads with buttons.
check supports suites and test cases, both named. We wrap that so that each
named set of cases we add are a test suite, with the set of devices being the
test cases. i.e.
litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY);
adds a suite named "foo:bar" and test cases for both devices given, with their
shortnames as test case name, resulting in:
"foo:bar", "trackpoint"
"foo:bar", "clickpad"
...
Multiple test functions can be added to a suite. For tests without a device
requirement there is litest_add_no_device_test(...).
The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow
the set of test cases. The test suite detects when run inside a debugger and
disables fork mode (the default).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 15:02:11 +10:00
|
|
|
struct libevdev *evdev;
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
struct libinput *libinput;
|
2018-05-24 16:52:42 +10:00
|
|
|
struct quirks *quirks;
|
2014-02-22 15:06:34 +01:00
|
|
|
bool owns_context;
|
2014-01-29 15:38:48 +10:00
|
|
|
struct libinput_device *libinput_device;
|
Add a device test suite
A rather large commit, copied from a similar (almost identical) suite in
libtouchpad and ported for libinput.
The goal here is to make testing for various devices easy, so the litest
("libinput test") wrappers do that. The idea is that each device has some
features, and tests are likely to exercise some features or won't work with
other features.
Each test case takes a list of required features and a list of excluded
features. The test suite will create a new test case for each device in the
suite that matches that set.
For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would
run on clickpads only, not on touchpads with buttons.
check supports suites and test cases, both named. We wrap that so that each
named set of cases we add are a test suite, with the set of devices being the
test cases. i.e.
litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY);
adds a suite named "foo:bar" and test cases for both devices given, with their
shortnames as test case name, resulting in:
"foo:bar", "trackpoint"
"foo:bar", "clickpad"
...
Multiple test functions can be added to a suite. For tests without a device
requirement there is litest_add_no_device_test(...).
The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow
the set of test cases. The test suite detects when run inside a debugger and
disables fork mode (the default).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 15:02:11 +10:00
|
|
|
struct litest_device_interface *interface;
|
2014-07-21 12:30:40 +10:00
|
|
|
|
2025-04-09 17:50:42 +10:00
|
|
|
struct {
|
|
|
|
|
struct input_event events[64];
|
|
|
|
|
size_t nevents;
|
|
|
|
|
} frame;
|
|
|
|
|
|
2014-07-21 12:30:40 +10:00
|
|
|
int ntouches_down;
|
2017-01-19 17:20:19 +10:00
|
|
|
int skip_ev_syn;
|
2017-01-19 15:58:13 +10:00
|
|
|
struct litest_semi_mt semi_mt; /** only used for semi-mt device */
|
2014-09-17 10:07:38 +10:00
|
|
|
|
2014-07-24 13:18:56 +10:00
|
|
|
void *private; /* device-specific data */
|
Add a device test suite
A rather large commit, copied from a similar (almost identical) suite in
libtouchpad and ported for libinput.
The goal here is to make testing for various devices easy, so the litest
("libinput test") wrappers do that. The idea is that each device has some
features, and tests are likely to exercise some features or won't work with
other features.
Each test case takes a list of required features and a list of excluded
features. The test suite will create a new test case for each device in the
suite that matches that set.
For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would
run on clickpads only, not on touchpads with buttons.
check supports suites and test cases, both named. We wrap that so that each
named set of cases we add are a test suite, with the set of devices being the
test cases. i.e.
litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY);
adds a suite named "foo:bar" and test cases for both devices given, with their
shortnames as test case name, resulting in:
"foo:bar", "trackpoint"
"foo:bar", "clickpad"
...
Multiple test functions can be added to a suite. For tests without a device
requirement there is litest_add_no_device_test(...).
The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow
the set of test cases. The test suite detects when run inside a debugger and
disables fork mode (the default).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 15:02:11 +10:00
|
|
|
};
|
|
|
|
|
|
2014-04-21 19:11:27 +02:00
|
|
|
struct axis_replacement {
|
|
|
|
|
int32_t evcode;
|
2015-12-10 16:05:37 +10:00
|
|
|
double value;
|
2014-04-21 19:11:27 +02:00
|
|
|
};
|
2014-02-22 15:06:34 +01:00
|
|
|
|
2017-03-29 12:31:12 +10:00
|
|
|
/**
|
|
|
|
|
* Same as litest_axis_set_value but allows for ranges outside 0..100%
|
|
|
|
|
*/
|
2016-02-05 10:15:35 +10:00
|
|
|
static inline void
|
2017-03-29 12:31:12 +10:00
|
|
|
litest_axis_set_value_unchecked(struct axis_replacement *axes, int code, double value)
|
2015-12-21 10:53:29 +10:00
|
|
|
{
|
|
|
|
|
while (axes->evcode != -1) {
|
|
|
|
|
if (axes->evcode == code) {
|
|
|
|
|
axes->value = value;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
axes++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_abort_msg("Missing axis code %d\n", code);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-29 12:31:12 +10:00
|
|
|
/**
|
|
|
|
|
* Takes a value in percent and sets the given axis to that code.
|
|
|
|
|
*/
|
|
|
|
|
static inline void
|
|
|
|
|
litest_axis_set_value(struct axis_replacement *axes, int code, double value)
|
|
|
|
|
{
|
|
|
|
|
litest_assert_double_ge(value, 0.0);
|
|
|
|
|
litest_assert_double_le(value, 100.0);
|
|
|
|
|
|
|
|
|
|
litest_axis_set_value_unchecked(axes, code, value);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-22 15:06:34 +01:00
|
|
|
struct libinput *
|
|
|
|
|
litest_create_context(void);
|
2020-07-03 10:47:13 +10:00
|
|
|
void
|
|
|
|
|
litest_destroy_context(struct libinput *li);
|
2025-04-07 13:15:28 +10:00
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(struct libinput *, litest_destroy_context);
|
|
|
|
|
|
|
|
|
|
#define _litest_context_destroy_ _cleanup_(litest_destroy_contextp)
|
|
|
|
|
|
2025-05-08 11:34:28 +10:00
|
|
|
void
|
|
|
|
|
litest_context_set_user_data(struct libinput *li, void *data);
|
|
|
|
|
void *
|
|
|
|
|
litest_context_get_user_data(struct libinput *li);
|
|
|
|
|
|
2015-03-13 09:32:37 +10:00
|
|
|
void
|
|
|
|
|
litest_disable_log_handler(struct libinput *libinput);
|
|
|
|
|
void
|
|
|
|
|
litest_restore_log_handler(struct libinput *libinput);
|
2017-01-13 11:44:28 +10:00
|
|
|
void
|
|
|
|
|
litest_set_log_handler_bug(struct libinput *libinput);
|
2014-02-22 15:06:34 +01:00
|
|
|
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
struct litest_parameters;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new set of parameters for a test case.
|
|
|
|
|
*
|
|
|
|
|
* This function takes a variable set of arguments in the format
|
|
|
|
|
* [name, type, count, arg1, arg2, arg3, ..], for example:
|
|
|
|
|
*
|
|
|
|
|
* litest_parameter_new("axis", 'u', 2, ABS_X, ABS_Y,
|
|
|
|
|
* "direction", 's', 4, "north", "south", "east", "west",
|
|
|
|
|
* NULL);
|
|
|
|
|
*
|
|
|
|
|
* Parsing stops at the first null name argument.
|
|
|
|
|
*/
|
|
|
|
|
struct litest_parameters *
|
|
|
|
|
_litest_parameters_new(const char *name, ...);
|
|
|
|
|
|
|
|
|
|
/* Helper to ensure it's always null-terminated */
|
|
|
|
|
#define litest_parameters_new(name_, ...) \
|
|
|
|
|
_litest_parameters_new(name_, __VA_ARGS__, NULL)
|
|
|
|
|
|
2025-02-11 14:44:48 +10:00
|
|
|
#define litest_with_parameters(params_, ...) \
|
|
|
|
|
for (struct litest_parameters *params_ = litest_parameters_new(__VA_ARGS__); \
|
|
|
|
|
params_; \
|
|
|
|
|
params_ = litest_parameters_unref(params_))
|
|
|
|
|
|
2025-02-13 22:10:02 +01:00
|
|
|
#define _LITEST_NAMED_I32(v_, n_, ...) (struct litest_named_i32){ .value = v_, .name = n_ }
|
|
|
|
|
/* Helper to default second argument to stringification of first argument.
|
|
|
|
|
* This allows for two uses of this macro:
|
|
|
|
|
* - litest_named_i32(0) expands to { 0, "0" }
|
|
|
|
|
* - litest_named_i32(0, "zero") expands to (effectively) { 0, "zero" }
|
|
|
|
|
*/
|
|
|
|
|
#define litest_named_i32(...) _LITEST_NAMED_I32(__VA_ARGS__, #__VA_ARGS__)
|
|
|
|
|
|
|
|
|
|
struct litest_named_i32 {
|
|
|
|
|
int32_t value;
|
|
|
|
|
const char *name;
|
|
|
|
|
};
|
|
|
|
|
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
struct litest_parameters_permutation_value {
|
|
|
|
|
struct list link;
|
|
|
|
|
char name[128];
|
|
|
|
|
const struct multivalue value;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Argument for the callback function to litest_parameters_permutations().
|
|
|
|
|
* This is simple wrapper around a linked list that contains all elements
|
|
|
|
|
* of the current permutation.
|
|
|
|
|
*/
|
|
|
|
|
struct litest_parameters_permutation {
|
|
|
|
|
struct list values; /* struct litest_parameters_permutation_value */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Callback function invoked for each permutation of a struct litest_parameters.
|
|
|
|
|
*/
|
|
|
|
|
typedef int (*litest_parameters_permutation_func_t)(
|
|
|
|
|
struct litest_parameters_permutation *permutation,
|
|
|
|
|
void *userdata);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Permutates the given parameters and calls func for every possible
|
|
|
|
|
* permutation. If func returns a nonzero status, permutation stops
|
|
|
|
|
* and that nonzero status is returned to the caller.
|
|
|
|
|
*
|
|
|
|
|
* Userdata is passed through as-is.
|
|
|
|
|
*/
|
|
|
|
|
int
|
|
|
|
|
litest_parameters_permutations(struct litest_parameters *params,
|
|
|
|
|
litest_parameters_permutation_func_t func,
|
|
|
|
|
void *userdata);
|
|
|
|
|
|
|
|
|
|
struct litest_parameters *
|
|
|
|
|
litest_parameters_ref(struct litest_parameters *p);
|
|
|
|
|
|
|
|
|
|
struct litest_parameters *
|
|
|
|
|
litest_parameters_unref(struct litest_parameters *params);
|
|
|
|
|
|
2021-02-05 14:51:02 +10:00
|
|
|
#define litest_add(func_, ...) \
|
|
|
|
|
_litest_add(__FILE__, #func_, func_, __VA_ARGS__)
|
|
|
|
|
#define litest_add_ranged(func_, ...) \
|
|
|
|
|
_litest_add_ranged(__FILE__, #func_, func_, __VA_ARGS__)
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
#define litest_add_parametrized(func_, ...) \
|
|
|
|
|
_litest_add_parametrized(__FILE__, #func_, func_, __VA_ARGS__)
|
2021-02-05 14:51:02 +10:00
|
|
|
#define litest_add_for_device(func_, ...) \
|
|
|
|
|
_litest_add_for_device(__FILE__, #func_, func_, __VA_ARGS__)
|
|
|
|
|
#define litest_add_ranged_for_device(func_, ...) \
|
|
|
|
|
_litest_add_ranged_for_device(__FILE__, #func_, func_, __VA_ARGS__)
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
#define litest_add_parametrized_for_device(func_, ...) \
|
|
|
|
|
_litest_add_parametrized_for_device(__FILE__, #func_, func_, __VA_ARGS__)
|
2021-02-05 14:51:02 +10:00
|
|
|
#define litest_add_no_device(func_) \
|
|
|
|
|
_litest_add_no_device(__FILE__, #func_, func_)
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
#define litest_add_parametrized_no_device(func_, ...) \
|
|
|
|
|
_litest_add_parametrized_no_device(__FILE__, #func_, func_, __VA_ARGS__)
|
2021-02-05 14:51:02 +10:00
|
|
|
#define litest_add_ranged_no_device(func_, ...) \
|
|
|
|
|
_litest_add_ranged_no_device(__FILE__, #func_, func_, __VA_ARGS__)
|
|
|
|
|
#define litest_add_deviceless(func_) \
|
|
|
|
|
_litest_add_deviceless(__FILE__, #func_, func_)
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
#define litest_add_parametrized_deviceless(func_, params) \
|
|
|
|
|
_litest_add_parametrize_deviceless(__FILE__, #func_, func_, params)
|
2018-06-21 17:05:30 +10:00
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
|
|
|
|
_litest_add(const char *name,
|
|
|
|
|
const char *funcname,
|
2020-01-03 18:06:54 -08:00
|
|
|
const void *func,
|
2019-07-01 16:12:26 +10:00
|
|
|
int64_t required_feature,
|
|
|
|
|
int64_t excluded_feature);
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
|
|
|
|
_litest_add_ranged(const char *name,
|
|
|
|
|
const char *funcname,
|
2020-01-03 18:06:54 -08:00
|
|
|
const void *func,
|
2019-07-01 16:12:26 +10:00
|
|
|
int64_t required,
|
|
|
|
|
int64_t excluded,
|
2016-02-05 10:15:35 +10:00
|
|
|
const struct range *range);
|
|
|
|
|
void
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
_litest_add_parametrized(const char *name,
|
|
|
|
|
const char *funcname,
|
|
|
|
|
const void *func,
|
|
|
|
|
int64_t required,
|
|
|
|
|
int64_t excluded,
|
|
|
|
|
struct litest_parameters *params);
|
|
|
|
|
void
|
2016-02-05 10:15:35 +10:00
|
|
|
_litest_add_for_device(const char *name,
|
|
|
|
|
const char *funcname,
|
2020-01-03 18:06:54 -08:00
|
|
|
const void *func,
|
2016-02-05 10:15:35 +10:00
|
|
|
enum litest_device_type type);
|
|
|
|
|
void
|
|
|
|
|
_litest_add_ranged_for_device(const char *name,
|
|
|
|
|
const char *funcname,
|
2020-01-03 18:06:54 -08:00
|
|
|
const void *func,
|
2016-02-05 10:15:35 +10:00
|
|
|
enum litest_device_type type,
|
|
|
|
|
const struct range *range);
|
|
|
|
|
void
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
_litest_add_parametrized_for_device(const char *name,
|
|
|
|
|
const char *funcname,
|
|
|
|
|
const void *func,
|
|
|
|
|
enum litest_device_type type,
|
|
|
|
|
struct litest_parameters *params);
|
|
|
|
|
void
|
2016-02-05 10:15:35 +10:00
|
|
|
_litest_add_no_device(const char *name, const char *funcname, const void *func);
|
|
|
|
|
void
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
_litest_add_parametrized_no_device(const char *name,
|
|
|
|
|
const char *funcname,
|
|
|
|
|
const void *func,
|
|
|
|
|
struct litest_parameters *params);
|
|
|
|
|
void
|
2016-02-05 10:15:35 +10:00
|
|
|
_litest_add_ranged_no_device(const char *name,
|
|
|
|
|
const char *funcname,
|
2020-01-03 18:06:54 -08:00
|
|
|
const void *func,
|
2016-02-05 10:15:35 +10:00
|
|
|
const struct range *range);
|
2018-06-21 17:05:30 +10:00
|
|
|
void
|
|
|
|
|
_litest_add_deviceless(const char *name, const char *funcname, const void *func);
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
void
|
|
|
|
|
_litest_add_parametrized_deviceless(const char *name,
|
|
|
|
|
const char *funcname,
|
|
|
|
|
const void *func,
|
|
|
|
|
struct litest_parameters *params);
|
2016-02-05 10:15:35 +10:00
|
|
|
|
|
|
|
|
struct litest_device *
|
|
|
|
|
litest_create_device(enum litest_device_type which);
|
|
|
|
|
|
|
|
|
|
struct litest_device *
|
|
|
|
|
litest_add_device(struct libinput *libinput, enum litest_device_type which);
|
2014-03-31 10:00:16 +10:00
|
|
|
struct libevdev_uinput *
|
|
|
|
|
litest_create_uinput_device_from_description(const char *name,
|
|
|
|
|
const struct input_id *id,
|
|
|
|
|
const struct input_absinfo *abs,
|
|
|
|
|
const int *events);
|
test: allow partial overriding the test devices
For specific tests we need something that e.g. looks like a touchpad, but has
a different name, a different number of slots, etc. In this case, the
following code will do exactly that:
struct input_absinfo overrides[] = {
{ .value = ABS_MT_SLOT, .minimum = 0, .maximum = 100 },
{ .value = -1 },
};
litest_create_device_with_overrides(LITEST_SYNAPTICS_CLICKPAD,
NULL, NULL, &overrides, NULL);
For general event codes, overrides can only add to the set of events, they
can't remove.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-03-31 14:54:46 +10:00
|
|
|
struct litest_device *
|
2017-08-17 02:07:18 +02:00
|
|
|
litest_create(enum litest_device_type which,
|
|
|
|
|
const char *name_override,
|
|
|
|
|
struct input_id *id_override,
|
|
|
|
|
const struct input_absinfo *abs_override,
|
|
|
|
|
const int *events_override);
|
|
|
|
|
|
|
|
|
|
struct litest_device *
|
test: allow partial overriding the test devices
For specific tests we need something that e.g. looks like a touchpad, but has
a different name, a different number of slots, etc. In this case, the
following code will do exactly that:
struct input_absinfo overrides[] = {
{ .value = ABS_MT_SLOT, .minimum = 0, .maximum = 100 },
{ .value = -1 },
};
litest_create_device_with_overrides(LITEST_SYNAPTICS_CLICKPAD,
NULL, NULL, &overrides, NULL);
For general event codes, overrides can only add to the set of events, they
can't remove.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-03-31 14:54:46 +10:00
|
|
|
litest_create_device_with_overrides(enum litest_device_type which,
|
|
|
|
|
const char *name_override,
|
|
|
|
|
struct input_id *id_override,
|
|
|
|
|
const struct input_absinfo *abs_override,
|
|
|
|
|
const int *events_override);
|
2014-02-22 15:06:34 +01:00
|
|
|
struct litest_device *
|
|
|
|
|
litest_add_device_with_overrides(struct libinput *libinput,
|
|
|
|
|
enum litest_device_type which,
|
|
|
|
|
const char *name_override,
|
|
|
|
|
struct input_id *id_override,
|
|
|
|
|
const struct input_absinfo *abs_override,
|
|
|
|
|
const int *events_override);
|
|
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
struct litest_device *
|
|
|
|
|
litest_current_device(void);
|
|
|
|
|
|
2020-07-03 12:46:38 +10:00
|
|
|
void
|
|
|
|
|
litest_grab_device(struct litest_device *d);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_ungrab_device(struct litest_device *d);
|
|
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
2025-04-07 15:12:51 +10:00
|
|
|
litest_device_destroy(struct litest_device *d);
|
2016-02-05 10:15:35 +10:00
|
|
|
|
2025-04-07 15:31:46 +10:00
|
|
|
DEFINE_DESTROY_CLEANUP_FUNC(litest_device);
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
const char *
|
|
|
|
|
litest_event_type_str(enum libinput_event_type type);
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
_litest_dispatch(struct libinput *li, const char *func, int line);
|
|
|
|
|
|
|
|
|
|
#define litest_dispatch(li_) \
|
|
|
|
|
_litest_dispatch(li_, __func__, __LINE__)
|
|
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
|
|
|
|
litest_event(struct litest_device *t, unsigned int type, unsigned int code, int value);
|
2025-07-29 12:34:38 +10:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_event_unchecked(struct litest_device *d,
|
|
|
|
|
unsigned int type,
|
|
|
|
|
unsigned int code,
|
|
|
|
|
int value);
|
|
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
int
|
|
|
|
|
litest_auto_assign_value(struct litest_device *d,
|
|
|
|
|
const struct input_event *ev,
|
|
|
|
|
int slot,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
struct axis_replacement *axes,
|
|
|
|
|
bool touching);
|
|
|
|
|
void
|
|
|
|
|
litest_touch_up(struct litest_device *d, unsigned int slot);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_touch_move(struct litest_device *d, unsigned int slot, double x, double y);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_touch_move_extended(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
struct axis_replacement *axes);
|
|
|
|
|
|
2018-09-28 11:47:32 +10:00
|
|
|
void
|
|
|
|
|
litest_touch_sequence(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x1,
|
|
|
|
|
double y1,
|
|
|
|
|
double x2,
|
|
|
|
|
double y2,
|
|
|
|
|
int steps);
|
|
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
|
|
|
|
litest_touch_down(struct litest_device *d, unsigned int slot, double x, double y);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_touch_down_extended(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
struct axis_replacement *axes);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_touch_move_to(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x_from,
|
|
|
|
|
double y_from,
|
|
|
|
|
double x_to,
|
|
|
|
|
double y_to,
|
test: drop the sleep_ms argument
This forces events for every ~10ms now. If we want a slower movement, we need
more steps - just like a real touchpad does it.
Cocinelle spatch files were variants of:
@@
expression A, B, C, D, E, F, G, H, I, J, K;
@@
- litest_touch_move_two_touches(A, B, C, D, E, F, G, H, I)
+ litest_touch_move_two_touches(A, B, C, D, E, F, G, H)
The only test that needed a real fix was touchpad_no_palm_detect_2fg_scroll,
it used 12ms before, now it's using 10ms so on the bcm5974 touchpad the second
finger was a speed-thumb. Increasing the events and thus slowing down the
pointer means it's a normal finger and the test succeeds again.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 09:16:52 +10:00
|
|
|
int steps);
|
2016-02-05 10:15:35 +10:00
|
|
|
|
2017-01-11 14:48:11 +10:00
|
|
|
void
|
|
|
|
|
litest_touch_move_to_extended(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x_from,
|
|
|
|
|
double y_from,
|
|
|
|
|
double x_to,
|
|
|
|
|
double y_to,
|
|
|
|
|
struct axis_replacement *axes,
|
test: drop the sleep_ms argument
This forces events for every ~10ms now. If we want a slower movement, we need
more steps - just like a real touchpad does it.
Cocinelle spatch files were variants of:
@@
expression A, B, C, D, E, F, G, H, I, J, K;
@@
- litest_touch_move_two_touches(A, B, C, D, E, F, G, H, I)
+ litest_touch_move_two_touches(A, B, C, D, E, F, G, H)
The only test that needed a real fix was touchpad_no_palm_detect_2fg_scroll,
it used 12ms before, now it's using 10ms so on the bcm5974 touchpad the second
finger was a speed-thumb. Increasing the events and thus slowing down the
pointer means it's a normal finger and the test succeeds again.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 09:16:52 +10:00
|
|
|
int steps);
|
2017-01-11 14:48:11 +10:00
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
|
|
|
|
litest_touch_move_two_touches(struct litest_device *d,
|
|
|
|
|
double x0,
|
|
|
|
|
double y0,
|
|
|
|
|
double x1,
|
|
|
|
|
double y1,
|
|
|
|
|
double dx,
|
|
|
|
|
double dy,
|
test: drop the sleep_ms argument
This forces events for every ~10ms now. If we want a slower movement, we need
more steps - just like a real touchpad does it.
Cocinelle spatch files were variants of:
@@
expression A, B, C, D, E, F, G, H, I, J, K;
@@
- litest_touch_move_two_touches(A, B, C, D, E, F, G, H, I)
+ litest_touch_move_two_touches(A, B, C, D, E, F, G, H)
The only test that needed a real fix was touchpad_no_palm_detect_2fg_scroll,
it used 12ms before, now it's using 10ms so on the bcm5974 touchpad the second
finger was a speed-thumb. Increasing the events and thus slowing down the
pointer means it's a normal finger and the test succeeds again.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 09:16:52 +10:00
|
|
|
int steps);
|
2016-02-05 10:15:35 +10:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_touch_move_three_touches(struct litest_device *d,
|
|
|
|
|
double x0,
|
|
|
|
|
double y0,
|
|
|
|
|
double x1,
|
|
|
|
|
double y1,
|
|
|
|
|
double x2,
|
|
|
|
|
double y2,
|
|
|
|
|
double dx,
|
|
|
|
|
double dy,
|
test: drop the sleep_ms argument
This forces events for every ~10ms now. If we want a slower movement, we need
more steps - just like a real touchpad does it.
Cocinelle spatch files were variants of:
@@
expression A, B, C, D, E, F, G, H, I, J, K;
@@
- litest_touch_move_two_touches(A, B, C, D, E, F, G, H, I)
+ litest_touch_move_two_touches(A, B, C, D, E, F, G, H)
The only test that needed a real fix was touchpad_no_palm_detect_2fg_scroll,
it used 12ms before, now it's using 10ms so on the bcm5974 touchpad the second
finger was a speed-thumb. Increasing the events and thus slowing down the
pointer means it's a normal finger and the test succeeds again.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 09:16:52 +10:00
|
|
|
int steps);
|
2016-02-05 10:15:35 +10:00
|
|
|
|
2020-09-11 08:43:58 +10:00
|
|
|
void
|
|
|
|
|
litest_tablet_set_tool_type(struct litest_device *d, unsigned int code);
|
|
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
|
|
|
|
litest_tablet_proximity_in(struct litest_device *d,
|
2023-05-11 13:45:25 +10:00
|
|
|
double x,
|
|
|
|
|
double y,
|
2016-02-05 10:15:35 +10:00
|
|
|
struct axis_replacement *axes);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_tablet_proximity_out(struct litest_device *d);
|
|
|
|
|
|
2021-11-17 14:46:07 +10:00
|
|
|
void
|
|
|
|
|
litest_tablet_tip_down(struct litest_device *d,
|
2023-05-11 13:45:25 +10:00
|
|
|
double x,
|
|
|
|
|
double y,
|
2021-11-17 14:46:07 +10:00
|
|
|
struct axis_replacement *axes);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_tablet_tip_up(struct litest_device *d,
|
2023-05-11 13:45:25 +10:00
|
|
|
double x,
|
|
|
|
|
double y,
|
2021-11-17 14:46:07 +10:00
|
|
|
struct axis_replacement *axes);
|
|
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
|
|
|
|
litest_tablet_motion(struct litest_device *d,
|
2023-05-11 13:45:25 +10:00
|
|
|
double x,
|
|
|
|
|
double y,
|
2016-02-05 10:15:35 +10:00
|
|
|
struct axis_replacement *axes);
|
|
|
|
|
|
2016-02-05 10:57:37 +10:00
|
|
|
void
|
|
|
|
|
litest_pad_ring_start(struct litest_device *d, double value);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_pad_ring_change(struct litest_device *d, double value);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_pad_ring_end(struct litest_device *d);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_pad_strip_start(struct litest_device *d, double value);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_pad_strip_change(struct litest_device *d, double value);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_pad_strip_end(struct litest_device *d);
|
|
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
|
|
|
|
litest_hover_start(struct litest_device *d, unsigned int slot, double x, double y);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_hover_end(struct litest_device *d, unsigned int slot);
|
|
|
|
|
|
2015-05-06 19:41:25 -04:00
|
|
|
void
|
|
|
|
|
litest_hover_move(struct litest_device *d, unsigned int slot, double x, double y);
|
2016-02-05 10:15:35 +10:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_hover_move_to(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x_from,
|
|
|
|
|
double y_from,
|
|
|
|
|
double x_to,
|
|
|
|
|
double y_to,
|
test: drop the sleep_ms argument
This forces events for every ~10ms now. If we want a slower movement, we need
more steps - just like a real touchpad does it.
Cocinelle spatch files were variants of:
@@
expression A, B, C, D, E, F, G, H, I, J, K;
@@
- litest_touch_move_two_touches(A, B, C, D, E, F, G, H, I)
+ litest_touch_move_two_touches(A, B, C, D, E, F, G, H)
The only test that needed a real fix was touchpad_no_palm_detect_2fg_scroll,
it used 12ms before, now it's using 10ms so on the bcm5974 touchpad the second
finger was a speed-thumb. Increasing the events and thus slowing down the
pointer means it's a normal finger and the test succeeds again.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 09:16:52 +10:00
|
|
|
int steps);
|
2016-02-05 10:15:35 +10:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_hover_move_two_touches(struct litest_device *d,
|
|
|
|
|
double x0,
|
|
|
|
|
double y0,
|
|
|
|
|
double x1,
|
|
|
|
|
double y1,
|
|
|
|
|
double dx,
|
|
|
|
|
double dy,
|
test: drop the sleep_ms argument
This forces events for every ~10ms now. If we want a slower movement, we need
more steps - just like a real touchpad does it.
Cocinelle spatch files were variants of:
@@
expression A, B, C, D, E, F, G, H, I, J, K;
@@
- litest_touch_move_two_touches(A, B, C, D, E, F, G, H, I)
+ litest_touch_move_two_touches(A, B, C, D, E, F, G, H)
The only test that needed a real fix was touchpad_no_palm_detect_2fg_scroll,
it used 12ms before, now it's using 10ms so on the bcm5974 touchpad the second
finger was a speed-thumb. Increasing the events and thus slowing down the
pointer means it's a normal finger and the test succeeds again.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 09:16:52 +10:00
|
|
|
int steps);
|
2016-02-05 10:15:35 +10:00
|
|
|
|
|
|
|
|
void
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(struct litest_device *d,
|
|
|
|
|
struct libinput *li,
|
|
|
|
|
unsigned int button,
|
|
|
|
|
bool is_press);
|
2016-02-05 10:15:35 +10:00
|
|
|
|
2017-11-20 10:49:08 +10:00
|
|
|
void
|
|
|
|
|
litest_button_click(struct litest_device *d, unsigned int button, bool is_press);
|
|
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
|
|
|
|
litest_button_scroll(struct litest_device *d,
|
|
|
|
|
unsigned int button,
|
|
|
|
|
double dx,
|
|
|
|
|
double dy);
|
2019-03-20 10:56:51 +10:00
|
|
|
void
|
|
|
|
|
litest_button_scroll_locked(struct litest_device *d,
|
|
|
|
|
unsigned int button,
|
|
|
|
|
double dx,
|
|
|
|
|
double dy);
|
2016-02-05 10:15:35 +10:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_keyboard_key(struct litest_device *d, unsigned int key, bool is_press);
|
|
|
|
|
|
2017-04-21 16:33:02 +10:00
|
|
|
void
|
|
|
|
|
litest_switch_action(struct litest_device *d,
|
|
|
|
|
enum libinput_switch sw,
|
|
|
|
|
enum libinput_switch_state state);
|
2017-01-20 16:54:16 +11:00
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
|
|
|
|
litest_wait_for_event(struct libinput *li);
|
|
|
|
|
|
|
|
|
|
void
|
2025-03-14 10:12:24 +10:00
|
|
|
_litest_wait_for_event_of_type(struct libinput *li, const char *func, int lineno, ...);
|
2024-09-11 16:23:08 +10:00
|
|
|
|
|
|
|
|
#define litest_wait_for_event_of_type(li_, ...) \
|
2025-03-14 10:12:24 +10:00
|
|
|
_litest_wait_for_event_of_type(li_, __func__, __LINE__, __VA_ARGS__, -1)
|
2016-02-05 10:15:35 +10:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_drain_events(struct libinput *li);
|
|
|
|
|
|
2019-02-12 11:59:09 +10:00
|
|
|
void
|
2024-09-11 16:19:33 +10:00
|
|
|
_litest_drain_events_of_type(struct libinput *li, ...);
|
|
|
|
|
|
|
|
|
|
#define litest_drain_events_of_type(li_, ...) \
|
|
|
|
|
_litest_drain_events_of_type(li_, __VA_ARGS__, -1)
|
2019-02-12 11:59:09 +10:00
|
|
|
|
2025-03-14 10:12:24 +10:00
|
|
|
#define litest_assert_event_type(e_, want_) \
|
|
|
|
|
_litest_assert_event_type(e_, want_, __func__, __LINE__)
|
2016-08-23 08:11:11 +10:00
|
|
|
void
|
2025-03-14 10:12:24 +10:00
|
|
|
_litest_assert_event_type(struct libinput_event *event,
|
|
|
|
|
enum libinput_event_type want,
|
|
|
|
|
const char *func,
|
|
|
|
|
int lineno);
|
2016-08-23 08:11:11 +10:00
|
|
|
|
2025-03-14 10:12:24 +10:00
|
|
|
#define litest_assert_event_type_is_one_of(ev_, ...) \
|
|
|
|
|
_litest_assert_event_type_is_one_of(ev_, __func__, __LINE__, __VA_ARGS__, -1)
|
|
|
|
|
void
|
|
|
|
|
_litest_assert_event_type_is_one_of(struct libinput_event *event,
|
|
|
|
|
const char *func,
|
|
|
|
|
int lineno,
|
|
|
|
|
...);
|
|
|
|
|
|
|
|
|
|
#define litest_assert_event_type_not_one_of(ev_, ...) \
|
|
|
|
|
_litest_assert_event_type_not_one_of(ev_, __func__, __LINE__, __VA_ARGS__, -1)
|
2024-10-14 18:58:24 +10:00
|
|
|
|
|
|
|
|
void
|
2025-03-14 10:12:24 +10:00
|
|
|
_litest_assert_event_type_not_one_of(struct libinput_event *event,
|
|
|
|
|
const char *func,
|
|
|
|
|
int lineno,
|
|
|
|
|
...);
|
2024-10-14 18:58:24 +10:00
|
|
|
|
2024-09-12 13:40:44 +10:00
|
|
|
#define litest_assert_empty_queue(li_) \
|
|
|
|
|
_litest_assert_empty_queue(li_, __func__, __LINE__)
|
|
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
2024-09-12 13:40:44 +10:00
|
|
|
_litest_assert_empty_queue(struct libinput *li, const char *func, int line);
|
2016-02-05 10:15:35 +10:00
|
|
|
|
2016-09-02 14:19:45 +10:00
|
|
|
void
|
|
|
|
|
litest_assert_touch_sequence(struct libinput *li);
|
|
|
|
|
|
2018-07-13 16:04:35 +10:00
|
|
|
void
|
|
|
|
|
litest_assert_touch_motion_frame(struct libinput *li);
|
|
|
|
|
void
|
|
|
|
|
litest_assert_touch_down_frame(struct libinput *li);
|
|
|
|
|
void
|
|
|
|
|
litest_assert_touch_up_frame(struct libinput *li);
|
|
|
|
|
void
|
|
|
|
|
litest_assert_touch_cancel(struct libinput *li);
|
|
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
struct libinput_event_pointer *
|
|
|
|
|
litest_is_button_event(struct libinput_event *event,
|
2015-05-04 09:30:51 +10:00
|
|
|
unsigned int button,
|
2015-04-16 10:42:16 +10:00
|
|
|
enum libinput_button_state state);
|
2016-02-05 10:15:35 +10:00
|
|
|
|
|
|
|
|
struct libinput_event_pointer *
|
|
|
|
|
litest_is_axis_event(struct libinput_event *event,
|
2018-11-22 10:24:54 +10:00
|
|
|
enum libinput_event_type axis_type,
|
2016-02-05 10:15:35 +10:00
|
|
|
enum libinput_pointer_axis axis,
|
|
|
|
|
enum libinput_pointer_axis_source source);
|
|
|
|
|
|
2018-11-22 10:24:54 +10:00
|
|
|
bool
|
|
|
|
|
litest_is_high_res_axis_event(struct libinput_event *event);
|
|
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
struct libinput_event_pointer *
|
|
|
|
|
litest_is_motion_event(struct libinput_event *event);
|
|
|
|
|
|
|
|
|
|
struct libinput_event_touch *
|
|
|
|
|
litest_is_touch_event(struct libinput_event *event, enum libinput_event_type type);
|
|
|
|
|
|
|
|
|
|
struct libinput_event_keyboard *
|
|
|
|
|
litest_is_keyboard_event(struct libinput_event *event,
|
|
|
|
|
unsigned int key,
|
|
|
|
|
enum libinput_key_state state);
|
|
|
|
|
|
|
|
|
|
struct libinput_event_gesture *
|
|
|
|
|
litest_is_gesture_event(struct libinput_event *event,
|
|
|
|
|
enum libinput_event_type type,
|
|
|
|
|
int nfingers);
|
|
|
|
|
|
|
|
|
|
struct libinput_event_tablet_tool *
|
|
|
|
|
litest_is_tablet_event(struct libinput_event *event, enum libinput_event_type type);
|
2015-07-07 11:52:05 +10:00
|
|
|
|
2016-02-05 10:57:37 +10:00
|
|
|
struct libinput_event_tablet_pad *
|
|
|
|
|
litest_is_pad_button_event(struct libinput_event *event,
|
|
|
|
|
unsigned int button,
|
|
|
|
|
enum libinput_button_state state);
|
|
|
|
|
struct libinput_event_tablet_pad *
|
2024-01-30 14:43:59 +10:00
|
|
|
litest_is_pad_dial_event(struct libinput_event *event, unsigned int number);
|
|
|
|
|
struct libinput_event_tablet_pad *
|
2016-02-05 10:57:37 +10:00
|
|
|
litest_is_pad_ring_event(struct libinput_event *event,
|
|
|
|
|
unsigned int number,
|
|
|
|
|
enum libinput_tablet_pad_ring_axis_source source);
|
|
|
|
|
struct libinput_event_tablet_pad *
|
|
|
|
|
litest_is_pad_strip_event(struct libinput_event *event,
|
|
|
|
|
unsigned int number,
|
|
|
|
|
enum libinput_tablet_pad_strip_axis_source source);
|
2019-01-17 11:08:27 +10:00
|
|
|
struct libinput_event_tablet_pad *
|
|
|
|
|
litest_is_pad_key_event(struct libinput_event *event,
|
|
|
|
|
unsigned int key,
|
|
|
|
|
enum libinput_key_state state);
|
2016-02-05 10:57:37 +10:00
|
|
|
|
2017-01-20 16:54:16 +11:00
|
|
|
struct libinput_event_switch *
|
|
|
|
|
litest_is_switch_event(struct libinput_event *event,
|
|
|
|
|
enum libinput_switch sw,
|
|
|
|
|
enum libinput_switch_state state);
|
|
|
|
|
|
2020-01-31 12:23:53 +10:00
|
|
|
struct libinput_event_tablet_tool *
|
|
|
|
|
litest_is_proximity_event(struct libinput_event *event,
|
|
|
|
|
enum libinput_tablet_tool_proximity_state state);
|
|
|
|
|
|
2018-11-22 10:24:54 +10:00
|
|
|
double
|
|
|
|
|
litest_event_pointer_get_value(struct libinput_event_pointer *ptrev,
|
|
|
|
|
enum libinput_pointer_axis axis);
|
|
|
|
|
|
|
|
|
|
enum libinput_pointer_axis_source
|
|
|
|
|
litest_event_pointer_get_axis_source(struct libinput_event_pointer *event);
|
|
|
|
|
|
2025-03-14 10:12:24 +10:00
|
|
|
#define litest_assert_key_event(li_, key_, state_) \
|
|
|
|
|
_litest_assert_key_event(li_, key_, state_, __func__, __LINE__)
|
|
|
|
|
|
2017-09-19 15:51:09 +10:00
|
|
|
void
|
2025-03-14 10:12:24 +10:00
|
|
|
_litest_assert_key_event(struct libinput *li,
|
|
|
|
|
unsigned int key,
|
|
|
|
|
enum libinput_key_state state,
|
|
|
|
|
const char *func,
|
|
|
|
|
int lineno);
|
2017-09-19 15:51:09 +10:00
|
|
|
|
2024-09-12 13:40:44 +10:00
|
|
|
#define litest_assert_button_event(li_, button_, state_) \
|
|
|
|
|
_litest_assert_button_event(li_, button_, state_, __func__, __LINE__)
|
|
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
2024-09-12 13:40:44 +10:00
|
|
|
_litest_assert_button_event(struct libinput *li,
|
|
|
|
|
unsigned int button,
|
|
|
|
|
enum libinput_button_state state,
|
|
|
|
|
const char *func,
|
|
|
|
|
int line);
|
2016-02-05 10:15:35 +10:00
|
|
|
|
2025-03-14 10:12:24 +10:00
|
|
|
#define litest_assert_switch_event(li_, sw_, state_) \
|
|
|
|
|
_litest_assert_switch_event(li_, sw_, state_, __func__, __LINE__)
|
|
|
|
|
|
2023-07-14 12:57:58 +10:00
|
|
|
void
|
2025-03-14 10:12:24 +10:00
|
|
|
_litest_assert_switch_event(struct libinput *li,
|
|
|
|
|
enum libinput_switch sw,
|
|
|
|
|
enum libinput_switch_state state,
|
|
|
|
|
const char *func,
|
|
|
|
|
int lineno);
|
2023-07-14 12:57:58 +10:00
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
|
|
|
|
litest_assert_scroll(struct libinput *li,
|
2018-11-22 10:24:54 +10:00
|
|
|
enum libinput_event_type axis_type,
|
2016-02-05 10:15:35 +10:00
|
|
|
enum libinput_pointer_axis axis,
|
|
|
|
|
int minimum_movement);
|
|
|
|
|
|
2018-11-22 10:24:54 +10:00
|
|
|
void
|
|
|
|
|
litest_assert_axis_end_sequence(struct libinput *li,
|
|
|
|
|
enum libinput_event_type axis_type,
|
|
|
|
|
enum libinput_pointer_axis axis,
|
|
|
|
|
enum libinput_pointer_axis_source source);
|
|
|
|
|
|
2024-09-12 13:40:44 +10:00
|
|
|
#define litest_assert_only_typed_events(...) \
|
|
|
|
|
_litest_assert_only_typed_events(__VA_ARGS__, __func__, __LINE__)
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
2024-09-12 13:40:44 +10:00
|
|
|
_litest_assert_only_typed_events(struct libinput *li,
|
|
|
|
|
enum libinput_event_type type,
|
|
|
|
|
const char *func,
|
|
|
|
|
int line);
|
2016-02-05 10:15:35 +10:00
|
|
|
|
2018-11-22 10:24:54 +10:00
|
|
|
void
|
|
|
|
|
litest_assert_only_axis_events(struct libinput *li, enum libinput_event_type axis_type);
|
|
|
|
|
|
2019-11-08 15:16:42 +10:00
|
|
|
void
|
|
|
|
|
litest_assert_no_typed_events(struct libinput *li, enum libinput_event_type type);
|
|
|
|
|
|
2025-03-14 10:12:24 +10:00
|
|
|
#define litest_assert_tablet_button_event(li_, button_, state_) \
|
|
|
|
|
_litest_assert_tablet_button_event(li_, button_, state_, __func__, __LINE__)
|
|
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
2025-03-14 10:12:24 +10:00
|
|
|
_litest_assert_tablet_button_event(struct libinput *li,
|
|
|
|
|
unsigned int button,
|
|
|
|
|
enum libinput_button_state state,
|
|
|
|
|
const char *func,
|
|
|
|
|
int lineno);
|
|
|
|
|
|
2025-04-08 15:48:31 +10:00
|
|
|
#define litest_assert_tablet_axis_event(li_) \
|
|
|
|
|
_litest_assert_tablet_axis_event(li_, __func__, __LINE__)
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_litest_assert_tablet_axis_event(struct libinput *li, const char *func, int lineno);
|
|
|
|
|
|
2025-03-14 10:12:24 +10:00
|
|
|
#define litest_assert_tablet_proximity_event(li_, state_) \
|
|
|
|
|
_litest_assert_tablet_proximity_event(li_, state_, __func__, __LINE__)
|
2016-02-05 10:15:35 +10:00
|
|
|
|
|
|
|
|
void
|
2025-03-14 10:12:24 +10:00
|
|
|
_litest_assert_tablet_proximity_event(struct libinput *li,
|
|
|
|
|
enum libinput_tablet_tool_proximity_state state,
|
|
|
|
|
const char *func,
|
|
|
|
|
int lineno);
|
|
|
|
|
|
|
|
|
|
#define litest_assert_tablet_tip_event(li_, state_) \
|
|
|
|
|
_litest_assert_tablet_tip_event(li_, state_, __func__, __LINE__)
|
2016-02-05 10:15:35 +10:00
|
|
|
|
2018-09-14 14:03:09 +10:00
|
|
|
void
|
2025-03-14 10:12:24 +10:00
|
|
|
_litest_assert_tablet_tip_event(struct libinput *li,
|
|
|
|
|
enum libinput_tablet_tool_tip_state state,
|
|
|
|
|
const char *func,
|
|
|
|
|
int lineno);
|
|
|
|
|
|
|
|
|
|
#define litest_assert_pad_button_event(li_, button_, state_) \
|
|
|
|
|
_litest_assert_pad_button_event(li_, button_, state_, __func__, __LINE__)
|
2018-09-14 14:03:09 +10:00
|
|
|
|
2016-02-05 10:57:37 +10:00
|
|
|
void
|
2025-03-14 10:12:24 +10:00
|
|
|
_litest_assert_pad_button_event(struct libinput *li,
|
|
|
|
|
unsigned int button,
|
|
|
|
|
enum libinput_button_state state,
|
|
|
|
|
const char *func,
|
|
|
|
|
int lineno);
|
|
|
|
|
|
|
|
|
|
#define litest_assert_pad_key_event(li_, key_, state_) \
|
|
|
|
|
_litest_assert_pad_key_event(li_, key_, state_, __func__, __LINE__)
|
|
|
|
|
|
2019-01-17 11:08:27 +10:00
|
|
|
void
|
2025-03-14 10:12:24 +10:00
|
|
|
_litest_assert_pad_key_event(struct libinput *li,
|
|
|
|
|
unsigned int key,
|
|
|
|
|
enum libinput_key_state state,
|
|
|
|
|
const char *func,
|
|
|
|
|
int lineno);
|
2021-02-15 17:48:34 +10:00
|
|
|
|
2024-09-12 13:40:44 +10:00
|
|
|
#define litest_assert_gesture_event(...) \
|
|
|
|
|
_litest_assert_gesture_event(__VA_ARGS__, __func__, __LINE__)
|
|
|
|
|
|
2021-02-15 17:48:34 +10:00
|
|
|
void
|
2024-09-12 13:40:44 +10:00
|
|
|
_litest_assert_gesture_event(struct libinput *li,
|
|
|
|
|
enum libinput_event_type type,
|
|
|
|
|
int nfingers,
|
|
|
|
|
const char *func,
|
|
|
|
|
int line);
|
2021-02-15 17:48:34 +10:00
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
struct libevdev_uinput *
|
|
|
|
|
litest_create_uinput_device(const char *name, struct input_id *id, ...);
|
|
|
|
|
|
|
|
|
|
struct libevdev_uinput *
|
|
|
|
|
litest_create_uinput_abs_device(const char *name,
|
|
|
|
|
struct input_id *id,
|
|
|
|
|
const struct input_absinfo *abs,
|
|
|
|
|
...);
|
|
|
|
|
|
|
|
|
|
void
|
2025-04-01 09:23:10 +10:00
|
|
|
_litest_timeout(struct libinput *li, const char *func, int lineno, int millis);
|
|
|
|
|
|
|
|
|
|
#define litest_timeout(li_, millis) \
|
|
|
|
|
_litest_timeout(li_, __func__, __LINE__, millis)
|
|
|
|
|
|
|
|
|
|
#define litest_timeout_tap(li_) litest_timeout(li_, 300)
|
|
|
|
|
#define litest_timeout_tapndrag(li_) litest_timeout(li_, 520)
|
|
|
|
|
#define litest_timeout_debounce(li_) litest_timeout(li_, 30)
|
|
|
|
|
#define litest_timeout_softbuttons(li_) litest_timeout(li_, 300)
|
|
|
|
|
#define litest_timeout_buttonscroll(li_) litest_timeout(li_, 300)
|
|
|
|
|
#define litest_timeout_wheel_scroll(li_) litest_timeout(li_, 600)
|
|
|
|
|
#define litest_timeout_edgescroll(li_) litest_timeout(li_, 300)
|
|
|
|
|
#define litest_timeout_finger_switch(li_) litest_timeout(li_, 140)
|
|
|
|
|
#define litest_timeout_middlebutton(li_) litest_timeout(li_, 70)
|
|
|
|
|
#define litest_timeout_dwt_short(li_) litest_timeout(li_, 220)
|
|
|
|
|
#define litest_timeout_dwt_long(li_) litest_timeout(li_, 520)
|
|
|
|
|
#define litest_timeout_gesture(li_) litest_timeout(li_, 120)
|
|
|
|
|
#define litest_timeout_gesture_scroll(li_) litest_timeout(li_, 180)
|
|
|
|
|
#define litest_timeout_gesture_hold(li_) litest_timeout(li_, 300)
|
|
|
|
|
#define litest_timeout_gesture_quick_hold(li_) litest_timeout(li_, 60)
|
|
|
|
|
#define litest_timeout_trackpoint(li_) litest_timeout(li_, 320)
|
|
|
|
|
#define litest_timeout_tablet_proxout(li_) litest_timeout(li_, 170)
|
|
|
|
|
#define litest_timeout_touch_arbitration(li_) litest_timeout(li_, 100)
|
|
|
|
|
#define litest_timeout_hysteresis(li_) litest_timeout(li_, 90)
|
|
|
|
|
#define litest_timeout_3fg_drag(li_) litest_timeout(li_, 800)
|
2025-06-02 15:11:08 +10:00
|
|
|
#define litest_timeout_eraser_button(li_) litest_timeout(li_, 50)
|
2024-09-06 11:38:35 +10:00
|
|
|
|
2025-06-11 09:36:07 +10:00
|
|
|
struct litest_logcapture {
|
|
|
|
|
char **errors;
|
|
|
|
|
char **infos;
|
|
|
|
|
char **debugs;
|
2025-06-27 10:37:33 +10:00
|
|
|
char **bugs;
|
2025-06-11 09:36:07 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_logcapture_destroy(struct litest_logcapture *c);
|
|
|
|
|
|
|
|
|
|
DEFINE_DESTROY_CLEANUP_FUNC(litest_logcapture);
|
|
|
|
|
|
|
|
|
|
struct litest_logcapture *
|
|
|
|
|
litest_logcapture_setup(struct libinput *li);
|
|
|
|
|
|
|
|
|
|
struct litest_logcapture *
|
|
|
|
|
litest_logcapture_remove(struct libinput *li, struct litest_logcapture *capture);
|
|
|
|
|
|
|
|
|
|
#define litest_with_logcapture(li_, capture_) \
|
|
|
|
|
for (struct litest_logcapture *capture_ = litest_logcapture_setup(li_); \
|
|
|
|
|
capture_ != NULL; \
|
|
|
|
|
capture_ = litest_logcapture_remove(li_, capture_))
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_litest_assert_logcapture_no_errors(struct litest_logcapture *c,
|
|
|
|
|
const char *file,
|
|
|
|
|
const char *func,
|
|
|
|
|
int lineno);
|
|
|
|
|
|
|
|
|
|
#define litest_assert_logcapture_no_errors(c_) \
|
|
|
|
|
_litest_assert_logcapture_no_errors(c_, __FILE__, __func__, __LINE__)
|
|
|
|
|
|
2025-04-09 13:42:43 +10:00
|
|
|
#define litest_with_event_frame(dev_) \
|
|
|
|
|
for (bool _i = ({litest_push_event_frame(dev_); true; }); \
|
|
|
|
|
_i; \
|
|
|
|
|
({ litest_pop_event_frame(dev_); _i = false; }))
|
|
|
|
|
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
|
|
|
|
litest_push_event_frame(struct litest_device *dev);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_pop_event_frame(struct litest_device *dev);
|
2014-09-17 10:07:38 +10:00
|
|
|
|
2017-02-09 11:06:01 +10:00
|
|
|
void
|
|
|
|
|
litest_filter_event(struct litest_device *dev, unsigned int type, unsigned int code);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_unfilter_event(struct litest_device *dev, unsigned int type, unsigned int code);
|
2016-02-05 10:15:35 +10:00
|
|
|
void
|
|
|
|
|
litest_semi_mt_touch_down(struct litest_device *d,
|
|
|
|
|
struct litest_semi_mt *semi_mt,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x,
|
|
|
|
|
double y);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_semi_mt_touch_move(struct litest_device *d,
|
|
|
|
|
struct litest_semi_mt *semi_mt,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x,
|
|
|
|
|
double y);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_semi_mt_touch_up(struct litest_device *d,
|
|
|
|
|
struct litest_semi_mt *semi_mt,
|
|
|
|
|
unsigned int slot);
|
2014-12-16 11:28:26 +10:00
|
|
|
|
2024-09-06 11:38:35 +10:00
|
|
|
static inline void
|
|
|
|
|
litest_enable_3fg_drag(struct libinput_device *device, unsigned int nfingers)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_3fg_drag_state enabled;
|
|
|
|
|
|
|
|
|
|
switch (nfingers) {
|
|
|
|
|
case 3:
|
|
|
|
|
enabled = LIBINPUT_CONFIG_3FG_DRAG_ENABLED_3FG;
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
enabled = LIBINPUT_CONFIG_3FG_DRAG_ENABLED_4FG;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
litest_abort_msg("Invalid finger count");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum libinput_config_status status =
|
|
|
|
|
libinput_device_config_3fg_drag_set_enabled(device, enabled);
|
|
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-17 10:02:17 +10:00
|
|
|
static inline void
|
|
|
|
|
litest_enable_tap(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_tap_set_enabled(device,
|
|
|
|
|
LIBINPUT_CONFIG_TAP_ENABLED);
|
|
|
|
|
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_disable_tap(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_tap_set_enabled(device,
|
|
|
|
|
LIBINPUT_CONFIG_TAP_DISABLED);
|
|
|
|
|
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-21 14:50:40 +10:00
|
|
|
static inline void
|
|
|
|
|
litest_set_tap_map(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_tap_button_map map)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_tap_set_button_map(device, map);
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-22 17:59:19 +10:00
|
|
|
static inline void
|
|
|
|
|
litest_enable_tap_drag(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_tap_set_drag_enabled(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_DRAG_ENABLED);
|
|
|
|
|
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_disable_tap_drag(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_tap_set_drag_enabled(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_DRAG_DISABLED);
|
|
|
|
|
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-30 14:48:12 +10:00
|
|
|
static inline bool
|
|
|
|
|
litest_has_2fg_scroll(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
return !!(libinput_device_config_scroll_get_methods(device) &
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_2FG);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_enable_2fg_scroll(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_scroll_set_method(device,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_2FG);
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
2022-12-10 19:40:07 +09:00
|
|
|
|
|
|
|
|
libinput_device_config_scroll_set_natural_scroll_enabled(device, 0);
|
2015-07-30 14:48:12 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_enable_edge_scroll(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_scroll_set_method(device,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_EDGE);
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
2022-12-10 19:40:07 +09:00
|
|
|
|
|
|
|
|
libinput_device_config_scroll_set_natural_scroll_enabled(device, 0);
|
2015-07-30 14:48:12 +10:00
|
|
|
}
|
|
|
|
|
|
2017-06-21 12:29:52 +10:00
|
|
|
static inline bool
|
|
|
|
|
litest_has_clickfinger(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
uint32_t methods = libinput_device_config_click_get_methods(device);
|
|
|
|
|
|
|
|
|
|
return methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-04 08:34:33 +10:00
|
|
|
static inline bool
|
|
|
|
|
litest_has_btnareas(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
uint32_t methods = libinput_device_config_click_get_methods(device);
|
|
|
|
|
|
|
|
|
|
return methods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-30 14:48:12 +10:00
|
|
|
static inline void
|
|
|
|
|
litest_enable_clickfinger(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_click_set_method(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-09 18:46:42 -03:00
|
|
|
static inline void
|
|
|
|
|
litest_set_clickfinger_map(struct litest_device *dev,
|
|
|
|
|
enum libinput_config_clickfinger_button_map map)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_click_set_clickfinger_button_map(device, map);
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-30 14:48:12 +10:00
|
|
|
static inline void
|
|
|
|
|
litest_enable_buttonareas(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_click_set_method(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-02 16:29:02 +02:00
|
|
|
static inline void
|
|
|
|
|
litest_enable_drag_lock_sticky(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_tap_set_drag_lock_enabled(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_DRAG_LOCK_ENABLED_STICKY);
|
|
|
|
|
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-30 14:48:12 +10:00
|
|
|
static inline void
|
|
|
|
|
litest_enable_drag_lock(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_tap_set_drag_lock_enabled(
|
|
|
|
|
device,
|
2024-09-02 16:29:02 +02:00
|
|
|
LIBINPUT_CONFIG_DRAG_LOCK_ENABLED_TIMEOUT);
|
2015-07-30 14:48:12 +10:00
|
|
|
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_disable_drag_lock(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_tap_set_drag_lock_enabled(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);
|
|
|
|
|
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-30 15:49:40 +10:00
|
|
|
static inline void
|
|
|
|
|
litest_enable_middleemu(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
|
|
|
|
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_disable_middleemu(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
|
|
|
|
|
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-16 09:40:50 +10:00
|
|
|
static inline void
|
|
|
|
|
litest_sendevents_off(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_sendevents_on(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_sendevents_ext_mouse(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_send_events_set_mode(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE);
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-27 19:19:49 +02:00
|
|
|
static inline void
|
|
|
|
|
litest_enable_hold_gestures(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_gesture_set_hold_enabled(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_HOLD_ENABLED);
|
|
|
|
|
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_disable_hold_gestures(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
enum libinput_config_status status, expected;
|
|
|
|
|
|
|
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
status = libinput_device_config_gesture_set_hold_enabled(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_HOLD_DISABLED);
|
|
|
|
|
|
|
|
|
|
litest_assert_int_eq(status, expected);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-23 14:54:00 +10:00
|
|
|
static inline bool
|
|
|
|
|
litest_touchpad_is_external(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
struct udev_device *udev_device;
|
|
|
|
|
const char *prop;
|
|
|
|
|
bool is_external;
|
|
|
|
|
|
2018-05-16 11:56:12 +10:00
|
|
|
if (libinput_device_get_id_vendor(dev->libinput_device) == VENDOR_ID_WACOM)
|
|
|
|
|
return true;
|
|
|
|
|
|
2017-03-23 14:54:00 +10:00
|
|
|
udev_device = libinput_device_get_udev_device(dev->libinput_device);
|
|
|
|
|
prop = udev_device_get_property_value(udev_device,
|
|
|
|
|
"ID_INPUT_TOUCHPAD_INTEGRATION");
|
|
|
|
|
is_external = prop && streq(prop, "external");
|
|
|
|
|
udev_device_unref(udev_device);
|
|
|
|
|
|
|
|
|
|
return is_external;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-10 13:57:12 +03:00
|
|
|
static inline int
|
|
|
|
|
litest_send_file(int sock, int fd)
|
|
|
|
|
{
|
|
|
|
|
char buf[40960];
|
|
|
|
|
int n = read(fd, buf, 40960);
|
2018-08-08 20:55:58 +10:00
|
|
|
litest_assert_int_gt(n, 0);
|
2018-07-10 13:57:12 +03:00
|
|
|
return write(sock, buf, n);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-29 10:59:45 +10:00
|
|
|
static inline int
|
|
|
|
|
litest_slot_count(struct litest_device *dev)
|
2020-01-09 11:13:18 +10:00
|
|
|
{
|
2020-01-09 10:10:31 +10:00
|
|
|
if (dev->which == LITEST_ALPS_3FG)
|
|
|
|
|
return 2;
|
|
|
|
|
|
2020-01-09 11:13:18 +10:00
|
|
|
return libevdev_get_num_slots(dev->evdev);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-28 10:57:45 +10:00
|
|
|
static inline bool
|
|
|
|
|
litest_has_palm_detect_size(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
double width, height;
|
|
|
|
|
unsigned int vendor;
|
|
|
|
|
unsigned int bustype;
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
vendor = libinput_device_get_id_vendor(dev->libinput_device);
|
|
|
|
|
bustype = libevdev_get_id_bustype(dev->evdev);
|
|
|
|
|
if (vendor == VENDOR_ID_WACOM)
|
|
|
|
|
return 0;
|
|
|
|
|
if (bustype == BUS_BLUETOOTH)
|
|
|
|
|
return 0;
|
|
|
|
|
if (vendor == VENDOR_ID_APPLE)
|
2023-04-06 15:33:42 +09:00
|
|
|
return 0;
|
2020-05-28 10:57:45 +10:00
|
|
|
|
|
|
|
|
rc = libinput_device_get_size(dev->libinput_device, &width, &height);
|
|
|
|
|
|
|
|
|
|
return rc == 0 && width >= 70;
|
|
|
|
|
}
|
|
|
|
|
|
Add a device test suite
A rather large commit, copied from a similar (almost identical) suite in
libtouchpad and ported for libinput.
The goal here is to make testing for various devices easy, so the litest
("libinput test") wrappers do that. The idea is that each device has some
features, and tests are likely to exercise some features or won't work with
other features.
Each test case takes a list of required features and a list of excluded
features. The test suite will create a new test case for each device in the
suite that matches that set.
For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would
run on clickpads only, not on touchpads with buttons.
check supports suites and test cases, both named. We wrap that so that each
named set of cases we add are a test suite, with the set of devices being the
test cases. i.e.
litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY);
adds a suite named "foo:bar" and test cases for both devices given, with their
shortnames as test case name, resulting in:
"foo:bar", "trackpoint"
"foo:bar", "clickpad"
...
Multiple test functions can be added to a suite. For tests without a device
requirement there is litest_add_no_device_test(...).
The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow
the set of test cases. The test suite detects when run inside a debugger and
disables fork mode (the default).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-06 15:02:11 +10:00
|
|
|
#endif /* LITEST_H */
|