[PATCH libevdev 9/9] test: test for logging function
Peter Hutterer
peter.hutterer at who-t.net
Tue Sep 3 00:07:47 PDT 2013
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
test/test-libevdev-init.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/test/test-libevdev-init.c b/test/test-libevdev-init.c
index 8f1d0d1..2610975 100644
--- a/test/test-libevdev-init.c
+++ b/test/test-libevdev-init.c
@@ -93,10 +93,16 @@ START_TEST(test_init_and_change_fd)
}
END_TEST
+
+static int log_fn_called = 0;
+static char *logdata = "test";
static void logfunc(enum libevdev_log_priority priority,
void *data,
const char *file, int line, const char *func,
- const char *f, va_list args) {}
+ const char *f, va_list args) {
+ ck_assert_int_eq(strcmp(logdata, data), 0);
+ log_fn_called++;
+}
START_TEST(test_log_init)
{
@@ -107,16 +113,19 @@ START_TEST(test_log_init)
dev = libevdev_new();
ck_assert(dev != NULL);
- libevdev_set_log_function(logfunc, NULL);
- libevdev_free(dev);
- dev = libevdev_new();
- ck_assert(dev != NULL);
+ libevdev_set_log_function(logfunc, logdata);
+ libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, NULL);
+
libevdev_set_log_function(NULL, NULL);
- libevdev_set_log_function(logfunc, NULL);
+ libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, NULL);
+
+ libevdev_set_log_function(logfunc, logdata);
+ libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, NULL);
+
+ ck_assert_int_eq(log_fn_called, 2);
+
libevdev_free(dev);
- /* well, we didn't crash. can't test this otherwise */
-
}
END_TEST
--
1.8.2.1
More information about the Input-tools
mailing list