Mesh: BLE Mesh Unit Test Application 52/238852/1
authorhimanshu <h.himanshu@samsung.com>
Sun, 28 Jun 2020 15:11:31 +0000 (20:41 +0530)
committerAnupam Roy <anupam.r@samsung.com>
Sun, 19 Jul 2020 14:52:03 +0000 (20:22 +0530)
This patch introduces the mesh unit
test application.

Change-Id: I9080e5250fe0e83cb25db54b4defdaa53a382089
Signed-off-by: himanshu <h.himanshu@samsung.com>
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
packaging/capi-network-bluetooth.spec
test/CMakeLists.txt
test/bt_mesh_unit_test.c [new file with mode: 0644]
test/bt_mesh_unit_test.h [new file with mode: 0644]

index cbb0314..b90b392 100644 (file)
@@ -120,6 +120,7 @@ install -m 0644 test/bt_infinite_spp_test_server.service %{buildroot}%{_unitdir}
 
 %files test
 %manifest %{name}.manifest
+%{_bindir}/bt_mesh_unit_test
 %{_bindir}/bt_unit_test
 %{_bindir}/bt_onoff
 %{_bindir}/ble_mouse
index 5c8019e..0d6a867 100644 (file)
@@ -18,6 +18,7 @@ FOREACH(src ${sources})
 ENDFOREACH()
 
 INSTALL(TARGETS bt_unit_test DESTINATION bin)
+INSTALL(TARGETS bt_mesh_unit_test DESTINATION bin)
 INSTALL(TARGETS bt_onoff DESTINATION bin)
 INSTALL(TARGETS ble_mouse DESTINATION bin)
 INSTALL(TARGETS hid_keyboard DESTINATION bin)
