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"
|
2014-03-31 10:00:16 +10:00
|
|
|
#include <limits.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_INT_H
|
|
|
|
|
#define LITEST_INT_H
|
|
|
|
|
#include "litest.h"
|
|
|
|
|
|
2014-03-31 10:00:16 +10:00
|
|
|
/* Use as designater for litest to change the value */
|
|
|
|
|
#define LITEST_AUTO_ASSIGN INT_MIN
|
|
|
|
|
|
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_test_device {
|
2018-06-22 16:57:51 +10:00
|
|
|
struct list node; /* global test device list */
|
|
|
|
|
|
2018-06-22 16:49:56 +10:00
|
|
|
enum litest_device_type type;
|
2019-07-01 16:12:26 +10:00
|
|
|
int64_t features;
|
2018-06-22 16:49:56 +10:00
|
|
|
const char *shortname;
|
|
|
|
|
void (*setup)(void); /* test fixture, used by check */
|
|
|
|
|
void (*teardown)(void); /* test fixture, used by check */
|
|
|
|
|
/**
|
2014-03-31 10:00:16 +10:00
|
|
|
* If create is non-NULL it will be called to initialize the device.
|
|
|
|
|
* For such devices, no overrides are possible. If create is NULL,
|
|
|
|
|
* the information in name, id, events, absinfo is used to
|
|
|
|
|
* create the device instead.
|
2019-03-22 15:44:32 +10:00
|
|
|
*
|
|
|
|
|
* @return true if the device needs to be created by litest, false if
|
|
|
|
|
* the device creates itself
|
2014-03-31 10:00:16 +10:00
|
|
|
*/
|
2019-03-22 15:44:32 +10:00
|
|
|
bool (*create)(struct litest_device *d);
|
2014-03-31 10:00:16 +10:00
|
|
|
|
2018-06-22 16:49:56 +10:00
|
|
|
/**
|
|
|
|
|
* The device name. Only used when create is NULL.
|
|
|
|
|
*/
|
|
|
|
|
const char *name;
|
|
|
|
|
/**
|
|
|
|
|
* The device id. Only used when create is NULL.
|
|
|
|
|
*/
|
|
|
|
|
const struct input_id *id;
|
|
|
|
|
/**
|
2014-03-31 10:00:16 +10:00
|
|
|
* List of event type/code tuples, terminated with -1, e.g.
|
|
|
|
|
* EV_REL, REL_X, EV_KEY, BTN_LEFT, -1
|
|
|
|
|
* Special tuple is INPUT_PROP_MAX, <actual property> to set.
|
|
|
|
|
*
|
|
|
|
|
* Any EV_ABS codes in this list will be initialized with a default
|
|
|
|
|
* axis range.
|
|
|
|
|
*/
|
2018-06-22 16:49:56 +10:00
|
|
|
int *events;
|
|
|
|
|
/**
|
|
|
|
|
* List of abs codes to enable, with absinfo.value determining the
|
|
|
|
|
* code to set. List must be terminated with absinfo.value -1
|
|
|
|
|
*/
|
|
|
|
|
struct input_absinfo *absinfo;
|
|
|
|
|
struct litest_device_interface *interface;
|
2015-02-02 10:47:52 +10:00
|
|
|
|
2018-06-22 16:49:56 +10:00
|
|
|
const char *udev_rule;
|
|
|
|
|
const char *quirk_file;
|
2019-06-10 22:00:40 +10:00
|
|
|
|
2019-09-26 20:06:11 -07:00
|
|
|
const struct key_value_str udev_properties[32];
|
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 {
|
2020-01-09 09:48:29 +10:00
|
|
|
bool (*touch_down)(struct litest_device *d, unsigned int slot, double x, double y);
|
|
|
|
|
bool (*touch_move)(struct litest_device *d, unsigned int slot, double x, double y);
|
|
|
|
|
bool (*touch_up)(struct litest_device *d, unsigned int slot);
|
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-07-06 16:26:21 +10:00
|
|
|
/**
|
|
|
|
|
* Default value for the given EV_ABS axis.
|
|
|
|
|
* @return 0 on success, nonzero otherwise
|
|
|
|
|
*/
|
|
|
|
|
int (*get_axis_default)(struct litest_device *d, unsigned int code, int32_t *value);
|
|
|
|
|
|
2014-03-31 10:00:16 +10:00
|
|
|
/**
|
|
|
|
|
* Set of of events to execute on touch down, terminated by a .type
|
|
|
|
|
* and .code value of -1. If the event value is LITEST_AUTO_ASSIGN,
|
|
|
|
|
* it will be automatically assigned by the framework (valid for x,
|
|
|
|
|
* y, tracking id and slot).
|
|
|
|
|
*
|
|
|
|
|
* These events are only used if touch_down is NULL.
|
|
|
|
|
*/
|
|
|
|
|
struct input_event *touch_down_events;
|
|
|
|
|
struct input_event *touch_move_events;
|
|
|
|
|
struct input_event *touch_up_events;
|
|
|
|
|
|
2014-04-21 19:11:27 +02:00
|
|
|
/**
|
|
|
|
|
* Tablet events, LITEST_AUTO_ASSIGN is allowed on event values for
|
|
|
|
|
* ABS_X, ABS_Y, ABS_DISTANCE and ABS_PRESSURE.
|
|
|
|
|
*/
|
|
|
|
|
struct input_event *tablet_proximity_in_events;
|
|
|
|
|
struct input_event *tablet_proximity_out_events;
|
|
|
|
|
struct input_event *tablet_motion_events;
|
|
|
|
|
|
2016-02-05 10:57:37 +10:00
|
|
|
/**
|
|
|
|
|
* Pad events, LITEST_AUTO_ASSIGN is allowed on event values
|
|
|
|
|
* for ABS_WHEEL
|
|
|
|
|
*/
|
|
|
|
|
struct input_event *pad_ring_start_events;
|
|
|
|
|
struct input_event *pad_ring_change_events;
|
|
|
|
|
struct input_event *pad_ring_end_events;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Pad events, LITEST_AUTO_ASSIGN is allowed on event values
|
|
|
|
|
* for ABS_RX
|
|
|
|
|
*/
|
|
|
|
|
struct input_event *pad_strip_start_events;
|
|
|
|
|
struct input_event *pad_strip_change_events;
|
|
|
|
|
struct input_event *pad_strip_end_events;
|
|
|
|
|
|
2015-05-27 13:02:52 +10:00
|
|
|
int min[2]; /* x/y axis minimum */
|
|
|
|
|
int max[2]; /* x/y axis maximum */
|
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
|
|
|
};
|
|
|
|
|
|
2020-07-03 12:29:16 +10:00
|
|
|
struct path {
|
|
|
|
|
struct list link;
|
|
|
|
|
char *path;
|
|
|
|
|
int fd;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct litest_context {
|
|
|
|
|
struct list paths;
|
|
|
|
|
};
|
|
|
|
|
|
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
|
|
|
void litest_set_current_device(struct litest_device *device);
|
2014-07-18 16:01:10 +10:00
|
|
|
int litest_scale(const struct litest_device *d, unsigned int axis, double val);
|
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
|
|
|
void litest_generic_device_teardown(void);
|
|
|
|
|
|
|
|
|
|
#endif
|