From a6a5df963f0b7aa720194a8af66494fc527792a0 Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Wed, 31 Mar 2021 13:23:04 +0300 Subject: [PATCH] [unit] Test for gbinder_idle_callback_invoke_later(). JB#53719 --- unit/coverage/run | 9 ++++--- unit/unit_eventloop/unit_eventloop.c | 39 ++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/unit/coverage/run b/unit/coverage/run index d6a2aea..ef255b7 100755 --- a/unit/coverage/run +++ b/unit/coverage/run @@ -1,4 +1,3 @@ - #!/bin/bash # # This script requires lcov, dirname @@ -65,9 +64,13 @@ for t in $TESTS ; do popd done +# Sometimes you need this, sometimes that :S +BASE_DIR="$TOP_DIR" +#BASE_DIR="$TOP_DIR/src" + FULL_COV="$COV_DIR/full.gcov" LIB_COV="$COV_DIR/lib.gcov" rm -f "$FULL_COV" "$LIB_COV" -lcov $LCOV_OPT -c -d "$TOP_DIR/build/coverage" -b "$TOP_DIR/src" -o "$FULL_COV" || exit 1 -lcov $LCOV_OPT -e "$FULL_COV" "$TOP_DIR/src/*" -o "$LIB_COV" || exit 1 +lcov $LCOV_OPT -c -d "$TOP_DIR/build/coverage" -b "$BASE_DIR" -o "$FULL_COV" || exit 1 +lcov $LCOV_OPT -e "$FULL_COV" "$BASE_DIR/*" -o "$LIB_COV" || exit 1 genhtml $GENHTML_OPT "$LIB_COV" -t "libgbinder" --output-directory "$COV_DIR/report" || exit 1 diff --git a/unit/unit_eventloop/unit_eventloop.c b/unit/unit_eventloop/unit_eventloop.c index b750351..ea058a2 100644 --- a/unit/unit_eventloop/unit_eventloop.c +++ b/unit/unit_eventloop/unit_eventloop.c @@ -48,6 +48,14 @@ test_unreached_proc( return G_SOURCE_CONTINUE; } +static +void +test_quit_cb( + gpointer data) +{ + g_main_loop_quit((GMainLoop*)data); +} + /*==========================================================================* * Test event loop integration *==========================================================================*/ @@ -212,14 +220,6 @@ test_timeout( * callback *==========================================================================*/ -static -void -test_quit_cb( - gpointer data) -{ - g_main_loop_quit((GMainLoop*)data); -} - static void test_callback( @@ -238,6 +238,28 @@ test_callback( g_main_loop_unref(loop); } +/*==========================================================================* + * invoke + *==========================================================================*/ + +static +void +test_invoke( + void) +{ + GMainLoop* loop = g_main_loop_new(NULL, FALSE); + + gbinder_eventloop_set(NULL); + gbinder_idle_callback_invoke_later(test_quit_cb, loop, NULL); + test_run(&test_opt, loop); + + gbinder_eventloop_set(NULL); + gbinder_idle_callback_invoke_later(NULL, loop, test_quit_cb); + test_run(&test_opt, loop); + + g_main_loop_unref(loop); +} + /*==========================================================================* * Common *==========================================================================*/ @@ -251,6 +273,7 @@ int main(int argc, char* argv[]) g_test_add_func(TEST_("idle"), test_idle); g_test_add_func(TEST_("timeout"), test_timeout); g_test_add_func(TEST_("callback"), test_callback); + g_test_add_func(TEST_("invoke"), test_invoke); test_init(&test_opt, argc, argv); return g_test_run(); }