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 <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2017-10-06 10:41:08 +10:00
parent 3b0f1d767a
commit 7e72c8e5bb

View file

@ -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