#include <check.h>
#include <errno.h>
#include <fcntl.h>
+#include <stdio.h>
#include "test-common.h"
+void test_logfunc_abort_on_error(enum libevdev_log_priority priority,
+ void *data,
+ const char *file, int line,
+ const char *func,
+ const char *format, va_list args)
+{
+ vprintf(format, args);
+ ck_abort();
+}
+
+void test_logfunc_ignore_error(enum libevdev_log_priority priority,
+ void *data,
+ const char *file, int line,
+ const char *func,
+ const char *format, va_list args)
+{
+}
+
int test_create_device(struct uinput_device **uidev_return,
struct libevdev **dev_return,
...)
const struct input_absinfo *abs,
...);
+void test_logfunc_abort_on_error(enum libevdev_log_priority priority,
+ void *data,
+ const char *file, int line,
+ const char *func,
+ const char *format, va_list args);
+void test_logfunc_ignore_error(enum libevdev_log_priority priority,
+ void *data,
+ const char *file, int line,
+ const char *func,
+ const char *format, va_list args);
#endif /* _TEST_COMMON_H_ */
dev = libevdev_new();
ck_assert(dev != NULL);
ck_assert_int_eq(libevdev_set_fd(dev, -1), -EBADF);
+
+ libevdev_set_log_function(test_logfunc_ignore_error, NULL);
ck_assert_int_eq(libevdev_change_fd(dev, -1), -1);
+ libevdev_set_log_function(test_logfunc_abort_on_error, NULL);
rc = uinput_device_new_with_events(&uidev,
TEST_DEVICE_NAME, DEFAULT_IDS,
-1);
ck_assert_msg(rc == 0, "Failed to create uinput device: %s", strerror(-rc));
ck_assert_int_eq(libevdev_set_fd(dev, uinput_device_get_fd(uidev)), 0);
+
+ libevdev_set_log_function(test_logfunc_ignore_error, NULL);
ck_assert_int_eq(libevdev_set_fd(dev, 0), -EBADF);
+ libevdev_set_log_function(test_logfunc_abort_on_error, NULL);
ck_assert_int_eq(libevdev_get_fd(dev), uinput_device_get_fd(uidev));
ck_assert_int_eq(log_fn_called, 2);
libevdev_free(dev);
+
+ libevdev_set_log_function(test_logfunc_abort_on_error, NULL);
}
END_TEST
-1);
ck_assert_msg(rc == 0, "Failed to create device: %s", strerror(-rc));
+ libevdev_set_log_function(test_logfunc_ignore_error, NULL);
rc = libevdev_grab(dev, 0);
ck_assert_int_eq(rc, -EINVAL);
rc = libevdev_grab(dev, 1);
ck_assert_int_eq(rc, -EINVAL);
+ libevdev_set_log_function(test_logfunc_abort_on_error, NULL);
rc = libevdev_grab(dev, LIBEVDEV_UNGRAB);
ck_assert_int_eq(rc, 0);
#include <unistd.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
+#include <libevdev/libevdev.h>
+
+#include "test-common.h"
extern Suite *event_name_suite(void);
extern Suite *event_code_suite(void);
if (is_debugger_attached())
setenv("CK_FORK", "no", 0);
+ libevdev_set_log_function(test_logfunc_abort_on_error, NULL);
+
Suite *s = libevdev_has_event_test();
SRunner *sr = srunner_create(s);
srunner_add_suite(sr, libevdev_events());
libevdev_enable_event_code(dev, EV_REL, REL_X, NULL);
libevdev_enable_event_code(dev, EV_REL, REL_Y, NULL);
+ libevdev_set_log_function(test_logfunc_ignore_error, NULL);
rc = libevdev_uinput_create_from_device(dev, -1, &uidev);
ck_assert_int_eq(rc, -EBADF);
ck_assert(uidev == NULL);
+ libevdev_set_log_function(test_logfunc_abort_on_error, NULL);
libevdev_free(dev);
}