diff --git a/test/bt_mesh_unit_test.c b/test/bt_mesh_unit_test.c
new file mode 100644 (file)
index 0000000..a64c1f4
--- /dev/null
@@ -0,0 +1,1226 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved *
+ *
+ * @author: Anupam Roy <anupam.r@samsung.com>
+ * @author: Himanshu <h.himanshu@samsung.com>
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <glib.h>
+#include <ctype.h>
+#ifdef ARCH64
+#include <stdint.h>
+#endif
+#include <sys/types.h>
+
+#include "bluetooth.h"
+#include "bluetooth_type_internal.h"
+#include "bluetooth_internal.h"
+#include "bluetooth_private.h"
+#include "bt_mesh_unit_test.h"
+
+static bt_mesh_unit_test_table_e current_tc_table;
+
+static bool need_to_set_params = false;
+static int g_test_id = -1;
+static tc_params_t g_test_param = {0,};
+
+static bt_mesh_node_h local_node;
+static bt_mesh_node_h node;
+static bt_mesh_model_h model;
+static bt_mesh_element_h element;
+static bt_mesh_network_h network;
+static bt_mesh_appkey_h appkey;
+static bt_mesh_netkey_h netkey;
+static bt_mesh_group_h group;
+static bt_mesh_group_h virtual_group;
+
+static bt_mesh_authentication_type_e request_type;
+
+static char* token;
+static bt_mesh_network_h networks[3];
+static bt_mesh_node_h nodes[3];
+static bt_mesh_element_h elements[3];
+static bt_mesh_netkey_h netkeys[10];
+
+static int current_network_index = 0;
+static int current_node_index = 0;
+static int current_element_index = 0;
+static int current_netkey_index = 0;
+
+GMainLoop *main_loop = NULL;
+
+tc_table_t tc_configuration[] = {
+       {"Back"
+               , BT_MESH_UNIT_TEST_FUNCTION_BACK},
+       {"bt_mesh_network_discover_node"
+               , BT_MESH_UNIT_TEST_FUNCTION_MESH_NETWORK_DISCOVER_NODE},
+       {"bt_mesh_node_reset"
+               , BT_MESH_UNIT_TEST_FUNCTION_NODE_RESET},
+       {"bt_mesh_node_get_ttl"
+               , BT_MESH_UNIT_TEST_FUNCTION_GET_TTL},
+       {"bt_mesh_node_set_ttl"
+               , BT_MESH_UNIT_TEST_FUNCTION_SET_TTL},
+       {"bt_mesh_model_bind_appkey"
+               , BT_MESH_UNIT_TEST_FUNCTION_MODEL_BIND_APPKEY},
+       {"bt_mesh_model_unbind_appkey"
+               , BT_MESH_UNIT_TEST_FUNCTION_MODEL_UNBIND_APPKEY},
+       {"bt_mesh_model_get_appkey_list"
+               , BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_APPKEY_LIST},
+       {"bt_mesh_model_configure_group_subscription"
+               , BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_GROUP_SUBSCRIPTION},
+       {"bt_mesh_model_configure_virtual_group_subscription"
+               , BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_VIRTUAL_GROUP_SUBSCRIPTION},
+       {"bt_mesh_model_get_subscription_list"
+               , BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_SUBSCRIPTION_LIST},
+       {"bt_mesh_model_set_publication"
+               , BT_MESH_UNIT_TEST_FUNCTION_MODEL_SET_PUBLICATION},
+       {"bt_mesh_model_get_publication"
+               , BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_PUBLICATION},
+       {"bt_mesh_appkey_get_netkey"
+               , BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_NETKEY},
+       {"select this menu to set parameters and then select the function again"
+               , BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS},
+       {NULL                                           , 0X0000},
+};
+
+tc_table_t tc_network[] = {
+       {"Back"
+               , BT_MESH_UNIT_TEST_FUNCTION_BACK},
+       {"bt_mesh_node_create"
+               , BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE},
+       {"bt_mesh_node_destroy"
+               , BT_MESH_UNIT_TEST_FUNCTION_NODE_DESTROY},
+       {"bt_mesh_node_create_element"
+               , BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE_ELEMENT},
+       {"bt_mesh_node_get_network"
+               , BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETWORK},
+       {"bt_mesh_element_create_model"
+               , BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_CREATE_MODEL},
+       {"bt_mesh_model_get_id"
+               , BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ID},
+       {"bt_mesh_model_destroy"
+               , BT_MESH_UNIT_TEST_FUNCTION_MODEL_DESTROY},
+       {"bt_mesh_model_get_element"
+               , BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ELEMENT},
+       {"bt_mesh_element_destroy"
+               , BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_DESTROY},
+       {"bt_mesh_element_foreach_models"
+               , BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_FOREACH_MODELS},
+       {"bt_mesh_element_get_node"
+               , BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_GET_NODE},
+       {"bt_mesh_network_create"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE},
+       {"bt_mesh_network_unprovisioned_device_scan"
+                , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_UNPROVISIONED_DEVICE_SCAN},
+        {"bt_mesh_network_provision_device"
+                , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_PROVISION_DEVICE},
+        {"bt_mesh_authentication_reply"
+                , BT_MESH_UNIT_TEST_FUNCTION_MESH_AUTHENTICATION_REPLY},
+        {"bt_mesh_network_set_provisioning_capabilities"
+                , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_PROVISIONING_CAPABILITIES},
+       {"bt_mesh_network_load"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_LOAD},
+       {"bt_mesh_network_set_name"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_NAME},
+       {"bt_mesh_network_get_name"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_NAME},
+       {"bt_mesh_network_add_netkey"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_ADD_NETKEY},
+       {"bt_mesh_network_foreach_netkeys"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_NETKEYS},
+       {"bt_mesh_netkey_get_index"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETKEY_GET_INDEX},
+       {"bt_mesh_netkey_update"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETKEY_UPDATE},
+       {"bt_mesh_netkey_delete"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETKEY_DELETE},
+       {"bt_mesh_netkey_add_appkey"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETKEY_ADD_APPKEY},
+       {"bt_mesh_netkey_foreach_appkeys"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETKEY_FOREACH_APPKEYS},
+       {"bt_mesh_appkey_get_index"
+               , BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_INDEX},
+       {"bt_mesh_appkey_update"
+               , BT_MESH_UNIT_TEST_FUNCTION_APPKEY_UPDATE},
+       {"bt_mesh_appkey_delete"
+               , BT_MESH_UNIT_TEST_FUNCTION_APPKEY_DELETE},
+       {"bt_mesh_network_foreach_nodes"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_NODES},
+       {"bt_mesh_network_create_group"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_GROUP},
+       {"bt_mesh_network_create_virtual_group"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_VIRTUAL_GROUP},
+       {"bt_mesh_network_remove_group"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_REMOVE_GROUP},
+       {"bt_mesh_network_foreach_groups"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_GROUPS},
+       {"bt_mesh_stop_unprovisioned_device_scan"
+               , BT_MESH_UNIT_TEST_FUNCTION_STOP_UNPROVISIONED_DEVICE_SCAN},
+       {"bt_mesh_authentication_set_request_cb"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_AUTHENTICATION_SET_REQUEST_CB},
+       {"bt_mesh_network_get_provisioning_capabilities"
+               , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_PROVISIONING_CAPABILITIES},
+       {"select this menu to set parameters and then select the function again"
+               , BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS},
+       {NULL                                           , 0X0000},
+};
+
+tc_table_t tc_main[] = {
+       {"bt_mesh_initialize"
+               , BT_MESH_UNIT_TEST_FUNCTION_INITIALIZE},
+       {"bt_mesh_deinitialize"
+               , BT_MESH_UNIT_TEST_FUNCTION_DEINITIALIZE},
+       {"Network"
+               , BT_MESH_UNIT_TEST_TABLE_NETWORK},
+       {"Configuration"
+               , BT_MESH_UNIT_TEST_TABLE_CONFIGURATION},
+       {"Finish"
+               , BT_MESH_UNIT_TEST_TABLE_FINISH},
+       {NULL                                           , 0x0000},
+};
+
+static void __bt_free_test_param(tc_params_t *param)
+{
+       int i = 0;
+
+       for (i = 0; i < param->param_count; i++)
+               g_free(param->params[i]);
+       g_free(param->params);
+       param->params = NULL;
+       param->param_count = 0;
+}
+
+void tc_usage_print(void){
+       int i=0;
+       tc_table_t *tc_table = NULL;
+       switch (current_tc_table) {
+       case BT_MESH_UNIT_TEST_TABLE_NETWORK:
+               tc_table = tc_network;
+               break;
+       case BT_MESH_UNIT_TEST_TABLE_CONFIGURATION:
+               tc_table = tc_configuration;
+               break;
+       default:
+               tc_table = tc_main;
+               break;
+       }
+       while (tc_table[i].tc_name) {
+               TC_PRT("Key %d : usage %s", tc_table[i].tc_code,tc_table[i].tc_name);
+               i++;
+       }
+}
+
+static const char *__bt_get_error_message(bt_error_e err)
+{
+       const char *err_str = NULL;
+
+       switch (err) {
+       case BT_ERROR_NONE:
+               err_str = "BT_ERROR_NONE";
+               break;
+       case BT_ERROR_CANCELLED:
+               err_str = "BT_ERROR_CANCELLED";
+               break;
+       case BT_ERROR_INVALID_PARAMETER:
+               err_str = "BT_ERROR_INVALID_PARAMETER";
+               break;
+       case BT_ERROR_OUT_OF_MEMORY:
+               err_str = "BT_ERROR_OUT_OF_MEMORY";
+               break;
+       case BT_ERROR_RESOURCE_BUSY:
+               err_str = "BT_ERROR_RESOURCE_BUSY";
+               break;
+       case BT_ERROR_TIMED_OUT:
+               err_str = "BT_ERROR_TIMED_OUT";
+               break;
+       case BT_ERROR_NOW_IN_PROGRESS:
+               err_str = "BT_ERROR_NOW_IN_PROGRESS";
+               break;
+       case BT_ERROR_NOT_INITIALIZED:
+               err_str = "BT_ERROR_NOT_INITIALIZED";
+               break;
+       case BT_ERROR_NOT_ENABLED:
+               err_str = "BT_ERROR_NOT_ENABLED";
+               break;
+       case BT_ERROR_ALREADY_DONE:
+               err_str = "BT_ERROR_ALREADY_DONE";
+               break;
+       case BT_ERROR_OPERATION_FAILED:
+               err_str = "BT_ERROR_OPERATION_FAILED";
+               break;
+       case BT_ERROR_NOT_IN_PROGRESS:
+               err_str = "BT_ERROR_NOT_IN_PROGRESS";
+               break;
+       default:
+               err_str = "NOT defined";
+               break;
+               }
+       return err_str;
+}
+
+void print_network_handle(bt_mesh_network_h network)
+{
+       if(network == NULL)
+               return;
+       bt_mesh_network_s* net = (bt_mesh_network_s*) network;
+       TC_PRT("network_handle=[%p]", (void*)net);
+       TC_PRT("Is Network local      [%d]", net->is_local);
+       TC_PRT("Is Network discovered [%d]", net->is_discovered);
+       TC_PRT("Network UUID          [%s]", net->uuid);
+       TC_PRT("Network Token         [%s]", net->token);
+       TC_PRT("Network Name          [%s]", net->name);
+       TC_PRT("Network Nodes         [%d]", net->num_nodes);
+}
+
+void print_node_handle(bt_mesh_node_h node)
+{
+       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("Is Node Local           [%d]", node_info->is_local);
+       TC_PRT("Is Node attached        [%d]", node_info->is_attached);
+       TC_PRT("Node Parent Network name[%s]", node_info->parent->name);
+       TC_PRT("Node UUID          ");
+       for(int i=0; i<16; i++) {
+               printf("%02x", node_info->uuid[i]);
+       }
+       TC_PRT("");
+       TC_PRT("Node Unicast            [%d]", node_info->unicast);
+
+}
+
+void print_element_handle(bt_mesh_element_h element)
+{
+       if(element == NULL)
+               return;
+       bt_mesh_element_s* element_info = (bt_mesh_element_s*) element;
+       TC_PRT("element_handle=[%p]", (void*)element_info);
+       TC_PRT("Is Element Local    [%d]", element_info->is_local);
+       TC_PRT("Element index       [%d]", element_info->index);
+}
+
+void print_model_handle(bt_mesh_model_h model)
+{
+       if(model == NULL)
+               return;
+       bt_mesh_model_s* model_info = (bt_mesh_model_s*) model;
+       TC_PRT("model_handle=[%p]", (void*)model_info);
+       TC_PRT("Is Model Local        [%d]", model_info->is_local);
+       TC_PRT("Model ID              [%d]", model_info->id);
+       TC_PRT("Model Pub Address     [%d]", model_info->pub_addr);
+}
+
+void print_netkey_handle(bt_mesh_netkey_h netkey)
+{
+       if(netkey == NULL)
+               return;
+       bt_mesh_netkey_s* netkey_info = (bt_mesh_netkey_s*) netkey;
+       TC_PRT("netkey_handle=[%p]", (void*)netkey_info);
+       TC_PRT("netkey->parent_network_name [%s]", netkey_info->parent->name);
+       TC_PRT("netkey->netkey_index        [%d]", netkey_info->netkey_index);
+}
+
+void print_appkey_handle(bt_mesh_appkey_h appkey)
+{
+       if(appkey == NULL)
+               return;
+       bt_mesh_appkey_s* appkey_info = (bt_mesh_appkey_s*) appkey;
+       TC_PRT("appkey_handle=[%p]", (void*)appkey_info);
+       TC_PRT("appkey->parent->netkey_index [%d]", appkey_info->parent->netkey_index);
+       TC_PRT("appkey->appkey_index         [%d]", appkey_info->appkey_index);
+}
+
+void print_group_handle(bt_mesh_group_h group)
+{
+       if(group == NULL)
+               return;
+       bt_mesh_group_s* group_info = (bt_mesh_group_s*) group;
+       TC_PRT("group_handle=[%p]", (void*)group_info);
+       TC_PRT("group->parent_network->name  [%s]", group_info->parent->name);
+       TC_PRT("group->addr                  [%d]", group_info->addr);
+       TC_PRT("group->label_uuid            [%s]", group_info->label_uuid);
+       TC_PRT("group->is_virtual            [%d]", group_info->is_virtual);
+       TC_PRT("group->ref_count             [%d]", group_info->ref_count);
+}
+
+bool __bt_mesh_network_group_info_cb(int result, bt_mesh_network_h network, int total,
+               bt_mesh_group_h group, void *user_data)
+{
+       bt_mesh_group_s* grp = (bt_mesh_group_s*) group;
+       TC_PRT("bt_mesh_network_group_info_cb");
+       TC_PRT("result: %s", __bt_get_error_message(result));
+       if(result == BT_ERROR_NONE) {
+               print_network_handle(network);
+               TC_PRT("grp->address [%d]",grp->addr);
+               return true;
+       }
+       return false;
+}
+
+void __bt_mesh_node_discover_status_cb(int result, bt_mesh_network_h network, bt_mesh_node_h node,
+               void *user_data)
+{
+       TC_PRT("bt_mesh_node_discover_status_cb");
+       TC_PRT("result: %s", __bt_get_error_message(result));
+       if(result == BT_ERROR_NONE) {
+               print_network_handle(network);
+               print_node_handle(node);
+       }
+}
+
+void __bt_mesh_node_ttl_cb(int result, bt_mesh_node_h node,
+               bt_mesh_node_ttl_operation_e ttl_op, uint8_t ttl, void *user_data)
+{
+       TC_PRT("bt_mesh_node_ttl_cb");
+       TC_PRT("result: %s", __bt_get_error_message(result));
+       if(result == BT_ERROR_NONE) {
+               print_node_handle(node);
+               TC_PRT("ttl_op is [%d]", ttl_op);
+               TC_PRT("ttl value is [%d]",ttl);
+       }
+}
+
+void __bt_mesh_model_bind_cb(int result, bt_mesh_model_h model, bt_mesh_appkey_h appkey,
+               void *user_data)
+{
+       TC_PRT("bt_mesh_model_bind_cb");
+       TC_PRT("result: %s", __bt_get_error_message(result));
+       if(result == BT_ERROR_NONE) {
+               print_model_handle(model);
+               print_appkey_handle(appkey);
+       }
+}
+
+void __bt_mesh_model_unbind_cb(int result, bt_mesh_model_h model, bt_mesh_appkey_h appkey,
+               void *user_data)
+{
+       TC_PRT("bt_mesh_model_unbind_cb");
+       TC_PRT("result: %s", __bt_get_error_message(result));
+       if(result == BT_ERROR_NONE) {
+               print_model_handle(model);
+               print_appkey_handle(appkey);
+       }
+}
+
+void __bt_mesh_model_appkey_list_cb(int result, bt_mesh_model_h model, int total,  const GSList *appkeylist,
+               void *user_data)
+{
+       const GSList* keylist = NULL;
+       TC_PRT("bt_mesh_model_appkey_list_cb");
+       TC_PRT("result: %s", __bt_get_error_message(result));
+       if(result == BT_ERROR_NONE) {
+               print_model_handle(model);
+               for(keylist = appkeylist; keylist!=NULL ;keylist = g_slist_next(keylist))
+                       print_appkey_handle((bt_mesh_appkey_h)keylist);
+       }
+}
+
+void __bt_mesh_model_subscription_op_cb(int result, bt_mesh_model_subscription_op_e op,
+               bt_mesh_model_h model, bt_mesh_group_h group, void *user_data)
+{
+       TC_PRT("bt_mesh_model_subscription_op_cb");
+       TC_PRT("result: %s", __bt_get_error_message(result));
+       if(result == BT_ERROR_NONE) {
+               print_model_handle(model);
+               print_group_handle(group);
+               if (op == BT_MESH_MODEL_SUBSCRIPTION_ADD) {
+                       TC_PRT("op is BT_MESH_MODEL_SUBSCRIPTION_ADD");
+               }
+               else if (op == BT_MESH_MODEL_SUBSCRIPTION_DELETE) {
+                       TC_PRT("op is BT_MESH_MODEL_SUBSCRIPTION_DELETE");
+               }
+               else if (op == BT_MESH_MODEL_SUBSCRIPTION_DELETE_ALL) {
+                       TC_PRT("op is BT_MESH_MODEL_SUBSCRIPTION_DELETE_ALL");
+               }
+               else if(op == BT_MESH_MODEL_SUBSCRIPTION_OVERWRITE) {
+                       TC_PRT("op is BT_MESH_MODEL_SUBSCRIPTION_OVERWRITE");
+               }
+               else {
+                       TC_PRT("Operation does not exist");
+               }
+       }
+}
+
+bool __bt_mesh_model_subscription_list_cb(int result, bt_mesh_model_h model, int total, const GSList *sub_addr,
+               void *user_data)
+{
+       const GSList* sublist = NULL;
+       TC_PRT("bt_mesh_model_subscription_list_cb");
+       TC_PRT("result: %s", __bt_get_error_message(result));
+       print_model_handle(model);
+       for(sublist = sub_addr; sublist != NULL; sublist = g_slist_next(sublist)) {
+               print_group_handle((bt_mesh_group_h)sublist);
+       }
+       return true;
+}
+
+void __bt_mesh_model_publication_status_cb(int result, bt_mesh_model_h model, bt_mesh_group_h group,
+               bt_mesh_appkey_h appkey, void *user_data)
+{
+       TC_PRT("bt_mesh_model_publication_status_cb");
+       TC_PRT("result: %s", __bt_get_error_message(result));
+       if(result == BT_ERROR_NONE) {
+               print_model_handle(model);
+               print_appkey_handle(appkey);
+       }
+}
+
+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("bt_mesh_network_appkey_info_cb");
+       TC_PRT("result: %s", __bt_get_error_message(result));
+       if(result == BT_ERROR_NONE) {
+               print_appkey_handle(appkey);
+               TC_PRT("Total appkeys are [%d]",total);
+               return true;
+       }
+       return false;
+}
+
+bool  __bt_mesh_network_netkey_info_cb(int result, bt_mesh_network_h network, int total,
+               bt_mesh_netkey_h netkey, uint16_t netkey_index, void *user_data)
+{
+       TC_PRT("bt_mesh_network_netkey_info_cb");
+       TC_PRT("result: %s", __bt_get_error_message(result));
+       if(result == BT_ERROR_NONE) {
+               print_network_handle(network);
+               print_netkey_handle(netkey);
+               TC_PRT("Total netkeys are [%d]",total);
+               return true;
+       }
+       return false;
+}
+
+void __bt_mesh_network_scan_unprovisioned_device_result_cb(int result, bt_mesh_network_h network,
+                       bt_mesh_scanning_state_e state, bt_mesh_scan_result_s *scan_res, void *user_data)
+{
+       TC_PRT("bt_mesh_network_scan_unprovisioned_device_result_cb");
+       TC_PRT("result: %s", __bt_get_error_message(result));
+       if(result == BT_ERROR_NONE) {
+               if (state == BT_MESH_SCANNING_STARTED) {
+                       TC_PRT("The scanning state is: STARTED");
+                       print_network_handle(network);
+               }
+               else if (state == BT_MESH_SCANNING_FINISHED) {
+                       TC_PRT("The scanning state is: STOPPED");
+               }
+               else if(scan_res != NULL){
+                       TC_PRT("Scan Result found");
+                       TC_PRT("Device UUID is %s\n", scan_res->uuid);
+                       TC_PRT("RSSI values is %d\n", scan_res->rssi);
+                       TC_PRT("OOB Info 0x%x\n", scan_res->oob_info);
+               }
+               else {
+                       TC_PRT("scan_res is NULL");
+               }
+       }
+}
+
+void __bt_mesh_network_device_provision_cb(int result, bt_mesh_network_h network,
+                       const char* dev_uuid, void* user_data)
+{
+       TC_PRT("bt_mesh_network_device_provision_cb");
+       TC_PRT("result: %s", __bt_get_error_message(result));
+       if(result == BT_ERROR_NONE) {
+               print_network_handle(network);
+               if(dev_uuid == NULL)
+                       TC_PRT("dev_uuid is NULL");
+               else
+                       TC_PRT("The device_uuid is [%s]", dev_uuid);
+       }
+}
+
+void __bt_mesh_authentication_request_cb(int result, bt_mesh_authentication_type_e auth_type,
+               char *auth_value, void *user_data)
+{
+       TC_PRT("bt_mesh_authentication_request_cb");
+       TC_PRT("result: %s", __bt_get_error_message(result));
+       if (result == BT_ERROR_NONE) {
+               TC_PRT("auth_value is [%s]", auth_value);
+               TC_PRT("auth_type is [%d]", auth_type);
+       }
+}
+
+int test_set_params(int test_id, char *param){
+       static int param_index = 0;
+       int param_count = 0;
+
+       if (param_index > 0 && param_index == g_test_param.param_count)
+               goto done;
+       switch (current_tc_table) {
+       case BT_MESH_UNIT_TEST_TABLE_NETWORK: {
+               switch(test_id) {
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE:
+                       param_count=1;
+                       TC_PRT("Input param(%d) (network_name)",param_index + 1);
+                       break;
+               case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_CREATE_MODEL:
+                       param_count = 1;
+                       switch(param_index) {
+                       case 0:
+                               TC_PRT("Input param(%d) (model_id)" ,param_index + 1);
+                               break;
+                       default:
+                               break;
+                       }
+                       break;
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_PROVISION_DEVICE:
+                       param_count = 1;
+                       TC_PRT("Input param(%d) (device_uuid)",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);
+                       break;
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_UNPROVISIONED_DEVICE_SCAN:
+                       param_count = 1;
+                       TC_PRT("Input param(%d) (scan_seconds)",param_index +1 );
+                       break;
+               case BT_MESH_UNIT_TEST_FUNCTION_MESH_AUTHENTICATION_REPLY:
+                       param_count=2;
+                       switch(param_index) {
+                       case 0:
+                               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("0: false,  1: true");
+                               break;
+                       }
+                       break;
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_PROVISIONING_CAPABILITIES:
+                       param_count = 4;
+                       switch(param_index) {
+                       case 0:
+                               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("0: false, 1 : true\n");
+                               break;
+                       case 2:
+                               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");
+                               TC_PRT("BT_MESH_OUT_OOB_METHOD_NUMERIC          = 0x08");
+                               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("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");
+                               TC_PRT("BT_MESH_IN_OOB_METHOD_ALPHANUMERIC      = 0x08\n");
+                               break;
+                       }
+                       break;
+               case BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS:
+                       need_to_set_params = true;
+                       TC_PRT("\nSelect the function again\n");
+                       break;
+               default:
+                       TC_PRT("There is no parameter to set\n");
+                       break;
+               }
+               break;
+       }
+       default:
+               TC_PRT("There is no parameter to set\n");
+               need_to_set_params = false;
+               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);
+                       param[len - 1] = '\0';
+                       g_test_param.params[param_index - 1] = g_strdup(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;
+}
+
+int test_input_callback(void *data)
+{
+       int ret = 0;
+#ifdef ARCH64
+       int test_id = (uintptr_t)data;
+#else
+       int test_id = (int)data;
+#endif
+
+       switch (current_tc_table) {
+       case BT_MESH_UNIT_TEST_TABLE_MAIN: {
+               switch (test_id) {
+               case 0x00ff:
+                       TC_PRT("Finished\n");
+                       g_main_loop_quit(main_loop);
+                       break;
+               case BT_MESH_UNIT_TEST_FUNCTION_INITIALIZE:
+                       ret = bt_mesh_initialize();
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               case BT_MESH_UNIT_TEST_FUNCTION_DEINITIALIZE:
+                       ret = bt_mesh_deinitialize();
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               default:
+                       break;
+               }
+               break;
+       }
+       case BT_MESH_UNIT_TEST_TABLE_NETWORK:{
+               switch (test_id) {
+               case BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE:{
+                       bt_mesh_node_features_s features;
+                       features.features = BT_MESH_FEATURE_RELAY;
+                       features.features |= BT_MESH_FEATURE_LOWPOWER;
+
+                       ret = bt_mesh_node_create(&features, &local_node);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NODE_DESTROY: {
+                       ret = bt_mesh_node_destroy(local_node);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETWORK: {
+                       if(current_network_index == 3) {
+                               TC_PRT("network instances are full\n");
+                               current_network_index = current_network_index%3;
+                               TC_PRT("Removing the network instance at index: [%d]", current_network_index);
+                       }
+                       ret = bt_mesh_node_get_network(local_node, &networks[current_network_index]);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       if(ret == BT_ERROR_NONE) {
+                               TC_PRT("current network instance stored at index: [%d]", current_network_index);
+                               current_network_index++;
+                       }
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE_ELEMENT: {
+                       ret = bt_mesh_node_create_element(local_node, &element);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_CREATE_MODEL: {
+                       bt_mesh_model_id_s mod_id;
+                       memset(&mod_id, 0x00, sizeof(bt_mesh_model_id_s));
+                       if(g_test_param.param_count > 0) {
+                               mod_id.model_id = (int)strtol(g_test_param.params[0], NULL, 16);
+                               __bt_free_test_param(&g_test_param);
+                       }
+                       mod_id.company_id = 0xFFFF;
+                       TC_PRT("The model_id is [%d]\n", mod_id.model_id);
+                       ret = bt_mesh_element_create_model(element,&mod_id, &model);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_GET_NODE: {
+                       if(current_node_index == 3) {
+                               TC_PRT("node instances are full\n");
+                               current_node_index = current_node_index%3;
+                               TC_PRT("Removing the node instance at index: [%d]", current_node_index);
+                       }
+                       ret = bt_mesh_element_get_node(element, &nodes[current_node_index]);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       if(ret == BT_ERROR_NONE) {
+                               TC_PRT("current node instance stored at index: [%d]", current_node_index);
+                               current_node_index++;
+                       }
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ID: {
+                       bt_mesh_model_id_s model_id;
+                       memset(&model_id, 0x00, sizeof(bt_mesh_model_id_s));
+                       ret = bt_mesh_model_get_id(model, &model_id);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       if(ret == BT_ERROR_NONE)
+                               TC_PRT("The model_id is %d", model_id.model_id);
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_MODEL_DESTROY: {
+                       ret = bt_mesh_model_destroy(model);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ELEMENT: {
+                       if(current_element_index == 3) {
+                               TC_PRT("node instances are full\n");
+                               current_element_index = current_element_index%3;
+                               TC_PRT("Removing the node instance at index: [%d]", current_element_index);
+                       }
+                       ret = bt_mesh_model_get_element(model, &elements[current_element_index]);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       if(ret == BT_ERROR_NONE) {
+                               print_element_handle(elements[current_element_index]);
+                               TC_PRT("current network instance stored at index: [%d]", current_element_index);
+                               current_element_index++;
+                       }
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_DESTROY: {
+                       ret = bt_mesh_element_destroy(element);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE: {
+                       char* network_name = "Mesh Test Network";
+                       if(g_test_param.param_count > 0) {
+                               network_name = g_strdup(g_test_param.params[0]);
+                               __bt_free_test_param(&g_test_param);
+                       }
+                       ret = bt_mesh_network_create(local_node, (const char*)network_name, &network, &token);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_LOAD: {
+                       ret = bt_mesh_network_load(token, &network);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       if(ret == BT_ERROR_NONE)
+                               print_network_handle(network);
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_NAME: {
+                       char* network_name="Mesh Test Network";
+                       if(g_test_param.param_count > 0) {
+                               network_name = g_strdup(g_test_param.params[0]);
+                               __bt_free_test_param(&g_test_param);
+                       }
+                       ret = bt_mesh_network_set_name(network,(const char*)network_name);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_NAME: {
+                       char* network_name;
+                       ret = bt_mesh_network_get_name(network,&network_name);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       if(ret == BT_ERROR_NONE)
+                               TC_PRT("network name is [%s]",network_name);
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_ADD_NETKEY: {
+                       if(current_netkey_index == 10) {
+                               TC_PRT("netkey instances are full\n");
+                               current_netkey_index = current_netkey_index%10;
+                               TC_PRT("Removing the netkey instance at index: [%d]", current_netkey_index);
+                       }
+                       ret = bt_mesh_network_add_netkey(network,&netkeys[current_netkey_index]);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       if(ret == BT_ERROR_NONE) {
+                               TC_PRT("cuurent netkey instance stored at index [%d]", current_netkey_index);
+                               print_netkey_handle(netkeys[current_netkey_index]);
+                               current_netkey_index++;
+                       }
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_NETKEYS: {
+                       ret = bt_mesh_network_foreach_netkeys(network, __bt_mesh_network_netkey_info_cb, NULL);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_GET_INDEX: {
+                       uint16_t index = 0;
+                       ret = bt_mesh_netkey_get_index(netkey, &index);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       if(ret == BT_ERROR_NONE)
+                               TC_PRT("The index of the netkey is: [%d]", index);
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_UPDATE: {
+                       ret = bt_mesh_netkey_update(netkey);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_DELETE: {
+                       ret = bt_mesh_netkey_delete(netkey);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_ADD_APPKEY: {
+                       ret = bt_mesh_netkey_add_appkey(netkey, &appkey);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       if(ret ==  BT_ERROR_NONE)
+                               print_appkey_handle(appkey);
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETKEY_FOREACH_APPKEYS: {
+                       ret = bt_mesh_netkey_foreach_appkeys(netkey, __bt_mesh_appkey_info_cb, NULL);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_INDEX: {
+                       uint16_t index = 0;
+                       ret = bt_mesh_appkey_get_index(appkey, &index);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       if(ret == BT_ERROR_NONE)
+                               TC_PRT("The index of the appkey is: [%d]", index);
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_UPDATE: {
+                       ret = bt_mesh_appkey_update(appkey);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_DELETE: {
+                       ret = bt_mesh_appkey_delete(appkey);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_NODES: {
+                       /* TODO */
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_GROUP: {
+                       uint16_t group_addr = 1;
+                       ret = bt_mesh_network_create_group(network, group_addr, &group);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_VIRTUAL_GROUP: {
+                       ret = bt_mesh_network_create_virtual_group(network, &virtual_group);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_REMOVE_GROUP: {
+                       ret = bt_mesh_network_remove_group(group);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_GROUPS: {
+                       ret = bt_mesh_network_foreach_groups(network, __bt_mesh_network_group_info_cb, NULL);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_UNPROVISIONED_DEVICE_SCAN: {
+                       bt_mesh_scan_params_s scan_params;
+                       scan_params.seconds = 30;
+                       if(g_test_param.param_count > 0) {
+                               scan_params.seconds = atoi(g_test_param.params[0]);
+                       }
+                       TC_PRT("The scan is set for [%d] seconds.", scan_params.seconds);
+                       ret = bt_mesh_network_unprovisioned_device_scan(network,&scan_params,
+                               __bt_mesh_network_scan_unprovisioned_device_result_cb, NULL);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_STOP_UNPROVISIONED_DEVICE_SCAN: {
+                       ret = bt_mesh_stop_unprovisioned_device_scan(network);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       if(ret == BT_ERROR_NONE)
+                               TC_PRT("Device SCAN : STOPPED\n");
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_PROVISION_DEVICE: {
+                       const char *dev_uuid = NULL;
+                       if(g_test_param.param_count > 0) {
+                               dev_uuid = g_test_param.params[0];
+                       }
+                       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));
+                       __bt_free_test_param(&g_test_param);
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_AUTHENTICATION_SET_REQUEST_CB: {
+                       ret =  bt_mesh_authentication_set_request_cb(__bt_mesh_authentication_request_cb, NULL);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case  BT_MESH_UNIT_TEST_FUNCTION_MESH_AUTHENTICATION_REPLY: {
+                       char* value;
+                       int len;
+                       bool auth_reply;
+                       if(g_test_param.param_count != 2){
+                               TC_PRT("Enter Input parameter first.\n");
+                               break;
+                       }
+                       len = strlen(g_test_param.params[0]);
+                       value = g_malloc0(len+1);
+                       g_strlcpy(value, g_test_param.params[0], len+1);
+                       auth_reply = atoi(g_test_param.params[1]);
+                       TC_PRT("\nauth_value is  [%s]\n", value);
+                       TC_PRT("auth_reply is    [%d]\n", auth_reply);
+                       TC_PRT("request_type is     [%d]\n",request_type);
+                       ret = bt_mesh_authentication_reply(request_type, (const char*)value, auth_reply);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       __bt_free_test_param(&g_test_param);
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_PROVISIONING_CAPABILITIES: {
+                       bt_mesh_provisioner_capabilities_s capabilities;
+                       if(g_test_param.param_count !=4) {
+                               TC_PRT("Enter Input parameter first.");
+                       }
+                       capabilities.public_oob = atoi(g_test_param.params[0]);
+                       capabilities.static_oob = atoi(g_test_param.params[1]);
+                       capabilities.out_oob = (int)strtol(g_test_param.params[2], NULL, 16);
+                       capabilities.in_oob = (int)strtol(g_test_param.params[3], NULL, 16);
+                       TC_PRT("capabilities.public_oob [%d]", capabilities.public_oob);
+                       TC_PRT("capabilities.static_oob [%d]", capabilities.static_oob);
+                       TC_PRT("capabilities.out_oob    [%d]", capabilities.out_oob);
+                       TC_PRT("capabilities.in_oob     [%d]", capabilities.in_oob);
+                       ret = bt_mesh_network_set_provisioning_capabilities(network, &capabilities);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       __bt_free_test_param(&g_test_param);
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_PROVISIONING_CAPABILITIES: {
+                       // TODO: need to implement
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: {
+                       need_to_set_params = true;
+                       TC_PRT("Select the function again\n");
+                       break;
+               }
+               default:
+                       break;
+               }
+               break;
+       }
+       case BT_MESH_UNIT_TEST_TABLE_CONFIGURATION: {
+               switch (test_id) {
+               case BT_MESH_UNIT_TEST_FUNCTION_MESH_NETWORK_DISCOVER_NODE: {
+                       char * dev_uuid = "";
+                       ret = bt_mesh_network_discover_node(network, (const char*)dev_uuid, __bt_mesh_node_discover_status_cb, NULL);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_NODE_RESET: {
+                       // TODO: need to implement
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_GET_TTL: {
+                       ret = bt_mesh_node_get_ttl(node, __bt_mesh_node_ttl_cb, NULL);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_SET_TTL: {
+                       int ttl = 60;
+                       ret = bt_mesh_node_set_ttl(node, ttl, __bt_mesh_node_ttl_cb, NULL);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_MODEL_BIND_APPKEY: {
+                       ret = bt_mesh_model_bind_appkey(model, appkey, __bt_mesh_model_bind_cb, NULL);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_MODEL_UNBIND_APPKEY: {
+                       ret = bt_mesh_model_unbind_appkey(model, appkey, __bt_mesh_model_unbind_cb, NULL);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_APPKEY_LIST: {
+                       ret = bt_mesh_model_get_appkey_list(model, __bt_mesh_model_appkey_list_cb, NULL);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_GROUP_SUBSCRIPTION: {
+                       bt_mesh_model_subscription_op_e model_op = BT_MESH_MODEL_SUBSCRIPTION_ADD;
+                       ret = bt_mesh_model_configure_group_subscription(model_op, model,  group,
+                                                               __bt_mesh_model_subscription_op_cb, NULL);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_VIRTUAL_GROUP_SUBSCRIPTION: {
+                       bt_mesh_model_subscription_op_e model_op = BT_MESH_MODEL_SUBSCRIPTION_ADD;
+                       ret = bt_mesh_model_configure_virtual_group_subscription(model_op, model,  virtual_group,
+                                       __bt_mesh_model_subscription_op_cb, NULL);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_SUBSCRIPTION_LIST: {
+                       ret = bt_mesh_model_get_subscription_list(model, __bt_mesh_model_subscription_list_cb, NULL);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_MODEL_SET_PUBLICATION: {
+                       bt_mesh_model_pub_params_s params;
+                       memset(&params, 0x00, sizeof(bt_mesh_model_pub_params_s));
+                       ret = bt_mesh_model_set_publication(model, appkey, group, &params,
+                                                       __bt_mesh_model_publication_status_cb, NULL);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_PUBLICATION: {
+                       ret = bt_mesh_model_get_publication(model, __bt_mesh_model_publication_status_cb,  NULL);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_NETKEY: {
+                       if(current_netkey_index == 10) {
+                               TC_PRT("netkey instances are full\n");
+                               current_netkey_index = current_netkey_index%10;
+                               TC_PRT("Removing the netkey instance at index: [%d]", current_netkey_index);
+                       }
+                       ret = bt_mesh_appkey_get_netkey(appkey, &netkeys[current_netkey_index]);
+                       TC_PRT("return %s\n", __bt_get_error_message(ret));
+                       if(ret == BT_ERROR_NONE) {
+                               TC_PRT("cuurent netkey instance stored at index [%d]", current_netkey_index);
+                               current_netkey_index++;
+                       }
+                       break;
+               }
+               default:
+                       break;
+               }
+               break;
+       }
+       default:
+               break;
+       }
+       return 0;
+}
+
+
+static gboolean key_event_cb(GIOChannel *chan,
+               GIOCondition cond,
+               gpointer data)
+{
+       char buf[BUFFER_LEN] = { 0 };
+
+#ifdef ARCH64
+       unsigned long len = 0;
+#else
+       unsigned int len = 0;
+#endif
+       int test_id;
+       bool is_call_api = false;
+
+       memset(buf, 0, sizeof(buf));
+
+       if (g_io_channel_read_chars(chan, buf, sizeof(buf),
+                               &len, NULL) == G_IO_STATUS_ERROR) {
+               TC_PRT("IO Channel read error");
+               return FALSE;
+       }
+
+       if (need_to_set_params == true) {
+               if (g_test_id == -1) {
+                       test_id = atoi(buf);
+                       g_test_id = test_id;
+               }
+               test_set_params(g_test_id, buf);
+               return TRUE;
+       } else {
+               TC_PRT("%s", buf);
+               test_id = atoi(buf);
+
+               g_test_id = -1;
+               need_to_set_params = false;
+       }
+
+       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
+                       && test_id < BT_MESH_UNIT_TEST_TABLE_FINISH) {
+                       current_tc_table = test_id;
+               }
+               else {
+                       is_call_api = true;
+               }
+       }
+
+       else {
+               if (buf[0] == '0' && buf[2] == 0) {
+                       current_tc_table = BT_MESH_UNIT_TEST_TABLE_MAIN;
+               }
+#if 0
+               if(test_id == 0) {
+                       current_tc_table = BT_MESH_UNIT_TEST_TABLE_MAIN;
+               }
+#endif
+               else {
+                       is_call_api = true;
+               }
+       }
+
+       tc_usage_print();
+       if (test_id && is_call_api) {
+#ifdef ARCH64
+               g_idle_add(test_input_callback, (void *)(uintptr_t)test_id);
+#else
+               g_idle_add(test_input_callback, (void *)test_id);
+#endif
+       }
+       return TRUE;
+}
+
+void sig_handler(int signo)
+{
+       if (signo == SIGINT) {
+               bt_mesh_deinitialize();
+               exit(0);
+       }
+}
+
+int main()
+{
+       GIOChannel *key_io;
+
+       current_tc_table = BT_MESH_UNIT_TEST_TABLE_MAIN;
+
+       key_io = g_io_channel_unix_new(fileno(stdin));
+
+       g_io_channel_set_encoding(key_io, NULL, NULL);
+       g_io_channel_set_flags(key_io, G_IO_FLAG_NONBLOCK, NULL);
+
+       g_io_add_watch(key_io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+                       key_event_cb, NULL);
+
+       g_io_channel_unref(key_io);
+
+       main_loop = g_main_loop_new(NULL, FALSE);
+
+       if (signal(SIGINT, sig_handler) == SIG_ERR)
+               TC_PRT("\n can't catch SIGINT\n");
+
+       g_main_loop_run(main_loop);
+
+       bt_mesh_deinitialize();
+
+       return 0;
+}
diff --git a/test/bt_mesh_unit_test.h b/test/bt_mesh_unit_test.h
new file mode 100644 (file)
index 0000000..e51346a
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * @author: Anupam Roy <anupam.r@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define BUFFER_LEN 49
+
+#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args)
+#define TC_PRT(format, args...) PRT(format"\n", ##args)
+
+typedef struct {
+       const char *tc_name;
+       int tc_code;
+} tc_table_t;
+
+typedef struct {
+       int param_count;
+       char **params;
+} tc_params_t;
+
+
+typedef enum {
+       BT_MESH_UNIT_TEST_TABLE_MAIN = 1,
+       BT_MESH_UNIT_TEST_TABLE_NETWORK = 3,
+       BT_MESH_UNIT_TEST_TABLE_CONFIGURATION,
+       BT_MESH_UNIT_TEST_TABLE_FINISH = 0XFF,
+} bt_mesh_unit_test_table_e;
+
+typedef enum {
+       BT_MESH_UNIT_TEST_FUNCTION_BACK = 0,
+       BT_MESH_UNIT_TEST_FUNCTION_INITIALIZE = 1,
+       BT_MESH_UNIT_TEST_FUNCTION_DEINITIALIZE,
+       BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE = 1,
+       BT_MESH_UNIT_TEST_FUNCTION_NODE_DESTROY,
+       BT_MESH_UNIT_TEST_FUNCTION_NODE_CREATE_ELEMENT,
+       BT_MESH_UNIT_TEST_FUNCTION_NODE_GET_NETWORK,
+       BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_CREATE_MODEL,
+       BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ID,
+       BT_MESH_UNIT_TEST_FUNCTION_MODEL_DESTROY,
+       BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_ELEMENT,
+       BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_DESTROY,
+       BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_FOREACH_MODELS,
+       BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_GET_NODE,
+       BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE,
+       BT_MESH_UNIT_TEST_FUNCTION_NETWORK_UNPROVISIONED_DEVICE_SCAN,
+       BT_MESH_UNIT_TEST_FUNCTION_NETWORK_PROVISION_DEVICE,
+       BT_MESH_UNIT_TEST_FUNCTION_MESH_AUTHENTICATION_REPLY,
+       BT_MESH_UNIT_TEST_FUNCTION_NETWORK_LOAD,
+       BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_NAME,
+       BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_NAME,
+       BT_MESH_UNIT_TEST_FUNCTION_NETWORK_ADD_NETKEY,
+       BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_NETKEYS,
+       BT_MESH_UNIT_TEST_FUNCTION_NETKEY_GET_INDEX,
+       BT_MESH_UNIT_TEST_FUNCTION_NETKEY_UPDATE,
+       BT_MESH_UNIT_TEST_FUNCTION_NETKEY_DELETE,
+       BT_MESH_UNIT_TEST_FUNCTION_NETKEY_ADD_APPKEY,
+       BT_MESH_UNIT_TEST_FUNCTION_NETKEY_FOREACH_APPKEYS,
+       BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_INDEX,
+       BT_MESH_UNIT_TEST_FUNCTION_APPKEY_UPDATE,
+       BT_MESH_UNIT_TEST_FUNCTION_APPKEY_DELETE,
+       BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_NODES,
+       BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_GROUP,
+       BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_VIRTUAL_GROUP,
+       BT_MESH_UNIT_TEST_FUNCTION_NETWORK_REMOVE_GROUP,
+       BT_MESH_UNIT_TEST_FUNCTION_NETWORK_FOREACH_GROUPS,
+       BT_MESH_UNIT_TEST_FUNCTION_STOP_UNPROVISIONED_DEVICE_SCAN,
+       BT_MESH_UNIT_TEST_FUNCTION_NETWORK_AUTHENTICATION_SET_REQUEST_CB,
+       BT_MESH_UNIT_TEST_FUNCTION_NETWORK_SET_PROVISIONING_CAPABILITIES,
+       BT_MESH_UNIT_TEST_FUNCTION_NETWORK_GET_PROVISIONING_CAPABILITIES,
+       BT_MESH_UNIT_TEST_FUNCTION_MESH_NETWORK_DISCOVER_NODE=1,
+       BT_MESH_UNIT_TEST_FUNCTION_NODE_RESET,
+       BT_MESH_UNIT_TEST_FUNCTION_GET_TTL,
+       BT_MESH_UNIT_TEST_FUNCTION_SET_TTL,
+       BT_MESH_UNIT_TEST_FUNCTION_MODEL_BIND_APPKEY,
+       BT_MESH_UNIT_TEST_FUNCTION_MODEL_UNBIND_APPKEY,
+       BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_APPKEY_LIST,
+       BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_GROUP_SUBSCRIPTION,
+       BT_MESH_UNIT_TEST_FUNCTION_MODEL_CONFIGURE_VIRTUAL_GROUP_SUBSCRIPTION,
+       BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_SUBSCRIPTION_LIST,
+       BT_MESH_UNIT_TEST_FUNCTION_MODEL_SET_PUBLICATION,
+       BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_PUBLICATION,
+       BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_NETKEY,
+       BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS = 0XFF,
+} bt_mesh_unit_test_function_e;
+
+int test_input_callback(void *data);