diff options
author | hwajeong.son <hwajeong.son@samsung.com> | 2018-08-20 13:20:53 +0900 |
---|---|---|
committer | hwajeong.son <hwajeong.son@samsung.com> | 2018-08-20 13:20:53 +0900 |
commit | 27763b024648b848430481a929d716038d887952 (patch) | |
tree | a5388eec33d3b55cbf75e2e1ea360c32de7de78f /unittest/beluga-adaptor_setting.cpp | |
parent | 81dc7d90889e619942f34c4a584768b4b3179445 (diff) | |
download | docker-adaptor-master.tar.gz docker-adaptor-master.tar.bz2 docker-adaptor-master.zip |
Tizen_4.0 baseHEADsubmit/trunk/20180820.042254submit/tizen_5.0/20190130.104846submit/tizen_4.0/20180823.034715submit/tizen_4.0/20180820.062059submit/tizen/20190131.060448accepted/tizen/unified/20190201.061305accepted/tizen/5.0/unified/20190208.044524accepted/tizen/4.0/unified/20180821.160805tizen_4.0masteraccepted/tizen_5.0_unifiedaccepted/tizen_4.0_unified
Signed-off-by: hwajeong.son <hwajeong.son@samsung.com>
Diffstat (limited to 'unittest/beluga-adaptor_setting.cpp')
-rwxr-xr-x | unittest/beluga-adaptor_setting.cpp | 145 |
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 |