From: DoHyun Pyun Date: Tue, 3 Dec 2019 01:35:16 +0000 (+0900) Subject: Include bt_onoff tool in capi-network-bluetooth-test rpm X-Git-Tag: submit/tizen_5.5/20191206.000647~1^2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d5dfe61fd121f5d0a01193318ad3e3dba8a6c12;p=platform%2Fcore%2Fapi%2Fbluetooth.git Include bt_onoff tool in capi-network-bluetooth-test rpm Change-Id: I7181a75c22d7ae9a5a7104b8a3e25553ab87f931 Signed-off-by: DoHyun Pyun --- diff --git a/packaging/capi-network-bluetooth.spec b/packaging/capi-network-bluetooth.spec index 2e37b83..60b1984 100644 --- a/packaging/capi-network-bluetooth.spec +++ b/packaging/capi-network-bluetooth.spec @@ -119,7 +119,7 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj %files test %manifest %{name}.manifest %{_bindir}/bt_unit_test -#%{_bindir}/bt_onoff +%{_bindir}/bt_onoff #/etc/smack/accesses.d/capi-network-bluetooth-test.efl %files devel diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bb1758f..00c90eb 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -17,4 +17,4 @@ FOREACH(src ${sources}) ENDFOREACH() INSTALL(TARGETS bt_unit_test DESTINATION bin) -#INSTALL(TARGETS bt_onoff DESTINATION bin) +INSTALL(TARGETS bt_onoff DESTINATION bin) diff --git a/test/bt_onoff.c b/test/bt_onoff.c index 28c7c89..038bc5f 100644 --- a/test/bt_onoff.c +++ b/test/bt_onoff.c @@ -30,6 +30,28 @@ GMainLoop *main_loop = NULL; static guint onoff_timer = 0; +static int cnt = 0; + +static gboolean __bt_onoff_timeout_cb(gpointer data); + +static void __bt_retry_onoff(bt_adapter_state_e state) +{ + int ret; + + cnt++; + + TC_PRT("Retry cnt: %d", cnt); + + onoff_timer = g_timeout_add(20000, (GSourceFunc)__bt_onoff_timeout_cb, NULL); + + if (state == BT_ADAPTER_DISABLED) + ret = bt_adapter_enable(); + else + ret = bt_adapter_disable(); + + TC_PRT("bt_adapter_%s() error(%d)", + state == BT_ADAPTER_DISABLED ? "enable" : "disable", ret); +} static void __bt_adapter_state_changed_cb(int result, bt_adapter_state_e adapter_state, void *user_data) @@ -45,10 +67,7 @@ static void __bt_adapter_state_changed_cb(int result, execv("all_log_dump.sh", argv); } - if (main_loop) - g_main_loop_quit(main_loop); - else - exit(0); + __bt_retry_onoff(adapter_state); } static gboolean __bt_onoff_timeout_cb(gpointer data) @@ -92,13 +111,14 @@ int main(int argc, char *argv[]) NULL); if (argc <= 1) { - if (state == BT_ADAPTER_DISABLED) + if (state == BT_ADAPTER_DISABLED) { ret = bt_adapter_enable(); else ret = bt_adapter_disable(); + TC_PRT("bt_adapter_%s() error(%d)", - state == BT_ADAPTER_DISABLED ? "enable" : "disable", - ret); + state == BT_ADAPTER_DISABLED ? "enable" : "disable", ret); + } } else { if (argv[1][0] == '0') { if (state == BT_ADAPTER_DISABLED) {