From 7e72c8e5bb32dea24cf37a492b44ab586d8b0bf4 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 6 Oct 2017 10:41:08 +1000 Subject: [PATCH] test: always init the log_handler count and reset it last When running with -j 1 and CK_FORK=no, the log_handler_count is shared between the tests. The log_priority tests can invoke the log handler during libinput_unref(), so on the next day the log handler starts with a nonzero log handler. Fix this by always initializing it to 0 in the tests we expect it to be zero and resetting it last. Signed-off-by: Peter Hutterer --- test/test-log.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/test/test-log.c b/test/test-log.c index 6b1e3923..2a9766c5 100644 --- a/test/test-log.c +++ b/test/test-log.c @@ -80,6 +80,9 @@ START_TEST(log_handler_invoked) { struct libinput *li; + log_handler_context = NULL; + log_handler_called = 0; + li = libinput_path_create_context(&simple_interface, NULL); libinput_log_set_priority(li, LIBINPUT_LOG_PRIORITY_DEBUG); @@ -89,11 +92,11 @@ START_TEST(log_handler_invoked) libinput_path_add_device(li, "/tmp"); ck_assert_int_gt(log_handler_called, 0); - log_handler_called = 0; libinput_unref(li); log_handler_context = NULL; + log_handler_called = 0; } END_TEST @@ -101,6 +104,8 @@ START_TEST(log_handler_NULL) { struct libinput *li; + log_handler_called = 0; + li = libinput_path_create_context(&simple_interface, NULL); libinput_log_set_priority(li, LIBINPUT_LOG_PRIORITY_DEBUG); libinput_log_set_handler(li, NULL); @@ -108,9 +113,10 @@ START_TEST(log_handler_NULL) libinput_path_add_device(li, "/tmp"); ck_assert_int_eq(log_handler_called, 0); - log_handler_called = 0; libinput_unref(li); + + log_handler_called = 0; } END_TEST @@ -118,6 +124,9 @@ START_TEST(log_priority) { struct libinput *li; + log_handler_context = NULL; + log_handler_called = 0; + li = libinput_path_create_context(&simple_interface, NULL); libinput_log_set_priority(li, LIBINPUT_LOG_PRIORITY_ERROR); libinput_log_set_handler(li, simple_log_handler); @@ -133,10 +142,10 @@ START_TEST(log_priority) libinput_path_add_device(li, "/dev/input/event0"); ck_assert_int_gt(log_handler_called, 1); - log_handler_called = 0; - libinput_unref(li); + log_handler_context = NULL; + log_handler_called = 0; } END_TEST