summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAbhay Agarwal <ay.agarwal@samsung.com>2020-09-10 20:47:28 +0530
committerAbhay Agarwal <ay.agarwal@samsung.com>2020-09-10 20:47:28 +0530
commitd47265b5ac64c3e0cea7e3c00d37aec9e0c667c5 (patch)
treea29d82b4af96cf8ede696e70231a511ec5d15594 /tests
parenta1347393d099989e3b5d9dc9db25007444d6fb86 (diff)
downloadbluetooth-d47265b5ac64c3e0cea7e3c00d37aec9e0c667c5.tar.gz
bluetooth-d47265b5ac64c3e0cea7e3c00d37aec9e0c667c5.tar.bz2
bluetooth-d47265b5ac64c3e0cea7e3c00d37aec9e0c667c5.zip
Mesh: Fix coding style issue
Change-Id: Ie89ac34cb0d7668ef3165b99caf47fe52dfef02d Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test/bt_mesh_unit_test.c278
1 files changed, 140 insertions, 138 deletions
diff --git a/tests/test/bt_mesh_unit_test.c b/tests/test/bt_mesh_unit_test.c
index 85980bd..c69f3d7 100644
--- a/tests/test/bt_mesh_unit_test.c
+++ b/tests/test/bt_mesh_unit_test.c
@@ -70,13 +70,14 @@ GMainLoop *mainloop = NULL;
static void wait_for_async_over()
{
if (mainloop)
- g_main_loop_quit(mainloop);
+ g_main_loop_quit(mainloop);
}
+
static void wait_for_async()
{
- TC_PRT("Wait for operation...\n");
- mainloop = g_main_loop_new(NULL, FALSE);
- g_main_loop_run(mainloop);
+ TC_PRT("Wait for operation...\n");
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
}
tc_table_t tc_control[] = {
@@ -285,7 +286,7 @@ static void __bt_free_test_param(tc_params_t *param)
}
void tc_usage_print(void){
- int i=0;
+ int i = 0;
tc_table_t *tc_table = NULL;
switch (current_tc_table) {
case BT_MESH_UNIT_TEST_TABLE_NETWORK:
@@ -305,7 +306,7 @@ void tc_usage_print(void){
break;
}
while (tc_table[i].tc_name) {
- TC_PRT("Key %d : usage %s", tc_table[i].tc_code,tc_table[i].tc_name);
+ TC_PRT("Key %d : usage %s", tc_table[i].tc_code, tc_table[i].tc_name);
i++;
}
}
@@ -360,7 +361,7 @@ static const char *__bt_get_error_message(bt_error_e err)
void print_network_handle(bt_mesh_network_h network)
{
- if(network == NULL)
+ if (network == NULL)
return;
bt_mesh_network_s* net = (bt_mesh_network_s*) network;
TC_PRT("network_handle = [%p]", (void*)net);
@@ -374,10 +375,10 @@ void print_network_handle(bt_mesh_network_h network)
void print_node_handle(bt_mesh_node_h node)
{
- if(node == NULL)
+ if (node == NULL)
return;
bt_mesh_node_s* node_info = (bt_mesh_node_s*) node;
- TC_PRT("node_handle = [%p]",(void*)node_info);
+ TC_PRT("node_handle = [%p]", (void*)node_info);
TC_PRT("node->is_local [%d]", node_info->is_local);
TC_PRT("node->is_attached [%d]", node_info->is_attached);
if (node_info->is_attached) {
@@ -390,7 +391,7 @@ void print_node_handle(bt_mesh_node_h node)
void print_element_handle(bt_mesh_element_h element)
{
- if(element == NULL)
+ if (element == NULL)
return;
bt_mesh_element_s* element_info = (bt_mesh_element_s*) element;
TC_PRT("element_handle = [%p]", (void*)element_info);
@@ -400,7 +401,7 @@ void print_element_handle(bt_mesh_element_h element)
void print_model_handle(bt_mesh_model_h model)
{
- if(model == NULL)
+ if (model == NULL)
return;
bt_mesh_model_s* model_info = (bt_mesh_model_s*) model;
TC_PRT("model_handle = [%p]", (void*)model_info);
@@ -411,7 +412,7 @@ void print_model_handle(bt_mesh_model_h model)
void print_netkey_handle(bt_mesh_netkey_h netkey)
{
- if(netkey == NULL)
+ if (netkey == NULL)
return;
bt_mesh_netkey_s* netkey_info = (bt_mesh_netkey_s*) netkey;
TC_PRT("netkey_handle = [%p]", (void*)netkey_info);
@@ -421,7 +422,7 @@ void print_netkey_handle(bt_mesh_netkey_h netkey)
void print_appkey_handle(bt_mesh_appkey_h appkey)
{
- if(appkey == NULL)
+ if (appkey == NULL)
return;
bt_mesh_appkey_s* appkey_info = (bt_mesh_appkey_s*) appkey;
TC_PRT("appkey_handle = [%p]", (void*)appkey_info);
@@ -431,7 +432,7 @@ void print_appkey_handle(bt_mesh_appkey_h appkey)
void print_group_handle(bt_mesh_group_h group)
{
- if(group == NULL)
+ if (group == NULL)
return;
bt_mesh_group_s* group_info = (bt_mesh_group_s*) group;
TC_PRT("group_handle = [%p]", (void*)group_info);
@@ -448,7 +449,7 @@ bool __bt_mesh_network_device_info_cb(int result, bt_mesh_network_h network, int
TC_PRT("Total number of Devices in network [%d]", total);
TC_PRT("result: %s", __bt_get_error_message(result));
- TC_PRT("primary unicast address is [%d]",primary_unicast);
+ TC_PRT("primary unicast address is [%d]", primary_unicast);
TC_PRT("Device UUID [%s]", dev_uuid);
return true;
}
@@ -482,9 +483,9 @@ void __bt_mesh_node_discover_status_cb(int result, bt_mesh_network_h network, bt
static gint __compare_model_handle(gconstpointer data, gconstpointer user_data)
{
- if(NULL == data)
+ if (NULL == data)
return -1;
- if(NULL == user_data)
+ if (NULL == user_data)
return -1;
if ((void*) data == (void*) user_data)
return 0;
@@ -509,9 +510,8 @@ static bool __bt_mesh_elem_foreach_model_cb(int result, bt_mesh_element_h elemen
if (model_id->model_id == BT_MESH_MODEL_ID_GEN_ONOFF_SRV) {
g_model_onoff_srv = model;
l = g_slist_find_custom(srv_model_list, model, __compare_model_handle);
- if(!l) {
+ if (!l)
srv_model_list = g_slist_append(srv_model_list, model);
- }
}
g_model = model;
}
@@ -637,8 +637,8 @@ void __bt_mesh_node_ttl_cb(int result, bt_mesh_node_h node,
if (result == BT_ERROR_NONE) {
print_node_handle(node);
- TC_PRT("ttl_op is [%s]", ttl_op? "TTL Set" : "TTL Get");
- TC_PRT("ttl value is [%d]",ttl);
+ TC_PRT("ttl_op is [%s]", ttl_op ? "TTL Set" : "TTL Get");
+ TC_PRT("ttl value is [%d]", ttl);
}
}
@@ -701,7 +701,7 @@ void __bt_mesh_model_subscription_op_cb(int result, bt_mesh_model_subscription_o
TC_PRT("result: %s", __bt_get_error_message(result));
if (result == BT_ERROR_NONE) {
call_success = true;
- switch(op) {
+ switch (op) {
case 0:
TC_PRT("Model Subscription Operation is ADD");
break;
@@ -763,10 +763,8 @@ bool __bt_mesh_appkey_info_cb(int result, bt_mesh_network_h network, int total,
bt_mesh_netkey_h netkey, bt_mesh_appkey_h appkey, uint16_t appkey_index, void *user_data)
{
TC_PRT("result: %s", __bt_get_error_message(result));
- //print_network_handle(network);
- //print_netkey_handle(netkey);
print_appkey_handle(appkey);
- TC_PRT("Total appkeys are [%d]",total);
+ TC_PRT("Total appkeys are [%d]", total);
return true;
}
@@ -774,9 +772,7 @@ bool __bt_mesh_network_netkey_info_cb(int result, bt_mesh_network_h network, in
bt_mesh_netkey_h netkey, uint16_t netkey_index, void *user_data)
{
TC_PRT("result: %s", __bt_get_error_message(result));
- //print_network_handle(network);
- //print_netkey_handle(netkey);
- TC_PRT("Total netkeys are [%d]",total);
+ TC_PRT("Total netkeys are [%d]", total);
if (result == BT_ERROR_NONE && netkey_index == 0) {
TC_PRT("Attempt to delete Primary Subnet");
result = bt_mesh_netkey_delete(netkey);
@@ -791,15 +787,15 @@ bool __bt_mesh_network_netkey_info_cb(int result, bt_mesh_network_h network, in
static gint __compare_dev_uuid(gconstpointer data, gconstpointer user_data)
{
- const char *uuid1 = data;
- const char *uuid2 = user_data;
+ const char *uuid1 = data;
+ const char *uuid2 = user_data;
- if(NULL == uuid1)
+ if (NULL == uuid1)
return -1;
- if(NULL == uuid2)
+ if (NULL == uuid2)
return -1;
- return g_strcmp0(uuid1, uuid2);
+ return g_strcmp0(uuid1, uuid2);
}
void __bt_mesh_network_scan_unprovisioned_device_result_cb(int result, bt_mesh_network_h network,
@@ -809,17 +805,15 @@ void __bt_mesh_network_scan_unprovisioned_device_result_cb(int result, bt_mesh_n
if (state == BT_MESH_SCANNING_STARTED) {
TC_PRT("The scanning state is: STARTED");
print_network_handle(network);
- }
- else if (state == BT_MESH_SCANNING_FINISHED) {
+ } else if (state == BT_MESH_SCANNING_FINISHED) {
TC_PRT("The scanning state is: STOPPED");
print_network_handle(network);
wait_for_async_over();
- }
- else {
+ } else {
GSList *l;
char *duuid = g_strdup(scan_res->uuid);
l = g_slist_find_custom(unprov_dev_list, duuid, __compare_dev_uuid);
- if(!l) {
+ if (!l) {
unprov_dev_list = g_slist_append(unprov_dev_list, duuid);
TC_PRT("New unprov Dev UUID %s", duuid);
TC_PRT("RSSI values is %d", scan_res->rssi);
@@ -834,16 +828,15 @@ void __bt_mesh_network_device_provision_cb(int result, bt_mesh_network_h network
const char* dev_uuid, void* user_data)
{
TC_PRT("result: %s", __bt_get_error_message(result));
- if(dev_uuid == NULL)
+ if (dev_uuid == NULL)
TC_PRT("Provisioned dev_uuid is NULL");
else {
GSList *l;
TC_PRT("Provisioned device_uuid [%s]", dev_uuid);
char *duuid = g_strdup(dev_uuid);
l = g_slist_find_custom(prov_dev_list, duuid, __compare_dev_uuid);
- if(!l) {
+ if (!l)
prov_dev_list = g_slist_append(prov_dev_list, duuid);
- }
}
wait_for_async_over();
}
@@ -897,7 +890,8 @@ int __bt_mesh_group_send_msg(bt_mesh_group_h group,
return ret;
}
-int test_set_params(int test_id, char *param){
+int test_set_params(int test_id, char *param)
+{
static int param_index = 0;
int param_count = 0;
@@ -905,76 +899,76 @@ int test_set_params(int test_id, char *param){
goto done;
switch (current_tc_table) {
case BT_MESH_UNIT_TEST_TABLE_NETWORK: {
- switch(test_id) {
+ switch (test_id) {
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE:
param_count = 2;
- switch(param_index) {
+ switch (param_index) {
case 0:
- TC_PRT("Input param(%d) (network_name)\n",param_index + 1);
+ TC_PRT("Input param(%d) (network_name)\n", param_index + 1);
break;
case 1:
- TC_PRT("Input param(%d) (Node Handle)\n",param_index + 1);
+ TC_PRT("Input param(%d) (Node Handle)\n", param_index + 1);
break;
}
break;
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_DESTROY:
param_count = 1;
- TC_PRT("Input param(%d) (network_handle)\n",param_index + 1);
+ TC_PRT("Input param(%d) (network_handle)\n", param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_AND_DESTROY_IN_LOOP:
param_count = 1;
- TC_PRT("Input param(%d) (Num networks to create & destroy)\n",param_index + 1);
+ TC_PRT("Input param(%d) (Num networks to create & destroy)\n", param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_IN_LOOP:
param_count = 1;
- TC_PRT("Input param(%d) (Number of networks)\n",param_index + 1);
+ TC_PRT("Input param(%d) (Number of networks)\n", param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_INIT_AND_DEINIT_IN_LOOP:
param_count = 1;
- TC_PRT("Input param(%d) (Number of networks)\n",param_index + 1);
+ TC_PRT("Input param(%d) (Number of networks)\n", param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_NODE_DESTROY:
param_count = 1;
- TC_PRT("Input param(%d) (node Handle)\n",param_index + 1);
+ TC_PRT("Input param(%d) (node Handle)\n", param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETWORK:
param_count = 1;
- TC_PRT("Input param(%d) (node Handle)\n",param_index + 1);
+ TC_PRT("Input param(%d) (node Handle)\n", param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE_ELEMENT:
param_count = 1;
- TC_PRT("Input param(%d) (node Handle)\n",param_index + 1);
+ TC_PRT("Input param(%d) (node Handle)\n", param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_CREATE_MODEL:
param_count = 2;
- switch(param_index) {
+ switch (param_index) {
case 0:
- TC_PRT("Input param(%d) (Element Handle)\n" ,param_index + 1);
+ TC_PRT("Input param(%d) (Element Handle)\n", param_index + 1);
break;
case 1:
- TC_PRT("Input param(%d) (Model ID)\n",param_index + 1);
+ TC_PRT("Input param(%d) (Model ID)\n", param_index + 1);
break;
}
break;
case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_GET_NODE:
- param_count=1;
- TC_PRT("Input param(%d) (Element Handle)\n",param_index + 1);
+ param_count = 1;
+ TC_PRT("Input param(%d) (Element Handle)\n", param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ID:
- param_count=1;
- TC_PRT("Input param(%d) (Model Handle)\n",param_index + 1);
+ param_count = 1;
+ TC_PRT("Input param(%d) (Model Handle)\n", param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_MODEL_DESTROY:
- param_count=1;
- TC_PRT("Input param(%d) (Model Handle)\n",param_index + 1);
+ param_count = 1;
+ TC_PRT("Input param(%d) (Model Handle)\n", param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ELEMENT:
- param_count=1;
- TC_PRT("Input param(%d) (Model Handle)\n",param_index + 1);
+ param_count = 1;
+ TC_PRT("Input param(%d) (Model Handle)\n", param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_DESTROY:
- param_count=1;
- TC_PRT("Input param(%d) (Element Handle)\n",param_index + 1);
+ param_count = 1;
+ TC_PRT("Input param(%d) (Element Handle)\n", param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_NODE_FOREACH_ELEMENTS:
param_count = 1;
@@ -986,53 +980,53 @@ int test_set_params(int test_id, char *param){
break;
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_GROUP:
param_count = 1;
- TC_PRT("Input param(%d) (group address)\n" ,param_index + 1);
+ TC_PRT("Input param(%d) (group address)\n", param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_REMOVE_GROUP:
param_count = 1;
- TC_PRT("Input param(%d) (group handle)\n" ,param_index + 1);
+ TC_PRT("Input param(%d) (group handle)\n", param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_UNPROVISIONED_DEVICE_SCAN:
param_count = 1;
- TC_PRT("Input param(%d) (Seconds)\n" ,param_index + 1);
+ TC_PRT("Input param(%d) (Seconds)\n" , param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_PROVISION_DEVICE:
param_count = 1;
- TC_PRT("Input param(%d) (device_uuid)\n",param_index+1);
+ TC_PRT("Input param(%d) (device_uuid)\n", param_index+1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_NAME:
- param_count=1;
- TC_PRT("Input param(%d) (network_name)",param_index + 1);
+ param_count = 1;
+ TC_PRT("Input param(%d) (network_name)", param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_LOAD:
param_count = 1;
TC_PRT("Input param(%d) (network Token)", param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_MESH_AUTHENTICATION_REPLY:
- param_count=2;
- switch(param_index) {
+ param_count = 2;
+ switch (param_index) {
case 0:
- TC_PRT("Input param(%d) (auth_value)\n",param_index +1);
+ TC_PRT("Input param(%d) (auth_value)\n", param_index +1);
break;
case 1:
- TC_PRT("Input param(%d) (auth_reply)\n",param_index + 1);
+ TC_PRT("Input param(%d) (auth_reply)\n", param_index + 1);
TC_PRT("0: false, 1: true");
break;
}
break;
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_PROVISIONING_CAPABILITIES:
param_count = 4;
- switch(param_index) {
+ switch (param_index) {
case 0:
- TC_PRT("\nInput param(%d) is_public_oob",param_index + 1);
+ TC_PRT("\nInput param(%d) is_public_oob", param_index + 1);
TC_PRT("0: false, 1: true\n");
break;
case 1:
- TC_PRT("\nInput param(%d) is_static_oob",param_index + 1);
+ TC_PRT("\nInput param(%d) is_static_oob", param_index + 1);
TC_PRT("0: false, 1 : true\n");
break;
case 2:
- TC_PRT("\nInput param(%d) output_oob",param_index + 1);
+ TC_PRT("\nInput param(%d) output_oob", param_index + 1);
TC_PRT("BT_MESH_OUT_OOB_METHOD_BLINK = 0x01");
TC_PRT("BT_MESH_OUT_OOB_METHOD_BEEP = 0x02");
TC_PRT("BT_MESH_OUT_OOB_METHOD_VIBRATE = 0x04");
@@ -1040,7 +1034,7 @@ int test_set_params(int test_id, char *param){
TC_PRT("BT_MESH_OUT_OOB_METHOD_ALPHANUMERIC = 0x10\n");
break;
case 3:
- TC_PRT("\nInput param(%d) input_oob",param_index + 1);
+ TC_PRT("\nInput param(%d) input_oob", param_index + 1);
TC_PRT("BT_MESH_IN_OOB_METHOD_PUSH = 0x01");
TC_PRT("BT_MESH_IN_OOB_METHOD_TWIST = 0x02");
TC_PRT("BT_MESH_IN_OOB_METHOD_NUMERIC = 0x04");
@@ -1091,34 +1085,34 @@ int test_set_params(int test_id, char *param){
break;
}
case BT_MESH_UNIT_TEST_TABLE_SCENARIO: {
- switch(test_id) {
+ switch (test_id) {
case BT_MESH_UNIT_TEST_SCENARIO_PROVISION_DEVICE:
param_count = 1;
- TC_PRT("Input param(%d) (device_uuid)\n",param_index+1);
+ TC_PRT("Input param(%d) (device_uuid)\n", param_index+1);
break;
case BT_MESH_UNIT_TEST_SCENARIO_NODE_RESET:
param_count = 1;
- TC_PRT("Input param(%d) (node handle)\n",param_index+1);
+ TC_PRT("Input param(%d) (node handle)\n", param_index+1);
break;
case BT_MESH_UNIT_TEST_SCENARIO_NODE_CONFIGURE_KEY:
param_count = 1;
- TC_PRT("Input param(%d) (node handle)\n",param_index+1);
+ TC_PRT("Input param(%d) (node handle)\n", param_index+1);
break;
case BT_MESH_UNIT_TEST_SCENARIO_MODEL_GENERIC_ONOFF_SET_ON:
param_count = 1;
- TC_PRT("Input param(%d) (model handle)\n",param_index+1);
+ TC_PRT("Input param(%d) (model handle)\n", param_index+1);
break;
case BT_MESH_UNIT_TEST_SCENARIO_MODEL_GENERIC_ONOFF_SET_OFF:
param_count = 1;
- TC_PRT("Input param(%d) (model handle)\n",param_index+1);
+ TC_PRT("Input param(%d) (model handle)\n", param_index+1);
break;
case BT_MESH_UNIT_TEST_SCENARIO_GROUP_GENERIC_ONOFF_SET_ON:
param_count = 1;
- TC_PRT("Input param(%d) (group handle)\n",param_index+1);
+ TC_PRT("Input param(%d) (group handle)\n", param_index+1);
break;
case BT_MESH_UNIT_TEST_SCENARIO_GROUP_GENERIC_ONOFF_SET_OFF:
param_count = 1;
- TC_PRT("Input param(%d) (group handle)\n",param_index+1);
+ TC_PRT("Input param(%d) (group handle)\n", param_index+1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS:
need_to_set_params = true;
@@ -1131,7 +1125,7 @@ int test_set_params(int test_id, char *param){
break;
}
case BT_MESH_UNIT_TEST_TABLE_CONFIGURATION: {
- switch(test_id) {
+ switch (test_id) {
case BT_MESH_UNIT_TEST_FUNCTION_MESH_NETWORK_DISCOVER_NODE:
param_count = 1;
TC_PRT("Input param(%d) (device_uuid)", param_index + 1);
@@ -1150,7 +1144,7 @@ int test_set_params(int test_id, char *param){
break;
case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_APPKEYS:
param_count = 2;
- switch(param_index) {
+ switch (param_index) {
case 0:
TC_PRT("Input param(%d) (Node Handle)", param_index + 1);
break;
@@ -1169,7 +1163,7 @@ int test_set_params(int test_id, char *param){
break;
case BT_MESH_UNIT_TEST_FUNCTION_MODEL_SET_PUBLICATION:
param_count = 3;
- switch(param_index) {
+ switch (param_index) {
case 0:
TC_PRT("\nInput param(%d) Model handle\n", param_index + 1);
break;
@@ -1188,7 +1182,7 @@ int test_set_params(int test_id, char *param){
case BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_GROUP_SUBSCRIPTION:
case BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_VIRTUAL_GROUP_SUBSCRIPTION:
param_count = 3;
- switch(param_index) {
+ switch (param_index) {
case 0:
TC_PRT("\nInput param(%d) Model handle\n", param_index + 1);
break;
@@ -1211,7 +1205,7 @@ int test_set_params(int test_id, char *param){
case BT_MESH_UNIT_TEST_FUNCTION_MODEL_BIND_APPKEY:
case BT_MESH_UNIT_TEST_FUNCTION_MODEL_UNBIND_APPKEY:
param_count = 2;
- switch(param_index) {
+ switch (param_index) {
case 0:
TC_PRT("\nInput param(%d) Model Handle\n", param_index + 1);
break;
@@ -1223,7 +1217,7 @@ int test_set_params(int test_id, char *param){
case BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_NETKEY:
case BT_MESH_UNIT_TEST_FUNCTION_NODE_CONFIGURE_APPKEY:
param_count = 3;
- switch(param_index) {
+ switch (param_index) {
case 0:
TC_PRT("\nInput param(%d) Node Handle\n", param_index + 1);
break;
@@ -1239,12 +1233,12 @@ int test_set_params(int test_id, char *param){
}
break;
case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_TTL:
- param_count=1;
+ param_count = 1;
TC_PRT("\nInput param(%d) Node Handle\n", param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_NODE_SET_TTL:
param_count = 2;
- switch(param_index) {
+ switch (param_index) {
case 0:
TC_PRT("\nInput param(%d) Node Handle\n", param_index + 1);
break;
@@ -1260,10 +1254,10 @@ int test_set_params(int test_id, char *param){
break;
}
case BT_MESH_UNIT_TEST_TABLE_CONTROL: {
- switch(test_id) {
+ switch (test_id) {
case BT_MESH_UNIT_TEST_FUNCTION_MODEL_SEND_MSG:
param_count = 4;
- switch(param_index) {
+ switch (param_index) {
case 0:
TC_PRT("Input param(%d) (Model Handle)\n", param_index + 1);
break;
@@ -1280,7 +1274,7 @@ int test_set_params(int test_id, char *param){
break;
case BT_MESH_UNIT_TEST_FUNCTION_GROUP_SEND_MSG:
param_count = 4;
- switch(param_index) {
+ switch (param_index) {
case 0:
TC_PRT("Input param(%d) (Group Handle)\n", param_index + 1);
break;
@@ -1306,7 +1300,8 @@ int test_set_params(int test_id, char *param){
need_to_set_params = false;
break;
}
- done:
+
+done:
if (need_to_set_params) {
if (param_index == 0) {
g_test_param.param_count = param_count;
@@ -1511,7 +1506,7 @@ int test_input_callback(void *data)
}
case BT_MESH_UNIT_TEST_FUNCTION_NODE_FOREACH_ELEMENTS: {
bt_mesh_node_h node_h = 0;
- if (g_test_param.param_count != 1){
+ if (g_test_param.param_count != 1) {
TC_PRT("Enter Input parameter first.\n");
break;
}
@@ -1522,7 +1517,7 @@ int test_input_callback(void *data)
}
case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_FOREACH_MODELS: {
bt_mesh_element_h element_h = 0;
- if (g_test_param.param_count != 1){
+ if (g_test_param.param_count != 1) {
TC_PRT("Enter Input parameter first.\n");
break;
}
@@ -1567,7 +1562,14 @@ int test_input_callback(void *data)
TC_PRT("Enter Input parameter first.\n");
break;
}
+
int num = atoi(g_test_param.params[0]);
+
+ if (num < 0 || num > INT_MAX) {
+ TC_PRT("Input Number out of bounds \n");
+ break;
+ }
+
TC_PRT("Create [%d] Networks", num);
for (int i = 0; i < num; i++) {
@@ -1665,6 +1667,12 @@ int test_input_callback(void *data)
break;
}
int num = atoi(g_test_param.params[0]);
+
+ if (num < 0 || num > INT_MAX) {
+ TC_PRT("Input Number out of bounds \n");
+ break;
+ }
+
TC_PRT("Create [%d] Networks", num);
for (int i = 0; i < num; i++) {
@@ -1740,6 +1748,12 @@ int test_input_callback(void *data)
break;
}
int num = atoi(g_test_param.params[0]);
+
+ if (num < 0 || num > INT_MAX) {
+ TC_PRT("Input Number out of bounds \n");
+ break;
+ }
+
TC_PRT("Create [%d] Networks", num);
for (int i = 0; i < num; i++) {
@@ -1751,6 +1765,7 @@ int test_input_callback(void *data)
TC_PRT("Mesh init failed!");
continue;
}
+
/* Create Node */
bt_mesh_node_h node_h;
bt_mesh_node_features_s features;
@@ -1812,11 +1827,10 @@ int test_input_callback(void *data)
/* Mesh De-Init */
ret = bt_mesh_deinitialize();
- if (ret == BT_ERROR_NONE) {
+ if (ret == BT_ERROR_NONE)
TC_PRT("Mesh De-init Passed!");
- } else {
+ else
TC_PRT("Mesh De-init failed!");
- }
}
break;
}
@@ -1835,13 +1849,13 @@ int test_input_callback(void *data)
break;
}
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_NAME: {
- char* network_name="tempName";
+ char* network_name = "tempName";
if (g_test_param.param_count != 1) {
TC_PRT("Enter parameter first!");
break;
}
network_name = g_strdup(g_test_param.params[0]);
- ret = bt_mesh_network_set_name(network,(const char*)network_name);
+ ret = bt_mesh_network_set_name(network, (const char*)network_name);
TC_PRT("return %s\n", __bt_get_error_message(ret));
g_free(network_name);
break;
@@ -2032,7 +2046,7 @@ int test_input_callback(void *data)
unprov_dev_list = NULL;
bt_mesh_scan_params_s scan_params;
memset(&scan_params, 0x00, sizeof(bt_mesh_scan_params_s));
- if(g_test_param.param_count != 1) {
+ if (g_test_param.param_count != 1) {
TC_PRT("Enter Input parameter first.\n");
break;
}
@@ -2052,12 +2066,12 @@ int test_input_callback(void *data)
}
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_PROVISION_DEVICE: {
const char *dev_uuid = "abababababababababababababababab";
- if(g_test_param.param_count != 1) {
+ if (g_test_param.param_count != 1) {
TC_PRT("Enter Input parameter first.\n");
break;
}
dev_uuid = g_test_param.params[0];
- TC_PRT("The dev_uuid is [%s]\n",dev_uuid);
+ TC_PRT("The dev_uuid is [%s]\n", dev_uuid);
ret = bt_mesh_network_provision_device(network, dev_uuid,
__bt_mesh_network_device_provision_cb, NULL);
TC_PRT("return %s\n", __bt_get_error_message(ret));
@@ -2073,7 +2087,7 @@ int test_input_callback(void *data)
char* value;
int len;
bool auth_reply;
- if(g_test_param.param_count !=2){
+ if (g_test_param.param_count != 2) {
TC_PRT("Enter Input parameter first.\n");
break;
}
@@ -2090,7 +2104,7 @@ int test_input_callback(void *data)
}
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_PROVISIONING_CAPABILITIES: {
bt_mesh_provisioner_capabilities_s capabilities;
- if(g_test_param.param_count !=4) {
+ if (g_test_param.param_count != 4) {
TC_PRT("Enter Input parameter first.");
break;
}
@@ -2607,11 +2621,12 @@ int test_input_callback(void *data)
}
case BT_MESH_UNIT_TEST_SCENARIO_PROVISION_DEVICE: {
const char *dev_uuid = "c2a6ff31ed00427d27a53698cca89029";
- if(g_test_param.param_count > 0) {
+
+ if (g_test_param.param_count > 0)
dev_uuid = g_test_param.params[0];
- }
+
g_device_uuid = g_strdup(dev_uuid);
- TC_PRT("The dev_uuid is [%s]\n",g_device_uuid);
+ TC_PRT("The dev_uuid is [%s]\n", g_device_uuid);
/* Stop any ongoing scan */
ret = bt_mesh_stop_unprovisioned_device_scan(network);
@@ -2644,9 +2659,8 @@ int test_input_callback(void *data)
}
case BT_MESH_UNIT_TEST_SCENARIO_NODE_RESET: {
bt_mesh_node_h node_h = g_node;
- if (g_test_param.param_count > 0) {
+ if (g_test_param.param_count > 0)
node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16));
- }
ret = bt_mesh_node_reset(node_h);
TC_PRT("return %s\n", __bt_get_error_message(ret));
@@ -2661,9 +2675,8 @@ int test_input_callback(void *data)
bt_mesh_node_key_configuration_e config = BT_MESH_NODE_KEY_ADD;
bt_mesh_model_subscription_op_e op = BT_MESH_MODEL_SUBSCRIPTION_ADD;
- if (g_test_param.param_count > 0) {
+ if (g_test_param.param_count > 0)
node_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16));
- }
/* Get remote node */
ret = bt_mesh_node_foreach_element(node_h, __bt_mesh_node_foreach_elem_cb, NULL);
@@ -2732,9 +2745,8 @@ int test_input_callback(void *data)
bt_mesh_appkey_h appkey_h = g_appkey;
bt_mesh_model_msg_params_s msg_params;
- if (g_test_param.param_count > 0) {
+ if (g_test_param.param_count > 0)
model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16));
- }
const char *msg_s = "01010000";
msg_params.opcode = 0x8202;
@@ -2750,9 +2762,8 @@ int test_input_callback(void *data)
bt_mesh_appkey_h appkey_h = g_appkey;
bt_mesh_model_msg_params_s msg_params;
- if (g_test_param.param_count > 0) {
+ if (g_test_param.param_count > 0)
model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16));
- }
const char *msg_s = "00010000";
msg_params.opcode = 0x8202;
@@ -2768,9 +2779,8 @@ int test_input_callback(void *data)
bt_mesh_appkey_h appkey_h = g_appkey;
bt_mesh_model_msg_params_s msg_params;
- if (g_test_param.param_count > 0) {
+ if (g_test_param.param_count > 0)
group_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16));
- }
const char *msg_s = "01010000";
msg_params.opcode = 0x8202;
@@ -2786,9 +2796,8 @@ int test_input_callback(void *data)
bt_mesh_appkey_h appkey_h = g_appkey;
bt_mesh_model_msg_params_s msg_params;
- if (g_test_param.param_count > 0) {
+ if (g_test_param.param_count > 0)
group_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16));
- }
const char *msg_s = "00010000";
msg_params.opcode = 0x8202;
@@ -2857,7 +2866,7 @@ static gboolean key_event_cb(GIOChannel *chan,
if (current_tc_table == BT_MESH_UNIT_TEST_TABLE_MAIN) {
if (test_id == 0)
current_tc_table = BT_MESH_UNIT_TEST_TABLE_MAIN;
- else if(test_id >= BT_MESH_UNIT_TEST_TABLE_NETWORK
+ else if (test_id >= BT_MESH_UNIT_TEST_TABLE_NETWORK
&& test_id <= BT_MESH_UNIT_TEST_TABLE_SCENARIO) {
current_tc_table = test_id;
} else if (test_id > BT_MESH_UNIT_TEST_TABLE_CONTROL
@@ -2869,17 +2878,10 @@ static gboolean key_event_cb(GIOChannel *chan,
}
else {
- if (buf[0] == '0' && buf[2] == 0) {
- current_tc_table = BT_MESH_UNIT_TEST_TABLE_MAIN;
- }
-#if 0
- if(test_id == 0) {
+ if (buf[0] == '0' && buf[2] == 0)
current_tc_table = BT_MESH_UNIT_TEST_TABLE_MAIN;
- }
-#endif
- else {
+ else
is_call_api = true;
- }
}
tc_usage_print();