mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-03-21 19:10:42 +01:00
test: Use only one test device for some udev and path tests
Some tests in test/path.c and test/udev.c are not dependent on device behaviour but rather managing of device lifetime etc. Run those tests only once with only one device, resulting more or less the same code coverage but shorter run time. Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
6595036d62
commit
4be59a972a
4 changed files with 54 additions and 23 deletions
|
|
@ -181,11 +181,8 @@ litest_add_no_device(const char *name, void *func)
|
|||
litest_add(name, func, LITEST_DISABLE_DEVICE, LITEST_DISABLE_DEVICE);
|
||||
}
|
||||
|
||||
void
|
||||
litest_add(const char *name,
|
||||
void *func,
|
||||
enum litest_device_feature required,
|
||||
enum litest_device_feature excluded)
|
||||
static struct suite *
|
||||
get_suite(const char *name)
|
||||
{
|
||||
struct suite *s;
|
||||
|
||||
|
|
@ -193,10 +190,8 @@ litest_add(const char *name,
|
|||
list_init(&all_tests);
|
||||
|
||||
list_for_each(s, &all_tests, node) {
|
||||
if (strcmp(s->name, name) == 0) {
|
||||
litest_add_tcase(s, func, required, excluded);
|
||||
return;
|
||||
}
|
||||
if (strcmp(s->name, name) == 0)
|
||||
return s;
|
||||
}
|
||||
|
||||
s = zalloc(sizeof(*s));
|
||||
|
|
@ -205,7 +200,37 @@ litest_add(const char *name,
|
|||
|
||||
list_init(&s->tests);
|
||||
list_insert(&all_tests, &s->node);
|
||||
litest_add_tcase(s, func, required, excluded);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void
|
||||
litest_add(const char *name,
|
||||
void *func,
|
||||
enum litest_device_feature required,
|
||||
enum litest_device_feature excluded)
|
||||
{
|
||||
litest_add_tcase(get_suite(name), func, required, excluded);
|
||||
}
|
||||
|
||||
void
|
||||
litest_add_for_device(const char *name,
|
||||
void *func,
|
||||
enum litest_device_type type)
|
||||
{
|
||||
struct suite *s;
|
||||
struct litest_test_device **dev = devices;
|
||||
|
||||
s = get_suite(name);
|
||||
while (*dev) {
|
||||
if ((*dev)->type == type) {
|
||||
litest_add_tcase_for_device(s, func, *dev);
|
||||
return;
|
||||
}
|
||||
dev++;
|
||||
}
|
||||
|
||||
ck_abort_msg("Invalid test device type");
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
|||
|
|
@ -79,6 +79,10 @@ struct libinput *litest_create_context(void);
|
|||
void litest_add(const char *name, void *func,
|
||||
enum litest_device_feature required_feature,
|
||||
enum litest_device_feature excluded_feature);
|
||||
void
|
||||
litest_add_for_device(const char *name,
|
||||
void *func,
|
||||
enum litest_device_type type);
|
||||
void litest_add_no_device(const char *name, void *func);
|
||||
|
||||
int litest_run(int argc, char **argv);
|
||||
|
|
|
|||
13
test/path.c
13
test/path.c
|
|
@ -793,8 +793,9 @@ START_TEST(path_seat_recycle)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
litest_add_no_device("path:create", path_create_NULL);
|
||||
litest_add_no_device("path:create", path_create_invalid);
|
||||
litest_add_no_device("path:create", path_create_destroy);
|
||||
|
|
@ -804,13 +805,13 @@ int main (int argc, char **argv) {
|
|||
litest_add_no_device("path:suspend", path_add_device_suspend_resume);
|
||||
litest_add_no_device("path:suspend", path_add_device_suspend_resume_fail);
|
||||
litest_add_no_device("path:suspend", path_add_device_suspend_resume_remove_device);
|
||||
litest_add("path:seat events", path_added_seat, LITEST_ANY, LITEST_ANY);
|
||||
litest_add_for_device("path:seat events", path_added_seat, LITEST_SYNAPTICS_CLICKPAD);
|
||||
litest_add("path:device events", path_added_device, LITEST_ANY, LITEST_ANY);
|
||||
litest_add("path:device events", path_device_sysname, LITEST_ANY, LITEST_ANY);
|
||||
litest_add("path:device events", path_add_device, LITEST_ANY, LITEST_ANY);
|
||||
litest_add_for_device("path:device events", path_add_device, LITEST_SYNAPTICS_CLICKPAD);
|
||||
litest_add_no_device("path:device events", path_add_invalid_path);
|
||||
litest_add("path:device events", path_remove_device, LITEST_ANY, LITEST_ANY);
|
||||
litest_add("path:device events", path_double_remove_device, LITEST_ANY, LITEST_ANY);
|
||||
litest_add_for_device("path:device events", path_remove_device, LITEST_SYNAPTICS_CLICKPAD);
|
||||
litest_add_for_device("path:device events", path_double_remove_device, LITEST_SYNAPTICS_CLICKPAD);
|
||||
litest_add_no_device("path:seat", path_seat_recycle);
|
||||
|
||||
return litest_run(argc, argv);
|
||||
|
|
|
|||
15
test/udev.c
15
test/udev.c
|
|
@ -407,19 +407,20 @@ START_TEST(udev_seat_recycle)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
litest_add_no_device("udev:create", udev_create_NULL);
|
||||
litest_add_no_device("udev:create", udev_create_seat0);
|
||||
litest_add_no_device("udev:create", udev_create_empty_seat);
|
||||
|
||||
litest_add_no_device("udev:seat events", udev_added_seat_default);
|
||||
|
||||
litest_add("udev:suspend", udev_double_suspend, LITEST_ANY, LITEST_ANY);
|
||||
litest_add("udev:suspend", udev_double_resume, LITEST_ANY, LITEST_ANY);
|
||||
litest_add("udev:suspend", udev_suspend_resume, LITEST_ANY, LITEST_ANY);
|
||||
litest_add("udev:device events", udev_device_sysname, LITEST_ANY, LITEST_ANY);
|
||||
litest_add("udev:seat", udev_seat_recycle, LITEST_ANY, LITEST_ANY);
|
||||
litest_add_for_device("udev:suspend", udev_double_suspend, LITEST_SYNAPTICS_CLICKPAD);
|
||||
litest_add_for_device("udev:suspend", udev_double_resume, LITEST_SYNAPTICS_CLICKPAD);
|
||||
litest_add_for_device("udev:suspend", udev_suspend_resume, LITEST_SYNAPTICS_CLICKPAD);
|
||||
litest_add_for_device("udev:device events", udev_device_sysname, LITEST_SYNAPTICS_CLICKPAD);
|
||||
litest_add_for_device("udev:seat", udev_seat_recycle, LITEST_SYNAPTICS_CLICKPAD);
|
||||
|
||||
return litest_run(argc, argv);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue