summaryrefslogtreecommitdiff
path: root/unittest/beluga-adaptor_setting.cpp
diff options
context:
space:
mode:
authorhwajeong.son <hwajeong.son@samsung.com>2018-08-20 13:20:53 +0900
committerhwajeong.son <hwajeong.son@samsung.com>2018-08-20 13:20:53 +0900
commit27763b024648b848430481a929d716038d887952 (patch)
treea5388eec33d3b55cbf75e2e1ea360c32de7de78f /unittest/beluga-adaptor_setting.cpp
parent81dc7d90889e619942f34c4a584768b4b3179445 (diff)
downloaddocker-adaptor-master.tar.gz
docker-adaptor-master.tar.bz2
docker-adaptor-master.zip
Signed-off-by: hwajeong.son <hwajeong.son@samsung.com>
Diffstat (limited to 'unittest/beluga-adaptor_setting.cpp')
-rwxr-xr-xunittest/beluga-adaptor_setting.cpp145
1 files changed, 145 insertions, 0 deletions
diff --git a/unittest/beluga-adaptor_setting.cpp b/unittest/beluga-adaptor_setting.cpp
new file mode 100755
index 0000000..083d39a
--- /dev/null
+++ b/unittest/beluga-adaptor_setting.cpp
@@ -0,0 +1,145 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gtest/gtest.h>
+#include <unistd.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <pthread.h>
+
+#include "sa_common.h"
+#include "adaptor_api.h"
+#include "adaptor_setting.h"
+#include "setup_system.h"
+#include "adaptor_util.h"
+#include "parse_file.h"
+#include "json_util.h"
+
+
+using ::testing::InitGoogleTest;
+
+TEST(beluga_adaptor_setting, beluga_adaptor_setup_user_certificates){
+ int ret = 0;
+
+ _D("[UNIT_TEST] setup_user_certificates ~~~~~");
+
+ setup_user_certificates();
+
+ EXPECT_EQ(0, ret);
+}
+
+TEST(beluga_adaptor_setting, beluga_adaptor_sa_split_files){
+ sa_error_e ret = SA_ERROR_NONE;
+ char *orig_config_file = "/opt/beluga/setup-adaptor/config/config.json";
+ char sa_config_file_path[2][256] = {
+ "/opt/beluga/setup-adaptor/config/devconfig_system.json"
+ "/opt/beluga/setup-adaptor/config/devconfig_target.json"
+ };
+
+ _D("[UNIT_TEST] sa_split_files ~~~~~");
+
+ sa_split_files(orig_config_file, sa_config_file_path[0], sa_config_file_path[1]);
+
+ EXPECT_EQ(SA_ERROR_NONE, ret);
+}
+
+TEST(beluga_adaptor_setting, beluga_adaptor_sa_inputfile_get_config_info){
+ int flagInitialized = 0;
+ sa_error_e ret = SA_ERROR_NONE;
+ sa_config_s config = { 0, };
+ char *file_path = "/opt/beluga/setup-adaptor/config/config.json";
+
+ _D("[UNIT_TEST] sa_inputfile_get_config_info ~~~~~");
+
+ ret = sa_inputfile_get_config_info(&config, file_path);
+ sa_inputfile_release_resource(&config);
+
+ EXPECT_EQ(SA_ERROR_NONE, ret);
+}
+
+TEST(beluga_adaptor_setting, beluga_adaptor_sa_setup_system){
+ int flagInitialized = 0;
+ sa_error_e ret = SA_ERROR_NONE;
+ sa_config_s config = { 0, };
+ char *file_path = "/opt/beluga/setup-adaptor/config/config.json";
+
+ _D("[UNIT_TEST] sa_inputfile_get_config_info ~~~~~");
+
+ ret = sa_inputfile_get_config_info(&config, file_path);
+
+ if (ret == SA_ERROR_NONE) {
+ if (config.systemData != NULL)
+ {
+ ret = sa_setup_system(config.systemData, flagInitialized);
+ if (ret != SA_ERROR_NONE)
+ _E("sa_setup_system return error(%d)", ret);
+ _D("sa_setup_system() completed !!! ret(%d)", ret);
+ }
+ }
+ sa_inputfile_release_resource(&config);
+ _D("setup_cb completed <<<<<<<<<<<<<<<<<<<<<<<<");
+
+ EXPECT_EQ(SA_ERROR_NONE, ret);
+}
+
+TEST(beluga_adaptor_setting, beluga_adaptor_sa_remove_config_file){
+ sa_error_e ret = SA_ERROR_NONE;
+
+ _D("[UNIT_TEST] sa_remove_config_file ~~~~~");
+
+ ret = sa_remove_config_file();
+
+ EXPECT_EQ(SA_ERROR_NONE, ret);
+}
+
+TEST(beluga_adaptor_setting, beluga_adaptor_setting_main_thread){
+
+ pthread_t t_setting;
+ int ret = 0;
+ char cmd_gen_socket[128] = "sudo touch /var/run/beluga_launcher_notify.sock";
+
+ ret = CLI_command(cmd_gen_socket, 0, NULL);
+
+ _D("[UNIT_TEST] pthread_create >>> SETTING_MAIN !!!");
+ ret = pthread_create(&t_setting, NULL, &setting_main_thread, (void *)NULL);
+ if (ret < 0) {
+ _E("[UNIT_TEST][SETTING_MAIN] thread create error (ret=%d)", ret);
+ ret = -1;
+ }
+ sleep(5);
+ pthread_cancel(t_setting);
+
+ EXPECT_EQ(0, ret);
+}
+
+TEST(beluga_adaptor_setting, beluga_adaptor_setting_main_thread_compare_config_file){
+
+ pthread_t t_setting;
+ int ret = 0;
+ char cmd_gen_socket[128] = "sudo touch /var/run/beluga_launcher_notify.sock";
+ char cmd_copy_config_file[256] = "sudo cp /opt/beluga/setup-adaptor/config/devconfig_system.json /opt/beluga/setup-adaptor/config/devconfig_system_applied.json";
+
+ ret = CLI_command(cmd_gen_socket, 0, NULL);
+ ret = CLI_command(cmd_copy_config_file, 0, NULL);
+
+ _D("[UNIT_TEST] pthread_create >>> SETTING_MAIN !!!");
+ ret = pthread_create(&t_setting, NULL, &setting_main_thread, (void *)NULL);
+ if (ret < 0) {
+ _E("[UNIT_TEST][SETTING_MAIN] thread create error (ret=%d)", ret);
+ ret = -1;
+ }
+ sleep(5);
+ pthread_cancel(t_setting);
+
+ EXPECT_EQ(0, ret);
+}
+
+TEST(beluga_adaptor_setting, DISABLED_beluga_adaptor_send_message_to_launcher){
+
+ int ret = 0;
+
+ ret = send_message_to_launcher(SA_START_LAUNCHER_SVC);
+
+ EXPECT_EQ(0, ret);
+} \ No newline at end of file