Add missing flags 72/272872/1
authorhyunuk.tak <hyunuk.tak@samsung.com>
Mon, 21 Mar 2022 02:48:45 +0000 (11:48 +0900)
committerhyunuk.tak <hyunuk.tak@samsung.com>
Mon, 28 Mar 2022 01:48:42 +0000 (10:48 +0900)
Change-Id: Icaa2d7cb37cdb8c1805cd978b4e5ffda78a29740
Signed-off-by: hyunuk.tak <hyunuk.tak@samsung.com>
CMakeLists.txt
packaging/capi-network-thread.spec
tests/thread-scenarios.c [deleted file]
tests/thread-test/thread-scenarios.c [new file with mode: 0644]

index 59a94cf2bd02cd1875f0feed16190189b1f9b946..77d991dc67829d2da7f21959ceac3ae1f025170d 100644 (file)
@@ -75,6 +75,9 @@ CONFIGURE_FILE(
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
 
 ADD_SUBDIRECTORY(tests/thread-test)
+IF(UNITTEST)
+ADD_SUBDIRECTORY(tests/unittest)
+ENDIF(UNITTEST)
 
 IF(UNIX)
 
index 5f7926099b836ef3289686037ebbf16ff7752b30..9db4f3ebb08b09ff5109753c8fe079ff7760cfbb 100644 (file)
@@ -135,7 +135,9 @@ genhtml %{name}.info -o out --legend --show-details
 %files test
 %manifest %{name}.manifest
 %attr(777,network_fw,network_fw) %{_bindir}/thread-test
+%if 0%{?gcov:1}
 %attr(777,network_fw,network_fw) %{_bindir}/thread-unittest
+%endif
 
 %if 0%{?gcov:1}
 %files gcov
diff --git a/tests/thread-scenarios.c b/tests/thread-scenarios.c
deleted file mode 100644 (file)
index 369282c..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 <stdlib.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include "thread.h"
-#include "thread-menu.h"
-#include "thread-type.h"
-#include "thread-log.h"
-#include "thread-util.h"
-
-static char g_name[NETWORK_DATA_SIZE + 1] = {"Thread-test"};
-static char g_key[NETWORK_DATA_SIZE + 1];
-static char g_pskc[NETWORK_DATA_SIZE + 1];
-static char g_str_channel[NETWORK_DATA_SIZE + 1] = {"07fff800"};
-static char g_str_extended_panid[NETWORK_DATA_SIZE + 1] = {"18446744073709551615"}; /* UINT64_MAX */
-static char g_str_panid[NETWORK_DATA_SIZE + 1] = {"65535"}; /* UINT16_MAX */
-static thread_network_h g_network;
-
-static char g_joiner_uuid[MENU_DATA_SIZE + 1];
-static char g_joiner_passphrase[MENU_DATA_SIZE + 1];
-
-uint32_t g_channel;
-uint64_t g_extended_panid;
-uint16_t g_panid;
-
-static char g_prov_url[MENU_DATA_SIZE + 1];
-static char g_vendor_name[MENU_DATA_SIZE + 1];
-static char g_vendor_model[MENU_DATA_SIZE + 1];
-static char g_vendor_sw_version[MENU_DATA_SIZE + 1];
-static char g_vendor_data[MENU_DATA_SIZE + 1];
-
-void _thread_joiner_start_callback(int result, void* user_data)
-{
-       msg("Thread joiner start callback, result: %s",
-                                       _thread_get_error_message(result));
-
-       return;
-}
-
-static int run_thread_scenario_startup(MManager *mm, struct menu_data *menu)
-{
-       FUNC_ENTRY;
-       int ret = THREAD_ERROR_NONE;
-       msg(" ### thread_scenario_startup ###");
-
-       thread_instance_h *g_instance = &(mm->t_instance);
-
-       /* Initialize thread */
-       ret = thread_initialize();
-       msg(" - thread_initialize() ret: [0x%X] [%s]", ret, _thread_get_error_message(ret));
-       retv_if(!(ret == THREAD_ERROR_NONE || ret == THREAD_ERROR_ALREADY_DONE), RET_SUCCESS);
-
-       /* thread enable */
-       ret = thread_enable(g_instance);
-       msg(" - thread_enable() ret: [0x%X] [%s]", ret, _thread_get_error_message(ret));
-       retv_if(!(ret == THREAD_ERROR_NONE || ret == THREAD_ERROR_ALREADY_DONE
-                       || ret == THREAD_ERROR_ALREADY_REGISTERED), RET_SUCCESS);
-
-       FUNC_EXIT;
-       return RET_SUCCESS;
-}
-
-static int run_thread_scenario_cleanup(MManager *mm, struct menu_data *menu)
-{
-       FUNC_ENTRY;
-       int ret = THREAD_ERROR_NONE;
-       msg(" ### thread_scenario_cleanup ###");
-
-       thread_instance_h g_instance = mm->t_instance;
-
-       /* thread disable */
-       ret = thread_disable(g_instance);
-       msg(" - thread_disable() ret: [0x%X] [%s]", ret, _thread_get_error_message(ret));
-       retv_if(!(ret == THREAD_ERROR_NONE || ret == THREAD_ERROR_ALREADY_DONE
-                       || ret == THREAD_ERROR_ALREADY_REGISTERED), RET_SUCCESS);
-
-       /* De-initialize thread */
-       ret = thread_deinitialize();
-       msg(" - thread_deinitialize() ret: [0x%X] [%s]", ret, _thread_get_error_message(ret));
-       retv_if(!(ret == THREAD_ERROR_NONE || ret == THREAD_ERROR_ALREADY_DONE), RET_SUCCESS);
-
-       FUNC_EXIT;
-       return RET_SUCCESS;
-}
-static int run_thread_joiner_join_network(MManager *mm, struct menu_data *menu)
-{
-       FUNC_ENTRY;
-       thread_instance_h g_instance = mm->t_instance;
-       if (g_instance == NULL)
-               goto OUT;
-       int ret = THREAD_ERROR_NONE;
-
-       /*factoryreset */
-       ret = thread_factoryreset(g_instance);
-       if (ret != THREAD_ERROR_NONE) {
-                msg("Failed: %s", _thread_get_error_message(ret));
-                goto OUT;
-       }
-
-       /*thread ifconfig up */
-       ret = thread_ifconfig_up(g_instance);
-       if (ret != THREAD_ERROR_NONE) {
-               msg("Failed: %s", _thread_get_error_message(ret));
-               goto OUT;
-       }
-
-       /*Joiner start*/
-       ret = thread_joiner_start(g_instance, g_joiner_passphrase, g_prov_url,
-                       g_vendor_name, g_vendor_model, g_vendor_sw_version,
-                       g_vendor_data, _thread_joiner_start_callback, NULL);
-       if (ret != THREAD_ERROR_NONE) {
-               msg("Failed: %s", _thread_get_error_message(ret));
-               goto OUT;
-       }
-
-       msg("thread_joiner_join_network success");
-OUT:
-       FUNC_EXIT;
-       return RET_SUCCESS;
-}
-
-static int run_thread_start_leader_as_commissioner(MManager *mm, struct menu_data *menu)
-{
-       FUNC_ENTRY;
-       thread_instance_h g_instance = mm->t_instance;
-       if (g_instance == NULL)
-       goto OUT;
-
-       sscanf(g_str_channel, "%x", &g_channel);
-       sscanf(g_str_extended_panid, "%zu", (size_t *)&g_extended_panid);
-       sscanf(g_str_panid, "%hu", &g_panid);
-
-       int ret = THREAD_ERROR_NONE;
-
-       /*factoryreset */
-       ret = thread_factoryreset(g_instance);
-       if (ret != THREAD_ERROR_NONE) {
-               msg("Failed: %s", _thread_get_error_message(ret));
-               goto OUT;
-       }
-
-       /* create operational_network */
-       ret = thread_network_create_operational_network(g_instance, g_name,
-                               g_key, g_pskc, g_channel, g_extended_panid,
-                               g_panid, &g_network);
-       if (ret != THREAD_ERROR_NONE) {
-               msg("Failed: %s", _thread_get_error_message(ret));
-               goto OUT;
-       }
-
-       /*attach operational network */
-       ret = thread_network_attach(g_instance);
-       if (ret != THREAD_ERROR_NONE) {
-               msg("Failed: %s", _thread_get_error_message(ret));
-               goto OUT;
-       }
-
-       /*thread ifconfig up */
-       ret = thread_ifconfig_up(g_instance);
-       if (ret != THREAD_ERROR_NONE) {
-               msg("Failed: %s", _thread_get_error_message(ret));
-               goto OUT;
-       }
-
-       /* thread commissioner start*/
-       ret = thread_commissioner_start(g_instance);
-       if (ret != THREAD_ERROR_NONE) {
-               msg("Failed: %s", _thread_get_error_message(ret));
-               goto OUT;
-       }
-
-       /* thread commissioner set commissioning data*/
-       ret = thread_commissioner_set_commisioning_data(g_instance, g_joiner_uuid,
-                                       g_joiner_passphrase);
-       if (ret != THREAD_ERROR_NONE) {
-               msg("Failed: %s", _thread_get_error_message(ret));
-               goto OUT;
-       }
-
-       msg("thread_commissioner_set_commisioning_data success");
-OUT:
-       FUNC_EXIT;
-       return RET_SUCCESS;
-}
-
-static struct menu_data menu_thread_joiner_join_network[] = {
-       { "1", "Type Joiner Passphrase", NULL, NULL, g_joiner_passphrase},
-       { "2", "run", NULL, run_thread_joiner_join_network, NULL},
-       { NULL, NULL, },
-};
-
-static struct menu_data menu_thread_start_leader_as_commissioner[] = {
-       { "1", "Joiner UUID", NULL, NULL, g_joiner_uuid},
-       { "2", "Joiner Passphrase", NULL, NULL, g_joiner_passphrase},
-       { "3", "run", NULL, run_thread_start_leader_as_commissioner, NULL},
-       { NULL, NULL, },
-};
-
-struct menu_data menu_thread_scenarios[] = {
-       { "1", "thread_scenario_startup",
-               NULL, run_thread_scenario_startup, NULL },
-       { "2", "thread_scenario_cleanup",
-               NULL, run_thread_scenario_cleanup, NULL },
-       { "3", "thread_start_leader_as_commissioner",
-               menu_thread_start_leader_as_commissioner, NULL, NULL},
-       { "4", "thread_joiner_join_network",
-               menu_thread_joiner_join_network, NULL, NULL },
-       { NULL, NULL, },
-};
diff --git a/tests/thread-test/thread-scenarios.c b/tests/thread-test/thread-scenarios.c
new file mode 100644 (file)
index 0000000..369282c
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "thread.h"
+#include "thread-menu.h"
+#include "thread-type.h"
+#include "thread-log.h"
+#include "thread-util.h"
+
+static char g_name[NETWORK_DATA_SIZE + 1] = {"Thread-test"};
+static char g_key[NETWORK_DATA_SIZE + 1];
+static char g_pskc[NETWORK_DATA_SIZE + 1];
+static char g_str_channel[NETWORK_DATA_SIZE + 1] = {"07fff800"};
+static char g_str_extended_panid[NETWORK_DATA_SIZE + 1] = {"18446744073709551615"}; /* UINT64_MAX */
+static char g_str_panid[NETWORK_DATA_SIZE + 1] = {"65535"}; /* UINT16_MAX */
+static thread_network_h g_network;
+
+static char g_joiner_uuid[MENU_DATA_SIZE + 1];
+static char g_joiner_passphrase[MENU_DATA_SIZE + 1];
+
+uint32_t g_channel;
+uint64_t g_extended_panid;
+uint16_t g_panid;
+
+static char g_prov_url[MENU_DATA_SIZE + 1];
+static char g_vendor_name[MENU_DATA_SIZE + 1];
+static char g_vendor_model[MENU_DATA_SIZE + 1];
+static char g_vendor_sw_version[MENU_DATA_SIZE + 1];
+static char g_vendor_data[MENU_DATA_SIZE + 1];
+
+void _thread_joiner_start_callback(int result, void* user_data)
+{
+       msg("Thread joiner start callback, result: %s",
+                                       _thread_get_error_message(result));
+
+       return;
+}
+
+static int run_thread_scenario_startup(MManager *mm, struct menu_data *menu)
+{
+       FUNC_ENTRY;
+       int ret = THREAD_ERROR_NONE;
+       msg(" ### thread_scenario_startup ###");
+
+       thread_instance_h *g_instance = &(mm->t_instance);
+
+       /* Initialize thread */
+       ret = thread_initialize();
+       msg(" - thread_initialize() ret: [0x%X] [%s]", ret, _thread_get_error_message(ret));
+       retv_if(!(ret == THREAD_ERROR_NONE || ret == THREAD_ERROR_ALREADY_DONE), RET_SUCCESS);
+
+       /* thread enable */
+       ret = thread_enable(g_instance);
+       msg(" - thread_enable() ret: [0x%X] [%s]", ret, _thread_get_error_message(ret));
+       retv_if(!(ret == THREAD_ERROR_NONE || ret == THREAD_ERROR_ALREADY_DONE
+                       || ret == THREAD_ERROR_ALREADY_REGISTERED), RET_SUCCESS);
+
+       FUNC_EXIT;
+       return RET_SUCCESS;
+}
+
+static int run_thread_scenario_cleanup(MManager *mm, struct menu_data *menu)
+{
+       FUNC_ENTRY;
+       int ret = THREAD_ERROR_NONE;
+       msg(" ### thread_scenario_cleanup ###");
+
+       thread_instance_h g_instance = mm->t_instance;
+
+       /* thread disable */
+       ret = thread_disable(g_instance);
+       msg(" - thread_disable() ret: [0x%X] [%s]", ret, _thread_get_error_message(ret));
+       retv_if(!(ret == THREAD_ERROR_NONE || ret == THREAD_ERROR_ALREADY_DONE
+                       || ret == THREAD_ERROR_ALREADY_REGISTERED), RET_SUCCESS);
+
+       /* De-initialize thread */
+       ret = thread_deinitialize();
+       msg(" - thread_deinitialize() ret: [0x%X] [%s]", ret, _thread_get_error_message(ret));
+       retv_if(!(ret == THREAD_ERROR_NONE || ret == THREAD_ERROR_ALREADY_DONE), RET_SUCCESS);
+
+       FUNC_EXIT;
+       return RET_SUCCESS;
+}
+static int run_thread_joiner_join_network(MManager *mm, struct menu_data *menu)
+{
+       FUNC_ENTRY;
+       thread_instance_h g_instance = mm->t_instance;
+       if (g_instance == NULL)
+               goto OUT;
+       int ret = THREAD_ERROR_NONE;
+
+       /*factoryreset */
+       ret = thread_factoryreset(g_instance);
+       if (ret != THREAD_ERROR_NONE) {
+                msg("Failed: %s", _thread_get_error_message(ret));
+                goto OUT;
+       }
+
+       /*thread ifconfig up */
+       ret = thread_ifconfig_up(g_instance);
+       if (ret != THREAD_ERROR_NONE) {
+               msg("Failed: %s", _thread_get_error_message(ret));
+               goto OUT;
+       }
+
+       /*Joiner start*/
+       ret = thread_joiner_start(g_instance, g_joiner_passphrase, g_prov_url,
+                       g_vendor_name, g_vendor_model, g_vendor_sw_version,
+                       g_vendor_data, _thread_joiner_start_callback, NULL);
+       if (ret != THREAD_ERROR_NONE) {
+               msg("Failed: %s", _thread_get_error_message(ret));
+               goto OUT;
+       }
+
+       msg("thread_joiner_join_network success");
+OUT:
+       FUNC_EXIT;
+       return RET_SUCCESS;
+}
+
+static int run_thread_start_leader_as_commissioner(MManager *mm, struct menu_data *menu)
+{
+       FUNC_ENTRY;
+       thread_instance_h g_instance = mm->t_instance;
+       if (g_instance == NULL)
+       goto OUT;
+
+       sscanf(g_str_channel, "%x", &g_channel);
+       sscanf(g_str_extended_panid, "%zu", (size_t *)&g_extended_panid);
+       sscanf(g_str_panid, "%hu", &g_panid);
+
+       int ret = THREAD_ERROR_NONE;
+
+       /*factoryreset */
+       ret = thread_factoryreset(g_instance);
+       if (ret != THREAD_ERROR_NONE) {
+               msg("Failed: %s", _thread_get_error_message(ret));
+               goto OUT;
+       }
+
+       /* create operational_network */
+       ret = thread_network_create_operational_network(g_instance, g_name,
+                               g_key, g_pskc, g_channel, g_extended_panid,
+                               g_panid, &g_network);
+       if (ret != THREAD_ERROR_NONE) {
+               msg("Failed: %s", _thread_get_error_message(ret));
+               goto OUT;
+       }
+
+       /*attach operational network */
+       ret = thread_network_attach(g_instance);
+       if (ret != THREAD_ERROR_NONE) {
+               msg("Failed: %s", _thread_get_error_message(ret));
+               goto OUT;
+       }
+
+       /*thread ifconfig up */
+       ret = thread_ifconfig_up(g_instance);
+       if (ret != THREAD_ERROR_NONE) {
+               msg("Failed: %s", _thread_get_error_message(ret));
+               goto OUT;
+       }
+
+       /* thread commissioner start*/
+       ret = thread_commissioner_start(g_instance);
+       if (ret != THREAD_ERROR_NONE) {
+               msg("Failed: %s", _thread_get_error_message(ret));
+               goto OUT;
+       }
+
+       /* thread commissioner set commissioning data*/
+       ret = thread_commissioner_set_commisioning_data(g_instance, g_joiner_uuid,
+                                       g_joiner_passphrase);
+       if (ret != THREAD_ERROR_NONE) {
+               msg("Failed: %s", _thread_get_error_message(ret));
+               goto OUT;
+       }
+
+       msg("thread_commissioner_set_commisioning_data success");
+OUT:
+       FUNC_EXIT;
+       return RET_SUCCESS;
+}
+
+static struct menu_data menu_thread_joiner_join_network[] = {
+       { "1", "Type Joiner Passphrase", NULL, NULL, g_joiner_passphrase},
+       { "2", "run", NULL, run_thread_joiner_join_network, NULL},
+       { NULL, NULL, },
+};
+
+static struct menu_data menu_thread_start_leader_as_commissioner[] = {
+       { "1", "Joiner UUID", NULL, NULL, g_joiner_uuid},
+       { "2", "Joiner Passphrase", NULL, NULL, g_joiner_passphrase},
+       { "3", "run", NULL, run_thread_start_leader_as_commissioner, NULL},
+       { NULL, NULL, },
+};
+
+struct menu_data menu_thread_scenarios[] = {
+       { "1", "thread_scenario_startup",
+               NULL, run_thread_scenario_startup, NULL },
+       { "2", "thread_scenario_cleanup",
+               NULL, run_thread_scenario_cleanup, NULL },
+       { "3", "thread_start_leader_as_commissioner",
+               menu_thread_start_leader_as_commissioner, NULL, NULL},
+       { "4", "thread_joiner_join_network",
+               menu_thread_joiner_join_network, NULL, NULL },
+       { NULL, NULL, },
+};