Lines Matching +full:libinput +full:- +full:test +full:- +full:suite +full:- +full:touch
52 #include <systemd/sd-bus.h>
61 #include "litest-int.h"
62 #include "libinput-util.h"
72 "/91-litest-fuzz-override-REMOVEME-XXXXXX.rules"
74 "/91-litest-test-device-REMOVEME-XXXXXXX.rules"
76 "/80-libinput-device-groups-litest-XXXXXX.rules"
95 of the test run */
129 if (pipe(pipefd) == -1) in litest_backtrace()
160 while ((nread = read(pipefd[0], buf, sizeof(buf) - 1)) > 0) { in litest_backtrace()
243 struct test { struct
255 struct suite { struct
271 struct libinput *li = libinput_device_get_context(device->libinput_device); in grab_device()
277 udev_device = libinput_device_get_udev_device(device->libinput_device); in grab_device()
287 list_for_each(p, &ctx->paths, link) { in grab_device()
288 if (streq(p->path, devnode)) { in grab_device()
289 int rc = ioctl(p->fd, EVIOCGRAB, (void*)mode ? 1 : 0); in grab_device()
290 ck_assert_int_gt(rc, -1); in grab_device()
333 if (ret == -1) { in litest_system()
350 litest_system("udevadm control --reload-rules"); in litest_reload_udev_rules()
354 litest_add_tcase_for_device(struct suite *suite, in litest_add_tcase_for_device() argument
360 struct test *t; in litest_add_tcase_for_device()
363 t->name = safe_strdup(funcname); in litest_add_tcase_for_device()
364 t->devname = safe_strdup(dev->shortname); in litest_add_tcase_for_device()
365 t->func = func; in litest_add_tcase_for_device()
366 t->setup = dev->setup; in litest_add_tcase_for_device()
367 t->teardown = dev->teardown ? in litest_add_tcase_for_device()
368 dev->teardown : litest_generic_device_teardown; in litest_add_tcase_for_device()
370 t->range = *range; in litest_add_tcase_for_device()
372 list_insert(&suite->tests, &t->node); in litest_add_tcase_for_device()
376 litest_add_tcase_no_device(struct suite *suite, in litest_add_tcase_no_device() argument
381 struct test *t; in litest_add_tcase_no_device()
390 t->name = safe_strdup(test_name); in litest_add_tcase_no_device()
391 t->devname = safe_strdup("no device"); in litest_add_tcase_no_device()
392 t->func = func; in litest_add_tcase_no_device()
394 t->range = *range; in litest_add_tcase_no_device()
395 t->setup = NULL; in litest_add_tcase_no_device()
396 t->teardown = NULL; in litest_add_tcase_no_device()
398 list_insert(&suite->tests, &t->node); in litest_add_tcase_no_device()
402 litest_add_tcase_deviceless(struct suite *suite, in litest_add_tcase_deviceless() argument
407 struct test *t; in litest_add_tcase_deviceless()
416 t->deviceless = true; in litest_add_tcase_deviceless()
417 t->name = safe_strdup(test_name); in litest_add_tcase_deviceless()
418 t->devname = safe_strdup("deviceless"); in litest_add_tcase_deviceless()
419 t->func = func; in litest_add_tcase_deviceless()
421 t->range = *range; in litest_add_tcase_deviceless()
422 t->setup = NULL; in litest_add_tcase_deviceless()
423 t->teardown = NULL; in litest_add_tcase_deviceless()
425 list_insert(&suite->tests, &t->node); in litest_add_tcase_deviceless()
428 static struct suite *
431 struct suite *s; in get_suite()
434 if (streq(s->name, name)) in get_suite()
439 s->name = safe_strdup(name); in get_suite()
441 list_init(&s->tests); in get_suite()
442 list_insert(&all_tests, &s->node); in get_suite()
453 /* strip the test- prefix */ in create_suite_name()
454 if (strstartswith(trunk, "test-")) in create_suite_name()
470 struct suite *suite; in litest_add_tcase() local
486 suite = get_suite(suite_name); in litest_add_tcase()
490 litest_add_tcase_deviceless(suite, func, funcname, range); in litest_add_tcase()
494 litest_add_tcase_no_device(suite, func, funcname, range); in litest_add_tcase()
500 if (dev->features & LITEST_IGNORED) in litest_add_tcase()
504 strstr(dev->shortname, filter_device) == NULL && in litest_add_tcase()
505 fnmatch(filter_device, dev->shortname, 0) != 0) in litest_add_tcase()
507 if ((dev->features & required) != required || in litest_add_tcase()
508 (dev->features & excluded) != 0) in litest_add_tcase()
511 litest_add_tcase_for_device(suite, in litest_add_tcase()
522 if (dev->features & LITEST_IGNORED) in litest_add_tcase()
526 strstr(dev->shortname, filter_device) == NULL && in litest_add_tcase()
527 fnmatch(filter_device, dev->shortname, 0) != 0) in litest_add_tcase()
530 litest_add_tcase_for_device(suite, in litest_add_tcase()
543 fprintf(stderr, "Test '%s' does not match any devices. Aborting.\n", funcname); in litest_add_tcase()
623 struct suite *s; in _litest_add_ranged_for_device()
642 strstr(dev->shortname, filter_device) == NULL && in _litest_add_ranged_for_device()
643 fnmatch(filter_device, dev->shortname, 0) != 0) { in _litest_add_ranged_for_device()
648 if (dev->type == type) { in _litest_add_ranged_for_device()
660 litest_abort_msg("Invalid test device type\n"); in _litest_add_ranged_for_device()
665 litest_log_handler(struct libinput *libinput, in litest_log_handler() argument
670 static int is_tty = -1; in litest_log_handler()
674 if (is_tty == -1) in litest_log_handler()
702 else if (strstr(format, "touch-size:") || in litest_log_handler()
708 else if (strstr(format, "edge-scroll:")) in litest_log_handler()
717 strstr(format, "libinput bug: ")) { in litest_log_handler()
727 litest_abort_msg("libinput bug triggered, aborting.\n"); in litest_log_handler()
731 if (strstr(format, "Touch jump detected and discarded")) { in litest_log_handler()
732 litest_abort_msg("libinput touch jump triggered, aborting.\n"); in litest_log_handler()
743 if (dev->udev_properties[0].key == NULL) in litest_init_device_udev_rules()
748 fprintf(f, "# %s\n", dev->shortname); in litest_init_device_udev_rules()
752 fprintf(f, "ATTRS{name}==\"litest %s*\"", dev->name); in litest_init_device_udev_rules()
754 kv = dev->udev_properties; in litest_init_device_udev_rules()
755 while (kv->key) { in litest_init_device_udev_rules()
756 fprintf(f, ", \\\n\tENV{%s}=\"%s\"", kv->key, kv->value); in litest_init_device_udev_rules()
757 if (strneq(kv->key, "EVDEV_ABS_", 10)) in litest_init_device_udev_rules()
766 * they exist, force a (re-)run of the keyboard builtin to set up in litest_init_device_udev_rules()
775 dev->name); in litest_init_device_udev_rules()
792 "%s/99-litest-XXXXXX.rules", in litest_init_all_device_udev_rules()
797 litest_assert_int_ne(fd, -1); in litest_init_all_device_udev_rules()
806 file->path = path; in litest_init_all_device_udev_rules()
807 list_insert(created_files, &file->link); in litest_init_all_device_udev_rules()
822 return -errno; in open_restricted()
826 p->path = safe_strdup(path); in open_restricted()
827 p->fd = fd; in open_restricted()
828 /* We specifically insert here so that the most-recently in open_restricted()
830 * we have multiple test devices with the same device path, in open_restricted()
834 list_insert(&ctx->paths, &p->link); in open_restricted()
846 list_for_each_safe(p, &ctx->paths, link) { in close_restricted()
847 if (p->fd != fd) in close_restricted()
849 list_remove(&p->link); in close_restricted()
850 free(p->path); in close_restricted()
868 list_remove(&f->link); in litest_signal()
869 unlink(f->path); in litest_signal()
870 rmdir(f->path); in litest_signal()
894 litest_assert_int_ne(rc, -1); in litest_setup_sighandler()
900 struct suite *s; in litest_free_test_list()
903 struct test *t; in litest_free_test_list()
905 list_for_each_safe(t, &s->tests, node) { in litest_free_test_list()
906 free(t->name); in litest_free_test_list()
907 free(t->devname); in litest_free_test_list()
908 list_remove(&t->node); in litest_free_test_list()
912 list_remove(&s->node); in litest_free_test_list()
913 free(s->name); in litest_free_test_list()
920 quirk_log_handler(struct libinput *unused, in quirk_log_handler()
939 /* This is the minimum-effort implementation here because its only in litest_export_xml()
940 * real purpose is to make test logs look pretty in the gitlab CI. in litest_export_xml()
943 * - there's no filename validation, if you supply a filename that in litest_export_xml()
945 * - every fork writes out a separate junit.xml file. gitlab is better in litest_export_xml()
948 * - most of the content is pretty useless because libcheck only gives in litest_export_xml()
950 * the duration of each test but it's more complicated to extract in litest_export_xml()
998 struct suite *s; in litest_run_suite()
999 struct test *t; in litest_run_suite()
1000 int count = -1; in litest_run_suite()
1019 /* Check just takes the suite/test name pointers but doesn't strdup in litest_run_suite()
1020 * them - we have to keep them around */ in litest_run_suite()
1023 /* For each test, create one test suite with one test case, then in litest_run_suite()
1024 add it to the test runner. The only benefit suites give us in in litest_run_suite()
1025 check is that we can filter them, but our test runner has a in litest_run_suite()
1026 --filter-group anyway. */ in litest_run_suite()
1028 list_for_each(t, &s->tests, node) { in litest_run_suite()
1029 Suite *suite; in litest_run_suite() local
1034 * test suite runner, just in case. Filtering in litest_run_suite()
1038 if (run_deviceless && !t->deviceless) in litest_run_suite()
1047 s->name, in litest_run_suite()
1048 t->name, in litest_run_suite()
1049 t->devname); in litest_run_suite()
1052 n->name = sname; in litest_run_suite()
1053 list_insert(&testnames, &n->node); in litest_run_suite()
1057 t->name, in litest_run_suite()
1058 t->devname); in litest_run_suite()
1061 n->name = tname; in litest_run_suite()
1062 list_insert(&testnames, &n->node); in litest_run_suite()
1066 t->setup, in litest_run_suite()
1067 t->teardown); in litest_run_suite()
1068 if (t->range.upper != t->range.lower) in litest_run_suite()
1070 t->func, in litest_run_suite()
1071 t->range.lower, in litest_run_suite()
1072 t->range.upper); in litest_run_suite()
1074 tcase_add_test(tc, t->func); in litest_run_suite()
1076 suite = suite_create(sname); in litest_run_suite()
1077 suite_add_tcase(suite, tc); in litest_run_suite()
1080 sr = srunner_create(suite); in litest_run_suite()
1082 srunner_add_suite(sr, suite); in litest_run_suite()
1103 /* tr_tcname is in the form "suite:testcase", let's in litest_run_suite()
1104 * convert this to "suite(testcase)" to make in litest_run_suite()
1105 * double-click selection in the terminal a bit in litest_run_suite()
1122 free(n->name); in litest_run_suite()
1145 assert(rc != -1); in litest_fork_subtests()
1165 while (wait(&status) != -1 && errno != ECHILD) { in litest_fork_subtests()
1174 while ((rc = read(pipes[f], buf, sizeof(buf) - 1)) > 0) { in litest_fork_subtests()
1188 int lock_fd = -1; in inhibit()
1196 return -1; in inhibit()
1200 fprintf(stderr, "Warning: inhibit failed: %s\n", strerror(-rc)); in inhibit()
1212 "sleep:shutdown:handle-lid-switch:handle-power-key:handle-suspend-key:handle-hibernate-key", in inhibit()
1213 "libinput test-suite runner", in inhibit()
1223 fprintf(stderr, "Warning: inhibit failed: %s\n", strerror(-rc)); in inhibit()
1301 while (orig[nelem].value != -1) { in merge_absinfo()
1310 while (override && override[i].value != -1) { in merge_absinfo()
1316 abs[nelem].value = -1; in merge_absinfo()
1335 while (orig[nelem] != -1) { in merge_events()
1344 while (override && override[i] != -1) { in merge_events()
1350 events[nelem] = -1; in merge_events()
1362 file->path = safe_strdup(dest); in litest_copy_file()
1367 suffixlen = file->path + in litest_copy_file()
1368 strlen(file->path) - in litest_copy_file()
1369 rindex(file->path, '.'); in litest_copy_file()
1370 out = mkstemps(file->path, suffixlen); in litest_copy_file()
1372 out = open(file->path, O_CREAT|O_WRONLY, 0644); in litest_copy_file()
1374 if (out == -1) in litest_copy_file()
1376 file->path, in litest_copy_file()
1378 litest_assert_int_ne(chmod(file->path, 0644), -1); in litest_copy_file()
1387 if (in == -1) in litest_copy_file()
1410 "# This is a run-time file for the libinput test suite and\n" in litest_install_model_quirks()
1411 "# should be removed on exit. If the test-suite is not currently \n" in litest_install_model_quirks()
1423 list_insert(created_files_list, &file->link); in litest_install_model_quirks()
1426 * test suite, we expect the others to be in place already */ in litest_install_model_quirks()
1434 list_insert(created_files_list, &file->link); in litest_install_model_quirks()
1440 list_insert(created_files_list, &file->link); in litest_install_model_quirks()
1452 if (!dev->quirk_file) in litest_init_device_quirk_file()
1456 "%s/99-%03d-%s.quirks", in litest_init_device_quirk_file()
1459 dev->shortname); in litest_init_device_quirk_file()
1461 litest_assert_int_ne(fd, -1); in litest_init_device_quirk_file()
1464 litest_assert_int_ge(fputs(dev->quirk_file, f), 0); in litest_init_device_quirk_file()
1471 return strendswith(dir->d_name, ".quirks"); in is_quirks_file()
1496 filename = namelist[idx]->d_name; in litest_install_source_quirks()
1501 list_append(created_files_list, &file->link); in litest_install_source_quirks()
1508 * Install the quirks from the various litest test devices
1522 file->path = path; in litest_install_device_quirks()
1523 list_insert(created_files_list, &file->link); in litest_install_device_quirks()
1534 char tmpdir[] = "/run/litest-XXXXXX"; in litest_setup_quirks()
1546 litest_assert_int_ne(chmod(tmpdir, 0755), -1); in litest_setup_quirks()
1548 file->path = safe_strdup(tmpdir); in litest_setup_quirks()
1553 list_append(created_files_list, &file->link); in litest_setup_quirks()
1575 if (rc == -1 && errno != EEXIST) { in mkdir_p()
1603 list_remove(&f->link); in litest_remove_udev_rules()
1604 unlink(f->path); in litest_remove_udev_rules()
1605 rmdir(f->path); in litest_remove_udev_rules()
1606 free(f->path); in litest_remove_udev_rules()
1615 * Creates a uinput device but does not add it to a libinput context
1636 if (dev->type == which) { in litest_create()
1646 d->which = which; in litest_create()
1649 if (dev->create) { in litest_create()
1650 create_device = dev->create(d); in litest_create()
1656 abs = merge_absinfo(dev->absinfo, abs_override); in litest_create()
1657 events = merge_events(dev->events, events_override); in litest_create()
1658 name = name_override ? name_override : dev->name; in litest_create()
1659 id = id_override ? id_override : dev->id; in litest_create()
1662 d->uinput = litest_create_uinput_device_from_description(name, in litest_create()
1666 d->interface = dev->interface; in litest_create()
1668 for (e = events; *e != -1; e += 2) { in litest_create()
1674 d->semi_mt.is_semi_mt = true; in litest_create()
1683 path = libevdev_uinput_get_devnode(d->uinput); in litest_create()
1686 litest_assert_int_ne(fd, -1); in litest_create()
1688 rc = libevdev_new_from_fd(fd, &d->evdev); in litest_create()
1695 struct libinput *
1698 struct libinput *libinput; in litest_create_context() local
1702 list_init(&ctx->paths); in litest_create_context()
1704 libinput = libinput_path_create_context(&interface, ctx); in litest_create_context()
1705 litest_assert_notnull(libinput); in litest_create_context()
1707 libinput_log_set_handler(libinput, litest_log_handler); in litest_create_context()
1709 libinput_log_set_priority(libinput, LIBINPUT_LOG_PRIORITY_DEBUG); in litest_create_context()
1711 return libinput; in litest_create_context()
1715 litest_destroy_context(struct libinput *li) in litest_destroy_context()
1725 list_for_each_safe(p, &ctx->paths, link) { in litest_destroy_context()
1732 litest_disable_log_handler(struct libinput *libinput) in litest_disable_log_handler() argument
1734 libinput_log_set_handler(libinput, NULL); in litest_disable_log_handler()
1738 litest_restore_log_handler(struct libinput *libinput) in litest_restore_log_handler() argument
1740 libinput_log_set_handler(libinput, litest_log_handler); in litest_restore_log_handler()
1742 libinput_log_set_priority(libinput, LIBINPUT_LOG_PRIORITY_DEBUG); in litest_restore_log_handler()
1747 litest_bug_log_handler(struct libinput *libinput, in litest_bug_log_handler() argument
1753 strstr(format, "libinput bug: ") || in litest_bug_log_handler()
1761 litest_set_log_handler_bug(struct libinput *libinput) in litest_set_log_handler_bug() argument
1763 libinput_log_set_handler(libinput, litest_bug_log_handler); in litest_set_log_handler_bug()
1767 litest_add_device_with_overrides(struct libinput *libinput, in litest_add_device_with_overrides() argument
1784 path = libevdev_uinput_get_devnode(d->uinput); in litest_add_device_with_overrides()
1787 d->libinput = libinput; in litest_add_device_with_overrides()
1788 d->libinput_device = libinput_path_add_device(d->libinput, path); in litest_add_device_with_overrides()
1789 litest_assert_ptr_notnull(d->libinput_device); in litest_add_device_with_overrides()
1790 ud = libinput_device_get_udev_device(d->libinput_device); in litest_add_device_with_overrides()
1791 d->quirks = quirks_fetch_for_device(quirks_context, ud); in litest_add_device_with_overrides()
1794 libinput_device_ref(d->libinput_device); in litest_add_device_with_overrides()
1796 if (d->interface) { in litest_add_device_with_overrides()
1800 if (!libevdev_has_event_code(d->evdev, EV_ABS, code)) in litest_add_device_with_overrides()
1802 if (libevdev_has_event_code(d->evdev, EV_ABS, code)) { in litest_add_device_with_overrides()
1803 d->interface->min[ABS_X] = libevdev_get_abs_minimum(d->evdev, code); in litest_add_device_with_overrides()
1804 d->interface->max[ABS_X] = libevdev_get_abs_maximum(d->evdev, code); in litest_add_device_with_overrides()
1808 if (!libevdev_has_event_code(d->evdev, EV_ABS, code)) in litest_add_device_with_overrides()
1810 if (libevdev_has_event_code(d->evdev, EV_ABS, code)) { in litest_add_device_with_overrides()
1811 d->interface->min[ABS_Y] = libevdev_get_abs_minimum(d->evdev, code); in litest_add_device_with_overrides()
1812 d->interface->max[ABS_Y] = libevdev_get_abs_maximum(d->evdev, code); in litest_add_device_with_overrides()
1814 d->interface->tool_type = BTN_TOOL_PEN; in litest_add_device_with_overrides()
1820 litest_add_device(struct libinput *libinput, in litest_add_device() argument
1823 return litest_add_device_with_overrides(libinput, in litest_add_device()
1845 dev->owns_context = true; in litest_create_device_with_overrides()
1872 litest_assert_int_ne(rc, -1); in udev_setup_monitor()
1924 libevdev_uinput_get_syspath(d->uinput)); in litest_delete_device()
1926 litest_assert_int_eq(d->skip_ev_syn, 0); in litest_delete_device()
1928 quirks_unref(d->quirks); in litest_delete_device()
1930 if (d->libinput_device) { in litest_delete_device()
1931 libinput_path_remove_device(d->libinput_device); in litest_delete_device()
1932 libinput_device_unref(d->libinput_device); in litest_delete_device()
1934 if (d->owns_context) { in litest_delete_device()
1935 libinput_dispatch(d->libinput); in litest_delete_device()
1936 litest_destroy_context(d->libinput); in litest_delete_device()
1938 close(libevdev_get_fd(d->evdev)); in litest_delete_device()
1939 libevdev_free(d->evdev); in litest_delete_device()
1940 libevdev_uinput_destroy(d->uinput); in litest_delete_device()
1941 free(d->private); in litest_delete_device()
1958 if (!libevdev_has_event_code(d->evdev, type, code)) in litest_event()
1961 if (d->skip_ev_syn && type == EV_SYN && code == SYN_REPORT) in litest_event()
1964 ret = libevdev_uinput_write_event(d->uinput, type, code, value); in litest_event()
1979 while (axis->evcode != -1) { in axis_replacement_value()
1980 if (axis->evcode == evcode) { in axis_replacement_value()
1985 *value = axis->value; in axis_replacement_value()
1988 *value = litest_scale(d, evcode, axis->value); in axis_replacement_value()
2007 int value = ev->value; in litest_auto_assign_value()
2009 if (value != LITEST_AUTO_ASSIGN || ev->type != EV_ABS) in litest_auto_assign_value()
2012 switch (ev->code) { in litest_auto_assign_value()
2031 if (!axis_replacement_value(d, axes, ev->code, &value)) in litest_auto_assign_value()
2035 if (!axis_replacement_value(d, axes, ev->code, &value) && in litest_auto_assign_value()
2036 d->interface->get_axis_default) { in litest_auto_assign_value()
2037 int error = d->interface->get_axis_default(d, in litest_auto_assign_value()
2038 ev->code, in litest_auto_assign_value()
2042 libevdev_event_code_get_name(EV_ABS, ev->code), in litest_auto_assign_value()
2043 ev->code); in litest_auto_assign_value()
2055 litest_event(d, EV_KEY, BTN_TOUCH, d->ntouches_down != 0 && !hover); in send_btntool()
2056 litest_event(d, EV_KEY, BTN_TOOL_FINGER, d->ntouches_down == 1); in send_btntool()
2057 litest_event(d, EV_KEY, BTN_TOOL_DOUBLETAP, d->ntouches_down == 2); in send_btntool()
2058 litest_event(d, EV_KEY, BTN_TOOL_TRIPLETAP, d->ntouches_down == 3); in send_btntool()
2059 litest_event(d, EV_KEY, BTN_TOOL_QUADTAP, d->ntouches_down == 4); in send_btntool()
2060 litest_event(d, EV_KEY, BTN_TOOL_QUINTTAP, d->ntouches_down == 5); in send_btntool()
2074 litest_assert_int_ge(d->ntouches_down, 0); in slot_start()
2075 d->ntouches_down++; in slot_start()
2079 /* If the test device overrides touch_down and says it didn't in slot_start()
2081 if (d->interface->touch_down && in slot_start()
2082 d->interface->touch_down(d, slot, x, y)) in slot_start()
2085 for (ev = d->interface->touch_down_events; in slot_start()
2086 ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1; in slot_start()
2098 if (filter_abs_xy && ev->type == EV_ABS && in slot_start()
2099 (ev->code == ABS_X || ev->code == ABS_Y)) in slot_start()
2102 litest_event(d, ev->type, ev->code, value); in slot_start()
2117 if (d->interface->touch_move && in slot_move()
2118 d->interface->touch_move(d, slot, x, y)) in slot_move()
2121 for (ev = d->interface->touch_move_events; in slot_move()
2122 ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1; in slot_move()
2134 if (filter_abs_xy && ev->type == EV_ABS && in slot_move()
2135 (ev->code == ABS_X || ev->code == ABS_Y)) in slot_move()
2138 litest_event(d, ev->type, ev->code, value); in slot_move()
2148 { .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = -1 }, in touch_up()
2153 { .type = -1, .code = -1 } in touch_up()
2156 litest_assert_int_gt(d->ntouches_down, 0); in touch_up()
2157 d->ntouches_down--; in touch_up()
2161 if (d->interface->touch_up && in touch_up()
2162 d->interface->touch_up(d, slot)) { in touch_up()
2164 } else if (d->interface->touch_up_events) { in touch_up()
2165 ev = d->interface->touch_up_events; in touch_up()
2170 ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1; in touch_up()
2179 litest_event(d, ev->type, ev->code, value); in touch_up()
2194 if (!d->semi_mt.is_semi_mt) { in litest_slot_start()
2199 if (d->ntouches_down >= 2 || slot > 1) in litest_slot_start()
2202 slot = d->ntouches_down; in litest_slot_start()
2204 if (d->ntouches_down == 0) { in litest_slot_start()
2209 l = min(x, d->semi_mt.touches[other].x); in litest_slot_start()
2210 t = min(y, d->semi_mt.touches[other].y); in litest_slot_start()
2211 r = max(x, d->semi_mt.touches[other].x); in litest_slot_start()
2212 b = max(y, d->semi_mt.touches[other].y); in litest_slot_start()
2216 if (d->ntouches_down == 0) in litest_slot_start()
2228 d->semi_mt.touches[slot].x = x; in litest_slot_start()
2229 d->semi_mt.touches[slot].y = y; in litest_slot_start()
2279 if (!d->semi_mt.is_semi_mt) { in litest_slot_move()
2284 if (d->ntouches_down > 2 || slot > 1) in litest_slot_move()
2287 if (d->ntouches_down == 1) { in litest_slot_move()
2292 l = min(x, d->semi_mt.touches[other].x); in litest_slot_move()
2293 t = min(y, d->semi_mt.touches[other].y); in litest_slot_move()
2294 r = max(x, d->semi_mt.touches[other].x); in litest_slot_move()
2295 b = max(y, d->semi_mt.touches[other].y); in litest_slot_move()
2301 if (d->ntouches_down == 2) { in litest_slot_move()
2308 d->semi_mt.touches[slot].x = x; in litest_slot_move()
2309 d->semi_mt.touches[slot].y = y; in litest_slot_move()
2315 if (!d->semi_mt.is_semi_mt) { in litest_touch_up()
2320 if (d->ntouches_down > 2 || slot > 1) in litest_touch_up()
2324 touch_up(d, d->ntouches_down - 1); in litest_touch_up()
2328 if (d->ntouches_down == 1) { in litest_touch_up()
2335 d->semi_mt.touches[other].x, in litest_touch_up()
2336 d->semi_mt.touches[other].y, in litest_touch_up()
2390 x_from + (x_to - x_from)/steps * i, in litest_touch_move_to_extended()
2391 y_from + (y_to - y_from)/steps * i, in litest_touch_move_to_extended()
2393 libinput_dispatch(d->libinput); in litest_touch_move_to_extended()
2395 libinput_dispatch(d->libinput); in litest_touch_move_to_extended()
2407 int value = ev->value; in auto_assign_tablet_value()
2409 if (value != LITEST_AUTO_ASSIGN || ev->type != EV_ABS) in auto_assign_tablet_value()
2412 switch (ev->code) { in auto_assign_tablet_value()
2425 if (!axis_replacement_value(d, axes, ev->code, &value) && in auto_assign_tablet_value()
2426 d->interface->get_axis_default) { in auto_assign_tablet_value()
2427 int error = d->interface->get_axis_default(d, ev->code, &value); in auto_assign_tablet_value()
2430 libevdev_event_code_get_name(EV_ABS, ev->code), in auto_assign_tablet_value()
2431 ev->code); in auto_assign_tablet_value()
2443 return value == -1 && (ev->code == ABS_PRESSURE || ev->code == ABS_DISTANCE); in tablet_ignore_event()
2462 d->interface->tool_type = code; in litest_tablet_set_tool_type()
2468 unsigned int tool = d->interface->tool_type; in litest_tool_event()
2480 /* If the test device overrides proximity_in and says it didn't in litest_tablet_proximity_in()
2482 if (d->interface->tablet_proximity_in && in litest_tablet_proximity_in()
2483 d->interface->tablet_proximity_in(d, d->interface->tool_type, &x, &y, axes)) in litest_tablet_proximity_in()
2486 ev = d->interface->tablet_proximity_in_events; in litest_tablet_proximity_in()
2487 while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) { in litest_tablet_proximity_in()
2490 switch (evbit(ev->type, ev->code)) { in litest_tablet_proximity_in()
2492 litest_tool_event(d, ev->value); in litest_tablet_proximity_in()
2497 litest_event(d, ev->type, ev->code, value); in litest_tablet_proximity_in()
2508 /* If the test device overrides proximity_out and says it didn't in litest_tablet_proximity_out()
2510 if (d->interface->tablet_proximity_out && in litest_tablet_proximity_out()
2511 d->interface->tablet_proximity_out(d, d->interface->tool_type)) in litest_tablet_proximity_out()
2514 ev = d->interface->tablet_proximity_out_events; in litest_tablet_proximity_out()
2515 while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) { in litest_tablet_proximity_out()
2518 switch (evbit(ev->type, ev->code)) { in litest_tablet_proximity_out()
2520 litest_tool_event(d, ev->value); in litest_tablet_proximity_out()
2523 value = auto_assign_tablet_value(d, ev, -1, -1, NULL); in litest_tablet_proximity_out()
2525 litest_event(d, ev->type, ev->code, value); in litest_tablet_proximity_out()
2539 /* If the test device overrides proximity_out and says it didn't in litest_tablet_motion()
2541 if (d->interface->tablet_motion && in litest_tablet_motion()
2542 d->interface->tablet_motion(d, &x, &y, axes)) in litest_tablet_motion()
2545 ev = d->interface->tablet_motion_events; in litest_tablet_motion()
2546 while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) { in litest_tablet_motion()
2549 litest_event(d, ev->type, ev->code, value); in litest_tablet_motion()
2559 /* If the test device overrides tip_down and says it didn't in litest_tablet_tip_down()
2561 if (d->interface->tablet_tip_down && in litest_tablet_tip_down()
2562 d->interface->tablet_tip_down(d, &x, &y, axes)) in litest_tablet_tip_down()
2574 /* If the test device overrides tip_down and says it didn't in litest_tablet_tip_up()
2576 if (d->interface->tablet_tip_up && in litest_tablet_tip_up()
2577 d->interface->tablet_tip_up(d, &x, &y, axes)) in litest_tablet_tip_up()
2600 libinput_dispatch(d->libinput); in litest_touch_move_two_touches()
2602 libinput_dispatch(d->libinput); in litest_touch_move_two_touches()
2630 libinput_dispatch(d->libinput); in litest_touch_move_three_touches()
2633 libinput_dispatch(d->libinput); in litest_touch_move_three_touches()
2645 {-1, -1 }, in litest_hover_start()
2658 { .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = -1 }, in litest_hover_end()
2660 { .type = -1, .code = -1 } in litest_hover_end()
2663 litest_assert_int_gt(d->ntouches_down, 0); in litest_hover_end()
2664 d->ntouches_down--; in litest_hover_end()
2668 if (d->interface->touch_up) { in litest_hover_end()
2669 d->interface->touch_up(d, slot); in litest_hover_end()
2671 } else if (d->interface->touch_up_events) { in litest_hover_end()
2672 ev = d->interface->touch_up_events; in litest_hover_end()
2676 while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) { in litest_hover_end()
2678 litest_event(d, ev->type, ev->code, value); in litest_hover_end()
2690 {-1, -1 }, in litest_hover_move()
2705 for (int i = 0; i < steps - 1; i++) { in litest_hover_move_to()
2707 x_from + (x_to - x_from)/steps * i, in litest_hover_move_to()
2708 y_from + (y_to - y_from)/steps * i); in litest_hover_move_to()
2709 libinput_dispatch(d->libinput); in litest_hover_move_to()
2711 libinput_dispatch(d->libinput); in litest_hover_move_to()
2725 for (int i = 0; i < steps - 1; i++) { in litest_hover_move_two_touches()
2732 libinput_dispatch(d->libinput); in litest_hover_move_two_touches()
2734 libinput_dispatch(d->libinput); in litest_hover_move_two_touches()
2753 litest_event(d, ev->type, ev->code, ev->value); in litest_button_click()
2758 struct libinput *li, in litest_button_click_debounced()
2774 struct libinput *li = dev->libinput; in litest_button_scroll()
2796 struct libinput *li = dev->libinput; in litest_button_scroll_locked()
2821 litest_event(d, ev->type, ev->code, ev->value); in litest_keyboard_key()
2860 abs = libevdev_get_abs_info(d->evdev, axis); in litest_scale_axis()
2863 return (abs->maximum - abs->minimum) * val/100.0 + abs->minimum; in litest_scale_axis()
2872 return (max - min) * val/100.0 + min; in litest_scale_range()
2887 min = d->interface->min[axis]; in litest_scale()
2888 max = d->interface->max[axis]; in litest_scale()
2903 if (ev->value != LITEST_AUTO_ASSIGN || in auto_assign_pad_value()
2904 ev->type != EV_ABS) in auto_assign_pad_value()
2907 abs = libevdev_get_abs_info(dev->evdev, ev->code); in auto_assign_pad_value()
2910 if (ev->code == ABS_RX || ev->code == ABS_RY) { in auto_assign_pad_value()
2911 double min = abs->minimum != 0 ? log2(abs->minimum) : 0, in auto_assign_pad_value()
2912 max = abs->maximum != 0 ? log2(abs->maximum) : 0; in auto_assign_pad_value()
2923 return litest_scale_range(abs->minimum, abs->maximum, value); in auto_assign_pad_value()
2932 ev = d->interface->pad_ring_start_events; in litest_pad_ring_start()
2933 while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) { in litest_pad_ring_start()
2935 litest_event(d, ev->type, ev->code, value); in litest_pad_ring_start()
2945 ev = d->interface->pad_ring_change_events; in litest_pad_ring_change()
2946 while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) { in litest_pad_ring_change()
2948 litest_event(d, ev->type, ev->code, value); in litest_pad_ring_change()
2958 ev = d->interface->pad_ring_end_events; in litest_pad_ring_end()
2959 while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) { in litest_pad_ring_end()
2960 litest_event(d, ev->type, ev->code, ev->value); in litest_pad_ring_end()
2970 ev = d->interface->pad_strip_start_events; in litest_pad_strip_start()
2971 while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) { in litest_pad_strip_start()
2973 litest_event(d, ev->type, ev->code, value); in litest_pad_strip_start()
2983 ev = d->interface->pad_strip_change_events; in litest_pad_strip_change()
2984 while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) { in litest_pad_strip_change()
2986 litest_event(d, ev->type, ev->code, value); in litest_pad_strip_change()
2996 ev = d->interface->pad_strip_end_events; in litest_pad_strip_end()
2997 while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) { in litest_pad_strip_end()
2998 litest_event(d, ev->type, ev->code, ev->value); in litest_pad_strip_end()
3004 litest_wait_for_event(struct libinput *li) in litest_wait_for_event()
3006 return litest_wait_for_event_of_type(li, -1); in litest_wait_for_event()
3010 litest_wait_for_event_of_type(struct libinput *li, ...) in litest_wait_for_event_of_type()
3020 while ((int)type != -1) { in litest_wait_for_event_of_type()
3057 litest_drain_events(struct libinput *li) in litest_drain_events()
3070 litest_drain_events_of_type(struct libinput *li, ...) in litest_drain_events_of_type()
3079 while ((int)type != -1) { in litest_drain_events_of_type()
3149 str = "TOUCH DOWN"; in litest_event_type_str()
3152 str = "TOUCH UP"; in litest_event_type_str()
3155 str = "TOUCH MOTION"; in litest_event_type_str()
3158 str = "TOUCH CANCEL"; in litest_event_type_str()
3161 str = "TOUCH FRAME"; in litest_event_type_str()
3320 _litest_assert_event_type_is_one_of(__VA_ARGS__, -1)
3332 while ((int)expected_type != -1 && !match) { in _litest_assert_event_type_is_one_of()
3349 while ((int)expected_type != -1) { in _litest_assert_event_type_is_one_of()
3356 if ((int)expected_type != -1) in _litest_assert_event_type_is_one_of()
3374 litest_assert_empty_queue(struct libinput *li) in litest_assert_empty_queue()
3420 libevdev_set_id_bustype(dev, id->bustype); in litest_create_uinput()
3421 libevdev_set_id_vendor(dev, id->vendor); in litest_create_uinput()
3422 libevdev_set_id_product(dev, id->product); in litest_create_uinput()
3423 libevdev_set_id_version(dev, id->version); in litest_create_uinput()
3427 while (abs && abs->value != -1) { in litest_create_uinput()
3430 /* abs_info->value is used for the code and may be outside in litest_create_uinput()
3432 a.value = abs->minimum; in litest_create_uinput()
3433 rc = libevdev_enable_event_code(dev, EV_ABS, abs->value, &a); in litest_create_uinput()
3439 (type = *events++) != -1 && in litest_create_uinput()
3440 (code = *events++) != -1) { in litest_create_uinput()
3453 /* workaround for a bug in libevdev pre-1.3 in litest_create_uinput()
3455 if (rc == -EBADF) in litest_create_uinput()
3456 rc = -EACCES; in litest_create_uinput()
3457 litest_assert_msg(rc == 0, "Failed to create uinput device: %s\n", strerror(-rc)); in litest_create_uinput()
3464 litest_assert_int_gt(fd, -1); in litest_create_uinput()
3471 * by the time libinput uses the device, we're finished here. in litest_create_uinput()
3477 while (abs && abs->value != -1) { in litest_create_uinput()
3478 if (abs->resolution != 0) { in litest_create_uinput()
3479 if (libevdev_get_abs_resolution(dev, abs->value) == in litest_create_uinput()
3480 abs->resolution) in litest_create_uinput()
3484 abs->value, in litest_create_uinput()
3536 while ((type = va_arg(args, int)) != -1 && in litest_create_uinput_abs_device_v()
3537 (code = va_arg(args, int)) != -1) { in litest_create_uinput_abs_device_v()
3540 litest_assert(event < &events[ARRAY_LENGTH(events) - 2]); in litest_create_uinput_abs_device_v()
3543 *event++ = -1; in litest_create_uinput_abs_device_v()
3544 *event++ = -1; in litest_create_uinput_abs_device_v()
3660 litest_assert_key_event(struct libinput *li, unsigned int key, in litest_assert_key_event()
3674 litest_assert_button_event(struct libinput *li, unsigned int button, in litest_assert_button_event()
3691 struct libinput_event_touch *touch; in litest_is_touch_event() local
3707 ck_abort_msg("%s: invalid touch type %d\n", __func__, type); in litest_is_touch_event()
3710 touch = libinput_event_get_touch_event(event); in litest_is_touch_event()
3712 return touch; in litest_is_touch_event()
3748 if (nfingers != -1) in litest_is_gesture_event()
3755 litest_assert_gesture_event(struct libinput *li, in litest_assert_gesture_event()
3784 litest_assert_tablet_button_event(struct libinput *li, unsigned int button, in litest_assert_tablet_button_event()
3867 void litest_assert_tablet_proximity_event(struct libinput *li, in litest_assert_tablet_proximity_event()
3878 void litest_assert_tablet_tip_event(struct libinput *li, in litest_assert_tablet_tip_event()
3999 litest_assert_switch_event(struct libinput *li, in litest_assert_switch_event()
4014 litest_assert_pad_button_event(struct libinput *li, in litest_assert_pad_button_event()
4028 litest_assert_pad_key_event(struct libinput *li, in litest_assert_pad_key_event()
4042 litest_assert_scroll(struct libinput *li, in litest_assert_scroll()
4108 litest_assert_axis_end_sequence(struct libinput *li, in litest_assert_axis_end_sequence()
4149 litest_assert_only_typed_events(struct libinput *li, in litest_assert_only_typed_events()
4169 litest_assert_only_axis_events(struct libinput *li, in litest_assert_only_axis_events()
4193 litest_assert_no_typed_events(struct libinput *li, in litest_assert_no_typed_events()
4213 litest_assert_touch_sequence(struct libinput *li) in litest_assert_touch_sequence()
4251 litest_assert_touch_motion_frame(struct libinput *li) in litest_assert_touch_motion_frame()
4278 litest_assert_touch_down_frame(struct libinput *li) in litest_assert_touch_down_frame()
4292 litest_assert_touch_up_frame(struct libinput *li) in litest_assert_touch_up_frame()
4306 litest_assert_touch_cancel(struct libinput *li) in litest_assert_touch_cancel()
4436 litest_assert_int_ge(dev->skip_ev_syn, 0); in litest_push_event_frame()
4437 dev->skip_ev_syn++; in litest_push_event_frame()
4443 litest_assert_int_gt(dev->skip_ev_syn, 0); in litest_pop_event_frame()
4444 dev->skip_ev_syn--; in litest_pop_event_frame()
4445 if (dev->skip_ev_syn == 0) in litest_pop_event_frame()
4454 libevdev_disable_event_code(dev->evdev, type, code); in litest_filter_event()
4462 /* would need an non-NULL argument for re-enabling, so simply abort in litest_unfilter_event()
4466 libevdev_enable_event_code(dev->evdev, type, code, NULL); in litest_unfilter_event()
4512 if (d->ntouches_down > 2 || slot > 1) in litest_semi_mt_touch_down()
4515 if (d->ntouches_down == 1) { in litest_semi_mt_touch_down()
4520 l = min(x, semi_mt->touches[other].x); in litest_semi_mt_touch_down()
4521 t = min(y, semi_mt->touches[other].y); in litest_semi_mt_touch_down()
4522 r = max(x, semi_mt->touches[other].x); in litest_semi_mt_touch_down()
4523 b = max(y, semi_mt->touches[other].y); in litest_semi_mt_touch_down()
4530 if (d->ntouches_down == 1) in litest_semi_mt_touch_down()
4531 litest_event(d, EV_ABS, ABS_MT_TRACKING_ID, ++semi_mt->tracking_id); in litest_semi_mt_touch_down()
4535 if (d->ntouches_down == 2) { in litest_semi_mt_touch_down()
4537 litest_event(d, EV_ABS, ABS_MT_TRACKING_ID, ++semi_mt->tracking_id); in litest_semi_mt_touch_down()
4544 semi_mt->touches[slot].x = x; in litest_semi_mt_touch_down()
4545 semi_mt->touches[slot].y = y; in litest_semi_mt_touch_down()
4556 if (d->ntouches_down > 2 || slot > 1) in litest_semi_mt_touch_move()
4559 if (d->ntouches_down == 1) { in litest_semi_mt_touch_move()
4564 l = min(x, semi_mt->touches[other].x); in litest_semi_mt_touch_move()
4565 t = min(y, semi_mt->touches[other].y); in litest_semi_mt_touch_move()
4566 r = max(x, semi_mt->touches[other].x); in litest_semi_mt_touch_move()
4567 b = max(y, semi_mt->touches[other].y); in litest_semi_mt_touch_move()
4575 if (d->ntouches_down == 2) { in litest_semi_mt_touch_move()
4582 semi_mt->touches[slot].x = x; in litest_semi_mt_touch_move()
4583 semi_mt->touches[slot].y = y; in litest_semi_mt_touch_move()
4592 if (d->ntouches_down >= 2 || slot > 1) in litest_semi_mt_touch_up()
4595 litest_event(d, EV_ABS, ABS_MT_SLOT, d->ntouches_down); in litest_semi_mt_touch_up()
4596 litest_event(d, EV_ABS, ABS_MT_TRACKING_ID, -1); in litest_semi_mt_touch_up()
4600 if (d->ntouches_down == 1) { in litest_semi_mt_touch_up()
4602 send_abs_xy(d, semi_mt->touches[other].x, semi_mt->touches[other].y); in litest_semi_mt_touch_up()
4604 send_abs_mt_xy(d, semi_mt->touches[other].x, semi_mt->touches[other].y); in litest_semi_mt_touch_up()
4630 { "filter-test", 1, 0, OPT_FILTER_TEST }, in litest_parse_argv()
4631 { "filter-device", 1, 0, OPT_FILTER_DEVICE }, in litest_parse_argv()
4632 { "filter-group", 1, 0, OPT_FILTER_GROUP }, in litest_parse_argv()
4633 { "filter-deviceless", 0, 0, OPT_FILTER_DEVICELESS }, in litest_parse_argv()
4634 { "xml-output", 1, 0, OPT_XML_PREFIX }, in litest_parse_argv()
4671 if (c == -1) in litest_parse_argv()
4676 printf("Usage: %s [--verbose] [--jobs] [--filter-...]\n" in litest_parse_argv()
4679 " --filter-test=.... \n" in litest_parse_argv()
4680 " Glob to filter on test names\n" in litest_parse_argv()
4681 " --filter-device=.... \n" in litest_parse_argv()
4683 " --filter-group=.... \n" in litest_parse_argv()
4684 " Glob to filter on test groups\n" in litest_parse_argv()
4685 " --filter-deviceless=.... \n" in litest_parse_argv()
4686 " Glob to filter on tests that do not create test devices\n" in litest_parse_argv()
4687 " --xml-output=/path/to/file-XXXXXXX.xml\n" in litest_parse_argv()
4688 " Write test output in libcheck's XML format\n" in litest_parse_argv()
4690 " prefix-XXXXXX.xml and only the prefix is your choice.\n" in litest_parse_argv()
4691 " --verbose\n" in litest_parse_argv()
4693 " --jobs 8\n" in litest_parse_argv()
4694 " Number of parallel test suites to run (default: 8).\n" in litest_parse_argv()
4696 " --list\n" in litest_parse_argv()
4699 "See the libinput-test-suite(1) man page for details.\n", in litest_parse_argv()
4749 if (pid == -1) in is_debugger_attached()
4774 struct suite *s; in litest_list_tests()
4778 struct test *t; in litest_list_tests()
4779 printf("%s:\n", s->name); in litest_list_tests()
4780 list_for_each(t, &s->tests, node) { in litest_list_tests()
4782 !streq(last_test_name, t->name)) in litest_list_tests()
4783 printf(" %s:\n", t->name); in litest_list_tests()
4785 last_test_name = t->name; in litest_list_tests()
4787 printf(" %s\n", t->devname); in litest_list_tests()
4802 list_append(&devices, &t->device->node); in litest_init_test_devices()
4816 c->setup(); in setup_tests()
4830 if (access("/dev/uinput", F_OK) == -1 && in check_device_access()
4831 access("/dev/input/uinput", F_OK) == -1) { in check_device_access()
4843 int tty_mode = -1; in disable_tty()
4847 * without forking, leave it as-is. in disable_tty()
4863 fprintf(stderr, "Failed to get terminal attribute: %d - %s\n", errno, strerror(errno)); in disable_tty()
4866 fprintf(stderr, "Failed to set terminal attribute: %d - %s\n", errno, strerror(errno)); in disable_tty()
4878 int tty_mode = -1; in main()
4919 if (tty_mode != -1) { in main()
4925 fprintf(stderr, "Failed to get terminal attribute: %d - %s\n", errno, strerror(errno)); in main()
4928 fprintf(stderr, "Failed to set terminal attribute: %d - %s\n", errno, strerror(errno)); in main()