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-05-04 09:13:22 +10:00
|
|
|
* Copyright © 2013 Marcin Slusarz <marcin.slusarz@gmail.com>
|
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
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-07-21 12:30:40 +10:00
|
|
|
#include <assert.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 <check.h>
|
2015-02-02 10:47:52 +10:00
|
|
|
#include <dirent.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 <errno.h>
|
|
|
|
|
#include <fcntl.h>
|
2015-05-20 10:12:39 +10:00
|
|
|
#include <fnmatch.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 <getopt.h>
|
|
|
|
|
#include <poll.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#include <unistd.h>
|
2014-06-03 07:51:37 +10:00
|
|
|
#include "linux/input.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 <sys/ptrace.h>
|
2015-06-05 10:52:04 +10:00
|
|
|
#include <sys/sendfile.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 <sys/timerfd.h>
|
|
|
|
|
#include <sys/wait.h>
|
2015-08-20 12:51:37 +02:00
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <sys/types.h>
|
2015-07-02 13:39:40 +10:00
|
|
|
#include <libudev.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 "litest.h"
|
|
|
|
|
#include "litest-int.h"
|
|
|
|
|
#include "libinput-util.h"
|
|
|
|
|
|
2015-02-02 10:47:52 +10:00
|
|
|
#define UDEV_RULES_D "/run/udev/rules.d"
|
|
|
|
|
#define UDEV_RULE_PREFIX "99-litest-"
|
2015-06-05 10:52:04 +10:00
|
|
|
#define UDEV_HWDB_D "/etc/udev/hwdb.d"
|
2015-07-27 15:53:53 +08:00
|
|
|
#define UDEV_MODEL_QUIRKS_RULE_FILE UDEV_RULES_D \
|
|
|
|
|
"/91-litest-model-quirks-REMOVEME.rules"
|
|
|
|
|
#define UDEV_MODEL_QUIRKS_HWDB_FILE UDEV_HWDB_D \
|
|
|
|
|
"/91-litest-model-quirks-REMOVEME.hwdb"
|
2015-07-27 16:08:04 +08:00
|
|
|
#define UDEV_TEST_DEVICE_RULE_FILE UDEV_RULES_D \
|
|
|
|
|
"/91-litest-test-device-REMOVEME.rules"
|
2015-02-02 10:47:52 +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
|
|
|
static int in_debugger = -1;
|
2014-06-18 19:51:19 +10:00
|
|
|
static int verbose = 0;
|
2015-05-20 10:12:39 +10:00
|
|
|
const char *filter_test = NULL;
|
2015-05-20 10:49:13 +10:00
|
|
|
const char *filter_device = NULL;
|
2015-05-20 11:00:37 +10:00
|
|
|
const char *filter_group = 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
|
|
|
|
2015-06-05 10:52:04 +10:00
|
|
|
static inline void litest_remove_model_quirks(void);
|
2015-07-22 10:44:44 +10:00
|
|
|
static void litest_init_udev_rules(void);
|
2015-06-05 10:52:04 +10:00
|
|
|
|
2015-05-04 09:13:22 +10:00
|
|
|
/* defined for the litest selftest */
|
|
|
|
|
#ifndef LITEST_DISABLE_BACKTRACE_LOGGING
|
|
|
|
|
#define litest_log(...) fprintf(stderr, __VA_ARGS__)
|
|
|
|
|
#define litest_vlog(format_, args_) vfprintf(stderr, format_, args_)
|
|
|
|
|
#else
|
2015-06-05 11:40:26 +10:00
|
|
|
#define litest_log(...) { /* __VA_ARGS__ */ }
|
|
|
|
|
#define litest_vlog(...) { /* __VA_ARGS__ */ }
|
2015-05-04 09:13:22 +10:00
|
|
|
#endif
|
|
|
|
|
|
2015-05-25 16:38:12 +10:00
|
|
|
#ifdef HAVE_LIBUNWIND
|
|
|
|
|
#define UNW_LOCAL_ONLY
|
|
|
|
|
#include <libunwind.h>
|
|
|
|
|
#include <dlfcn.h>
|
|
|
|
|
|
2015-05-08 09:31:44 +10:00
|
|
|
static char cwd[PATH_MAX];
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
litest_backtrace_get_lineno(const char *executable,
|
|
|
|
|
unw_word_t addr,
|
|
|
|
|
char *file_return,
|
|
|
|
|
int *line_return)
|
|
|
|
|
{
|
|
|
|
|
#if HAVE_ADDR2LINE
|
|
|
|
|
FILE* f;
|
|
|
|
|
char buffer[PATH_MAX];
|
|
|
|
|
char *s;
|
2015-05-25 17:27:14 +10:00
|
|
|
unsigned int i;
|
2015-05-08 09:31:44 +10:00
|
|
|
|
2015-06-01 18:04:59 -07:00
|
|
|
if (!cwd[0]) {
|
|
|
|
|
if (getcwd(cwd, sizeof(cwd)) == NULL)
|
|
|
|
|
cwd[0] = 0; /* contents otherwise undefined. */
|
|
|
|
|
}
|
2015-05-08 09:31:44 +10:00
|
|
|
|
|
|
|
|
sprintf (buffer,
|
|
|
|
|
ADDR2LINE " -C -e %s -i %lx",
|
|
|
|
|
executable,
|
|
|
|
|
(unsigned long) addr);
|
|
|
|
|
|
|
|
|
|
f = popen(buffer, "r");
|
|
|
|
|
if (f == NULL) {
|
|
|
|
|
litest_log("Failed to execute: %s\n", buffer);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buffer[0] = '?';
|
2015-05-25 17:04:56 +10:00
|
|
|
if (fgets(buffer, sizeof(buffer), f) == NULL) {
|
|
|
|
|
pclose(f);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-05-25 16:50:54 +10:00
|
|
|
pclose(f);
|
2015-05-08 09:31:44 +10:00
|
|
|
|
|
|
|
|
if (buffer[0] == '?')
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
s = strrchr(buffer, ':');
|
|
|
|
|
if (!s)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
*s = '\0';
|
|
|
|
|
s++;
|
|
|
|
|
sscanf(s, "%d", line_return);
|
|
|
|
|
|
|
|
|
|
/* now strip cwd from buffer */
|
|
|
|
|
s = buffer;
|
|
|
|
|
i = 0;
|
2015-05-25 17:27:14 +10:00
|
|
|
while(i < strlen(cwd) && *s != '\0' && cwd[i] == *s) {
|
2015-05-08 09:31:44 +10:00
|
|
|
*s = '\0';
|
|
|
|
|
s++;
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (i > 0)
|
|
|
|
|
*(--s) = '.';
|
|
|
|
|
strcpy(file_return, s);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
#else /* HAVE_ADDR2LINE */
|
|
|
|
|
return false;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-04 09:13:22 +10:00
|
|
|
static void
|
|
|
|
|
litest_backtrace(void)
|
|
|
|
|
{
|
|
|
|
|
unw_cursor_t cursor;
|
|
|
|
|
unw_context_t context;
|
|
|
|
|
unw_word_t off;
|
|
|
|
|
unw_proc_info_t pip;
|
|
|
|
|
int ret;
|
|
|
|
|
char procname[256];
|
|
|
|
|
Dl_info dlinfo;
|
|
|
|
|
/* filename and i are unused ifdef LITEST_SHUTUP */
|
|
|
|
|
const char *filename __attribute__((unused));
|
|
|
|
|
int i __attribute__((unused)) = 0;
|
|
|
|
|
|
|
|
|
|
pip.unwind_info = NULL;
|
|
|
|
|
ret = unw_getcontext(&context);
|
|
|
|
|
if (ret) {
|
|
|
|
|
litest_log("unw_getcontext failed: %s [%d]\n",
|
|
|
|
|
unw_strerror(ret),
|
|
|
|
|
ret);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret = unw_init_local(&cursor, &context);
|
|
|
|
|
if (ret) {
|
|
|
|
|
litest_log("unw_init_local failed: %s [%d]\n",
|
|
|
|
|
unw_strerror(ret),
|
|
|
|
|
ret);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_log("\nBacktrace:\n");
|
|
|
|
|
ret = unw_step(&cursor);
|
|
|
|
|
while (ret > 0) {
|
2015-05-08 09:31:44 +10:00
|
|
|
char file[PATH_MAX];
|
|
|
|
|
int line;
|
|
|
|
|
bool have_lineno = false;
|
|
|
|
|
|
2015-05-04 09:13:22 +10:00
|
|
|
ret = unw_get_proc_info(&cursor, &pip);
|
|
|
|
|
if (ret) {
|
|
|
|
|
litest_log("unw_get_proc_info failed: %s [%d]\n",
|
|
|
|
|
unw_strerror(ret),
|
|
|
|
|
ret);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret = unw_get_proc_name(&cursor, procname, 256, &off);
|
|
|
|
|
if (ret && ret != -UNW_ENOMEM) {
|
|
|
|
|
if (ret != -UNW_EUNSPEC)
|
|
|
|
|
litest_log("unw_get_proc_name failed: %s [%d]\n",
|
|
|
|
|
unw_strerror(ret),
|
|
|
|
|
ret);
|
|
|
|
|
procname[0] = '?';
|
|
|
|
|
procname[1] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dladdr((void *)(pip.start_ip + off), &dlinfo) &&
|
|
|
|
|
dlinfo.dli_fname &&
|
2015-05-08 09:31:44 +10:00
|
|
|
*dlinfo.dli_fname) {
|
2015-05-04 09:13:22 +10:00
|
|
|
filename = dlinfo.dli_fname;
|
2015-05-08 09:31:44 +10:00
|
|
|
have_lineno = litest_backtrace_get_lineno(filename,
|
|
|
|
|
(pip.start_ip + off),
|
|
|
|
|
file,
|
|
|
|
|
&line);
|
|
|
|
|
} else {
|
2015-05-04 09:13:22 +10:00
|
|
|
filename = "?";
|
2015-05-08 09:31:44 +10:00
|
|
|
}
|
2015-05-04 09:13:22 +10:00
|
|
|
|
2015-05-08 09:31:44 +10:00
|
|
|
if (have_lineno) {
|
2015-07-20 03:27:09 +02:00
|
|
|
litest_log("%d: %s() (%s:%d)\n",
|
2015-05-08 09:31:44 +10:00
|
|
|
i,
|
|
|
|
|
procname,
|
|
|
|
|
file,
|
|
|
|
|
line);
|
|
|
|
|
} else {
|
2015-07-20 03:27:09 +02:00
|
|
|
litest_log("%d: %s (%s%s+%#x) [%p]\n",
|
2015-05-08 09:31:44 +10:00
|
|
|
i,
|
|
|
|
|
filename,
|
|
|
|
|
procname,
|
|
|
|
|
ret == -UNW_ENOMEM ? "..." : "",
|
|
|
|
|
(int)off,
|
|
|
|
|
(void *)(pip.start_ip + off));
|
|
|
|
|
}
|
2015-05-04 09:13:22 +10:00
|
|
|
|
2015-05-08 09:31:44 +10:00
|
|
|
i++;
|
2015-05-04 09:13:22 +10:00
|
|
|
ret = unw_step(&cursor);
|
|
|
|
|
if (ret < 0)
|
|
|
|
|
litest_log("unw_step failed: %s [%d]\n",
|
|
|
|
|
unw_strerror(ret),
|
|
|
|
|
ret);
|
|
|
|
|
}
|
|
|
|
|
litest_log("\n");
|
|
|
|
|
}
|
|
|
|
|
#else /* HAVE_LIBUNWIND */
|
|
|
|
|
static inline void
|
|
|
|
|
litest_backtrace(void)
|
|
|
|
|
{
|
|
|
|
|
/* thou shall install libunwind */
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_fail_condition(const char *file,
|
|
|
|
|
int line,
|
|
|
|
|
const char *func,
|
|
|
|
|
const char *condition,
|
|
|
|
|
const char *message,
|
|
|
|
|
...)
|
|
|
|
|
{
|
|
|
|
|
litest_log("FAILED: %s\n", condition);
|
|
|
|
|
|
|
|
|
|
if (message) {
|
|
|
|
|
va_list args;
|
|
|
|
|
va_start(args, message);
|
|
|
|
|
litest_vlog(message, args);
|
|
|
|
|
va_end(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_log("in %s() (%s:%d)\n", func, file, line);
|
|
|
|
|
litest_backtrace();
|
|
|
|
|
abort();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
litest_log("FAILED COMPARISON: %s %s %s\n", astr, operator, bstr);
|
|
|
|
|
litest_log("Resolved to: %d %s %d\n", a, operator, b);
|
|
|
|
|
litest_log("in %s() (%s:%d)\n", func, file, line);
|
|
|
|
|
litest_backtrace();
|
|
|
|
|
abort();
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-08 08:16:39 +10:00
|
|
|
void
|
|
|
|
|
litest_fail_comparison_ptr(const char *file,
|
|
|
|
|
int line,
|
|
|
|
|
const char *func,
|
|
|
|
|
const char *comparison)
|
|
|
|
|
{
|
|
|
|
|
litest_log("FAILED COMPARISON: %s\n", comparison);
|
|
|
|
|
litest_log("in %s() (%s:%d)\n", func, file, line);
|
|
|
|
|
litest_backtrace();
|
|
|
|
|
abort();
|
|
|
|
|
}
|
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 test {
|
|
|
|
|
struct list node;
|
|
|
|
|
char *name;
|
|
|
|
|
TCase *tc;
|
|
|
|
|
enum litest_device_type devices;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct suite {
|
|
|
|
|
struct list node;
|
|
|
|
|
struct list tests;
|
|
|
|
|
char *name;
|
|
|
|
|
Suite *suite;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static struct litest_device *current_device;
|
|
|
|
|
|
2015-05-20 09:21:26 +10:00
|
|
|
struct litest_device *litest_current_device(void)
|
|
|
|
|
{
|
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
|
|
|
return current_device;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-20 09:21:26 +10:00
|
|
|
void litest_set_current_device(struct litest_device *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
|
|
|
current_device = device;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void litest_generic_device_teardown(void)
|
|
|
|
|
{
|
|
|
|
|
litest_delete_device(current_device);
|
|
|
|
|
current_device = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern struct litest_test_device litest_keyboard_device;
|
|
|
|
|
extern struct litest_test_device litest_synaptics_clickpad_device;
|
2014-03-24 15:25:32 +10:00
|
|
|
extern struct litest_test_device litest_synaptics_touchpad_device;
|
2014-06-11 08:59:11 +10:00
|
|
|
extern struct litest_test_device litest_synaptics_t440_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
|
|
|
extern struct litest_test_device litest_trackpoint_device;
|
|
|
|
|
extern struct litest_test_device litest_bcm5974_device;
|
2014-01-21 15:18:09 +10:00
|
|
|
extern struct litest_test_device litest_mouse_device;
|
2014-01-22 09:58:43 +10:00
|
|
|
extern struct litest_test_device litest_wacom_touch_device;
|
2014-04-21 19:11:28 +02:00
|
|
|
extern struct litest_test_device litest_wacom_bamboo_tablet_device;
|
2014-04-21 19:11:29 +02:00
|
|
|
extern struct litest_test_device litest_wacom_cintiq_tablet_device;
|
2014-04-21 19:11:30 +02:00
|
|
|
extern struct litest_test_device litest_wacom_intuos_tablet_device;
|
2014-04-21 19:11:31 +02:00
|
|
|
extern struct litest_test_device litest_wacom_isdv4_tablet_device;
|
2014-07-24 13:18:56 +10:00
|
|
|
extern struct litest_test_device litest_alps_device;
|
2014-08-21 11:08:29 +10:00
|
|
|
extern struct litest_test_device litest_generic_singletouch_device;
|
2014-10-29 10:59:58 +10:00
|
|
|
extern struct litest_test_device litest_qemu_tablet_device;
|
2014-10-29 12:08:20 +10:00
|
|
|
extern struct litest_test_device litest_xen_virtual_pointer_device;
|
2014-11-06 16:10:15 +10:00
|
|
|
extern struct litest_test_device litest_vmware_virtmouse_device;
|
2014-12-11 13:30:33 +10:00
|
|
|
extern struct litest_test_device litest_synaptics_hover_device;
|
2015-01-28 15:37:21 +10:00
|
|
|
extern struct litest_test_device litest_synaptics_carbon3rd_device;
|
2015-02-25 16:30:06 +10:00
|
|
|
extern struct litest_test_device litest_protocol_a_screen;
|
2015-03-04 10:27:22 +10:00
|
|
|
extern struct litest_test_device litest_wacom_finger_device;
|
2015-04-08 09:54:33 +10:00
|
|
|
extern struct litest_test_device litest_keyboard_blackwidow_device;
|
2015-04-13 10:23:47 +10:00
|
|
|
extern struct litest_test_device litest_wheel_only_device;
|
2015-04-17 15:59:36 +10:00
|
|
|
extern struct litest_test_device litest_mouse_roccat_device;
|
2015-04-24 15:07:58 +10:00
|
|
|
extern struct litest_test_device litest_ms_surface_cover_device;
|
2015-04-28 16:45:35 +10:00
|
|
|
extern struct litest_test_device litest_logitech_trackball_device;
|
2015-05-06 19:41:25 -04:00
|
|
|
extern struct litest_test_device litest_atmel_hover_device;
|
2015-06-16 15:36:40 +10:00
|
|
|
extern struct litest_test_device litest_alps_dualpoint_device;
|
2015-06-26 11:06:05 +10:00
|
|
|
extern struct litest_test_device litest_mouse_low_dpi_device;
|
2015-07-06 17:05:02 +02:00
|
|
|
extern struct litest_test_device litest_generic_multitouch_screen_device;
|
2015-07-06 17:05:03 +02:00
|
|
|
extern struct litest_test_device litest_nexus4_device;
|
2015-07-10 12:01:15 +10:00
|
|
|
extern struct litest_test_device litest_magicpad_device;
|
2015-07-10 14:11:11 +10:00
|
|
|
extern struct litest_test_device litest_elantech_touchpad_device;
|
2015-10-28 09:13:24 +10:00
|
|
|
extern struct litest_test_device litest_mouse_gladius_device;
|
2015-11-09 10:18:17 +10:00
|
|
|
extern struct litest_test_device litest_mouse_wheel_click_angle_device;
|
2015-12-13 22:27:55 -08:00
|
|
|
extern struct litest_test_device litest_apple_keyboard_device;
|
2015-12-23 15:15:29 +10:00
|
|
|
extern struct litest_test_device litest_anker_mouse_kbd_device;
|
2015-06-29 14:42:11 +10:00
|
|
|
extern struct litest_test_device litest_waltop_tablet_device;
|
2015-12-11 10:53:06 +10:00
|
|
|
extern struct litest_test_device litest_huion_tablet_device;
|
2016-01-29 10:09:13 +10:00
|
|
|
extern struct litest_test_device litest_cyborg_rat_device;
|
2016-02-04 11:20:38 +10:00
|
|
|
extern struct litest_test_device litest_yubikey_device;
|
|
|
|
|
extern struct litest_test_device litest_synaptics_i2c_device;
|
2016-02-11 13:52:55 +10:00
|
|
|
extern struct litest_test_device litest_wacom_cintiq_24hd_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_test_device* devices[] = {
|
|
|
|
|
&litest_synaptics_clickpad_device,
|
2014-03-24 15:25:32 +10:00
|
|
|
&litest_synaptics_touchpad_device,
|
2014-06-11 08:59:11 +10:00
|
|
|
&litest_synaptics_t440_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
|
|
|
&litest_keyboard_device,
|
|
|
|
|
&litest_trackpoint_device,
|
|
|
|
|
&litest_bcm5974_device,
|
2014-01-21 15:18:09 +10:00
|
|
|
&litest_mouse_device,
|
2014-01-22 09:58:43 +10:00
|
|
|
&litest_wacom_touch_device,
|
2014-04-21 19:11:28 +02:00
|
|
|
&litest_wacom_bamboo_tablet_device,
|
2014-04-21 19:11:29 +02:00
|
|
|
&litest_wacom_cintiq_tablet_device,
|
2014-04-21 19:11:30 +02:00
|
|
|
&litest_wacom_intuos_tablet_device,
|
2014-04-21 19:11:31 +02:00
|
|
|
&litest_wacom_isdv4_tablet_device,
|
2014-07-24 13:18:56 +10:00
|
|
|
&litest_alps_device,
|
2014-08-21 11:08:29 +10:00
|
|
|
&litest_generic_singletouch_device,
|
2014-10-29 10:59:58 +10:00
|
|
|
&litest_qemu_tablet_device,
|
2014-10-29 12:08:20 +10:00
|
|
|
&litest_xen_virtual_pointer_device,
|
2014-11-06 16:10:15 +10:00
|
|
|
&litest_vmware_virtmouse_device,
|
2014-12-11 13:30:33 +10:00
|
|
|
&litest_synaptics_hover_device,
|
2015-01-28 15:37:21 +10:00
|
|
|
&litest_synaptics_carbon3rd_device,
|
2015-02-25 16:30:06 +10:00
|
|
|
&litest_protocol_a_screen,
|
2015-03-04 10:27:22 +10:00
|
|
|
&litest_wacom_finger_device,
|
2015-04-08 09:54:33 +10:00
|
|
|
&litest_keyboard_blackwidow_device,
|
2015-04-13 10:23:47 +10:00
|
|
|
&litest_wheel_only_device,
|
2015-04-17 15:59:36 +10:00
|
|
|
&litest_mouse_roccat_device,
|
2015-04-24 15:07:58 +10:00
|
|
|
&litest_ms_surface_cover_device,
|
2015-04-28 16:45:35 +10:00
|
|
|
&litest_logitech_trackball_device,
|
2015-05-06 19:41:25 -04:00
|
|
|
&litest_atmel_hover_device,
|
2015-06-16 15:36:40 +10:00
|
|
|
&litest_alps_dualpoint_device,
|
2015-06-26 11:06:05 +10:00
|
|
|
&litest_mouse_low_dpi_device,
|
2015-07-06 17:05:02 +02:00
|
|
|
&litest_generic_multitouch_screen_device,
|
2015-07-06 17:05:03 +02:00
|
|
|
&litest_nexus4_device,
|
2015-07-10 12:01:15 +10:00
|
|
|
&litest_magicpad_device,
|
2015-07-10 14:11:11 +10:00
|
|
|
&litest_elantech_touchpad_device,
|
2015-10-28 09:13:24 +10:00
|
|
|
&litest_mouse_gladius_device,
|
2015-11-09 10:18:17 +10:00
|
|
|
&litest_mouse_wheel_click_angle_device,
|
2015-12-13 22:27:55 -08:00
|
|
|
&litest_apple_keyboard_device,
|
2015-12-23 15:15:29 +10:00
|
|
|
&litest_anker_mouse_kbd_device,
|
2015-06-29 14:42:11 +10:00
|
|
|
&litest_waltop_tablet_device,
|
2015-12-11 10:53:06 +10:00
|
|
|
&litest_huion_tablet_device,
|
2016-01-29 10:09:13 +10:00
|
|
|
&litest_cyborg_rat_device,
|
2016-02-04 11:20:38 +10:00
|
|
|
&litest_yubikey_device,
|
|
|
|
|
&litest_synaptics_i2c_device,
|
2016-02-11 13:52:55 +10:00
|
|
|
&litest_wacom_cintiq_24hd_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
|
|
|
NULL,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static struct list all_tests;
|
|
|
|
|
|
2015-06-05 10:52:04 +10:00
|
|
|
static inline void
|
|
|
|
|
litest_system(const char *command)
|
2015-02-02 10:47:52 +10:00
|
|
|
{
|
2015-06-05 10:52:04 +10:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
ret = system(command);
|
|
|
|
|
|
2015-06-01 18:04:59 -07:00
|
|
|
if (ret == -1) {
|
2015-06-05 10:52:04 +10:00
|
|
|
litest_abort_msg("Failed to execute: %s", command);
|
2015-06-01 18:04:59 -07:00
|
|
|
} else if (WIFEXITED(ret)) {
|
|
|
|
|
if (WEXITSTATUS(ret))
|
2015-06-05 10:52:04 +10:00
|
|
|
litest_abort_msg("'%s' failed with %d",
|
|
|
|
|
command,
|
2015-06-01 18:04:59 -07:00
|
|
|
WEXITSTATUS(ret));
|
|
|
|
|
} else if (WIFSIGNALED(ret)) {
|
2015-06-05 10:52:04 +10:00
|
|
|
litest_abort_msg("'%s' terminated with signal %d",
|
|
|
|
|
command,
|
2015-06-01 18:04:59 -07:00
|
|
|
WTERMSIG(ret));
|
|
|
|
|
}
|
2015-02-02 10:47:52 +10:00
|
|
|
}
|
|
|
|
|
|
2015-06-05 10:52:04 +10:00
|
|
|
static void
|
|
|
|
|
litest_reload_udev_rules(void)
|
|
|
|
|
{
|
|
|
|
|
litest_system("udevadm control --reload-rules");
|
|
|
|
|
litest_system("udevadm hwdb --update");
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-02 10:47:52 +10:00
|
|
|
static int
|
|
|
|
|
litest_udev_rule_filter(const struct dirent *entry)
|
|
|
|
|
{
|
2015-06-05 10:39:30 +10:00
|
|
|
return strneq(entry->d_name,
|
|
|
|
|
UDEV_RULE_PREFIX,
|
|
|
|
|
strlen(UDEV_RULE_PREFIX));
|
2015-02-02 10:47:52 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
litest_drop_udev_rules(void)
|
|
|
|
|
{
|
|
|
|
|
int n;
|
|
|
|
|
int rc;
|
|
|
|
|
struct dirent **entries;
|
|
|
|
|
char path[PATH_MAX];
|
|
|
|
|
|
|
|
|
|
n = scandir(UDEV_RULES_D,
|
|
|
|
|
&entries,
|
|
|
|
|
litest_udev_rule_filter,
|
|
|
|
|
alphasort);
|
2015-07-22 10:44:44 +10:00
|
|
|
if (n <= 0)
|
2015-02-02 10:47:52 +10:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
while (n--) {
|
|
|
|
|
rc = snprintf(path, sizeof(path),
|
|
|
|
|
"%s/%s",
|
|
|
|
|
UDEV_RULES_D,
|
|
|
|
|
entries[n]->d_name);
|
|
|
|
|
if (rc > 0 &&
|
|
|
|
|
(size_t)rc == strlen(UDEV_RULES_D) +
|
|
|
|
|
strlen(entries[n]->d_name) + 1)
|
|
|
|
|
unlink(path);
|
|
|
|
|
else
|
|
|
|
|
fprintf(stderr,
|
|
|
|
|
"Failed to delete %s. Remaining tests are unreliable\n",
|
|
|
|
|
entries[n]->d_name);
|
|
|
|
|
free(entries[n]);
|
|
|
|
|
}
|
|
|
|
|
free(entries);
|
|
|
|
|
|
|
|
|
|
litest_reload_udev_rules();
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
static void
|
|
|
|
|
litest_add_tcase_for_device(struct suite *suite,
|
2015-05-20 10:12:39 +10:00
|
|
|
const char *funcname,
|
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 *func,
|
2015-05-06 08:09:50 +10:00
|
|
|
const struct litest_test_device *dev,
|
|
|
|
|
const struct range *range)
|
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 test *t;
|
|
|
|
|
const char *test_name = dev->shortname;
|
|
|
|
|
|
|
|
|
|
list_for_each(t, &suite->tests, node) {
|
2015-05-26 08:46:05 +10:00
|
|
|
if (!streq(t->name, test_name))
|
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
|
|
|
continue;
|
|
|
|
|
|
2015-05-06 08:09:50 +10:00
|
|
|
if (range)
|
|
|
|
|
tcase_add_loop_test(t->tc,
|
|
|
|
|
func,
|
|
|
|
|
range->lower,
|
|
|
|
|
range->upper);
|
|
|
|
|
else
|
|
|
|
|
tcase_add_test(t->tc, func);
|
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
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t = zalloc(sizeof(*t));
|
2015-02-19 07:22:59 +10:00
|
|
|
assert(t != 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
|
|
|
t->name = strdup(test_name);
|
|
|
|
|
t->tc = tcase_create(test_name);
|
|
|
|
|
list_insert(&suite->tests, &t->node);
|
2015-02-02 10:47:52 +10:00
|
|
|
/* we can't guarantee that we clean up properly if a test fails, the
|
|
|
|
|
udev rules used for a previous test may still be in place. Add an
|
|
|
|
|
unchecked fixture to always clean up all rules before/after a
|
|
|
|
|
test case completes */
|
|
|
|
|
tcase_add_unchecked_fixture(t->tc,
|
|
|
|
|
litest_drop_udev_rules,
|
|
|
|
|
litest_drop_udev_rules);
|
2014-03-31 09:38:49 +10:00
|
|
|
tcase_add_checked_fixture(t->tc, dev->setup,
|
|
|
|
|
dev->teardown ? dev->teardown : litest_generic_device_teardown);
|
2015-06-18 13:18:16 +10:00
|
|
|
if (range)
|
|
|
|
|
tcase_add_loop_test(t->tc,
|
|
|
|
|
func,
|
|
|
|
|
range->lower,
|
|
|
|
|
range->upper);
|
|
|
|
|
else
|
|
|
|
|
tcase_add_test(t->tc, func);
|
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
|
|
|
suite_add_tcase(suite->suite, t->tc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2015-05-06 08:09:50 +10:00
|
|
|
litest_add_tcase_no_device(struct suite *suite,
|
|
|
|
|
void *func,
|
|
|
|
|
const struct range *range)
|
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 test *t;
|
|
|
|
|
const char *test_name = "no device";
|
|
|
|
|
|
2015-05-20 10:49:13 +10:00
|
|
|
if (filter_device &&
|
|
|
|
|
fnmatch(filter_device, test_name, 0) != 0)
|
|
|
|
|
return;
|
|
|
|
|
|
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
|
|
|
list_for_each(t, &suite->tests, node) {
|
2015-05-26 08:46:05 +10:00
|
|
|
if (!streq(t->name, test_name))
|
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
|
|
|
continue;
|
|
|
|
|
|
2015-05-06 08:09:50 +10:00
|
|
|
if (range)
|
|
|
|
|
tcase_add_loop_test(t->tc, func, range->lower, range->upper);
|
|
|
|
|
else
|
|
|
|
|
tcase_add_test(t->tc, func);
|
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
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t = zalloc(sizeof(*t));
|
2015-02-19 07:22:59 +10:00
|
|
|
assert(t != 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
|
|
|
t->name = strdup(test_name);
|
|
|
|
|
t->tc = tcase_create(test_name);
|
|
|
|
|
list_insert(&suite->tests, &t->node);
|
|
|
|
|
tcase_add_test(t->tc, func);
|
|
|
|
|
suite_add_tcase(suite->suite, t->tc);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-20 10:12:39 +10:00
|
|
|
static struct suite *
|
|
|
|
|
get_suite(const char *name)
|
|
|
|
|
{
|
|
|
|
|
struct suite *s;
|
|
|
|
|
|
|
|
|
|
if (all_tests.next == NULL && all_tests.prev == NULL)
|
|
|
|
|
list_init(&all_tests);
|
|
|
|
|
|
|
|
|
|
list_for_each(s, &all_tests, node) {
|
2015-05-26 08:46:05 +10:00
|
|
|
if (streq(s->name, name))
|
2015-05-20 10:12:39 +10:00
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s = zalloc(sizeof(*s));
|
|
|
|
|
assert(s != NULL);
|
|
|
|
|
s->name = strdup(name);
|
|
|
|
|
s->suite = suite_create(s->name);
|
|
|
|
|
|
|
|
|
|
list_init(&s->tests);
|
|
|
|
|
list_insert(&all_tests, &s->node);
|
|
|
|
|
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
static void
|
2015-05-20 10:12:39 +10:00
|
|
|
litest_add_tcase(const char *suite_name,
|
|
|
|
|
const char *funcname,
|
|
|
|
|
void *func,
|
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_feature required,
|
2015-05-06 08:09:50 +10:00
|
|
|
enum litest_device_feature excluded,
|
|
|
|
|
const struct range *range)
|
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 **dev = devices;
|
2015-05-20 10:12:39 +10:00
|
|
|
struct suite *suite;
|
2015-12-02 09:27:22 +10:00
|
|
|
bool added = false;
|
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-08-04 12:49:59 +10:00
|
|
|
assert(required >= LITEST_DISABLE_DEVICE);
|
|
|
|
|
assert(excluded >= LITEST_DISABLE_DEVICE);
|
|
|
|
|
|
2015-05-20 10:12:39 +10:00
|
|
|
if (filter_test &&
|
|
|
|
|
fnmatch(filter_test, funcname, 0) != 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-05-20 11:00:37 +10:00
|
|
|
if (filter_group &&
|
|
|
|
|
fnmatch(filter_group, suite_name, 0) != 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-05-20 10:12:39 +10:00
|
|
|
suite = get_suite(suite_name);
|
|
|
|
|
|
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
|
|
|
if (required == LITEST_DISABLE_DEVICE &&
|
|
|
|
|
excluded == LITEST_DISABLE_DEVICE) {
|
2015-05-06 08:09:50 +10:00
|
|
|
litest_add_tcase_no_device(suite, func, range);
|
2015-12-02 09:27:22 +10:00
|
|
|
added = true;
|
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
|
|
|
} else if (required != LITEST_ANY || excluded != LITEST_ANY) {
|
2015-05-20 10:49:13 +10:00
|
|
|
for (; *dev; dev++) {
|
|
|
|
|
if (filter_device &&
|
|
|
|
|
fnmatch(filter_device, (*dev)->shortname, 0) != 0)
|
|
|
|
|
continue;
|
|
|
|
|
if (((*dev)->features & required) != required ||
|
|
|
|
|
((*dev)->features & excluded) != 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
litest_add_tcase_for_device(suite,
|
|
|
|
|
funcname,
|
|
|
|
|
func,
|
|
|
|
|
*dev,
|
|
|
|
|
range);
|
2015-12-02 09:27:22 +10:00
|
|
|
added = true;
|
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
|
|
|
}
|
|
|
|
|
} else {
|
2015-05-20 10:49:13 +10:00
|
|
|
for (; *dev; dev++) {
|
|
|
|
|
if (filter_device &&
|
|
|
|
|
fnmatch(filter_device, (*dev)->shortname, 0) != 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
2015-05-20 10:12:39 +10:00
|
|
|
litest_add_tcase_for_device(suite,
|
|
|
|
|
funcname,
|
|
|
|
|
func,
|
|
|
|
|
*dev,
|
|
|
|
|
range);
|
2015-12-02 09:27:22 +10:00
|
|
|
added = true;
|
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-12-02 09:27:22 +10:00
|
|
|
|
|
|
|
|
if (!added) {
|
|
|
|
|
fprintf(stderr, "Test '%s' does not match any devices. Aborting.\n", funcname);
|
|
|
|
|
abort();
|
|
|
|
|
}
|
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
|
2015-05-20 10:12:39 +10:00
|
|
|
_litest_add_no_device(const char *name, const char *funcname, void *func)
|
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-20 10:12:39 +10:00
|
|
|
_litest_add(name, funcname, func, LITEST_DISABLE_DEVICE, LITEST_DISABLE_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
|
|
|
}
|
|
|
|
|
|
2015-05-06 08:09:50 +10:00
|
|
|
void
|
2015-05-20 10:12:39 +10:00
|
|
|
_litest_add_ranged_no_device(const char *name,
|
|
|
|
|
const char *funcname,
|
|
|
|
|
void *func,
|
|
|
|
|
const struct range *range)
|
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-20 10:12:39 +10:00
|
|
|
_litest_add_ranged(name,
|
|
|
|
|
funcname,
|
|
|
|
|
func,
|
|
|
|
|
LITEST_DISABLE_DEVICE,
|
|
|
|
|
LITEST_DISABLE_DEVICE,
|
|
|
|
|
range);
|
2014-07-14 00:01:10 +02: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
|
|
|
|
2014-07-14 00:01:10 +02:00
|
|
|
void
|
2015-05-20 10:12:39 +10:00
|
|
|
_litest_add(const char *name,
|
|
|
|
|
const char *funcname,
|
|
|
|
|
void *func,
|
|
|
|
|
enum litest_device_feature required,
|
|
|
|
|
enum litest_device_feature excluded)
|
2014-07-14 00:01:10 +02:00
|
|
|
{
|
2015-05-20 10:12:39 +10:00
|
|
|
_litest_add_ranged(name,
|
|
|
|
|
funcname,
|
|
|
|
|
func,
|
|
|
|
|
required,
|
|
|
|
|
excluded,
|
|
|
|
|
NULL);
|
2015-05-06 08:09:50 +10:00
|
|
|
}
|
2014-07-14 00:01:10 +02:00
|
|
|
|
2015-05-06 08:09:50 +10:00
|
|
|
void
|
2015-05-20 10:12:39 +10:00
|
|
|
_litest_add_ranged(const char *name,
|
|
|
|
|
const char *funcname,
|
|
|
|
|
void *func,
|
|
|
|
|
enum litest_device_feature required,
|
|
|
|
|
enum litest_device_feature excluded,
|
|
|
|
|
const struct range *range)
|
2015-05-06 08:09:50 +10:00
|
|
|
{
|
2015-05-20 10:12:39 +10:00
|
|
|
litest_add_tcase(name, funcname, func, required, excluded, range);
|
2014-07-14 00:01:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2015-05-20 10:12:39 +10:00
|
|
|
_litest_add_for_device(const char *name,
|
|
|
|
|
const char *funcname,
|
|
|
|
|
void *func,
|
|
|
|
|
enum litest_device_type type)
|
2014-07-14 00:01:10 +02:00
|
|
|
{
|
2015-05-20 10:12:39 +10:00
|
|
|
_litest_add_ranged_for_device(name, funcname, func, type, NULL);
|
2014-07-14 00:01:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2015-05-20 10:12:39 +10:00
|
|
|
_litest_add_ranged_for_device(const char *name,
|
|
|
|
|
const char *funcname,
|
|
|
|
|
void *func,
|
|
|
|
|
enum litest_device_type type,
|
|
|
|
|
const struct range *range)
|
2014-07-14 00:01:10 +02:00
|
|
|
{
|
|
|
|
|
struct suite *s;
|
|
|
|
|
struct litest_test_device **dev = devices;
|
2015-05-28 13:33:54 +10:00
|
|
|
bool device_filtered = false;
|
2014-07-14 00:01:10 +02:00
|
|
|
|
2014-08-04 12:49:59 +10:00
|
|
|
assert(type < LITEST_NO_DEVICE);
|
|
|
|
|
|
2015-05-22 14:55:24 +10:00
|
|
|
if (filter_test &&
|
|
|
|
|
fnmatch(filter_test, funcname, 0) != 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-05-20 11:00:37 +10:00
|
|
|
if (filter_group &&
|
|
|
|
|
fnmatch(filter_group, name, 0) != 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-07-14 00:01:10 +02:00
|
|
|
s = get_suite(name);
|
2015-05-20 10:49:13 +10:00
|
|
|
for (; *dev; dev++) {
|
|
|
|
|
if (filter_device &&
|
2015-05-28 13:33:54 +10:00
|
|
|
fnmatch(filter_device, (*dev)->shortname, 0) != 0) {
|
|
|
|
|
device_filtered = true;
|
2015-05-20 10:49:13 +10:00
|
|
|
continue;
|
2015-05-28 13:33:54 +10:00
|
|
|
}
|
2015-05-20 10:49:13 +10:00
|
|
|
|
2014-07-14 00:01:10 +02:00
|
|
|
if ((*dev)->type == type) {
|
2015-05-20 10:12:39 +10:00
|
|
|
litest_add_tcase_for_device(s,
|
|
|
|
|
funcname,
|
|
|
|
|
func,
|
|
|
|
|
*dev,
|
|
|
|
|
range);
|
2014-07-14 00:01:10 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-28 13:33:54 +10:00
|
|
|
/* only abort if no filter was set, that's a bug */
|
|
|
|
|
if (!device_filtered)
|
|
|
|
|
litest_abort_msg("Invalid test device type");
|
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-06-06 09:44:43 +10:00
|
|
|
static int
|
|
|
|
|
is_debugger_attached(void)
|
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
|
|
|
{
|
|
|
|
|
int status;
|
|
|
|
|
int rc;
|
|
|
|
|
int pid = fork();
|
|
|
|
|
|
|
|
|
|
if (pid == -1)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if (pid == 0) {
|
|
|
|
|
int ppid = getppid();
|
|
|
|
|
if (ptrace(PTRACE_ATTACH, ppid, NULL, NULL) == 0) {
|
|
|
|
|
waitpid(ppid, NULL, 0);
|
|
|
|
|
ptrace(PTRACE_CONT, NULL, NULL);
|
|
|
|
|
ptrace(PTRACE_DETACH, ppid, NULL, NULL);
|
|
|
|
|
rc = 0;
|
|
|
|
|
} else {
|
|
|
|
|
rc = 1;
|
|
|
|
|
}
|
|
|
|
|
_exit(rc);
|
|
|
|
|
} else {
|
|
|
|
|
waitpid(pid, &status, 0);
|
|
|
|
|
rc = WEXITSTATUS(status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-06 15:55:15 +10:00
|
|
|
static void
|
2014-06-18 19:51:19 +10:00
|
|
|
litest_log_handler(struct libinput *libinput,
|
|
|
|
|
enum libinput_log_priority pri,
|
2014-06-06 15:55:15 +10:00
|
|
|
const char *format,
|
|
|
|
|
va_list args)
|
|
|
|
|
{
|
|
|
|
|
const char *priority = NULL;
|
|
|
|
|
|
|
|
|
|
switch(pri) {
|
|
|
|
|
case LIBINPUT_LOG_PRIORITY_INFO: priority = "info"; break;
|
|
|
|
|
case LIBINPUT_LOG_PRIORITY_ERROR: priority = "error"; break;
|
|
|
|
|
case LIBINPUT_LOG_PRIORITY_DEBUG: priority = "debug"; break;
|
2015-03-13 10:11:41 +10:00
|
|
|
default:
|
|
|
|
|
abort();
|
2014-06-06 15:55:15 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf(stderr, "litest %s: ", priority);
|
|
|
|
|
vfprintf(stderr, format, args);
|
2015-07-29 16:06:20 +10:00
|
|
|
|
|
|
|
|
if (strstr(format, "client bug: ") ||
|
|
|
|
|
strstr(format, "libinput bug: "))
|
|
|
|
|
litest_abort_msg("libinput bug triggered, aborting.\n");
|
2014-06-06 15:55:15 +10:00
|
|
|
}
|
|
|
|
|
|
2014-06-13 11:11:05 +10:00
|
|
|
static int
|
|
|
|
|
open_restricted(const char *path, int flags, void *userdata)
|
|
|
|
|
{
|
2015-05-06 11:55:48 +10:00
|
|
|
int fd = open(path, flags);
|
|
|
|
|
return fd < 0 ? -errno : fd;
|
2014-06-13 11:11:05 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
close_restricted(int fd, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
close(fd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct libinput_interface interface = {
|
|
|
|
|
.open_restricted = open_restricted,
|
|
|
|
|
.close_restricted = close_restricted,
|
|
|
|
|
};
|
|
|
|
|
|
2015-05-22 09:06:07 +10:00
|
|
|
static inline int
|
2015-05-20 09:21:26 +10:00
|
|
|
litest_run(int argc, char **argv)
|
|
|
|
|
{
|
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 suite *s, *snext;
|
|
|
|
|
int failed;
|
|
|
|
|
SRunner *sr = NULL;
|
|
|
|
|
|
2015-05-22 14:56:09 +10:00
|
|
|
if (list_empty(&all_tests)) {
|
|
|
|
|
fprintf(stderr,
|
|
|
|
|
"Error: filters are too strict, no tests to run.\n");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
if (in_debugger == -1) {
|
|
|
|
|
in_debugger = is_debugger_attached();
|
|
|
|
|
if (in_debugger)
|
|
|
|
|
setenv("CK_FORK", "no", 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list_for_each(s, &all_tests, node) {
|
|
|
|
|
if (!sr)
|
|
|
|
|
sr = srunner_create(s->suite);
|
|
|
|
|
else
|
|
|
|
|
srunner_add_suite(sr, s->suite);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-19 10:33:24 +10:00
|
|
|
if (getenv("LITEST_VERBOSE"))
|
|
|
|
|
verbose = 1;
|
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-22 10:44:44 +10:00
|
|
|
litest_init_udev_rules();
|
|
|
|
|
|
2014-09-01 12:40:59 +10:00
|
|
|
srunner_run_all(sr, CK_ENV);
|
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
|
|
|
failed = srunner_ntests_failed(sr);
|
|
|
|
|
srunner_free(sr);
|
|
|
|
|
|
|
|
|
|
list_for_each_safe(s, snext, &all_tests, node) {
|
|
|
|
|
struct test *t, *tnext;
|
|
|
|
|
|
|
|
|
|
list_for_each_safe(t, tnext, &s->tests, node) {
|
|
|
|
|
free(t->name);
|
|
|
|
|
list_remove(&t->node);
|
|
|
|
|
free(t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list_remove(&s->node);
|
|
|
|
|
free(s->name);
|
|
|
|
|
free(s);
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-22 10:44:44 +10:00
|
|
|
litest_remove_model_quirks();
|
|
|
|
|
litest_reload_udev_rules();
|
|
|
|
|
|
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
|
|
|
return failed;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
static struct input_absinfo *
|
|
|
|
|
merge_absinfo(const struct input_absinfo *orig,
|
|
|
|
|
const struct input_absinfo *override)
|
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
|
|
|
{
|
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 input_absinfo *abs;
|
2014-07-03 11:00:54 +10:00
|
|
|
unsigned int nelem, i;
|
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
|
|
|
size_t sz = ABS_MAX + 1;
|
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
|
|
|
|
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
|
|
|
if (!orig)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
abs = calloc(sz, sizeof(*abs));
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert(abs != NULL);
|
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
|
|
|
|
|
|
|
|
nelem = 0;
|
|
|
|
|
while (orig[nelem].value != -1) {
|
|
|
|
|
abs[nelem] = orig[nelem];
|
|
|
|
|
nelem++;
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_lt(nelem, sz);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* just append, if the same axis is present twice, libevdev will
|
|
|
|
|
only use the last value anyway */
|
|
|
|
|
i = 0;
|
|
|
|
|
while (override && override[i].value != -1) {
|
|
|
|
|
abs[nelem++] = override[i++];
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_lt(nelem, sz);
|
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
|
|
|
}
|
|
|
|
|
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_lt(nelem, sz);
|
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
|
|
|
abs[nelem].value = -1;
|
|
|
|
|
|
|
|
|
|
return abs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int*
|
|
|
|
|
merge_events(const int *orig, const int *override)
|
|
|
|
|
{
|
|
|
|
|
int *events;
|
2014-07-03 11:00:54 +10:00
|
|
|
unsigned int nelem, i;
|
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
|
|
|
size_t sz = KEY_MAX * 3;
|
|
|
|
|
|
|
|
|
|
if (!orig)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
events = calloc(sz, sizeof(int));
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert(events != NULL);
|
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
|
|
|
|
|
|
|
|
nelem = 0;
|
|
|
|
|
while (orig[nelem] != -1) {
|
|
|
|
|
events[nelem] = orig[nelem];
|
|
|
|
|
nelem++;
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_lt(nelem, sz);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* just append, if the same axis is present twice, libevdev will
|
|
|
|
|
* ignore the double definition anyway */
|
|
|
|
|
i = 0;
|
|
|
|
|
while (override && override[i] != -1) {
|
|
|
|
|
events[nelem++] = override[i++];
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_le(nelem, sz);
|
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
|
|
|
}
|
|
|
|
|
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_lt(nelem, sz);
|
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
|
|
|
events[nelem] = -1;
|
|
|
|
|
|
|
|
|
|
return events;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-05 10:52:04 +10:00
|
|
|
static inline void
|
|
|
|
|
litest_copy_file(const char *dest, const char *src, const char *header)
|
|
|
|
|
{
|
2015-09-04 13:35:01 +02:00
|
|
|
int in, out, length;
|
2015-06-05 10:52:04 +10:00
|
|
|
|
|
|
|
|
out = open(dest, O_CREAT|O_WRONLY, 0644);
|
|
|
|
|
litest_assert_int_gt(out, -1);
|
|
|
|
|
|
2015-09-04 13:35:01 +02:00
|
|
|
if (header) {
|
|
|
|
|
length = strlen(header);
|
|
|
|
|
litest_assert_int_eq(write(out, header, length), length);
|
|
|
|
|
}
|
2015-06-05 10:52:04 +10:00
|
|
|
|
|
|
|
|
in = open(src, O_RDONLY);
|
|
|
|
|
litest_assert_int_gt(in, -1);
|
|
|
|
|
/* lazy, just check for error and empty file copy */
|
2015-12-11 15:34:50 +10:00
|
|
|
litest_assert_int_gt(sendfile(out, in, NULL, 40960), 0);
|
2015-06-05 10:52:04 +10:00
|
|
|
close(out);
|
|
|
|
|
close(in);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_install_model_quirks(void)
|
|
|
|
|
{
|
2015-07-01 10:55:23 +10:00
|
|
|
const char *warning =
|
2015-06-05 10:52:04 +10:00
|
|
|
"#################################################################\n"
|
|
|
|
|
"# WARNING: REMOVE THIS FILE\n"
|
2015-07-01 10:55:23 +10:00
|
|
|
"# This is a run-time file for the libinput test suite and\n"
|
2015-06-05 10:52:04 +10:00
|
|
|
"# should be removed on exit. If the test-suite is not currently \n"
|
|
|
|
|
"# running, remove this file and update your hwdb: \n"
|
|
|
|
|
"# sudo udevadm hwdb --update\n"
|
2015-07-01 10:55:23 +10:00
|
|
|
"#################################################################\n\n";
|
2015-07-27 15:53:53 +08:00
|
|
|
litest_copy_file(UDEV_MODEL_QUIRKS_RULE_FILE,
|
|
|
|
|
LIBINPUT_MODEL_QUIRKS_UDEV_RULES_FILE,
|
2015-07-01 10:55:23 +10:00
|
|
|
warning);
|
2015-07-27 15:53:53 +08:00
|
|
|
litest_copy_file(UDEV_MODEL_QUIRKS_HWDB_FILE,
|
|
|
|
|
LIBINPUT_MODEL_QUIRKS_UDEV_HWDB_FILE,
|
2015-07-01 10:55:23 +10:00
|
|
|
warning);
|
2015-07-27 16:08:04 +08:00
|
|
|
litest_copy_file(UDEV_TEST_DEVICE_RULE_FILE,
|
|
|
|
|
LIBINPUT_TEST_DEVICE_RULES_FILE,
|
2015-07-01 10:55:23 +10:00
|
|
|
warning);
|
2015-06-05 10:52:04 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
litest_remove_model_quirks(void)
|
|
|
|
|
{
|
2015-07-27 15:53:53 +08:00
|
|
|
unlink(UDEV_MODEL_QUIRKS_RULE_FILE);
|
|
|
|
|
unlink(UDEV_MODEL_QUIRKS_HWDB_FILE);
|
2015-07-27 16:08:04 +08:00
|
|
|
unlink(UDEV_TEST_DEVICE_RULE_FILE);
|
2015-06-05 10:52:04 +10:00
|
|
|
}
|
|
|
|
|
|
2015-07-22 10:44:44 +10:00
|
|
|
static void
|
|
|
|
|
litest_init_udev_rules(void)
|
2015-02-02 10:47:52 +10:00
|
|
|
{
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
rc = mkdir(UDEV_RULES_D, 0755);
|
|
|
|
|
if (rc == -1 && errno != EEXIST)
|
|
|
|
|
ck_abort_msg("Failed to create udev rules directory (%s)\n",
|
|
|
|
|
strerror(errno));
|
|
|
|
|
|
2015-06-05 10:52:04 +10:00
|
|
|
rc = mkdir(UDEV_HWDB_D, 0755);
|
|
|
|
|
if (rc == -1 && errno != EEXIST)
|
|
|
|
|
ck_abort_msg("Failed to create udev hwdb directory (%s)\n",
|
|
|
|
|
strerror(errno));
|
|
|
|
|
|
|
|
|
|
litest_install_model_quirks();
|
2015-07-22 10:44:44 +10:00
|
|
|
litest_reload_udev_rules();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
litest_init_device_udev_rules(struct litest_test_device *dev)
|
|
|
|
|
{
|
|
|
|
|
int rc;
|
|
|
|
|
FILE *f;
|
|
|
|
|
char *path = NULL;
|
2015-06-05 10:52:04 +10:00
|
|
|
|
|
|
|
|
if (!dev->udev_rule)
|
2015-07-22 10:44:44 +10:00
|
|
|
return NULL;
|
2015-06-05 10:52:04 +10:00
|
|
|
|
2015-05-28 19:01:01 -07:00
|
|
|
rc = xasprintf(&path,
|
2015-02-02 10:47:52 +10:00
|
|
|
"%s/%s%s.rules",
|
|
|
|
|
UDEV_RULES_D,
|
|
|
|
|
UDEV_RULE_PREFIX,
|
|
|
|
|
dev->shortname);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_eq(rc,
|
|
|
|
|
(int)(
|
|
|
|
|
strlen(UDEV_RULES_D) +
|
|
|
|
|
strlen(UDEV_RULE_PREFIX) +
|
|
|
|
|
strlen(dev->shortname) + 7));
|
2015-02-02 10:47:52 +10:00
|
|
|
f = fopen(path, "w");
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_notnull(f);
|
|
|
|
|
litest_assert_int_ge(fputs(dev->udev_rule, f), 0);
|
2015-02-02 10:47:52 +10:00
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
|
|
litest_reload_udev_rules();
|
|
|
|
|
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
static struct litest_device *
|
|
|
|
|
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 *d = NULL;
|
|
|
|
|
struct litest_test_device **dev;
|
|
|
|
|
const char *name;
|
|
|
|
|
const struct input_id *id;
|
|
|
|
|
struct input_absinfo *abs;
|
|
|
|
|
int *events;
|
2015-02-02 10:47:52 +10:00
|
|
|
char *udev_file;
|
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
|
|
|
|
|
|
|
|
dev = devices;
|
|
|
|
|
while (*dev) {
|
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
|
|
|
if ((*dev)->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
|
|
|
break;
|
|
|
|
|
dev++;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-25 22:56:01 +01:00
|
|
|
if (!*dev)
|
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
|
|
|
ck_abort_msg("Invalid device type %d\n", which);
|
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
|
|
|
|
|
|
|
|
d = zalloc(sizeof(*d));
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert(d != NULL);
|
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
|
|
|
|
2015-07-22 10:44:44 +10:00
|
|
|
udev_file = litest_init_device_udev_rules(*dev);
|
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
|
|
|
/* device has custom create method */
|
|
|
|
|
if ((*dev)->create) {
|
|
|
|
|
(*dev)->create(d);
|
2015-02-02 10:47:52 +10:00
|
|
|
if (abs_override || events_override) {
|
|
|
|
|
if (udev_file)
|
|
|
|
|
unlink(udev_file);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_abort_msg("Custom create cannot be overridden");
|
2015-02-02 10:47:52 +10:00
|
|
|
}
|
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
|
|
|
|
2015-07-27 10:54:36 +10:00
|
|
|
d->udev_rule_file = udev_file;
|
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
|
|
|
return d;
|
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
|
|
|
}
|
|
|
|
|
|
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
|
|
|
abs = merge_absinfo((*dev)->absinfo, abs_override);
|
|
|
|
|
events = merge_events((*dev)->events, events_override);
|
|
|
|
|
name = name_override ? name_override : (*dev)->name;
|
|
|
|
|
id = id_override ? id_override : (*dev)->id;
|
|
|
|
|
|
|
|
|
|
d->uinput = litest_create_uinput_device_from_description(name,
|
|
|
|
|
id,
|
|
|
|
|
abs,
|
|
|
|
|
events);
|
|
|
|
|
d->interface = (*dev)->interface;
|
2015-02-02 10:47:52 +10:00
|
|
|
d->udev_rule_file = udev_file;
|
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
|
|
|
free(abs);
|
|
|
|
|
free(events);
|
|
|
|
|
|
|
|
|
|
return d;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-22 15:06:34 +01:00
|
|
|
struct libinput *
|
|
|
|
|
litest_create_context(void)
|
|
|
|
|
{
|
|
|
|
|
struct libinput *libinput =
|
|
|
|
|
libinput_path_create_context(&interface, NULL);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_notnull(libinput);
|
2014-06-18 19:51:19 +10:00
|
|
|
|
|
|
|
|
libinput_log_set_handler(libinput, litest_log_handler);
|
|
|
|
|
if (verbose)
|
|
|
|
|
libinput_log_set_priority(libinput, LIBINPUT_LOG_PRIORITY_DEBUG);
|
|
|
|
|
|
2014-02-22 15:06:34 +01:00
|
|
|
return libinput;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-13 09:32:37 +10:00
|
|
|
void
|
|
|
|
|
litest_disable_log_handler(struct libinput *libinput)
|
|
|
|
|
{
|
|
|
|
|
libinput_log_set_handler(libinput, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_restore_log_handler(struct libinput *libinput)
|
|
|
|
|
{
|
|
|
|
|
libinput_log_set_handler(libinput, litest_log_handler);
|
|
|
|
|
}
|
|
|
|
|
|
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 *
|
2014-02-22 15:06:34 +01:00
|
|
|
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)
|
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 *d;
|
|
|
|
|
int fd;
|
|
|
|
|
int rc;
|
|
|
|
|
const char *path;
|
|
|
|
|
|
|
|
|
|
d = litest_create(which,
|
|
|
|
|
name_override,
|
|
|
|
|
id_override,
|
|
|
|
|
abs_override,
|
|
|
|
|
events_override);
|
|
|
|
|
|
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
|
|
|
path = libevdev_uinput_get_devnode(d->uinput);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert(path != 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
|
|
|
fd = open(path, O_RDWR|O_NONBLOCK);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_ne(fd, -1);
|
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
|
|
|
|
|
|
|
|
rc = libevdev_new_from_fd(fd, &d->evdev);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_eq(rc, 0);
|
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-02-22 15:06:34 +01:00
|
|
|
d->libinput = libinput;
|
2014-01-29 15:38:48 +10:00
|
|
|
d->libinput_device = libinput_path_add_device(d->libinput, path);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert(d->libinput_device != NULL);
|
2014-01-29 15:38:48 +10:00
|
|
|
libinput_device_ref(d->libinput_device);
|
|
|
|
|
|
2014-03-31 10:00:16 +10:00
|
|
|
if (d->interface) {
|
|
|
|
|
d->interface->min[ABS_X] = libevdev_get_abs_minimum(d->evdev, ABS_X);
|
|
|
|
|
d->interface->max[ABS_X] = libevdev_get_abs_maximum(d->evdev, ABS_X);
|
|
|
|
|
d->interface->min[ABS_Y] = libevdev_get_abs_minimum(d->evdev, ABS_Y);
|
|
|
|
|
d->interface->max[ABS_Y] = libevdev_get_abs_maximum(d->evdev, ABS_Y);
|
|
|
|
|
}
|
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
|
|
|
return d;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-29 14:08:46 +10:00
|
|
|
struct litest_device *
|
|
|
|
|
litest_add_device(struct libinput *libinput,
|
|
|
|
|
enum litest_device_type which)
|
|
|
|
|
{
|
|
|
|
|
return litest_add_device_with_overrides(libinput,
|
|
|
|
|
which,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-22 15:06:34 +01:00
|
|
|
struct litest_device *
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev =
|
|
|
|
|
litest_add_device_with_overrides(litest_create_context(),
|
|
|
|
|
which,
|
|
|
|
|
name_override,
|
|
|
|
|
id_override,
|
|
|
|
|
abs_override,
|
|
|
|
|
events_override);
|
|
|
|
|
dev->owns_context = true;
|
|
|
|
|
return dev;
|
|
|
|
|
}
|
|
|
|
|
|
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 *
|
|
|
|
|
litest_create_device(enum litest_device_type which)
|
|
|
|
|
{
|
|
|
|
|
return litest_create_device_with_overrides(which, NULL, NULL, NULL, 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
|
|
|
int
|
|
|
|
|
litest_handle_events(struct litest_device *d)
|
|
|
|
|
{
|
|
|
|
|
struct pollfd fd;
|
|
|
|
|
|
|
|
|
|
fd.fd = libinput_get_fd(d->libinput);
|
|
|
|
|
fd.events = POLLIN;
|
|
|
|
|
|
|
|
|
|
while (poll(&fd, 1, 1))
|
|
|
|
|
libinput_dispatch(d->libinput);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_delete_device(struct litest_device *d)
|
|
|
|
|
{
|
|
|
|
|
if (!d)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-02-02 10:47:52 +10:00
|
|
|
if (d->udev_rule_file) {
|
|
|
|
|
unlink(d->udev_rule_file);
|
|
|
|
|
free(d->udev_rule_file);
|
|
|
|
|
d->udev_rule_file = NULL;
|
2015-07-22 10:44:44 +10:00
|
|
|
litest_reload_udev_rules();
|
2015-02-02 10:47:52 +10:00
|
|
|
}
|
|
|
|
|
|
2014-01-29 15:38:48 +10:00
|
|
|
libinput_device_unref(d->libinput_device);
|
2014-07-14 00:04:14 +02:00
|
|
|
libinput_path_remove_device(d->libinput_device);
|
2014-02-22 15:06:34 +01:00
|
|
|
if (d->owns_context)
|
2014-06-25 00:06:58 +02:00
|
|
|
libinput_unref(d->libinput);
|
2016-02-04 21:08:30 +10:00
|
|
|
close(libevdev_get_fd(d->evdev));
|
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
|
|
|
libevdev_free(d->evdev);
|
|
|
|
|
libevdev_uinput_destroy(d->uinput);
|
2014-07-24 13:18:56 +10:00
|
|
|
free(d->private);
|
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
|
|
|
memset(d,0, sizeof(*d));
|
|
|
|
|
free(d);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_event(struct litest_device *d, unsigned int type,
|
|
|
|
|
unsigned int code, int value)
|
|
|
|
|
{
|
2014-09-17 10:07:38 +10:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
if (d->skip_ev_syn && type == EV_SYN && code == SYN_REPORT)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ret = libevdev_uinput_write_event(d->uinput, type, code, value);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_eq(ret, 0);
|
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
|
|
|
static bool
|
2015-12-10 16:05:37 +10:00
|
|
|
axis_replacement_value(struct litest_device *d,
|
|
|
|
|
struct axis_replacement *axes,
|
2015-07-06 16:26:21 +10:00
|
|
|
int32_t evcode,
|
|
|
|
|
int32_t *value)
|
2015-06-22 12:48:04 +02:00
|
|
|
{
|
|
|
|
|
struct axis_replacement *axis = axes;
|
|
|
|
|
|
2015-07-22 12:22:33 +10:00
|
|
|
if (!axes)
|
|
|
|
|
return false;
|
|
|
|
|
|
2015-06-22 12:48:04 +02:00
|
|
|
while (axis->evcode != -1) {
|
2015-07-06 16:26:21 +10:00
|
|
|
if (axis->evcode == evcode) {
|
2015-12-10 16:05:37 +10:00
|
|
|
*value = litest_scale(d, evcode, axis->value);
|
2015-07-06 16:26:21 +10:00
|
|
|
return true;
|
|
|
|
|
}
|
2015-06-22 12:48:04 +02:00
|
|
|
axis++;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-06 16:26:21 +10:00
|
|
|
return false;
|
2015-06-22 12:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-24 13:18:56 +10:00
|
|
|
int
|
|
|
|
|
litest_auto_assign_value(struct litest_device *d,
|
|
|
|
|
const struct input_event *ev,
|
2015-05-06 19:41:25 -04:00
|
|
|
int slot, double x, double y,
|
2015-06-22 12:48:04 +02:00
|
|
|
struct axis_replacement *axes,
|
2015-05-06 19:41:25 -04:00
|
|
|
bool touching)
|
2014-03-31 10:00:16 +10:00
|
|
|
{
|
|
|
|
|
static int tracking_id;
|
|
|
|
|
int value = ev->value;
|
|
|
|
|
|
|
|
|
|
if (value != LITEST_AUTO_ASSIGN || ev->type != EV_ABS)
|
|
|
|
|
return value;
|
|
|
|
|
|
|
|
|
|
switch (ev->code) {
|
|
|
|
|
case ABS_X:
|
|
|
|
|
case ABS_MT_POSITION_X:
|
|
|
|
|
value = litest_scale(d, ABS_X, x);
|
|
|
|
|
break;
|
|
|
|
|
case ABS_Y:
|
|
|
|
|
case ABS_MT_POSITION_Y:
|
|
|
|
|
value = litest_scale(d, ABS_Y, y);
|
|
|
|
|
break;
|
|
|
|
|
case ABS_MT_TRACKING_ID:
|
|
|
|
|
value = ++tracking_id;
|
|
|
|
|
break;
|
|
|
|
|
case ABS_MT_SLOT:
|
|
|
|
|
value = slot;
|
|
|
|
|
break;
|
2015-05-06 19:41:25 -04:00
|
|
|
case ABS_MT_DISTANCE:
|
|
|
|
|
value = touching ? 0 : 1;
|
|
|
|
|
break;
|
2015-06-22 12:48:04 +02:00
|
|
|
default:
|
2015-12-10 16:05:37 +10:00
|
|
|
if (!axis_replacement_value(d, axes, ev->code, &value) &&
|
2015-07-06 16:26:21 +10:00
|
|
|
d->interface->get_axis_default)
|
|
|
|
|
d->interface->get_axis_default(d, ev->code, &value);
|
2015-06-22 12:48:04 +02:00
|
|
|
break;
|
2014-03-31 10:00:16 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-21 12:30:40 +10:00
|
|
|
static void
|
2015-12-02 09:48:01 +10:00
|
|
|
send_btntool(struct litest_device *d, bool hover)
|
2014-07-21 12:30:40 +10:00
|
|
|
{
|
2015-12-02 09:48:01 +10:00
|
|
|
litest_event(d, EV_KEY, BTN_TOUCH, d->ntouches_down != 0 && !hover);
|
2014-07-21 12:30:40 +10:00
|
|
|
litest_event(d, EV_KEY, BTN_TOOL_FINGER, d->ntouches_down == 1);
|
|
|
|
|
litest_event(d, EV_KEY, BTN_TOOL_DOUBLETAP, d->ntouches_down == 2);
|
|
|
|
|
litest_event(d, EV_KEY, BTN_TOOL_TRIPLETAP, d->ntouches_down == 3);
|
|
|
|
|
litest_event(d, EV_KEY, BTN_TOOL_QUADTAP, d->ntouches_down == 4);
|
|
|
|
|
litest_event(d, EV_KEY, BTN_TOOL_QUINTTAP, d->ntouches_down == 5);
|
|
|
|
|
}
|
2014-03-31 10:00:16 +10:00
|
|
|
|
2015-05-06 19:41:25 -04:00
|
|
|
static void
|
2015-06-22 12:48:04 +02:00
|
|
|
litest_slot_start(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
struct axis_replacement *axes,
|
|
|
|
|
bool touching)
|
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-03-31 10:00:16 +10:00
|
|
|
struct input_event *ev;
|
|
|
|
|
|
2015-02-19 07:22:59 +10:00
|
|
|
assert(d->ntouches_down >= 0);
|
|
|
|
|
d->ntouches_down++;
|
2014-07-21 12:30:40 +10:00
|
|
|
|
2015-12-02 09:48:01 +10:00
|
|
|
send_btntool(d, !touching);
|
2014-07-21 12:30:40 +10:00
|
|
|
|
2014-03-31 10:00:16 +10:00
|
|
|
if (d->interface->touch_down) {
|
|
|
|
|
d->interface->touch_down(d, slot, x, y);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ev = d->interface->touch_down_events;
|
|
|
|
|
while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) {
|
2015-05-06 19:41:25 -04:00
|
|
|
int value = litest_auto_assign_value(d,
|
|
|
|
|
ev,
|
|
|
|
|
slot,
|
|
|
|
|
x,
|
|
|
|
|
y,
|
2015-06-22 12:48:04 +02:00
|
|
|
axes,
|
2015-05-06 19:41:25 -04:00
|
|
|
touching);
|
2015-08-20 13:43:40 +02:00
|
|
|
if (value != LITEST_AUTO_ASSIGN)
|
|
|
|
|
litest_event(d, ev->type, ev->code, value);
|
2014-03-31 10:00:16 +10:00
|
|
|
ev++;
|
|
|
|
|
}
|
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-06 19:41:25 -04:00
|
|
|
void
|
2015-06-22 12:48:04 +02:00
|
|
|
litest_touch_down(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x,
|
|
|
|
|
double y)
|
2015-05-06 19:41:25 -04:00
|
|
|
{
|
2015-06-22 12:48:04 +02:00
|
|
|
litest_slot_start(d, slot, x, y, NULL, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_touch_down_extended(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
struct axis_replacement *axes)
|
|
|
|
|
{
|
|
|
|
|
litest_slot_start(d, slot, x, y, axes, true);
|
2015-05-06 19:41:25 -04: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
|
|
|
void
|
|
|
|
|
litest_touch_up(struct litest_device *d, unsigned int slot)
|
|
|
|
|
{
|
|
|
|
|
struct input_event *ev;
|
|
|
|
|
struct input_event up[] = {
|
2014-03-31 10:00:16 +10:00
|
|
|
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
|
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
|
|
|
{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = -1 },
|
|
|
|
|
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
|
2014-03-31 10:00:16 +10:00
|
|
|
{ .type = -1, .code = -1 }
|
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-17 11:21:23 +10:00
|
|
|
litest_assert_int_gt(d->ntouches_down, 0);
|
2015-02-19 07:22:59 +10:00
|
|
|
d->ntouches_down--;
|
2014-07-21 12:30:40 +10:00
|
|
|
|
2015-12-02 09:48:01 +10:00
|
|
|
send_btntool(d, false);
|
2014-07-21 12:30:40 +10:00
|
|
|
|
2014-03-24 15:25:32 +10:00
|
|
|
if (d->interface->touch_up) {
|
|
|
|
|
d->interface->touch_up(d, slot);
|
2014-03-31 10:00:16 +10:00
|
|
|
return;
|
|
|
|
|
} else if (d->interface->touch_up_events) {
|
|
|
|
|
ev = d->interface->touch_up_events;
|
|
|
|
|
} else
|
|
|
|
|
ev = up;
|
|
|
|
|
|
|
|
|
|
while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) {
|
2015-05-06 19:41:25 -04:00
|
|
|
int value = litest_auto_assign_value(d,
|
|
|
|
|
ev,
|
|
|
|
|
slot,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
2015-06-22 12:48:04 +02:00
|
|
|
NULL,
|
2015-05-06 19:41:25 -04:00
|
|
|
false);
|
2014-03-31 10:00:16 +10:00
|
|
|
litest_event(d, ev->type, ev->code, value);
|
|
|
|
|
ev++;
|
2014-03-24 15:25:32 +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
|
|
|
}
|
|
|
|
|
|
2015-05-06 19:41:25 -04:00
|
|
|
static void
|
2015-06-22 12:48:04 +02:00
|
|
|
litest_slot_move(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
struct axis_replacement *axes,
|
|
|
|
|
bool touching)
|
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-03-31 10:00:16 +10:00
|
|
|
struct input_event *ev;
|
|
|
|
|
|
|
|
|
|
if (d->interface->touch_move) {
|
|
|
|
|
d->interface->touch_move(d, slot, x, y);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ev = d->interface->touch_move_events;
|
|
|
|
|
while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) {
|
2015-05-06 19:41:25 -04:00
|
|
|
int value = litest_auto_assign_value(d,
|
|
|
|
|
ev,
|
|
|
|
|
slot,
|
|
|
|
|
x,
|
|
|
|
|
y,
|
2015-06-22 12:48:04 +02:00
|
|
|
axes,
|
2015-05-06 19:41:25 -04:00
|
|
|
touching);
|
2015-08-20 13:43:40 +02:00
|
|
|
if (value != LITEST_AUTO_ASSIGN)
|
|
|
|
|
litest_event(d, ev->type, ev->code, value);
|
2014-03-31 10:00:16 +10:00
|
|
|
ev++;
|
|
|
|
|
}
|
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-06 19:41:25 -04:00
|
|
|
void
|
2015-06-22 12:48:04 +02:00
|
|
|
litest_touch_move(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x,
|
|
|
|
|
double y)
|
|
|
|
|
{
|
|
|
|
|
litest_slot_move(d, slot, x, y, NULL, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_touch_move_extended(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
struct axis_replacement *axes)
|
2015-05-06 19:41:25 -04:00
|
|
|
{
|
2015-06-22 12:48:04 +02:00
|
|
|
litest_slot_move(d, slot, x, y, axes, true);
|
2015-05-06 19:41:25 -04: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
|
|
|
void
|
2016-03-30 11:36:59 +10:00
|
|
|
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,
|
|
|
|
|
int steps, int sleep_ms)
|
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-09-25 13:20:47 +02:00
|
|
|
for (int i = 0; i < steps - 1; i++) {
|
2016-03-30 11:36:59 +10:00
|
|
|
litest_touch_move_extended(d, slot,
|
|
|
|
|
x_from + (x_to - x_from)/steps * i,
|
|
|
|
|
y_from + (y_to - y_from)/steps * i,
|
|
|
|
|
axes);
|
2014-09-25 13:20:47 +02:00
|
|
|
if (sleep_ms) {
|
|
|
|
|
libinput_dispatch(d->libinput);
|
|
|
|
|
msleep(sleep_ms);
|
|
|
|
|
libinput_dispatch(d->libinput);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-03-30 11:36:59 +10:00
|
|
|
litest_touch_move_extended(d, slot, x_to, y_to, 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,
|
|
|
|
|
int steps, int sleep_ms)
|
|
|
|
|
{
|
|
|
|
|
litest_touch_move_to_extended(d, slot,
|
|
|
|
|
x_from, y_from,
|
|
|
|
|
x_to, y_to,
|
|
|
|
|
NULL,
|
|
|
|
|
steps, sleep_ms);
|
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
|
|
|
static int
|
|
|
|
|
auto_assign_tablet_value(struct litest_device *d,
|
|
|
|
|
const struct input_event *ev,
|
|
|
|
|
int x, int y,
|
|
|
|
|
struct axis_replacement *axes)
|
|
|
|
|
{
|
|
|
|
|
int value = ev->value;
|
|
|
|
|
|
|
|
|
|
if (value != LITEST_AUTO_ASSIGN || ev->type != EV_ABS)
|
|
|
|
|
return value;
|
|
|
|
|
|
|
|
|
|
switch (ev->code) {
|
|
|
|
|
case ABS_X:
|
|
|
|
|
value = litest_scale(d, ABS_X, x);
|
|
|
|
|
break;
|
|
|
|
|
case ABS_Y:
|
|
|
|
|
value = litest_scale(d, ABS_Y, y);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2015-12-11 17:39:57 +10:00
|
|
|
if (!axis_replacement_value(d, axes, ev->code, &value) &&
|
|
|
|
|
d->interface->get_axis_default)
|
|
|
|
|
d->interface->get_axis_default(d, ev->code, &value);
|
2014-04-21 19:11:27 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
tablet_ignore_event(const struct input_event *ev, int value)
|
|
|
|
|
{
|
|
|
|
|
return value == -1 && (ev->code == ABS_PRESSURE || ev->code == ABS_DISTANCE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_tablet_proximity_in(struct litest_device *d, int x, int y, struct axis_replacement *axes)
|
|
|
|
|
{
|
|
|
|
|
struct input_event *ev;
|
|
|
|
|
|
|
|
|
|
ev = d->interface->tablet_proximity_in_events;
|
|
|
|
|
while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) {
|
|
|
|
|
int value = auto_assign_tablet_value(d, ev, x, y, axes);
|
|
|
|
|
if (!tablet_ignore_event(ev, value))
|
|
|
|
|
litest_event(d, ev->type, ev->code, value);
|
|
|
|
|
ev++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_tablet_proximity_out(struct litest_device *d)
|
|
|
|
|
{
|
|
|
|
|
struct input_event *ev;
|
|
|
|
|
|
|
|
|
|
ev = d->interface->tablet_proximity_out_events;
|
|
|
|
|
while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) {
|
|
|
|
|
int value = auto_assign_tablet_value(d, ev, -1, -1, NULL);
|
|
|
|
|
if (!tablet_ignore_event(ev, value))
|
|
|
|
|
litest_event(d, ev->type, ev->code, value);
|
|
|
|
|
ev++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_tablet_motion(struct litest_device *d, int x, int y, struct axis_replacement *axes)
|
|
|
|
|
{
|
|
|
|
|
struct input_event *ev;
|
|
|
|
|
|
|
|
|
|
ev = d->interface->tablet_motion_events;
|
|
|
|
|
while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) {
|
|
|
|
|
int value = auto_assign_tablet_value(d, ev, x, y, axes);
|
|
|
|
|
if (!tablet_ignore_event(ev, value))
|
|
|
|
|
litest_event(d, ev->type, ev->code, value);
|
|
|
|
|
ev++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-12 20:05:25 +01:00
|
|
|
void
|
|
|
|
|
litest_touch_move_two_touches(struct litest_device *d,
|
|
|
|
|
double x0, double y0,
|
|
|
|
|
double x1, double y1,
|
|
|
|
|
double dx, double dy,
|
|
|
|
|
int steps, int sleep_ms)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < steps - 1; i++) {
|
2016-01-22 11:36:40 +10:00
|
|
|
litest_push_event_frame(d);
|
2015-03-12 20:05:25 +01:00
|
|
|
litest_touch_move(d, 0, x0 + dx / steps * i,
|
|
|
|
|
y0 + dy / steps * i);
|
|
|
|
|
litest_touch_move(d, 1, x1 + dx / steps * i,
|
|
|
|
|
y1 + dy / steps * i);
|
2016-01-22 11:36:40 +10:00
|
|
|
litest_pop_event_frame(d);
|
2015-03-12 20:05:25 +01:00
|
|
|
if (sleep_ms) {
|
|
|
|
|
libinput_dispatch(d->libinput);
|
|
|
|
|
msleep(sleep_ms);
|
|
|
|
|
}
|
2015-12-07 11:39:52 +10:00
|
|
|
libinput_dispatch(d->libinput);
|
2015-03-12 20:05:25 +01:00
|
|
|
}
|
2016-01-22 11:36:40 +10:00
|
|
|
litest_push_event_frame(d);
|
2015-03-12 20:05:25 +01:00
|
|
|
litest_touch_move(d, 0, x0 + dx, y0 + dy);
|
|
|
|
|
litest_touch_move(d, 1, x1 + dx, y1 + dy);
|
2016-01-22 11:36:40 +10:00
|
|
|
litest_pop_event_frame(d);
|
2015-03-12 20:05:25 +01:00
|
|
|
}
|
|
|
|
|
|
2015-07-07 11:52:05 +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,
|
|
|
|
|
int steps, int sleep_ms)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < steps - 1; i++) {
|
|
|
|
|
litest_touch_move(d, 0, x0 + dx / steps * i,
|
|
|
|
|
y0 + dy / steps * i);
|
|
|
|
|
litest_touch_move(d, 1, x1 + dx / steps * i,
|
|
|
|
|
y1 + dy / steps * i);
|
|
|
|
|
litest_touch_move(d, 2, x2 + dx / steps * i,
|
|
|
|
|
y2 + dy / steps * i);
|
|
|
|
|
if (sleep_ms) {
|
|
|
|
|
libinput_dispatch(d->libinput);
|
|
|
|
|
msleep(sleep_ms);
|
|
|
|
|
libinput_dispatch(d->libinput);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
litest_touch_move(d, 0, x0 + dx, y0 + dy);
|
|
|
|
|
litest_touch_move(d, 1, x1 + dx, y1 + dy);
|
|
|
|
|
litest_touch_move(d, 2, x2 + dx, y2 + dy);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-06 19:41:25 -04:00
|
|
|
void
|
2015-06-22 12:48:04 +02:00
|
|
|
litest_hover_start(struct litest_device *d,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x,
|
|
|
|
|
double y)
|
2015-05-06 19:41:25 -04:00
|
|
|
{
|
2015-06-22 12:48:04 +02:00
|
|
|
litest_slot_start(d, slot, x, y, NULL, 0);
|
2015-05-06 19:41:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_hover_end(struct litest_device *d, unsigned int slot)
|
|
|
|
|
{
|
|
|
|
|
struct input_event *ev;
|
|
|
|
|
struct input_event up[] = {
|
|
|
|
|
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
|
|
|
|
|
{ .type = EV_ABS, .code = ABS_MT_DISTANCE, .value = 1 },
|
|
|
|
|
{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = -1 },
|
|
|
|
|
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
|
|
|
|
|
{ .type = -1, .code = -1 }
|
|
|
|
|
};
|
|
|
|
|
|
2015-06-17 11:21:23 +10:00
|
|
|
litest_assert_int_gt(d->ntouches_down, 0);
|
2015-05-06 19:41:25 -04:00
|
|
|
d->ntouches_down--;
|
|
|
|
|
|
2015-12-02 09:48:01 +10:00
|
|
|
send_btntool(d, true);
|
2015-05-06 19:41:25 -04:00
|
|
|
|
|
|
|
|
if (d->interface->touch_up) {
|
|
|
|
|
d->interface->touch_up(d, slot);
|
|
|
|
|
return;
|
|
|
|
|
} else if (d->interface->touch_up_events) {
|
|
|
|
|
ev = d->interface->touch_up_events;
|
|
|
|
|
} else
|
|
|
|
|
ev = up;
|
|
|
|
|
|
|
|
|
|
while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) {
|
2015-06-22 12:48:04 +02:00
|
|
|
int value = litest_auto_assign_value(d, ev, slot, 0, 0, NULL, false);
|
2015-05-06 19:41:25 -04:00
|
|
|
litest_event(d, ev->type, ev->code, value);
|
|
|
|
|
ev++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_hover_move(struct litest_device *d, unsigned int slot,
|
|
|
|
|
double x, double y)
|
|
|
|
|
{
|
2015-06-22 12:48:04 +02:00
|
|
|
litest_slot_move(d, slot, x, y, NULL, false);
|
2015-05-06 19:41:25 -04: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,
|
|
|
|
|
int steps, int sleep_ms)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < steps - 1; i++) {
|
|
|
|
|
litest_hover_move(d, slot,
|
|
|
|
|
x_from + (x_to - x_from)/steps * i,
|
|
|
|
|
y_from + (y_to - y_from)/steps * i);
|
|
|
|
|
if (sleep_ms) {
|
|
|
|
|
libinput_dispatch(d->libinput);
|
|
|
|
|
msleep(sleep_ms);
|
|
|
|
|
libinput_dispatch(d->libinput);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
litest_hover_move(d, slot, x_to, y_to);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_hover_move_two_touches(struct litest_device *d,
|
|
|
|
|
double x0, double y0,
|
|
|
|
|
double x1, double y1,
|
|
|
|
|
double dx, double dy,
|
|
|
|
|
int steps, int sleep_ms)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < steps - 1; i++) {
|
|
|
|
|
litest_push_event_frame(d);
|
|
|
|
|
litest_hover_move(d, 0, x0 + dx / steps * i,
|
|
|
|
|
y0 + dy / steps * i);
|
|
|
|
|
litest_hover_move(d, 1, x1 + dx / steps * i,
|
|
|
|
|
y1 + dy / steps * i);
|
|
|
|
|
litest_pop_event_frame(d);
|
|
|
|
|
if (sleep_ms) {
|
|
|
|
|
libinput_dispatch(d->libinput);
|
|
|
|
|
msleep(sleep_ms);
|
|
|
|
|
libinput_dispatch(d->libinput);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
litest_push_event_frame(d);
|
|
|
|
|
litest_hover_move(d, 0, x0 + dx, y0 + dy);
|
|
|
|
|
litest_hover_move(d, 1, x1 + dx, y1 + dy);
|
|
|
|
|
litest_pop_event_frame(d);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
2014-03-25 22:56:58 +01:00
|
|
|
litest_button_click(struct litest_device *d, unsigned int button, bool is_press)
|
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 input_event *ev;
|
|
|
|
|
struct input_event click[] = {
|
|
|
|
|
{ .type = EV_KEY, .code = button, .value = is_press ? 1 : 0 },
|
|
|
|
|
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ARRAY_FOR_EACH(click, ev)
|
|
|
|
|
litest_event(d, ev->type, ev->code, ev->value);
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-06 16:32:53 +01:00
|
|
|
void
|
|
|
|
|
litest_button_scroll(struct litest_device *dev,
|
|
|
|
|
unsigned int button,
|
|
|
|
|
double dx, double dy)
|
|
|
|
|
{
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
litest_button_click(dev, button, 1);
|
|
|
|
|
|
|
|
|
|
libinput_dispatch(li);
|
|
|
|
|
litest_timeout_buttonscroll();
|
|
|
|
|
libinput_dispatch(li);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, dx);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, dy);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
|
|
|
|
litest_button_click(dev, button, 0);
|
|
|
|
|
|
|
|
|
|
libinput_dispatch(li);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 22:24:10 +02:00
|
|
|
void
|
|
|
|
|
litest_keyboard_key(struct litest_device *d, unsigned int key, bool is_press)
|
|
|
|
|
{
|
|
|
|
|
litest_button_click(d, key, is_press);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-10 16:05:37 +10:00
|
|
|
static int
|
|
|
|
|
litest_scale_axis(const struct litest_device *d,
|
|
|
|
|
unsigned int axis,
|
|
|
|
|
double val)
|
|
|
|
|
{
|
|
|
|
|
const struct input_absinfo *abs;
|
|
|
|
|
|
|
|
|
|
litest_assert_double_ge(val, 0.0);
|
|
|
|
|
litest_assert_double_le(val, 100.0);
|
|
|
|
|
|
|
|
|
|
abs = libevdev_get_abs_info(d->evdev, axis);
|
|
|
|
|
litest_assert_notnull(abs);
|
|
|
|
|
|
|
|
|
|
return (abs->maximum - abs->minimum) * val/100.0 + abs->minimum;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
|
int min, max;
|
2015-12-01 15:26:48 +10:00
|
|
|
litest_assert_double_ge(val, 0.0);
|
|
|
|
|
litest_assert_double_le(val, 100.0);
|
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-12-10 16:05:37 +10:00
|
|
|
if (axis <= ABS_Y) {
|
2015-12-10 16:05:37 +10:00
|
|
|
min = d->interface->min[axis];
|
|
|
|
|
max = d->interface->max[axis];
|
|
|
|
|
return (max - min) * val/100.0 + min;
|
|
|
|
|
} else {
|
|
|
|
|
return litest_scale_axis(d, axis, 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
|
|
|
}
|
2014-01-22 11:20:50 +10:00
|
|
|
|
2014-08-20 17:15:50 +10:00
|
|
|
void
|
|
|
|
|
litest_wait_for_event(struct libinput *li)
|
|
|
|
|
{
|
|
|
|
|
return litest_wait_for_event_of_type(li, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_wait_for_event_of_type(struct libinput *li, ...)
|
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
enum libinput_event_type types[32] = {LIBINPUT_EVENT_NONE};
|
|
|
|
|
size_t ntypes = 0;
|
|
|
|
|
enum libinput_event_type type;
|
2015-07-02 14:22:05 +10:00
|
|
|
struct pollfd fds;
|
2014-08-20 17:15:50 +10:00
|
|
|
|
|
|
|
|
va_start(args, li);
|
|
|
|
|
type = va_arg(args, int);
|
|
|
|
|
while ((int)type != -1) {
|
|
|
|
|
assert(type > 0);
|
|
|
|
|
assert(ntypes < ARRAY_LENGTH(types));
|
|
|
|
|
types[ntypes++] = type;
|
2014-09-01 12:39:38 +10:00
|
|
|
type = va_arg(args, int);
|
2014-08-20 17:15:50 +10:00
|
|
|
}
|
|
|
|
|
va_end(args);
|
|
|
|
|
|
2015-07-02 14:22:05 +10:00
|
|
|
fds.fd = libinput_get_fd(li);
|
|
|
|
|
fds.events = POLLIN;
|
|
|
|
|
fds.revents = 0;
|
|
|
|
|
|
2014-08-20 17:15:50 +10:00
|
|
|
while (1) {
|
|
|
|
|
size_t i;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
|
|
|
|
|
while ((type = libinput_next_event_type(li)) == LIBINPUT_EVENT_NONE) {
|
2015-07-02 14:22:05 +10:00
|
|
|
poll(&fds, 1, -1);
|
2014-08-20 17:15:50 +10:00
|
|
|
libinput_dispatch(li);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* no event mask means wait for any event */
|
|
|
|
|
if (ntypes == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ntypes; i++) {
|
|
|
|
|
if (type == types[i])
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-22 11:20:50 +10:00
|
|
|
void
|
|
|
|
|
litest_drain_events(struct libinput *li)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
|
|
|
|
|
libinput_dispatch(li);
|
|
|
|
|
while ((event = libinput_get_event(li))) {
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
libinput_dispatch(li);
|
|
|
|
|
}
|
|
|
|
|
}
|
test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.
The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.
Both functions abort on failure, so the caller does not need to check the
return value.
Example code for creating a rel device:
struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
EV_REL, REL_X,
EV_REL, REL_Y,
EV_KEY, BTN_LEFT,
INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
-1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
...
libevdev_uinput_destroy(uinput);
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-03-26 20:09:42 +10:00
|
|
|
|
2014-12-11 14:02:37 +10:00
|
|
|
static const char *
|
|
|
|
|
litest_event_type_str(struct libinput_event *event)
|
|
|
|
|
{
|
|
|
|
|
const char *str = NULL;
|
|
|
|
|
|
|
|
|
|
switch (libinput_event_get_type(event)) {
|
|
|
|
|
case LIBINPUT_EVENT_NONE:
|
|
|
|
|
abort();
|
|
|
|
|
case LIBINPUT_EVENT_DEVICE_ADDED:
|
|
|
|
|
str = "ADDED";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_DEVICE_REMOVED:
|
|
|
|
|
str = "REMOVED";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_KEYBOARD_KEY:
|
|
|
|
|
str = "KEY";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_POINTER_MOTION:
|
|
|
|
|
str = "MOTION";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
|
|
|
|
|
str = "ABSOLUTE";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_POINTER_BUTTON:
|
|
|
|
|
str = "BUTTON";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_POINTER_AXIS:
|
|
|
|
|
str = "AXIS";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_DOWN:
|
|
|
|
|
str = "TOUCH DOWN";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_UP:
|
|
|
|
|
str = "TOUCH UP";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_MOTION:
|
|
|
|
|
str = "TOUCH MOTION";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_CANCEL:
|
|
|
|
|
str = "TOUCH CANCEL";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_FRAME:
|
|
|
|
|
str = "TOUCH FRAME";
|
|
|
|
|
break;
|
2015-01-22 16:41:50 +01:00
|
|
|
case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN:
|
|
|
|
|
str = "GESTURE SWIPE START";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
|
|
|
|
|
str = "GESTURE SWIPE UPDATE";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_GESTURE_SWIPE_END:
|
|
|
|
|
str = "GESTURE SWIPE END";
|
|
|
|
|
break;
|
2015-03-04 15:24:04 +01:00
|
|
|
case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN:
|
|
|
|
|
str = "GESTURE PINCH START";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
|
|
|
|
|
str = "GESTURE PINCH UPDATE";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_GESTURE_PINCH_END:
|
|
|
|
|
str = "GESTURE PINCH END";
|
|
|
|
|
break;
|
2015-11-16 16:27:46 +10:00
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_AXIS:
|
2016-02-03 17:11:42 +10:00
|
|
|
str = "TABLET TOOL AXIS";
|
2014-12-18 09:39:46 +10:00
|
|
|
break;
|
2015-11-16 16:27:46 +10:00
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY:
|
2016-02-03 17:11:42 +10:00
|
|
|
str = "TABLET TOOL PROX";
|
2014-12-18 09:39:46 +10:00
|
|
|
break;
|
2015-11-16 16:27:46 +10:00
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_TIP:
|
2016-02-03 17:11:42 +10:00
|
|
|
str = "TABLET TOOL TIP";
|
2015-11-11 13:39:43 +10:00
|
|
|
break;
|
2015-11-16 16:27:46 +10:00
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_BUTTON:
|
2016-02-03 17:11:42 +10:00
|
|
|
str = "TABLET TOOL BUTTON";
|
2014-12-18 09:39:46 +10:00
|
|
|
break;
|
2016-01-21 12:35:11 +10:00
|
|
|
case LIBINPUT_EVENT_TABLET_PAD_BUTTON:
|
|
|
|
|
str = "TABLET PAD BUTTON";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_TABLET_PAD_RING:
|
|
|
|
|
str = "TABLET PAD RING";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_TABLET_PAD_STRIP:
|
|
|
|
|
str = "TABLET PAD STRIP";
|
|
|
|
|
break;
|
2014-12-11 14:02:37 +10:00
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-06 10:58:11 +10:00
|
|
|
static void
|
|
|
|
|
litest_print_event(struct libinput_event *event)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event_pointer *p;
|
2015-11-16 16:28:55 +10:00
|
|
|
struct libinput_event_tablet_tool *t;
|
2014-06-06 10:58:11 +10:00
|
|
|
struct libinput_device *dev;
|
|
|
|
|
enum libinput_event_type type;
|
|
|
|
|
double x, y;
|
|
|
|
|
|
|
|
|
|
dev = libinput_event_get_device(event);
|
|
|
|
|
type = libinput_event_get_type(event);
|
|
|
|
|
|
|
|
|
|
fprintf(stderr,
|
2014-12-11 14:02:37 +10:00
|
|
|
"device %s type %s ",
|
2014-06-06 10:58:11 +10:00
|
|
|
libinput_device_get_sysname(dev),
|
2014-12-11 14:02:37 +10:00
|
|
|
litest_event_type_str(event));
|
2014-06-06 10:58:11 +10:00
|
|
|
switch (type) {
|
|
|
|
|
case LIBINPUT_EVENT_POINTER_MOTION:
|
|
|
|
|
p = libinput_event_get_pointer_event(event);
|
|
|
|
|
x = libinput_event_pointer_get_dx(p);
|
|
|
|
|
y = libinput_event_pointer_get_dy(p);
|
2014-12-11 14:02:37 +10:00
|
|
|
fprintf(stderr, "%.2f/%.2f", x, y);
|
2014-06-06 10:58:11 +10:00
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
|
|
|
|
|
p = libinput_event_get_pointer_event(event);
|
|
|
|
|
x = libinput_event_pointer_get_absolute_x(p);
|
|
|
|
|
y = libinput_event_pointer_get_absolute_y(p);
|
2014-12-11 14:02:37 +10:00
|
|
|
fprintf(stderr, "%.2f/%.2f", x, y);
|
2014-06-06 10:58:11 +10:00
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_POINTER_BUTTON:
|
|
|
|
|
p = libinput_event_get_pointer_event(event);
|
|
|
|
|
fprintf(stderr,
|
2014-12-11 14:02:37 +10:00
|
|
|
"button %d state %d",
|
2014-06-06 10:58:11 +10:00
|
|
|
libinput_event_pointer_get_button(p),
|
|
|
|
|
libinput_event_pointer_get_button_state(p));
|
|
|
|
|
break;
|
2014-12-11 14:11:27 +10:00
|
|
|
case LIBINPUT_EVENT_POINTER_AXIS:
|
|
|
|
|
p = libinput_event_get_pointer_event(event);
|
2015-08-05 09:45:45 +10:00
|
|
|
x = 0.0;
|
|
|
|
|
y = 0.0;
|
|
|
|
|
if (libinput_event_pointer_has_axis(p,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))
|
|
|
|
|
y = libinput_event_pointer_get_axis_value(p,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
|
|
|
|
|
if (libinput_event_pointer_has_axis(p,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))
|
|
|
|
|
x = libinput_event_pointer_get_axis_value(p,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
|
|
|
|
|
fprintf(stderr, "vert %.f horiz %.2f", y, x);
|
2014-12-11 14:11:27 +10:00
|
|
|
break;
|
2015-11-16 16:27:46 +10:00
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY:
|
2015-11-16 16:28:55 +10:00
|
|
|
t = libinput_event_get_tablet_tool_event(event);
|
2016-04-08 09:14:59 +10:00
|
|
|
fprintf(stderr, "proximity %d",
|
2015-11-16 16:28:55 +10:00
|
|
|
libinput_event_tablet_tool_get_proximity_state(t));
|
2015-11-11 14:05:18 +10:00
|
|
|
break;
|
2015-11-16 16:27:46 +10:00
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_TIP:
|
2015-11-16 16:28:55 +10:00
|
|
|
t = libinput_event_get_tablet_tool_event(event);
|
2016-04-08 09:14:59 +10:00
|
|
|
fprintf(stderr, "tip %d",
|
2015-11-16 16:28:55 +10:00
|
|
|
libinput_event_tablet_tool_get_tip_state(t));
|
2015-11-11 13:39:43 +10:00
|
|
|
break;
|
2015-11-16 16:27:46 +10:00
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_BUTTON:
|
2015-11-16 16:28:55 +10:00
|
|
|
t = libinput_event_get_tablet_tool_event(event);
|
2016-04-08 09:14:59 +10:00
|
|
|
fprintf(stderr, "button %d state %d",
|
2015-11-16 16:28:55 +10:00
|
|
|
libinput_event_tablet_tool_get_button(t),
|
|
|
|
|
libinput_event_tablet_tool_get_button_state(t));
|
2015-11-11 14:05:18 +10:00
|
|
|
break;
|
2014-06-06 10:58:11 +10:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_assert_empty_queue(struct libinput *li)
|
|
|
|
|
{
|
|
|
|
|
bool empty_queue = true;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
|
|
|
|
|
libinput_dispatch(li);
|
|
|
|
|
while ((event = libinput_get_event(li))) {
|
|
|
|
|
empty_queue = false;
|
|
|
|
|
fprintf(stderr,
|
|
|
|
|
"Unexpected event: ");
|
|
|
|
|
litest_print_event(event);
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
libinput_dispatch(li);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert(empty_queue);
|
2014-06-06 10:58:11 +10:00
|
|
|
}
|
|
|
|
|
|
2015-07-02 13:39:40 +10:00
|
|
|
static struct libevdev_uinput *
|
|
|
|
|
litest_create_uinput(const char *name,
|
|
|
|
|
const struct input_id *id,
|
|
|
|
|
const struct input_absinfo *abs_info,
|
|
|
|
|
const int *events)
|
test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.
The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.
Both functions abort on failure, so the caller does not need to check the
return value.
Example code for creating a rel device:
struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
EV_REL, REL_X,
EV_REL, REL_Y,
EV_KEY, BTN_LEFT,
INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
-1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
...
libevdev_uinput_destroy(uinput);
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-03-26 20:09:42 +10:00
|
|
|
{
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
struct libevdev *dev;
|
|
|
|
|
int type, code;
|
2014-07-15 15:35:20 +10:00
|
|
|
int rc, fd;
|
|
|
|
|
const struct input_absinfo *abs;
|
test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.
The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.
Both functions abort on failure, so the caller does not need to check the
return value.
Example code for creating a rel device:
struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
EV_REL, REL_X,
EV_REL, REL_Y,
EV_KEY, BTN_LEFT,
INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
-1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
...
libevdev_uinput_destroy(uinput);
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-03-26 20:09:42 +10:00
|
|
|
const struct input_absinfo default_abs = {
|
|
|
|
|
.value = 0,
|
|
|
|
|
.minimum = 0,
|
2016-04-07 15:44:23 +10:00
|
|
|
.maximum = 100,
|
test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.
The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.
Both functions abort on failure, so the caller does not need to check the
return value.
Example code for creating a rel device:
struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
EV_REL, REL_X,
EV_REL, REL_Y,
EV_KEY, BTN_LEFT,
INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
-1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
...
libevdev_uinput_destroy(uinput);
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-03-26 20:09:42 +10:00
|
|
|
.fuzz = 0,
|
|
|
|
|
.flat = 0,
|
|
|
|
|
.resolution = 100
|
|
|
|
|
};
|
2014-06-24 16:23:12 +02:00
|
|
|
char buf[512];
|
2014-07-15 15:35:20 +10:00
|
|
|
const char *devnode;
|
test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.
The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.
Both functions abort on failure, so the caller does not need to check the
return value.
Example code for creating a rel device:
struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
EV_REL, REL_X,
EV_REL, REL_Y,
EV_KEY, BTN_LEFT,
INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
-1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
...
libevdev_uinput_destroy(uinput);
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-03-26 20:09:42 +10:00
|
|
|
|
|
|
|
|
dev = libevdev_new();
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert(dev != NULL);
|
test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.
The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.
Both functions abort on failure, so the caller does not need to check the
return value.
Example code for creating a rel device:
struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
EV_REL, REL_X,
EV_REL, REL_Y,
EV_KEY, BTN_LEFT,
INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
-1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
...
libevdev_uinput_destroy(uinput);
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-03-26 20:09:42 +10:00
|
|
|
|
2014-06-24 16:23:12 +02:00
|
|
|
snprintf(buf, sizeof(buf), "litest %s", name);
|
|
|
|
|
libevdev_set_name(dev, buf);
|
test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.
The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.
Both functions abort on failure, so the caller does not need to check the
return value.
Example code for creating a rel device:
struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
EV_REL, REL_X,
EV_REL, REL_Y,
EV_KEY, BTN_LEFT,
INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
-1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
...
libevdev_uinput_destroy(uinput);
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-03-26 20:09:42 +10:00
|
|
|
if (id) {
|
|
|
|
|
libevdev_set_id_bustype(dev, id->bustype);
|
|
|
|
|
libevdev_set_id_vendor(dev, id->vendor);
|
|
|
|
|
libevdev_set_id_product(dev, id->product);
|
2015-01-28 15:59:03 +10:00
|
|
|
libevdev_set_id_version(dev, id->version);
|
test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.
The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.
Both functions abort on failure, so the caller does not need to check the
return value.
Example code for creating a rel device:
struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
EV_REL, REL_X,
EV_REL, REL_Y,
EV_KEY, BTN_LEFT,
INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
-1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
...
libevdev_uinput_destroy(uinput);
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-03-26 20:09:42 +10:00
|
|
|
}
|
|
|
|
|
|
2014-07-15 15:35:20 +10:00
|
|
|
abs = abs_info;
|
test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.
The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.
Both functions abort on failure, so the caller does not need to check the
return value.
Example code for creating a rel device:
struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
EV_REL, REL_X,
EV_REL, REL_Y,
EV_KEY, BTN_LEFT,
INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
-1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
...
libevdev_uinput_destroy(uinput);
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-03-26 20:09:42 +10:00
|
|
|
while (abs && abs->value != -1) {
|
|
|
|
|
rc = libevdev_enable_event_code(dev, EV_ABS,
|
|
|
|
|
abs->value, abs);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_eq(rc, 0);
|
test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.
The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.
Both functions abort on failure, so the caller does not need to check the
return value.
Example code for creating a rel device:
struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
EV_REL, REL_X,
EV_REL, REL_Y,
EV_KEY, BTN_LEFT,
INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
-1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
...
libevdev_uinput_destroy(uinput);
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-03-26 20:09:42 +10:00
|
|
|
abs++;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-31 10:00:16 +10:00
|
|
|
while (events &&
|
|
|
|
|
(type = *events++) != -1 &&
|
|
|
|
|
(code = *events++) != -1) {
|
test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.
The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.
Both functions abort on failure, so the caller does not need to check the
return value.
Example code for creating a rel device:
struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
EV_REL, REL_X,
EV_REL, REL_Y,
EV_KEY, BTN_LEFT,
INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
-1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
...
libevdev_uinput_destroy(uinput);
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-03-26 20:09:42 +10:00
|
|
|
if (type == INPUT_PROP_MAX) {
|
|
|
|
|
rc = libevdev_enable_property(dev, code);
|
|
|
|
|
} else {
|
|
|
|
|
rc = libevdev_enable_event_code(dev, type, code,
|
|
|
|
|
type == EV_ABS ? &default_abs : NULL);
|
|
|
|
|
}
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_eq(rc, 0);
|
test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.
The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.
Both functions abort on failure, so the caller does not need to check the
return value.
Example code for creating a rel device:
struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
EV_REL, REL_X,
EV_REL, REL_Y,
EV_KEY, BTN_LEFT,
INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
-1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
...
libevdev_uinput_destroy(uinput);
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-03-26 20:09:42 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rc = libevdev_uinput_create_from_device(dev,
|
|
|
|
|
LIBEVDEV_UINPUT_OPEN_MANAGED,
|
|
|
|
|
&uinput);
|
2014-09-17 10:30:45 +10:00
|
|
|
/* workaround for a bug in libevdev pre-1.3
|
|
|
|
|
http://cgit.freedesktop.org/libevdev/commit/?id=debe9b030c8069cdf78307888ef3b65830b25122 */
|
|
|
|
|
if (rc == -EBADF)
|
|
|
|
|
rc = -EACCES;
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_msg(rc == 0, "Failed to create uinput device: %s", strerror(-rc));
|
test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.
The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.
Both functions abort on failure, so the caller does not need to check the
return value.
Example code for creating a rel device:
struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
EV_REL, REL_X,
EV_REL, REL_Y,
EV_KEY, BTN_LEFT,
INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
-1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
...
libevdev_uinput_destroy(uinput);
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-03-26 20:09:42 +10:00
|
|
|
|
|
|
|
|
libevdev_free(dev);
|
|
|
|
|
|
2014-07-15 15:35:20 +10:00
|
|
|
devnode = libevdev_uinput_get_devnode(uinput);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_notnull(devnode);
|
2014-07-15 15:35:20 +10:00
|
|
|
fd = open(devnode, O_RDONLY);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_gt(fd, -1);
|
2014-07-15 15:35:20 +10:00
|
|
|
rc = libevdev_new_from_fd(fd, &dev);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_eq(rc, 0);
|
2014-07-15 15:35:20 +10:00
|
|
|
|
2015-05-06 10:49:17 +10:00
|
|
|
/* uinput does not yet support setting the resolution, so we set it
|
|
|
|
|
* afterwards. This is of course racy as hell but the way we
|
|
|
|
|
* _generally_ use this function by the time libinput uses the
|
|
|
|
|
* device, we're finished here */
|
2014-07-15 15:35:20 +10:00
|
|
|
abs = abs_info;
|
|
|
|
|
while (abs && abs->value != -1) {
|
|
|
|
|
if (abs->resolution != 0) {
|
|
|
|
|
rc = libevdev_kernel_set_abs_info(dev,
|
|
|
|
|
abs->value,
|
|
|
|
|
abs);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_eq(rc, 0);
|
2014-07-15 15:35:20 +10:00
|
|
|
}
|
|
|
|
|
abs++;
|
|
|
|
|
}
|
|
|
|
|
close(fd);
|
|
|
|
|
libevdev_free(dev);
|
|
|
|
|
|
test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.
The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.
Both functions abort on failure, so the caller does not need to check the
return value.
Example code for creating a rel device:
struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
EV_REL, REL_X,
EV_REL, REL_Y,
EV_KEY, BTN_LEFT,
INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
-1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
...
libevdev_uinput_destroy(uinput);
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-03-26 20:09:42 +10:00
|
|
|
return uinput;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-02 13:39:40 +10:00
|
|
|
struct libevdev_uinput *
|
|
|
|
|
litest_create_uinput_device_from_description(const char *name,
|
|
|
|
|
const struct input_id *id,
|
|
|
|
|
const struct input_absinfo *abs_info,
|
|
|
|
|
const int *events)
|
|
|
|
|
{
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
const char *syspath;
|
|
|
|
|
|
|
|
|
|
struct udev *udev;
|
|
|
|
|
struct udev_monitor *udev_monitor;
|
|
|
|
|
struct udev_device *udev_device;
|
|
|
|
|
const char *udev_action;
|
2015-07-06 11:37:46 +10:00
|
|
|
const char *udev_syspath = NULL;
|
2015-07-14 14:19:25 +10:00
|
|
|
int rc;
|
2015-07-02 13:39:40 +10:00
|
|
|
|
|
|
|
|
udev = udev_new();
|
|
|
|
|
litest_assert_notnull(udev);
|
|
|
|
|
udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
|
|
|
|
|
litest_assert_notnull(udev_monitor);
|
|
|
|
|
udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "input",
|
|
|
|
|
NULL);
|
|
|
|
|
/* remove O_NONBLOCK */
|
2015-07-14 14:19:25 +10:00
|
|
|
rc = fcntl(udev_monitor_get_fd(udev_monitor), F_SETFL, 0);
|
|
|
|
|
litest_assert_int_ne(rc, -1);
|
2015-07-02 13:39:40 +10:00
|
|
|
litest_assert_int_eq(udev_monitor_enable_receiving(udev_monitor),
|
|
|
|
|
0);
|
|
|
|
|
|
|
|
|
|
uinput = litest_create_uinput(name, id, abs_info, events);
|
|
|
|
|
|
|
|
|
|
syspath = libevdev_uinput_get_syspath(uinput);
|
|
|
|
|
|
|
|
|
|
/* blocking, we don't want to continue until udev is ready */
|
|
|
|
|
do {
|
|
|
|
|
udev_device = udev_monitor_receive_device(udev_monitor);
|
|
|
|
|
litest_assert_notnull(udev_device);
|
|
|
|
|
udev_action = udev_device_get_action(udev_device);
|
|
|
|
|
if (strcmp(udev_action, "add") != 0) {
|
|
|
|
|
udev_device_unref(udev_device);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
udev_syspath = udev_device_get_syspath(udev_device);
|
|
|
|
|
} while (!udev_syspath || strcmp(udev_syspath, syspath) != 0);
|
|
|
|
|
|
|
|
|
|
litest_assert(udev_device_get_property_value(udev_device, "ID_INPUT"));
|
|
|
|
|
|
|
|
|
|
udev_device_unref(udev_device);
|
|
|
|
|
udev_monitor_unref(udev_monitor);
|
|
|
|
|
udev_unref(udev);
|
|
|
|
|
|
|
|
|
|
return uinput;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-31 10:00:16 +10:00
|
|
|
static struct libevdev_uinput *
|
|
|
|
|
litest_create_uinput_abs_device_v(const char *name,
|
|
|
|
|
struct input_id *id,
|
|
|
|
|
const struct input_absinfo *abs,
|
|
|
|
|
va_list args)
|
|
|
|
|
{
|
|
|
|
|
int events[KEY_MAX * 2 + 2]; /* increase this if not sufficient */
|
|
|
|
|
int *event = events;
|
|
|
|
|
int type, code;
|
|
|
|
|
|
|
|
|
|
while ((type = va_arg(args, int)) != -1 &&
|
|
|
|
|
(code = va_arg(args, int)) != -1) {
|
|
|
|
|
*event++ = type;
|
|
|
|
|
*event++ = code;
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert(event < &events[ARRAY_LENGTH(events) - 2]);
|
2014-03-31 10:00:16 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*event++ = -1;
|
|
|
|
|
*event++ = -1;
|
|
|
|
|
|
|
|
|
|
return litest_create_uinput_device_from_description(name, id,
|
|
|
|
|
abs, events);
|
|
|
|
|
}
|
|
|
|
|
|
test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.
The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.
Both functions abort on failure, so the caller does not need to check the
return value.
Example code for creating a rel device:
struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
EV_REL, REL_X,
EV_REL, REL_Y,
EV_KEY, BTN_LEFT,
INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
-1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
...
libevdev_uinput_destroy(uinput);
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-03-26 20:09:42 +10:00
|
|
|
struct libevdev_uinput *
|
|
|
|
|
litest_create_uinput_abs_device(const char *name,
|
|
|
|
|
struct input_id *id,
|
|
|
|
|
const struct input_absinfo *abs,
|
|
|
|
|
...)
|
|
|
|
|
{
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
|
|
va_start(args, abs);
|
|
|
|
|
uinput = litest_create_uinput_abs_device_v(name, id, abs, args);
|
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
|
|
return uinput;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct libevdev_uinput *
|
|
|
|
|
litest_create_uinput_device(const char *name, struct input_id *id, ...)
|
|
|
|
|
{
|
|
|
|
|
struct libevdev_uinput *uinput;
|
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
|
|
va_start(args, id);
|
|
|
|
|
uinput = litest_create_uinput_abs_device_v(name, id, NULL, args);
|
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
|
|
return uinput;
|
|
|
|
|
}
|
2014-09-03 10:53:00 +10:00
|
|
|
|
2015-04-16 10:42:16 +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)
|
2014-09-03 10:53:00 +10:00
|
|
|
{
|
|
|
|
|
struct libinput_event_pointer *ptrev;
|
2015-05-04 11:29:49 +10:00
|
|
|
enum libinput_event_type type = LIBINPUT_EVENT_POINTER_BUTTON;
|
2014-09-03 10:53:00 +10:00
|
|
|
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert(event != NULL);
|
|
|
|
|
litest_assert_int_eq(libinput_event_get_type(event), type);
|
2014-09-03 10:53:00 +10:00
|
|
|
ptrev = libinput_event_get_pointer_event(event);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_eq(libinput_event_pointer_get_button(ptrev),
|
|
|
|
|
button);
|
|
|
|
|
litest_assert_int_eq(libinput_event_pointer_get_button_state(ptrev),
|
|
|
|
|
state);
|
2015-04-16 10:42:16 +10:00
|
|
|
|
|
|
|
|
return ptrev;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-04 13:11:21 +10:00
|
|
|
struct libinput_event_pointer *
|
|
|
|
|
litest_is_axis_event(struct libinput_event *event,
|
|
|
|
|
enum libinput_pointer_axis axis,
|
|
|
|
|
enum libinput_pointer_axis_source source)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event_pointer *ptrev;
|
|
|
|
|
enum libinput_event_type type = LIBINPUT_EVENT_POINTER_AXIS;
|
|
|
|
|
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert(event != NULL);
|
|
|
|
|
litest_assert_int_eq(libinput_event_get_type(event), type);
|
2015-05-04 13:11:21 +10:00
|
|
|
ptrev = libinput_event_get_pointer_event(event);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert(libinput_event_pointer_has_axis(ptrev, axis));
|
2015-05-04 13:11:21 +10:00
|
|
|
|
|
|
|
|
if (source != 0)
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_eq(libinput_event_pointer_get_axis_source(ptrev),
|
|
|
|
|
source);
|
2015-05-04 13:11:21 +10:00
|
|
|
|
|
|
|
|
return ptrev;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-04 13:17:27 +10:00
|
|
|
struct libinput_event_pointer *
|
|
|
|
|
litest_is_motion_event(struct libinput_event *event)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event_pointer *ptrev;
|
|
|
|
|
enum libinput_event_type type = LIBINPUT_EVENT_POINTER_MOTION;
|
|
|
|
|
double x, y, ux, uy;
|
|
|
|
|
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert(event != NULL);
|
|
|
|
|
litest_assert_int_eq(libinput_event_get_type(event), type);
|
2015-05-04 13:17:27 +10:00
|
|
|
ptrev = libinput_event_get_pointer_event(event);
|
|
|
|
|
|
|
|
|
|
x = libinput_event_pointer_get_dx(ptrev);
|
|
|
|
|
y = libinput_event_pointer_get_dy(ptrev);
|
|
|
|
|
ux = libinput_event_pointer_get_dx_unaccelerated(ptrev);
|
|
|
|
|
uy = libinput_event_pointer_get_dy_unaccelerated(ptrev);
|
|
|
|
|
|
|
|
|
|
/* No 0 delta motion events */
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert(x != 0.0 || y != 0.0 ||
|
|
|
|
|
ux != 0.0 || uy != 0.0);
|
2015-05-04 13:17:27 +10:00
|
|
|
|
|
|
|
|
return ptrev;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-03 10:53:00 +10:00
|
|
|
void
|
|
|
|
|
litest_assert_button_event(struct libinput *li, unsigned int button,
|
|
|
|
|
enum libinput_button_state state)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
|
2014-09-03 10:57:25 +10:00
|
|
|
litest_wait_for_event(li);
|
2014-09-03 10:53:00 +10:00
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
|
2015-04-16 10:42:16 +10:00
|
|
|
litest_is_button_event(event, button, state);
|
|
|
|
|
|
2014-09-03 10:53:00 +10:00
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
}
|
2014-09-17 15:35:31 +02:00
|
|
|
|
2015-05-04 13:51:39 +10:00
|
|
|
struct libinput_event_touch *
|
|
|
|
|
litest_is_touch_event(struct libinput_event *event,
|
|
|
|
|
enum libinput_event_type type)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event_touch *touch;
|
|
|
|
|
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert(event != NULL);
|
2015-05-04 13:51:39 +10:00
|
|
|
|
|
|
|
|
if (type == 0)
|
|
|
|
|
type = libinput_event_get_type(event);
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_DOWN:
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_UP:
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_MOTION:
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_FRAME:
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_eq(libinput_event_get_type(event), type);
|
2015-05-04 13:51:39 +10:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ck_abort_msg("%s: invalid touch type %d\n", __func__, type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
touch = libinput_event_get_touch_event(event);
|
|
|
|
|
|
|
|
|
|
return touch;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-05 15:43:08 +10:00
|
|
|
struct libinput_event_keyboard *
|
|
|
|
|
litest_is_keyboard_event(struct libinput_event *event,
|
|
|
|
|
unsigned int key,
|
|
|
|
|
enum libinput_key_state state)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event_keyboard *kevent;
|
|
|
|
|
enum libinput_event_type type = LIBINPUT_EVENT_KEYBOARD_KEY;
|
|
|
|
|
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert(event != NULL);
|
|
|
|
|
litest_assert_int_eq(libinput_event_get_type(event), type);
|
2015-05-05 15:43:08 +10:00
|
|
|
|
|
|
|
|
kevent = libinput_event_get_keyboard_event(event);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert(kevent != NULL);
|
2015-05-05 15:43:08 +10:00
|
|
|
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_eq(libinput_event_keyboard_get_key(kevent), key);
|
|
|
|
|
litest_assert_int_eq(libinput_event_keyboard_get_key_state(kevent),
|
|
|
|
|
state);
|
2015-05-05 15:43:08 +10:00
|
|
|
return kevent;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-07 11:52:05 +10:00
|
|
|
struct libinput_event_gesture *
|
|
|
|
|
litest_is_gesture_event(struct libinput_event *event,
|
|
|
|
|
enum libinput_event_type type,
|
|
|
|
|
int nfingers)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event_gesture *gevent;
|
|
|
|
|
|
|
|
|
|
litest_assert(event != NULL);
|
|
|
|
|
litest_assert_int_eq(libinput_event_get_type(event), type);
|
|
|
|
|
|
|
|
|
|
gevent = libinput_event_get_gesture_event(event);
|
|
|
|
|
litest_assert(gevent != NULL);
|
|
|
|
|
|
|
|
|
|
if (nfingers != -1)
|
|
|
|
|
litest_assert_int_eq(libinput_event_gesture_get_finger_count(gevent),
|
|
|
|
|
nfingers);
|
|
|
|
|
return gevent;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-10 13:06:08 +10:00
|
|
|
struct libinput_event_tablet_tool *
|
|
|
|
|
litest_is_tablet_event(struct libinput_event *event,
|
2015-11-11 14:03:05 +10:00
|
|
|
enum libinput_event_type type)
|
|
|
|
|
{
|
2015-11-16 16:28:55 +10:00
|
|
|
struct libinput_event_tablet_tool *tevent;
|
2015-11-11 14:03:05 +10:00
|
|
|
|
|
|
|
|
litest_assert(event != NULL);
|
|
|
|
|
litest_assert_int_eq(libinput_event_get_type(event), type);
|
|
|
|
|
|
2015-11-16 16:28:55 +10:00
|
|
|
tevent = libinput_event_get_tablet_tool_event(event);
|
2015-11-11 14:03:05 +10:00
|
|
|
litest_assert(tevent != NULL);
|
|
|
|
|
|
|
|
|
|
return tevent;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-19 17:39:11 +10:00
|
|
|
void
|
|
|
|
|
litest_assert_tablet_button_event(struct libinput *li, unsigned int button,
|
|
|
|
|
enum libinput_button_state state)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event *event;
|
2015-11-16 16:28:55 +10:00
|
|
|
struct libinput_event_tablet_tool *tev;
|
2015-11-16 16:27:46 +10:00
|
|
|
enum libinput_event_type type = LIBINPUT_EVENT_TABLET_TOOL_BUTTON;
|
2015-02-19 17:39:11 +10:00
|
|
|
|
|
|
|
|
litest_wait_for_event(li);
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
|
2015-06-29 15:09:23 +10:00
|
|
|
litest_assert_notnull(event);
|
|
|
|
|
litest_assert_int_eq(libinput_event_get_type(event), type);
|
2015-11-16 16:28:55 +10:00
|
|
|
tev = libinput_event_get_tablet_tool_event(event);
|
|
|
|
|
litest_assert_int_eq(libinput_event_tablet_tool_get_button(tev),
|
2015-06-29 15:09:23 +10:00
|
|
|
button);
|
2015-11-16 16:28:55 +10:00
|
|
|
litest_assert_int_eq(libinput_event_tablet_tool_get_button_state(tev),
|
2015-06-29 15:09:23 +10:00
|
|
|
state);
|
2015-02-19 17:39:11 +10:00
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-02 17:16:18 +10:00
|
|
|
void litest_assert_tablet_proximity_event(struct libinput *li,
|
|
|
|
|
enum libinput_tablet_tool_proximity_state state)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
struct libinput_event_tablet_tool *tev;
|
|
|
|
|
enum libinput_event_type type = LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY;
|
|
|
|
|
|
|
|
|
|
litest_wait_for_event(li);
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
|
|
|
|
|
litest_assert_notnull(event);
|
|
|
|
|
litest_assert_int_eq(libinput_event_get_type(event), type);
|
|
|
|
|
tev = libinput_event_get_tablet_tool_event(event);
|
|
|
|
|
litest_assert_int_eq(libinput_event_tablet_tool_get_proximity_state(tev),
|
|
|
|
|
state);
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-10 10:57:27 +10:00
|
|
|
void
|
|
|
|
|
litest_assert_scroll(struct libinput *li,
|
|
|
|
|
enum libinput_pointer_axis axis,
|
2014-11-10 11:03:46 +10:00
|
|
|
int minimum_movement)
|
2014-09-17 15:35:31 +02:00
|
|
|
{
|
|
|
|
|
struct libinput_event *event, *next_event;
|
|
|
|
|
struct libinput_event_pointer *ptrev;
|
2015-05-05 11:52:32 +10:00
|
|
|
int value;
|
2014-09-17 15:35:31 +02:00
|
|
|
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
next_event = libinput_get_event(li);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert(next_event != NULL); /* At least 1 scroll + stop scroll */
|
2014-09-17 15:35:31 +02:00
|
|
|
|
|
|
|
|
while (event) {
|
2015-05-04 13:11:21 +10:00
|
|
|
ptrev = litest_is_axis_event(event, axis, 0);
|
2014-09-17 15:35:31 +02:00
|
|
|
|
|
|
|
|
if (next_event) {
|
2015-05-05 11:52:32 +10:00
|
|
|
value = libinput_event_pointer_get_axis_value(ptrev,
|
|
|
|
|
axis);
|
2014-09-17 15:35:31 +02:00
|
|
|
/* Normal scroll event, check dir */
|
2014-11-10 11:03:46 +10:00
|
|
|
if (minimum_movement > 0) {
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_ge(value, minimum_movement);
|
2014-09-17 15:35:31 +02:00
|
|
|
} else {
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_le(value, minimum_movement);
|
2014-09-17 15:35:31 +02:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* Last scroll event, must be 0 */
|
2015-07-23 15:23:30 +08:00
|
|
|
ck_assert_double_eq(
|
2014-12-24 11:10:04 +10:00
|
|
|
libinput_event_pointer_get_axis_value(ptrev, axis),
|
2015-07-23 15:23:30 +08:00
|
|
|
0.0);
|
2014-09-17 15:35:31 +02:00
|
|
|
}
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
event = next_event;
|
|
|
|
|
next_event = libinput_get_event(li);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-09-16 16:08:29 +10:00
|
|
|
|
2014-12-18 11:29:32 +10:00
|
|
|
void
|
|
|
|
|
litest_assert_only_typed_events(struct libinput *li,
|
|
|
|
|
enum libinput_event_type type)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
|
|
|
|
|
assert(type != LIBINPUT_EVENT_NONE);
|
|
|
|
|
|
|
|
|
|
libinput_dispatch(li);
|
|
|
|
|
event = libinput_get_event(li);
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_notnull(event);
|
2014-12-18 11:29:32 +10:00
|
|
|
|
|
|
|
|
while (event) {
|
2015-05-04 09:13:22 +10:00
|
|
|
litest_assert_int_eq(libinput_event_get_type(event),
|
|
|
|
|
type);
|
2014-12-18 11:29:32 +10:00
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
libinput_dispatch(li);
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-16 16:08:29 +10:00
|
|
|
void
|
|
|
|
|
litest_timeout_tap(void)
|
|
|
|
|
{
|
|
|
|
|
msleep(200);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-04 08:42:44 +10:00
|
|
|
void
|
|
|
|
|
litest_timeout_tapndrag(void)
|
|
|
|
|
{
|
|
|
|
|
msleep(520);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-16 16:08:29 +10:00
|
|
|
void
|
|
|
|
|
litest_timeout_softbuttons(void)
|
|
|
|
|
{
|
|
|
|
|
msleep(300);
|
|
|
|
|
}
|
2014-09-17 10:07:38 +10:00
|
|
|
|
2014-11-06 16:32:53 +01:00
|
|
|
void
|
|
|
|
|
litest_timeout_buttonscroll(void)
|
|
|
|
|
{
|
|
|
|
|
msleep(300);
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-16 13:30:24 +01:00
|
|
|
void
|
|
|
|
|
litest_timeout_finger_switch(void)
|
|
|
|
|
{
|
|
|
|
|
msleep(120);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-06 14:36:31 +10:00
|
|
|
void
|
|
|
|
|
litest_timeout_edgescroll(void)
|
|
|
|
|
{
|
|
|
|
|
msleep(300);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-13 16:38:44 +10:00
|
|
|
void
|
|
|
|
|
litest_timeout_middlebutton(void)
|
|
|
|
|
{
|
|
|
|
|
msleep(70);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-21 16:58:27 +10:00
|
|
|
void
|
|
|
|
|
litest_timeout_dwt_short(void)
|
|
|
|
|
{
|
|
|
|
|
msleep(220);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_timeout_dwt_long(void)
|
|
|
|
|
{
|
|
|
|
|
msleep(520);
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-07 11:52:05 +10:00
|
|
|
void
|
|
|
|
|
litest_timeout_gesture(void)
|
|
|
|
|
{
|
|
|
|
|
msleep(120);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-17 10:07:38 +10:00
|
|
|
void
|
|
|
|
|
litest_push_event_frame(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
assert(!dev->skip_ev_syn);
|
|
|
|
|
dev->skip_ev_syn = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_pop_event_frame(struct litest_device *dev)
|
|
|
|
|
{
|
|
|
|
|
assert(dev->skip_ev_syn);
|
|
|
|
|
dev->skip_ev_syn = false;
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
2014-12-16 11:28:26 +10:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
send_abs_xy(struct litest_device *d, double x, double y)
|
|
|
|
|
{
|
|
|
|
|
struct input_event e;
|
|
|
|
|
int val;
|
|
|
|
|
|
|
|
|
|
e.type = EV_ABS;
|
|
|
|
|
e.code = ABS_X;
|
|
|
|
|
e.value = LITEST_AUTO_ASSIGN;
|
2015-06-22 12:48:04 +02:00
|
|
|
val = litest_auto_assign_value(d, &e, 0, x, y, NULL, true);
|
2014-12-16 11:28:26 +10:00
|
|
|
litest_event(d, EV_ABS, ABS_X, val);
|
|
|
|
|
|
|
|
|
|
e.code = ABS_Y;
|
2015-06-22 12:48:04 +02:00
|
|
|
val = litest_auto_assign_value(d, &e, 0, x, y, NULL, true);
|
2014-12-16 11:28:26 +10:00
|
|
|
litest_event(d, EV_ABS, ABS_Y, val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
send_abs_mt_xy(struct litest_device *d, double x, double y)
|
|
|
|
|
{
|
|
|
|
|
struct input_event e;
|
|
|
|
|
int val;
|
|
|
|
|
|
|
|
|
|
e.type = EV_ABS;
|
|
|
|
|
e.code = ABS_MT_POSITION_X;
|
|
|
|
|
e.value = LITEST_AUTO_ASSIGN;
|
2015-06-22 12:48:04 +02:00
|
|
|
val = litest_auto_assign_value(d, &e, 0, x, y, NULL, true);
|
2014-12-16 11:28:26 +10:00
|
|
|
litest_event(d, EV_ABS, ABS_MT_POSITION_X, val);
|
|
|
|
|
|
|
|
|
|
e.code = ABS_MT_POSITION_Y;
|
|
|
|
|
e.value = LITEST_AUTO_ASSIGN;
|
2015-06-22 12:48:04 +02:00
|
|
|
val = litest_auto_assign_value(d, &e, 0, x, y, NULL, true);
|
2014-12-16 11:28:26 +10:00
|
|
|
litest_event(d, EV_ABS, ABS_MT_POSITION_Y, val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_semi_mt_touch_down(struct litest_device *d,
|
|
|
|
|
struct litest_semi_mt *semi_mt,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x, double y)
|
|
|
|
|
{
|
|
|
|
|
double t, l, r = 0, b = 0; /* top, left, right, bottom */
|
|
|
|
|
|
|
|
|
|
if (d->ntouches_down > 2 || slot > 1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (d->ntouches_down == 1) {
|
|
|
|
|
l = x;
|
|
|
|
|
t = y;
|
|
|
|
|
} else {
|
|
|
|
|
int other = (slot + 1) % 2;
|
|
|
|
|
l = min(x, semi_mt->touches[other].x);
|
|
|
|
|
t = min(y, semi_mt->touches[other].y);
|
|
|
|
|
r = max(x, semi_mt->touches[other].x);
|
|
|
|
|
b = max(y, semi_mt->touches[other].y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
send_abs_xy(d, l, t);
|
|
|
|
|
|
|
|
|
|
litest_event(d, EV_ABS, ABS_MT_SLOT, 0);
|
|
|
|
|
|
|
|
|
|
if (d->ntouches_down == 1)
|
|
|
|
|
litest_event(d, EV_ABS, ABS_MT_TRACKING_ID, ++semi_mt->tracking_id);
|
|
|
|
|
|
|
|
|
|
send_abs_mt_xy(d, l, t);
|
|
|
|
|
|
|
|
|
|
if (d->ntouches_down == 2) {
|
|
|
|
|
litest_event(d, EV_ABS, ABS_MT_SLOT, 1);
|
|
|
|
|
litest_event(d, EV_ABS, ABS_MT_TRACKING_ID, ++semi_mt->tracking_id);
|
|
|
|
|
|
|
|
|
|
send_abs_mt_xy(d, r, b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_event(d, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
|
|
|
|
semi_mt->touches[slot].x = x;
|
|
|
|
|
semi_mt->touches[slot].y = y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_semi_mt_touch_move(struct litest_device *d,
|
|
|
|
|
struct litest_semi_mt *semi_mt,
|
|
|
|
|
unsigned int slot,
|
|
|
|
|
double x, double y)
|
|
|
|
|
{
|
|
|
|
|
double t, l, r = 0, b = 0; /* top, left, right, bottom */
|
|
|
|
|
|
|
|
|
|
if (d->ntouches_down > 2 || slot > 1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (d->ntouches_down == 1) {
|
|
|
|
|
l = x;
|
|
|
|
|
t = y;
|
|
|
|
|
} else {
|
|
|
|
|
int other = (slot + 1) % 2;
|
|
|
|
|
l = min(x, semi_mt->touches[other].x);
|
|
|
|
|
t = min(y, semi_mt->touches[other].y);
|
|
|
|
|
r = max(x, semi_mt->touches[other].x);
|
|
|
|
|
b = max(y, semi_mt->touches[other].y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
send_abs_xy(d, l, t);
|
|
|
|
|
|
|
|
|
|
litest_event(d, EV_ABS, ABS_MT_SLOT, 0);
|
|
|
|
|
send_abs_mt_xy(d, l, t);
|
|
|
|
|
|
|
|
|
|
if (d->ntouches_down == 2) {
|
|
|
|
|
litest_event(d, EV_ABS, ABS_MT_SLOT, 1);
|
|
|
|
|
send_abs_mt_xy(d, r, b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_event(d, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
|
|
|
|
semi_mt->touches[slot].x = x;
|
|
|
|
|
semi_mt->touches[slot].y = y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
litest_semi_mt_touch_up(struct litest_device *d,
|
|
|
|
|
struct litest_semi_mt *semi_mt,
|
|
|
|
|
unsigned int slot)
|
|
|
|
|
{
|
|
|
|
|
/* note: ntouches_down is decreased before we get here */
|
|
|
|
|
if (d->ntouches_down >= 2 || slot > 1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
litest_event(d, EV_ABS, ABS_MT_SLOT, d->ntouches_down);
|
|
|
|
|
litest_event(d, EV_ABS, ABS_MT_TRACKING_ID, -1);
|
|
|
|
|
|
|
|
|
|
/* if we have one finger left, send x/y coords for that finger left.
|
|
|
|
|
this is likely to happen with a real touchpad */
|
|
|
|
|
if (d->ntouches_down == 1) {
|
|
|
|
|
int other = (slot + 1) % 2;
|
|
|
|
|
send_abs_xy(d, semi_mt->touches[other].x, semi_mt->touches[other].y);
|
|
|
|
|
litest_event(d, EV_ABS, ABS_MT_SLOT, 0);
|
|
|
|
|
send_abs_mt_xy(d, semi_mt->touches[other].x, semi_mt->touches[other].y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_event(d, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
2015-05-20 09:36:01 +10:00
|
|
|
|
2015-05-25 08:56:53 +10:00
|
|
|
enum litest_mode {
|
|
|
|
|
LITEST_MODE_ERROR,
|
|
|
|
|
LITEST_MODE_TEST,
|
|
|
|
|
LITEST_MODE_LIST,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static inline enum litest_mode
|
2015-05-20 09:46:54 +10:00
|
|
|
litest_parse_argv(int argc, char **argv)
|
|
|
|
|
{
|
2015-05-20 10:12:39 +10:00
|
|
|
enum {
|
|
|
|
|
OPT_FILTER_TEST,
|
2015-05-20 10:49:13 +10:00
|
|
|
OPT_FILTER_DEVICE,
|
2015-05-20 11:00:37 +10:00
|
|
|
OPT_FILTER_GROUP,
|
2015-05-20 10:12:39 +10:00
|
|
|
OPT_LIST,
|
|
|
|
|
OPT_VERBOSE,
|
|
|
|
|
};
|
2015-05-20 09:46:54 +10:00
|
|
|
static const struct option opts[] = {
|
2015-05-20 10:12:39 +10:00
|
|
|
{ "filter-test", 1, 0, OPT_FILTER_TEST },
|
2015-05-20 10:49:13 +10:00
|
|
|
{ "filter-device", 1, 0, OPT_FILTER_DEVICE },
|
2015-05-20 11:00:37 +10:00
|
|
|
{ "filter-group", 1, 0, OPT_FILTER_GROUP },
|
2015-05-20 10:12:39 +10:00
|
|
|
{ "list", 0, 0, OPT_LIST },
|
|
|
|
|
{ "verbose", 0, 0, OPT_VERBOSE },
|
2015-05-20 09:46:54 +10:00
|
|
|
{ 0, 0, 0, 0}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
|
int c;
|
|
|
|
|
int option_index = 0;
|
|
|
|
|
|
|
|
|
|
c = getopt_long(argc, argv, "", opts, &option_index);
|
|
|
|
|
if (c == -1)
|
|
|
|
|
break;
|
|
|
|
|
switch(c) {
|
2015-05-20 10:12:39 +10:00
|
|
|
case OPT_FILTER_TEST:
|
|
|
|
|
filter_test = optarg;
|
|
|
|
|
break;
|
2015-05-20 10:49:13 +10:00
|
|
|
case OPT_FILTER_DEVICE:
|
|
|
|
|
filter_device = optarg;
|
|
|
|
|
break;
|
2015-05-20 11:00:37 +10:00
|
|
|
case OPT_FILTER_GROUP:
|
|
|
|
|
filter_group = optarg;
|
|
|
|
|
break;
|
2015-05-20 10:12:39 +10:00
|
|
|
case OPT_LIST:
|
2015-05-25 08:56:53 +10:00
|
|
|
return LITEST_MODE_LIST;
|
2015-05-20 10:12:39 +10:00
|
|
|
case OPT_VERBOSE:
|
2015-05-20 09:46:54 +10:00
|
|
|
verbose = 1;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fprintf(stderr, "usage: %s [--list]\n", argv[0]);
|
2015-05-25 08:56:53 +10:00
|
|
|
return LITEST_MODE_ERROR;
|
2015-05-20 09:46:54 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-25 08:56:53 +10:00
|
|
|
return LITEST_MODE_TEST;
|
2015-05-20 09:46:54 +10:00
|
|
|
}
|
|
|
|
|
|
2015-05-22 09:06:07 +10:00
|
|
|
#ifndef LITEST_NO_MAIN
|
2015-05-25 08:56:53 +10:00
|
|
|
static void
|
|
|
|
|
litest_list_tests(struct list *tests)
|
|
|
|
|
{
|
|
|
|
|
struct suite *s;
|
|
|
|
|
|
|
|
|
|
list_for_each(s, tests, node) {
|
|
|
|
|
struct test *t;
|
|
|
|
|
printf("%s:\n", s->name);
|
|
|
|
|
list_for_each(t, &s->tests, node) {
|
|
|
|
|
printf(" %s\n", t->name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-20 09:36:01 +10:00
|
|
|
int
|
|
|
|
|
main(int argc, char **argv)
|
|
|
|
|
{
|
2015-05-25 08:56:53 +10:00
|
|
|
enum litest_mode mode;
|
|
|
|
|
|
2015-05-22 14:56:09 +10:00
|
|
|
list_init(&all_tests);
|
|
|
|
|
|
2015-07-02 14:21:45 +10:00
|
|
|
setenv("CK_DEFAULT_TIMEOUT", "10", 0);
|
2015-07-27 16:08:04 +08:00
|
|
|
setenv("LIBINPUT_RUNNING_TEST_SUITE", "1", 1);
|
2015-07-02 14:21:45 +10:00
|
|
|
|
2015-05-25 08:56:53 +10:00
|
|
|
mode = litest_parse_argv(argc, argv);
|
|
|
|
|
if (mode == LITEST_MODE_ERROR)
|
2015-05-20 09:46:54 +10:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
2015-05-20 09:36:01 +10:00
|
|
|
litest_setup_tests();
|
|
|
|
|
|
2015-05-25 08:56:53 +10:00
|
|
|
if (mode == LITEST_MODE_LIST) {
|
|
|
|
|
litest_list_tests(&all_tests);
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-20 09:36:01 +10:00
|
|
|
return litest_run(argc, argv);
|
|
|
|
|
}
|
2015-05-22 09:06:07 +10:00
|
|
|
#endif
|