Make temporary folder and files for logging test
authorBoyeon <boyeon.son@samsung.com>
Tue, 14 May 2019 12:28:01 +0000 (21:28 +0900)
committer손보연/Tizen Platform Lab(SR)/Engineer/삼성전자 <boyeon.son@samsung.com>
Thu, 16 May 2019 06:23:11 +0000 (15:23 +0900)
src/devicemanagerservice.c

index be11488..eedcfa3 100644 (file)
@@ -51,8 +51,33 @@ static char *__make_log_archive_request(const char *log_path_arr[], const char *
        return request_json;
 }
 
-// static void __make_temp_logs()
 // Make temporary log directories and files using app_get_data_path() API
+static char *__make_temp_logs(const char *file_name)
+{
+       char *data_path = NULL;
+       char *file_path = NULL;
+       FILE *fp;
+
+       data_path = app_get_data_path();
+
+       if (!data_path)
+               return NULL;
+
+       file_path = g_strdup_printf("%s/%s", data_path, file_name);
+       free(data_path);
+
+       fp = fopen(file_path, "w");
+
+       if (!fp) {
+               free(file_path);
+               return NULL;
+       }
+
+       fputs("test", fp);
+       fclose(fp);
+
+       return file_path;
+}
 
 static void __reboot_result_callback(idm_command_h command, idm_result_e result, idm_reason_e reason, const char *detail, void *data)
 {
@@ -156,12 +181,9 @@ static void __get_log_archive(const char *log_path_arr[], const char *archive_fi
 static Eina_Bool __command_stop(void *data)
 {
        app_data *ad = data;
-       char log_path_arr[][3] = {
-               "/TBD/",
-               "/TBD/",
-               NULL
-       }; // The last item of this array must be NULL
-       char *archive_file = "/TBD/log.zip"
+       char *data_path = app_get_data_path();
+       char *log_path_arr[3] = {NULL,}; // The last item of this array must be NULL
+       char *archive_file = NULL;
 
        if (ad->command) {
                idm_command_stop(ad->command);
@@ -170,9 +192,18 @@ static Eina_Bool __command_stop(void *data)
        }
        ad->timer = NULL;
 
+       log_path_arr[0] = __make_temp_logs("test1.log");
+       log_path_arr[1] = __make_temp_logs("test2.log");
+
+       archive_file = g_strdup_printf("%s/%s", data_path, "log_archive.zip");
+
        // Get log archive
        __get_log_archive(log_path_arr, archive_file, 3, __get_log_archive_result_cb, ad);
 
+       g_free(log_path_arr[0]);
+       g_free(log_path_arr[1]);
+       g_free(archive_file);
+
        // 3. reboot cmd 실행
        __reboot(ad);