summaryrefslogtreecommitdiff
path: root/test/test-libevdev-init.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2014-01-17 10:21:48 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2014-01-22 09:14:40 +1000
commit0c0188698554a00eb0d910ef7610998156724f49 (patch)
treedac53e51e9361431e75a740e279914965b2972e6 /test/test-libevdev-init.c
parent77bf0fe228b86e78d7b61f0f66e7526a1c5a0c50 (diff)
downloadlibevdev-0c0188698554a00eb0d910ef7610998156724f49.tar.gz
test: abort on unexpected log messages
Add two log functions, one that aborts on a received message. We know when we expect to receive an error, so anytime this happens unexpectedly should terminate the test. And for those tests do issue a log message, let them ignore it and don't print anything. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'test/test-libevdev-init.c')
-rw-r--r--test/test-libevdev-init.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/test-libevdev-init.c b/test/test-libevdev-init.c
index bf0b874..6be3d74 100644
--- a/test/test-libevdev-init.c
+++ b/test/test-libevdev-init.c
@@ -73,7 +73,10 @@ START_TEST(test_init_and_change_fd)
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,
@@ -87,7 +90,10 @@ START_TEST(test_init_and_change_fd)
-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));
@@ -136,6 +142,8 @@ START_TEST(test_log_init)
ck_assert_int_eq(log_fn_called, 2);
libevdev_free(dev);
+
+ libevdev_set_log_function(test_logfunc_abort_on_error, NULL);
}
END_TEST
@@ -247,10 +255,12 @@ START_TEST(test_device_grab)
-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);