From: injun.yang Date: Fri, 23 Feb 2018 02:08:52 +0000 (+0900) Subject: Remove redundant code X-Git-Tag: submit/tizen_4.0/20180328.084945~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b7b16a2e9234032b501af2ea27c21c14f2b33191;p=platform%2Fcore%2Fapi%2Fbluetooth.git Remove redundant code Change-Id: I982da86ab480c4bd75d3923b8d80fbb0d255ce09 --- diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c index 667a6b2..416f315 100644 --- a/test/bt_unit_test.c +++ b/test/bt_unit_test.c @@ -224,6 +224,8 @@ tc_table_t tc_adapter[] = { , BT_UNIT_TEST_FUNCTION_ADAPTER_IS_SERVICE_USED}, {"bt_adapter_get_visibility" , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_VISIBILITY}, + {"bt_adapter_set_visibility" + , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY}, {"bt_adapter_set_device_discovery_state_changed_cb" , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB}, {"bt_adapter_unset_device_discovery_state_changed_cb" @@ -331,6 +333,8 @@ tc_table_t tc_adapter_le[] = { , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_UUID}, {"Register scan filter (Service Solicitation UUID)" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_SOLICITATION_UUID}, + {"Register scan filter (Manufacturer DATA)" + , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_MANUFACTURER_DATA}, {"Register iBeaconscan filter (Manufacturer DATA)" , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_IBEACON_DATA}, {"Unregister all scan filters" @@ -2164,7 +2168,8 @@ void __bt_device_connection_state_changed_cb(bool connected, TC_PRT("__bt_device_connection_state_changed_cb [%d]", connected); TC_PRT("address [%s]", conn_info->remote_address); TC_PRT("link type [%d]", conn_info->link); - TC_PRT("disconnection reason [%d]", conn_info->disconn_reason); + if (!connected) + TC_PRT("disconnection reason [%d]", conn_info->disconn_reason); } void __bt_device_att_mtu_changed_cb(int result, bt_device_att_mtu_info_s *mtu_info, void *user_data) @@ -2183,10 +2188,9 @@ void __bt_device_att_mtu_changed_cb(int result, bt_device_att_mtu_info_s *mtu_in } } - bool __bt_device_connected_profile(bt_profile_e profile, void *user_data) { - TC_PRT("__bt_device_connected_profile [%d]", profile); + TC_PRT("__bt_device_connected_profile [0x%04x]", profile); return true; } @@ -2801,7 +2805,7 @@ void __bt_gatt_server_write_value_requested_cb(const char *remote_address, bt_gatt_h gatt_handle, bool response_needed, int offset, const char *value, int len, void *user_data) { - int i, resp_status = BT_ATT_ERROR_NONE; + int i, resp_status = BT_ATT_ERROR_NONE; __print_gatt_handler(gatt_handle); TC_PRT("[%s] req_id %d, response_needed %d, offset %d, len %d", @@ -3514,129 +3518,33 @@ int test_set_params(int test_id, char *param) { static int param_index = 0; const char *param_type = NULL; + int param_count = 0; + + if (param_index > 0 && param_index == g_test_param.param_count) + goto done; switch (current_tc_table) { case BT_UNIT_TEST_TABLE_ADAPTER: { switch (test_id) { - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY: + param_count = 1; TC_PRT("Input param(%d) (non-discoverable: -1, always: 0, limited-discoverable(time): N)", param_index + 1); - param_index++; - break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], - param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_CONNECTABLE: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); break; - } case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_MANUFACTURER_DATA: - { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_BYTE_ARRAY; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_BYTE_ARRAY; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_EXT_DATA: { - if (param_index == 0) { - g_test_param.param_count = 5; - g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len); - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, len); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - + case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_EXT_DATA: + param_count = 5; + param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - param_index++; - break; - - } default: TC_PRT("There is no param to set\n"); need_to_set_params = false; @@ -3649,118 +3557,40 @@ int test_set_params(int test_id, char *param) case BT_UNIT_TEST_TABLE_ADAPTER_LE: { switch (test_id) { case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE: + param_count = 1; + TC_PRT("Scan mode\n (0 : Balanced (5000/2000 ms), 1: Low Latency (5000/5000 ms), 2 : Low Energy (5000/500 ms)"); + break; case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA: + param_count = 1; + TC_PRT("Select advertising data \n (0 : Service uuid, 1: Service solicitation 2 : Appearance & Tx power, 3 : All, 4 : ANCS"); + TC_PRT("\t (Default scan response : Service Data &Local name & Manufacturer data)"); + break; case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_MODE: + param_count = 1; + TC_PRT("Input mode \n (0 : Balanced(500 ms), 1 : Low Latency(150 ms), 2 : Low Energy (1000 ms))"); + break; case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_FILTER_POLICY: + param_count = 1; + TC_PRT("Input filter_policy \n (0 : No use White List, 1 : Allow scan, 2 : Allow conneciton, 3 : Allow scan & conneciton)"); + break; case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CONNECTABLE: - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE: - TC_PRT("Scan mode\n (0 : Balanced (5000/2000 ms), 1: Low Latency (5000/5000 ms), 2 : Low Energy (5000/500 ms)"); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA: - TC_PRT("Select advertising data \n (0 : Service uuid, 1: Service solicitation 2 : Appearance & Tx power, 3 : All, 4 : ANCS"); - TC_PRT("\t (Default scan response : Service Data &Local name & Manufacturer data)"); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_MODE: - TC_PRT("Input mode \n (0 : Balanced(500 ms), 1 : Low Latency(150 ms), 2 : Low Energy (1000 ms))"); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_FILTER_POLICY: - TC_PRT("Input filter_policy \n (0 : No use White List, 1 : Allow scan, 2 : Allow conneciton, 3 : Allow scan & conneciton)"); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_ADVERTISING_CONNECTABLE: - TC_PRT("Input adv type \n (0 : Non-connectable (ADV_SCAN_IND), 1 : Connectable (ADV_IND) "); - break; - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING: - TC_PRT("Input adv slot id \n (Default is 0, Maximum is 2) "); - break; - } - param_index++; - + param_count = 1; + TC_PRT("Input adv type \n (0 : Non-connectable (ADV_SCAN_IND), 1 : Connectable (ADV_IND) "); break; - } - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE_PRIVACY: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_ADVERTISING: + param_count = 1; + TC_PRT("Input adv slot id \n (Default is 0, Maximum is 2) "); break; - } - - case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_REMOTE_OOB_EXT_DATA: { - if (param_index == 0) { - g_test_param.param_count = 3; - g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len); - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, len); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE_PRIVACY: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + break; + case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_REMOTE_OOB_EXT_DATA: + param_count = 3; + param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - param_index++; - break; - - } default: TC_PRT("There is no param to set\n"); need_to_set_params = false; @@ -3772,124 +3602,21 @@ int test_set_params(int test_id, char *param) case BT_UNIT_TEST_TABLE_DEVICE: { switch (test_id) { - case BT_UNIT_TEST_FUNCTION_DEVICE_IS_PROFILE_CONNECTED: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - - break; - } - - case BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND_BY_TYPE: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - + case BT_UNIT_TEST_FUNCTION_DEVICE_IS_PROFILE_CONNECTED: + case BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND_BY_TYPE: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_INT; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); break; - } - - case BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION_MODE: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - TC_PRT("Input param(%d) mode (0 : balanced, 1 : low latency, 2 : low power) : %s", param_index + 1, param_type); - param_index++; - + case BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION_MODE: + param_count = 1; + TC_PRT("Input param(%d) mode (0 : balanced, 1 : low latency, 2 : low power) ", param_index + 1); break; - } - - case BT_UNIT_TEST_FUNCTION_DEVICE_REQUEST_ATT_MTU: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count); - param_type = "int(1, 2, 10, ...., 512)"; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - + case BT_UNIT_TEST_FUNCTION_DEVICE_REQUEST_ATT_MTU: + param_count = 1; + param_type = "int(1, 2, 10, ...., 512)"; TC_PRT("Input param(%d) : %s", param_index + 1, param_type); - param_index++; - break; - } - default: TC_PRT("There is no param to set\n"); need_to_set_params = false; @@ -3898,97 +3625,52 @@ int test_set_params(int test_id, char *param) break; } + case BT_UNIT_TEST_TABLE_SOCKET: { switch (test_id) { - case BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM_CUSTOM_UUID: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) * g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - + case BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM_CUSTOM_UUID: + case BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM_CUSTOM_UUID: + case BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - param_index++; + break; + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; break; } - case BT_UNIT_TEST_FUNCTION_SOCKET_CONNECT_RFCOMM_CUSTOM_UUID: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) * g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } + break; + } - TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - param_index++; + case BT_UNIT_TEST_TABLE_OPP: { + switch (test_id) { + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; break; } - case BT_UNIT_TEST_FUNCTION_SOCKET_SEND_DATA: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; + break; + } + case BT_UNIT_TEST_TABLE_AUDIO: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_AUDIO_CONNECT: + case BT_UNIT_TEST_FUNCTION_AUDIO_DISCONNECT: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_INT; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + break; + case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_DIALING: + case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_INCOMING: + case BT_UNIT_TEST_FUNCTION_CALL_LIST_ADD: + case BT_UNIT_TEST_FUNCTION_AG_SWITCH_HEADSET: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); break; - } default: TC_PRT("There is no param to set\n"); need_to_set_params = false; @@ -3997,7 +3679,8 @@ int test_set_params(int test_id, char *param) break; } - case BT_UNIT_TEST_TABLE_OPP: { + + case BT_UNIT_TEST_TABLE_PAN: { switch (test_id) { default: TC_PRT("There is no param to set\n"); @@ -4007,299 +3690,33 @@ int test_set_params(int test_id, char *param) break; } - case BT_UNIT_TEST_TABLE_AUDIO: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_AUDIO_CONNECT: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - } - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } + case BT_UNIT_TEST_TABLE_GATT: { + switch (test_id) { + case BT_UNIT_TEST_FUNCTION_GATT_CONNECT: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); + break; + case BT_UNIT_TEST_FUNCTION_GATT_SET_WRITE_TYPE: { + param_count = 3; + param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; + switch (param_index) { + case 0: + TC_PRT("Input Service UUID"); + break; + case 1: + TC_PRT("Input Characteristic UUID"); + break; + case 2: + TC_PRT("Input write_type (0 : no response, 1 : with reponse, 2 : signed)"); + break; } - - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - break; } - case BT_UNIT_TEST_FUNCTION_AUDIO_DISCONNECT: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - - break; - } - - case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_DIALING: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - - break; - } - case BT_UNIT_TEST_FUNCTION_AG_CALL_EVENT_INCOMING: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - - break; - } - case BT_UNIT_TEST_FUNCTION_CALL_LIST_ADD: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - - break; - } - case BT_UNIT_TEST_FUNCTION_AG_SWITCH_HEADSET: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - - break; - } - - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } - case BT_UNIT_TEST_TABLE_PAN: { - switch (test_id) { - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; - } - - break; - } - case BT_UNIT_TEST_TABLE_GATT: { - switch (test_id) { - case BT_UNIT_TEST_FUNCTION_GATT_CONNECT: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_SET_WRITE_TYPE: { - if (param_index == 0) { - g_test_param.param_count = 3; - g_test_param.params = g_malloc0(sizeof(char*) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - switch (param_index) { - case 0: - TC_PRT("Input Service UUID"); - break; - case 1: - TC_PRT("Input Characteristic UUID"); - break; - case 2: - TC_PRT("Input write_type (0 : no response, 1 : with reponse, 2 : signed)"); - break; - } - - param_index++; - - break; - } - case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_READ_VALUE: { - if (param_index == 0) { - g_test_param.param_count = 3; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } + case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_READ_VALUE: { + param_count = 3; switch (param_index) { case 0: @@ -4312,36 +3729,10 @@ int test_set_params(int test_id, char *param) TC_PRT("Input Descriptor UUID or nothing"); break; } - - param_index++; - break; } case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_WRITE_VALUE: { - if (param_index == 0) { - g_test_param.param_count = 5; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - - param_index = 0; - return 0; - } + param_count = 5; switch (param_index) { case 0: @@ -4360,35 +3751,10 @@ int test_set_params(int test_id, char *param) TC_PRT("Input Value"); break; } - - param_index++; - break; } case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_SET_CHAR_VALUE_CHANGED_CB: { - if (param_index == 0) { - g_test_param.param_count = 2; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } + param_count = 2; switch (param_index) { case 0: @@ -4398,35 +3764,10 @@ int test_set_params(int test_id, char *param) TC_PRT("Input Characteristic UUID"); break; } - - param_index++; - break; } case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_UNSET_CHAR_VALUE_CHANGED_CB: { - if (param_index == 0) { - g_test_param.param_count = 2; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } + param_count = 2; switch (param_index) { case 0: @@ -4436,45 +3777,15 @@ int test_set_params(int test_id, char *param) TC_PRT("Input Characteristic UUID"); break; } - - param_index++; - break; } case BT_UNIT_TEST_FUNCTION_ANCS_POSITIVE_ACTION: case BT_UNIT_TEST_FUNCTION_ANCS_NEGATIVE_ACTION: - case BT_UNIT_TEST_FUNCTION_ANCS_GET_NOTI_ATTR: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; + case BT_UNIT_TEST_FUNCTION_ANCS_GET_NOTI_ATTR: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); break; - } - default: TC_PRT("There is no param to set\n"); need_to_set_params = false; @@ -4483,105 +3794,27 @@ int test_set_params(int test_id, char *param) break; } + case BT_UNIT_TEST_TABLE_HPS: { switch (test_id) { - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_CREATE: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_CREATE: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_BOOL; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); break; - } case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_HDR: case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_ENTITY: - case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_URI: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - switch (param_index) { - case 0: - TC_PRT("Input Value in string"); - break; - } - - param_index++; - + case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_URI: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; + TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); break; - } case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_SET_CP: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - } - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - switch (param_index) { - case 0: - TC_PRT("Input Value Type (avail. : \n1.HTTP_GET, \n2.HTTP_HEAD, \n3.HTTP_POST, \n4.HTTP_PUT, \n5.HTTP_DELETE, \n6.HTTPS_GET, \n7.HTTPS_HEAD, \n8.HTTPS_POST, \n9.HTTPS_PUT, \n10.HTTPS_DELETE, \n11.HTTP_CANCEL"); - break; - } - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - + param_count = 1; + TC_PRT("Input Value Type (avail. : \n1.HTTP_GET, \n2.HTTP_HEAD, \ + \n3.HTTP_POST, \n4.HTTP_PUT, \n5.HTTP_DELETE, \ + \n6.HTTPS_GET, \n7.HTTPS_HEAD, \n8.HTTPS_POST, \ + \n9.HTTPS_PUT, \n10.HTTPS_DELETE, \n11.HTTP_CANCEL"); break; } default: @@ -4594,245 +3827,75 @@ int test_set_params(int test_id, char *param) case BT_UNIT_TEST_TABLE_DPM: { switch (test_id) { - case BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_BLUETOOTH_MODE: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - } - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - switch (param_index) { - case 0: - TC_PRT("Input Value Type (avail. : \n0.BT_DPM_BT_ALLOWED, \n1.BT_DPM_HANDSFREE_ONLY, \n2.BT_DPM_BT_RESTRICTED"); - break; - } - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - - break; - } + case BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_BLUETOOTH_MODE: + param_count = 1; + TC_PRT("Input Value Type (avail. : \n0.BT_DPM_BT_ALLOWED, \n1.BT_DPM_HANDSFREE_ONLY, \n2.BT_DPM_BT_RESTRICTED"); + break; + + case BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_DEVICE_RESTRICTION: + case BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_UUID_RESTRICTION: + case BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_OUTGOING_CALL: + case BT_UNIT_TEST_FUNCTION_DPM_SET_PAIRING_STATE: + case BT_UNIT_TEST_FUNCTION_DPM_SET_DESKTOP_CONNECTIVITY_STATE: + case BT_UNIT_TEST_FUNCTION_DPM_SET_DISCOVERABLE_STATE: + case BT_UNIT_TEST_FUNCTION_DPM_SET_LIMITED_DISCOVERABLE_STATE: + case BT_UNIT_TEST_FUNCTION_DPM_SET_DATA_TRANSFER_STATE: + param_count = 1; + TC_PRT("Input Value Type (avail. : \n0.BT_DPM_BT_ALLOWED, \n1.BT_DPM_RESTRICTED"); break; - case BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_DEVICE_RESTRICTION: - case BT_UNIT_TEST_FUNCTION_DPM_ACTIVATE_UUID_RESTRICTION: - case BT_UNIT_TEST_FUNCTION_DPM_SET_ALLOW_OUTGOING_CALL: - case BT_UNIT_TEST_FUNCTION_DPM_SET_PAIRING_STATE: - case BT_UNIT_TEST_FUNCTION_DPM_SET_DESKTOP_CONNECTIVITY_STATE: - case BT_UNIT_TEST_FUNCTION_DPM_SET_DISCOVERABLE_STATE: - case BT_UNIT_TEST_FUNCTION_DPM_SET_LIMITED_DISCOVERABLE_STATE: - case BT_UNIT_TEST_FUNCTION_DPM_SET_DATA_TRANSFER_STATE: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - } - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - switch (param_index) { - case 0: - TC_PRT("Input Value Type (avail. : \n0.BT_DPM_BT_ALLOWED, \n1.BT_DPM_RESTRICTED"); - break; - } - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - - break; - } + case BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_BLACKLIST: + case BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_WHITELIST: + case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_BLACKLIST: + case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_WHITELIST: + param_count = 1; + TC_PRT("Input device Address"); break; - case BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_BLACKLIST: - case BT_UNIT_TEST_FUNCTION_DPM_ADD_DEVICES_TO_WHITELIST: - case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_BLACKLIST: - case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_DEVICE_FROM_WHITELIST: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - switch (param_index) { - case 0: - TC_PRT("Input device Address"); - break; - } - param_index++; - - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_BLACKLIST: - case BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_WHITELIST: - case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_BLACKLIST: - case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_WHITELIST: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - switch (param_index) { - case 0: - TC_PRT("Input UUID"); - break; - } - param_index++; - - break; - } - case BT_UNIT_TEST_FUNCTION_DPM_SET_PROFILE_STATE: { - if (param_index == 0) { - g_test_param.param_count = 2; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - } - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - switch (param_index) { - case 0: - TC_PRT("Input Profile Type (avail. : \n0.BT_DPM_POLICY_A2DP_PROFILE_STATE, \ - \n1.BT_DPM_POLICY_AVRCP_PROFILE_STATE, \ - \n2.BT_DPM_POLICY_BPP_PROFILE_STATE, \ - \n3.BT_DPM_POLICY_DUN_PROFILE_STATE, \ - \n4.BT_DPM_POLICY_FTP_PROFILE_STATE, \ - \n5.BT_DPM_POLICY_HFP_PROFILE_STATE, \ - \n6.BT_DPM_POLICY_HSP_PROFILE_STATE, \ - \n7.BT_DPM_POLICY_PBAP_PROFILE_STATE, \ - \n8.BT_DPM_POLICY_SAP_PROFILE_STATE, \ - \n9.BT_DPM_POLICY_SPP_PROFILE_STATE"); - break; - case 1: - TC_PRT("Input Value Type (avail. : \n0.BT_DPM_BT_ALLOWED, \n1.BT_DPM_RESTRICTED"); - break; - } - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - + case BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_BLACKLIST: + case BT_UNIT_TEST_FUNCTION_DPM_ADD_UUIDS_TO_WHITELIST: + case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_BLACKLIST: + case BT_UNIT_TEST_FUNCTION_DPM_REMOVE_UUIDS_FROM_WHITELIST: + param_count = 1; + TC_PRT("Input UUID"); + break; + case BT_UNIT_TEST_FUNCTION_DPM_SET_PROFILE_STATE: + param_count = 2; + switch (param_index) { + case 0: + TC_PRT("Input Profile Type (avail. : \n0.BT_DPM_POLICY_A2DP_PROFILE_STATE, \ + \n1.BT_DPM_POLICY_AVRCP_PROFILE_STATE, \ + \n2.BT_DPM_POLICY_BPP_PROFILE_STATE, \ + \n3.BT_DPM_POLICY_DUN_PROFILE_STATE, \ + \n4.BT_DPM_POLICY_FTP_PROFILE_STATE, \ + \n5.BT_DPM_POLICY_HFP_PROFILE_STATE, \ + \n6.BT_DPM_POLICY_HSP_PROFILE_STATE, \ + \n7.BT_DPM_POLICY_PBAP_PROFILE_STATE, \ + \n8.BT_DPM_POLICY_SAP_PROFILE_STATE, \ + \n9.BT_DPM_POLICY_SPP_PROFILE_STATE"); break; - } - case BT_UNIT_TEST_FUNCTION_DPM_GET_PROFILE_STATE: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - } - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - switch (param_index) { - case 0: - TC_PRT("Input Profile Type (avail. : \n0.BT_DPM_POLICY_A2DP_PROFILE_STATE, \ - \n1.BT_DPM_POLICY_AVRCP_PROFILE_STATE, \ - \n2.BT_DPM_POLICY_BPP_PROFILE_STATE, \ - \n3.BT_DPM_POLICY_DUN_PROFILE_STATE, \ - \n4.BT_DPM_POLICY_FTP_PROFILE_STATE, \ - \n5.BT_DPM_POLICY_HFP_PROFILE_STATE, \ - \n6.BT_DPM_POLICY_HSP_PROFILE_STATE, \ - \n7.BT_DPM_POLICY_PBAP_PROFILE_STATE, \ - \n8.BT_DPM_POLICY_SAP_PROFILE_STATE, \ - \n9.BT_DPM_POLICY_SPP_PROFILE_STATE"); - break; - } - - TC_PRT("Input param(%d) type:%s", - param_index + 1, param_type); - param_index++; - + case 1: + TC_PRT("Input Value Type (avail. : \n0.BT_DPM_BT_ALLOWED, \n1.BT_DPM_RESTRICTED"); break; } + break; + case BT_UNIT_TEST_FUNCTION_DPM_GET_PROFILE_STATE: + param_count = 1; + TC_PRT("Input Profile Type (avail. : \n0.BT_DPM_POLICY_A2DP_PROFILE_STATE, \ + \n1.BT_DPM_POLICY_AVRCP_PROFILE_STATE, \ + \n2.BT_DPM_POLICY_BPP_PROFILE_STATE, \ + \n3.BT_DPM_POLICY_DUN_PROFILE_STATE, \ + \n4.BT_DPM_POLICY_FTP_PROFILE_STATE, \ + \n5.BT_DPM_POLICY_HFP_PROFILE_STATE, \ + \n6.BT_DPM_POLICY_HSP_PROFILE_STATE, \ + \n7.BT_DPM_POLICY_PBAP_PROFILE_STATE, \ + \n8.BT_DPM_POLICY_SAP_PROFILE_STATE, \ + \n9.BT_DPM_POLICY_SPP_PROFILE_STATE"); - default: - TC_PRT("There is no param to set\n"); - need_to_set_params = false; - break; break; + default: + TC_PRT("There is no param to set\n"); + need_to_set_params = false; + break; + break; } break; } @@ -4840,42 +3903,10 @@ int test_set_params(int test_id, char *param) case BT_UNIT_TEST_TABLE_PXP: { switch (test_id) { case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_LINKLOSS_ALERT: - case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_IMMEDIATE_ALERT: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - switch (param_index) { - case 0: - TC_PRT("Input Value Type (avail. : \n0.NONE, \n1.MILD, \n2.HIGH"); - break; - } - - param_index++; - + case BT_UNIT_TEST_FUNCTION_PXP_MONITOR_WRITE_IMMEDIATE_ALERT: + param_count = 1; + TC_PRT("Input Value Type (avail. : \n0.NONE, \n1.MILD, \n2.HIGH"); break; - } default: TC_PRT("There is no param to set\n"); need_to_set_params = false; @@ -4896,34 +3927,10 @@ int test_set_params(int test_id, char *param) } case BT_UNIT_TEST_TABLE_HID: { switch (test_id) { - case BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_RC_KEY_EVENT: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - + case BT_UNIT_TEST_FUNCTION_HID_DEVICE_SEND_RC_KEY_EVENT: + param_count = 1; TC_PRT("Select TV control mode (1 : Vol Up, 2 : Vol Down, 3 : CH Up, 4 : CH Down) : "); - param_index++; - break; - } default: TC_PRT("There is no param to set\n"); need_to_set_params = false; @@ -4932,56 +3939,16 @@ int test_set_params(int test_id, char *param) break; } + case BT_UNIT_TEST_TABLE_IPSP: { switch (test_id) { - case BT_UNIT_TEST_FUNCTION_IPSP_CONNECT_WITH_APP_SERVER_SOCKET: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) * g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; - test_input_callback(GINT_TO_POINTER(test_id)); - param_index = 0; - return 0; - } - + case BT_UNIT_TEST_FUNCTION_IPSP_CONNECT_WITH_APP_SERVER_SOCKET: + param_count = 1; TC_PRT("IPSP Client : Input IPSP App server's IPv6 address to connect :"); - - param_index++; break; - } case BT_UNIT_TEST_FUNCTION_IPSP_SEND_IPV6_APP_DATA: { - if (param_index == 0) { - g_test_param.param_count = 2; - g_test_param.params = g_malloc0(sizeof(char *) * g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; - test_input_callback(GINT_TO_POINTER(test_id)); - param_index = 0; - return 0; - } + param_count = 2; + param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; switch (param_index) { case 0: @@ -4991,40 +3958,12 @@ int test_set_params(int test_id, char *param) TC_PRT("IPSP : input data to send :"); break; } - - param_index++; - break; } - case BT_UNIT_TEST_FUNCTION_IPSP_RECV_IPV6_APP_DATA: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) * g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; - test_input_callback(GINT_TO_POINTER(test_id)); - param_index = 0; - return 0; - } - - TC_PRT("IPSP : Input current role of Application[Server[0]/Client[1] :"); - - param_index++; - - break; - } - + case BT_UNIT_TEST_FUNCTION_IPSP_RECV_IPV6_APP_DATA: + param_count = 1; + TC_PRT("IPSP : Input current role of Application[Server[0]/Client[1] :"); + break; default: TC_PRT("There is no param to set\n"); need_to_set_params = false; @@ -5048,34 +3987,11 @@ int test_set_params(int test_id, char *param) case BT_UNIT_TEST_TABLE_HF: { switch (test_id) { - case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_WITH_PARAM: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - } - - if (param_index > 0) { - g_test_param.params[param_index - 1] = g_malloc0(strlen(param) + 1); - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - + case BT_UNIT_TEST_FUNCTION_HF_NOTIFY_CALL_WITH_PARAM: + param_count = 1; + param_type = BT_UNIT_TEST_PARAM_TYPE_INT; TC_PRT("Input param(%d) type:%s", param_index + 1, param_type); - param_index++; - break; - } default: TC_PRT("There is no param to set\n"); need_to_set_params = false; @@ -5084,6 +4000,7 @@ int test_set_params(int test_id, char *param) break; } + case BT_UNIT_TEST_TABLE_PBAP_CLIENT: if (!TIZEN_PROFILE_WEARABLE_IVI) goto __default__; @@ -5097,38 +4014,13 @@ int test_set_params(int test_id, char *param) break; } + case BT_UNIT_TEST_TABLE_ETC: { switch (test_id) { - case BT_UNIT_TEST_FUNCTION_CHECK_FEATURE: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) * g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_STRING; - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - + case BT_UNIT_TEST_FUNCTION_CHECK_FEATURE: + param_count = 1; TC_PRT("Input feature string(ex. tizen.org/feature/network.bluetooth)"); - param_index++; break; - } default: TC_PRT("There is no param to set\n"); need_to_set_params = false; @@ -5137,139 +4029,20 @@ int test_set_params(int test_id, char *param) break; } + case BT_UNIT_TEST_TABLE_OTP: { switch (test_id) { - case BT_UNIT_TEST_FUNCTION_OTP_SERVER_INIT: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - switch (param_index) { - case 0: - TC_PRT("Input Value in string"); - break; - } - - param_index++; - - break; - } - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_SELECT_OBJ: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - param_type = BT_UNIT_TEST_PARAM_TYPE_INT; - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - switch (param_index) { - case 0: - TC_PRT("Input Value in uint64_t"); - break; - } - - param_index++; - + case BT_UNIT_TEST_FUNCTION_OTP_SERVER_INIT: + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CREATE_OBJ: + param_count = 1; + TC_PRT("Input Value in string"); break; - } - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_CREATE_OBJ: { - if (param_index == 0) { - g_test_param.param_count = 1; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - param_index = 0; - return 0; - } - - switch (param_index) { - case 0: - TC_PRT("Input Value in string"); - break; - } - - param_index++; - + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_SELECT_OBJ: + param_count = 1; + TC_PRT("Input Value in uint64_t"); break; - } - case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_WRITE_OBJ: { - if (param_index == 0) { - g_test_param.param_count = 4; - g_test_param.params = g_malloc0(sizeof(char *) *g_test_param.param_count); - } - - if (param_index > 0) { - int len = strlen(param); - g_test_param.params[param_index - 1] = g_malloc0(len + 1); - /* Remove new line character */ - param[len - 1] = '\0'; - strncpy(g_test_param.params[param_index - 1], param, strlen(param)); - } - - if (param_index == g_test_param.param_count) { - need_to_set_params = false; -#ifdef ARCH64 - test_input_callback((void *)(uintptr_t)test_id); -#else - test_input_callback((void *)test_id); -#endif - - param_index = 0; - return 0; - } + case BT_UNIT_TEST_FUNCTION_OTP_CLIENT_WRITE_OBJ: + param_count = 4; switch (param_index) { case 0: @@ -5285,11 +4058,7 @@ int test_set_params(int test_id, char *param) TC_PRT("Input mode"); break; } - - param_index++; - break; - } default: TC_PRT("There is no param to set\n"); need_to_set_params = false; @@ -5305,6 +4074,35 @@ __default__: break; } +done: + if (need_to_set_params) { + if (param_index == 0) { + g_test_param.param_count = param_count; + g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count); + } + + if (param_index > 0) { + int len = strlen(param); + g_test_param.params[param_index - 1] = g_malloc0(len + 1); + /* Remove new line character */ + param[len - 1] = '\0'; + strncpy(g_test_param.params[param_index - 1], param, strlen(param)); + } + + if (param_index == g_test_param.param_count) { + need_to_set_params = false; +#ifdef ARCH64 + test_input_callback((void *)(uintptr_t)test_id); +#else + test_input_callback((void *)test_id); +#endif + param_index = 0; + return 0; + } + + param_index++; + } + return 0; } @@ -6356,7 +5154,7 @@ int test_input_callback(void *data) case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_MANUFACTURER_DATA: { bt_scan_filter_h scan_filter = NULL; int manufacturer_id = 117; /* samsung */ - char param_data[] = {0x2, 0x2, 0x2, 0x2}; + char param_data[] = {0x42, 0x04}; /* Use "appearance & tx power level" of bt_adapter_le_add_XXX_advertising_data */ ret = bt_adapter_le_scan_filter_create(&scan_filter); diff --git a/test/bt_unit_test.h b/test/bt_unit_test.h index 1eed23b..21e6291 100644 --- a/test/bt_unit_test.h +++ b/test/bt_unit_test.h @@ -125,7 +125,7 @@ typedef enum { BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_ADDRESS, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_UUID, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_SOLICITATION_UUID, -BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_MANUFACTURER_DATA, + BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_MANUFACTURER_DATA, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_IBEACON_DATA, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_UNREGISTER_ALL_SCAN_FILTERS, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB,