Tizen 2.1 base
[platform/core/system/sync-agent.git] / TC / testcase / utc_sync_agent_framework_fsapi.c
1 /*
2  * sync-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #include <tet_api.h>
19
20 #include <sync_agent.h>
21
22 enum {
23         POSITIVE_TC_IDX = 0x01,
24         NEGATIVE_TC_IDX,
25 };
26
27 static void startup(void);
28 static void cleanup(void);
29
30 void (*tet_startup) (void) = startup;
31 void (*tet_cleanup) (void) = cleanup;
32
33 #define FILE_SRC                "../../../testcase/fw-test-file/file_src"
34 #define FILE_DST                "../../../testcase/fw-test-file/file_dst"
35 #define FILE_DST_DIR    "../../../testcase/fw-test-file/dir_src/file_dst"
36 #define DIR_SRC                 "../../../testcase/fw-test-file/dir_src"
37 #define DIR_DST                 "../../../testcase/fw-test-file/dir_dst"
38 #define NOT_EXISTING    "./not_existing"
39
40 #define API_NAME_SYNC_AGENT_IS_EXISTING_FS      "sync_agent_is_existing_fs"
41 #define API_NAME_SYNC_AGENT_GET_FS_INFO "sync_agent_get_fs_info"
42 #define API_NAME_SYNC_AGENT_FREE_FS_INFO        "sync_agent_free_fs_info"
43 #define API_NAME_SYNC_AGENT_GET_FS_MEM_SIZE     "sync_agent_get_fs_mem_size"
44 #define API_NAME_SYNC_AGENT_GET_FILE_SIZE       "sync_agent_get_file_size"
45 #define API_NAME_SYNC_AGENT_COPY_FILE   "sync_agent_copy_file"
46 #define API_NAME_SYNC_AGENT_DELETE_FILE "sync_agent_delete_file"
47 #define API_NAME_SYNC_AGENT_MOVE_FILE   "sync_agent_move_file"
48 #define API_NAME_SYNC_AGENT_RENAME_FILE "sync_agent_rename_file"
49 #define API_NAME_SYNC_AGENT_GET_FILE_LIST       "sync_agent_get_file_list"
50 #define API_NAME_SYNC_AGENT_READ_FILE   "sync_agent_read_file"
51 #define API_NAME_SYNC_AGENT_READ_WHOLE_FILE     "sync_agent_read_whole_file"
52 #define API_NAME_SYNC_AGENT_FREE_FILE   "sync_agent_free_file"
53 #define API_NAME_SYNC_AGENT_WRITE_FILE  "sync_agent_write_file"
54 #define API_NAME_SYNC_AGENT_WRITE_WHOLE_FILE    "sync_agent_write_whole_file"
55 #define API_NAME_SYNC_AGENT_APPEND_FILE "sync_agent_append_file"
56 #define API_NAME_SYNC_AGENT_CREATE_DIRECTORY    "sync_agent_create_directory"
57 #define API_NAME_SYNC_AGENT_DELETE_DIRECTORY    "sync_agent_delete_directory"
58 #define API_NAME_SYNC_AGENT_EMPTY_DIRECTORY_CONTENTS    "sync_agent_empty_directory_contents"
59 #define API_NAME_SYNC_AGENT_RENAME_DIRECTORY    "sync_agent_rename_directory"
60 #define API_NAME_SYNC_AGENT_GET_DIRECTORY_LIST  "sync_agent_get_directory_list"
61 #define API_NAME_SYNC_AGENT_FILE_MD5_VALIDATION "sync_agent_file_md5_validation"
62
63 static void utc_sync_agent_framework_sync_agent_is_existing_fs_p(void);
64 static void utc_sync_agent_framework_sync_agent_is_existing_fs_n(void);
65 static void utc_sync_agent_framework_sync_agent_get_fs_info_p(void);
66 static void utc_sync_agent_framework_sync_agent_get_fs_info_n(void);
67 static void utc_sync_agent_framework_sync_agent_free_fs_info_p(void);
68 static void utc_sync_agent_framework_sync_agent_free_fs_info_n(void);
69 static void utc_sync_agent_framework_sync_agent_get_fs_mem_size_p(void);
70 static void utc_sync_agent_framework_sync_agent_get_fs_mem_size_n(void);
71 static void utc_sync_agent_framework_sync_agent_get_file_size_p(void);
72 static void utc_sync_agent_framework_sync_agent_get_file_size_n(void);
73 static void utc_sync_agent_framework_sync_agent_copy_file_p(void);
74 static void utc_sync_agent_framework_sync_agent_copy_file_n(void);
75 static void utc_sync_agent_framework_sync_agent_delete_file_p(void);
76 static void utc_sync_agent_framework_sync_agent_delete_file_n(void);
77 static void utc_sync_agent_framework_sync_agent_move_file_p(void);
78 static void utc_sync_agent_framework_sync_agent_move_file_n(void);
79 static void utc_sync_agent_framework_sync_agent_rename_file_p(void);
80 static void utc_sync_agent_framework_sync_agent_rename_file_n(void);
81 static void utc_sync_agent_framework_sync_agent_get_file_list_p(void);
82 static void utc_sync_agent_framework_sync_agent_get_file_list_n(void);
83 static void utc_sync_agent_framework_sync_agent_read_file_p(void);
84 static void utc_sync_agent_framework_sync_agent_read_file_n(void);
85 static void utc_sync_agent_framework_sync_agent_read_whole_file_p(void);
86 static void utc_sync_agent_framework_sync_agent_read_whole_file_n(void);
87 static void utc_sync_agent_framework_sync_agent_free_file_p(void);
88 static void utc_sync_agent_framework_sync_agent_free_file_n(void);
89 static void utc_sync_agent_framework_sync_agent_write_file_p(void);
90 static void utc_sync_agent_framework_sync_agent_write_file_n(void);
91 static void utc_sync_agent_framework_sync_agent_write_whole_file_p(void);
92 static void utc_sync_agent_framework_sync_agent_write_whole_file_n(void);
93 static void utc_sync_agent_framework_sync_agent_append_file_p(void);
94 static void utc_sync_agent_framework_sync_agent_append_file_n(void);
95 static void utc_sync_agent_framework_sync_agent_create_directory_p(void);
96 static void utc_sync_agent_framework_sync_agent_create_directory_n(void);
97 static void utc_sync_agent_framework_sync_agent_delete_directory_p(void);
98 static void utc_sync_agent_framework_sync_agent_delete_directory_n(void);
99 static void utc_sync_agent_framework_sync_agent_empty_directory_contents_p(void);
100 static void utc_sync_agent_framework_sync_agent_empty_directory_contents_n(void);
101 static void utc_sync_agent_framework_sync_agent_rename_directory_p(void);
102 static void utc_sync_agent_framework_sync_agent_rename_directory_n(void);
103 static void utc_sync_agent_framework_sync_agent_get_directory_list_p(void);
104 static void utc_sync_agent_framework_sync_agent_get_directory_list_n(void);
105 static void utc_sync_agent_framework_sync_agent_file_md5_validation_p(void);
106 static void utc_sync_agent_framework_sync_agent_file_md5_validation_n(void);
107
108 struct tet_testlist tet_testlist[] = {
109         {utc_sync_agent_framework_sync_agent_is_existing_fs_p, POSITIVE_TC_IDX},
110         {utc_sync_agent_framework_sync_agent_is_existing_fs_n, NEGATIVE_TC_IDX},
111         {utc_sync_agent_framework_sync_agent_get_fs_info_p, POSITIVE_TC_IDX},
112         {utc_sync_agent_framework_sync_agent_get_fs_info_n, NEGATIVE_TC_IDX},
113         {utc_sync_agent_framework_sync_agent_free_fs_info_p, POSITIVE_TC_IDX},
114         {utc_sync_agent_framework_sync_agent_free_fs_info_n, NEGATIVE_TC_IDX},
115         {utc_sync_agent_framework_sync_agent_get_fs_mem_size_p, POSITIVE_TC_IDX},
116         {utc_sync_agent_framework_sync_agent_get_fs_mem_size_n, NEGATIVE_TC_IDX},
117         {utc_sync_agent_framework_sync_agent_get_file_size_p, POSITIVE_TC_IDX},
118         {utc_sync_agent_framework_sync_agent_get_file_size_n, NEGATIVE_TC_IDX},
119         {utc_sync_agent_framework_sync_agent_copy_file_p, POSITIVE_TC_IDX},
120         {utc_sync_agent_framework_sync_agent_copy_file_n, NEGATIVE_TC_IDX},
121         {utc_sync_agent_framework_sync_agent_delete_file_p, POSITIVE_TC_IDX},
122         {utc_sync_agent_framework_sync_agent_delete_file_n, NEGATIVE_TC_IDX},
123         {utc_sync_agent_framework_sync_agent_move_file_p, POSITIVE_TC_IDX},
124         {utc_sync_agent_framework_sync_agent_move_file_n, NEGATIVE_TC_IDX},
125         {utc_sync_agent_framework_sync_agent_rename_file_p, POSITIVE_TC_IDX},
126         {utc_sync_agent_framework_sync_agent_rename_file_n, NEGATIVE_TC_IDX},
127         {utc_sync_agent_framework_sync_agent_get_file_list_p, POSITIVE_TC_IDX},
128         {utc_sync_agent_framework_sync_agent_get_file_list_n, NEGATIVE_TC_IDX},
129         {utc_sync_agent_framework_sync_agent_read_file_p, POSITIVE_TC_IDX},
130         {utc_sync_agent_framework_sync_agent_read_file_n, NEGATIVE_TC_IDX},
131         {utc_sync_agent_framework_sync_agent_read_whole_file_p, POSITIVE_TC_IDX},
132         {utc_sync_agent_framework_sync_agent_read_whole_file_n, NEGATIVE_TC_IDX},
133         {utc_sync_agent_framework_sync_agent_free_file_p, POSITIVE_TC_IDX},
134         {utc_sync_agent_framework_sync_agent_free_file_n, NEGATIVE_TC_IDX},
135         {utc_sync_agent_framework_sync_agent_write_file_p, POSITIVE_TC_IDX},
136         {utc_sync_agent_framework_sync_agent_write_file_n, NEGATIVE_TC_IDX},
137         {utc_sync_agent_framework_sync_agent_write_whole_file_p, POSITIVE_TC_IDX},
138         {utc_sync_agent_framework_sync_agent_write_whole_file_n, NEGATIVE_TC_IDX},
139         {utc_sync_agent_framework_sync_agent_append_file_p, POSITIVE_TC_IDX},
140         {utc_sync_agent_framework_sync_agent_append_file_n, NEGATIVE_TC_IDX},
141         {utc_sync_agent_framework_sync_agent_create_directory_p, POSITIVE_TC_IDX},
142         {utc_sync_agent_framework_sync_agent_create_directory_n, NEGATIVE_TC_IDX},
143         {utc_sync_agent_framework_sync_agent_delete_directory_p, POSITIVE_TC_IDX},
144         {utc_sync_agent_framework_sync_agent_delete_directory_n, NEGATIVE_TC_IDX},
145         {utc_sync_agent_framework_sync_agent_empty_directory_contents_p, POSITIVE_TC_IDX},
146         {utc_sync_agent_framework_sync_agent_empty_directory_contents_n, NEGATIVE_TC_IDX},
147         {utc_sync_agent_framework_sync_agent_rename_directory_p, POSITIVE_TC_IDX},
148         {utc_sync_agent_framework_sync_agent_rename_directory_n, NEGATIVE_TC_IDX},
149         {utc_sync_agent_framework_sync_agent_get_directory_list_p, POSITIVE_TC_IDX},
150         {utc_sync_agent_framework_sync_agent_get_directory_list_n, NEGATIVE_TC_IDX},
151         {utc_sync_agent_framework_sync_agent_file_md5_validation_p, POSITIVE_TC_IDX},
152         {utc_sync_agent_framework_sync_agent_file_md5_validation_n, NEGATIVE_TC_IDX},
153         {NULL, 0}
154 };
155
156 static void startup(void)
157 {
158         /* start of TC */
159 }
160
161 static void cleanup(void)
162 {
163         /* start of TC */
164 }
165
166 static void utc_sync_agent_framework_sync_agent_is_existing_fs_p(void)
167 {
168         char *api_name = API_NAME_SYNC_AGENT_IS_EXISTING_FS;
169         int ret = 0;
170
171         ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
172         if (ret == SYNC_AGENT_FSAPI_FALSE) {
173                 dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
174                 dts_fail(api_name);
175         }
176
177         ret = sync_agent_is_existing_fs(FILE_SRC);
178         if (ret == SYNC_AGENT_FSAPI_FALSE) {
179                 dts_message(api_name, "sync_agent_is_existing_fs returned [%d]", ret);
180                 dts_fail(api_name);
181         } else {
182                 sync_agent_delete_file(FILE_SRC);
183                 dts_pass(api_name);
184         }
185 }
186
187 static void utc_sync_agent_framework_sync_agent_is_existing_fs_n(void)
188 {
189         char *api_name = API_NAME_SYNC_AGENT_IS_EXISTING_FS;
190         int ret = 0;
191
192         ret = sync_agent_is_existing_fs(NOT_EXISTING);
193         if (ret == SYNC_AGENT_FSAPI_FALSE) {
194                 dts_pass(api_name);
195         } else {
196                 dts_message(api_name, "sync_agent_is_existing_fs returned [%d]", ret);
197                 dts_fail(api_name);
198         }
199 }
200
201 static void utc_sync_agent_framework_sync_agent_get_fs_info_p(void)
202 {
203         char *api_name = API_NAME_SYNC_AGENT_GET_FS_INFO;
204         int ret = 0;
205         char *fs_info = NULL;
206
207         ret = sync_agent_get_fs_info(&fs_info);
208         if (ret == SYNC_AGENT_FSAPI_FALSE) {
209                 dts_message(api_name, "sync_agent_get_fs_info returned [%d]", ret);
210                 dts_fail(api_name);
211         } else {
212                 dts_pass(api_name);
213         }
214 }
215
216 static void utc_sync_agent_framework_sync_agent_get_fs_info_n(void)
217 {
218         char *api_name = API_NAME_SYNC_AGENT_GET_FS_INFO;
219         int ret = 0;
220         char *fs_info = NULL;
221
222         ret = sync_agent_get_fs_info(NULL);
223         if (ret == SYNC_AGENT_FSAPI_FALSE) {
224                 dts_pass(api_name);
225         } else {
226                 dts_message(api_name, "sync_agent_get_fs_info returned [%d]", ret);
227                 dts_fail(api_name);
228         }
229 }
230
231 static void utc_sync_agent_framework_sync_agent_free_fs_info_p(void)
232 {
233         char *api_name = API_NAME_SYNC_AGENT_FREE_FS_INFO;
234         int ret = 0;
235         char *fs_info = NULL;
236
237         ret = sync_agent_get_fs_info(&fs_info);
238         if (ret == SYNC_AGENT_FSAPI_FALSE) {
239                 dts_message(api_name, "sync_agent_get_fs_info returned [%d]", ret);
240                 dts_fail(api_name);
241         }
242
243         ret = sync_agent_free_fs_info(fs_info);
244         if (ret == SYNC_AGENT_FSAPI_FALSE) {
245                 dts_message(api_name, "sync_agent_free_fs_info returned [%d]", ret);
246                 dts_fail(api_name);
247         } else {
248                 dts_pass(api_name);
249         }
250 }
251
252 static void utc_sync_agent_framework_sync_agent_free_fs_info_n(void)
253 {
254         char *api_name = API_NAME_SYNC_AGENT_FREE_FS_INFO;
255         int ret = 0;
256
257         ret = sync_agent_free_fs_info(NULL);
258         if (ret == SYNC_AGENT_FSAPI_FALSE) {
259                 dts_pass(api_name);
260         } else {
261                 dts_message(api_name, "sync_agent_free_fs_info returned [%d]", ret);
262                 dts_fail(api_name);
263         }
264 }
265
266 static void utc_sync_agent_framework_sync_agent_get_fs_mem_size_p(void)
267 {
268         char *api_name = API_NAME_SYNC_AGENT_GET_FS_MEM_SIZE;
269         int ret = 0;
270         long double size_free = 0;
271         long double size_total = 0;
272
273         ret = sync_agent_get_fs_mem_size("/", &size_free, &size_total);
274         if (ret == SYNC_AGENT_FSAPI_FALSE) {
275                 dts_message(api_name, "sync_agent_get_fs_mem_size returned [%d]", ret);
276                 dts_fail(api_name);
277         } else {
278                 dts_pass(api_name);
279         }
280 }
281
282 static void utc_sync_agent_framework_sync_agent_get_fs_mem_size_n(void)
283 {
284         char *api_name = API_NAME_SYNC_AGENT_GET_FS_MEM_SIZE;
285         int ret = 0;
286         long double size_free = 0;
287         long double size_total = 0;
288
289         ret = sync_agent_get_fs_mem_size(NOT_EXISTING, &size_free, &size_total);
290         if (ret == SYNC_AGENT_FSAPI_FALSE) {
291                 dts_pass(api_name);
292         } else {
293                 dts_message(api_name, "sync_agent_get_fs_mem_size returned [%d]", ret);
294                 dts_fail(api_name);
295         }
296 }
297
298 static void utc_sync_agent_framework_sync_agent_get_file_size_p(void)
299 {
300         char *api_name = API_NAME_SYNC_AGENT_GET_FILE_SIZE;
301         int ret = 0;
302         unsigned long size = 0;
303
304         ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
305         if (ret == SYNC_AGENT_FSAPI_FALSE) {
306                 dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
307                 dts_fail(api_name);
308         }
309
310         ret = sync_agent_get_file_size(FILE_SRC, &size);
311         if (ret == SYNC_AGENT_FSAPI_FALSE) {
312                 dts_message(api_name, "sync_agent_get_file_size returned [%d]", ret);
313                 dts_fail(api_name);
314         } else {
315                 sync_agent_delete_file(FILE_SRC);
316                 dts_pass(api_name);
317         }
318 }
319
320 static void utc_sync_agent_framework_sync_agent_get_file_size_n(void)
321 {
322         char *api_name = API_NAME_SYNC_AGENT_GET_FILE_SIZE;
323         int ret = 0;
324         unsigned long size = 0;
325
326         ret = sync_agent_get_file_size(NOT_EXISTING, &size);
327         if (ret == SYNC_AGENT_FSAPI_FALSE) {
328                 dts_pass(api_name);
329         } else {
330                 dts_message(api_name, "sync_agent_get_file_size returned [%d]", ret);
331                 dts_fail(api_name);
332         }
333 }
334
335 static void utc_sync_agent_framework_sync_agent_copy_file_p(void)
336 {
337         char *api_name = API_NAME_SYNC_AGENT_COPY_FILE;
338         int ret = 0;
339
340         ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
341         if (ret == SYNC_AGENT_FSAPI_FALSE) {
342                 dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
343                 dts_fail(api_name);
344         }
345
346         ret = sync_agent_copy_file(FILE_SRC, FILE_DST);
347         if (ret == SYNC_AGENT_FSAPI_FALSE) {
348                 sync_agent_delete_file(FILE_SRC);
349                 dts_message(api_name, "sync_agent_copy_file returned [%d]", ret);
350                 dts_fail(api_name);
351         } else {
352                 sync_agent_delete_file(FILE_SRC);
353                 sync_agent_delete_file(FILE_DST);
354                 dts_pass(api_name);
355         }
356 }
357
358 static void utc_sync_agent_framework_sync_agent_copy_file_n(void)
359 {
360         char *api_name = API_NAME_SYNC_AGENT_COPY_FILE;
361         int ret = 0;
362
363         ret = sync_agent_copy_file(NOT_EXISTING, FILE_DST);
364         if (ret == SYNC_AGENT_FSAPI_FALSE) {
365                 dts_pass(api_name);
366         } else {
367                 dts_message(api_name, "sync_agent_copy_file returned [%d]", ret);
368                 dts_fail(api_name);
369         }
370 }
371
372 static void utc_sync_agent_framework_sync_agent_delete_file_p(void)
373 {
374         char *api_name = API_NAME_SYNC_AGENT_DELETE_FILE;
375         int ret = 0;
376
377         ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
378         if (ret == SYNC_AGENT_FSAPI_FALSE) {
379                 dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
380                 dts_fail(api_name);
381         }
382
383         ret = sync_agent_delete_file(FILE_SRC);
384         if (ret == SYNC_AGENT_FSAPI_FALSE) {
385                 dts_message(api_name, "sync_agent_delete_file returned [%d]", ret);
386                 dts_fail(api_name);
387         } else {
388                 dts_pass(api_name);
389         }
390 }
391
392 static void utc_sync_agent_framework_sync_agent_delete_file_n(void)
393 {
394         char *api_name = API_NAME_SYNC_AGENT_DELETE_FILE;
395         int ret = 0;
396
397         ret = sync_agent_delete_file(NOT_EXISTING);
398         if (ret == SYNC_AGENT_FSAPI_FALSE) {
399                 dts_pass(api_name);
400         } else {
401                 dts_message(api_name, "sync_agent_delete_file returned [%d]", ret);
402                 dts_fail(api_name);
403         }
404 }
405
406 static void utc_sync_agent_framework_sync_agent_move_file_p(void)
407 {
408         char *api_name = API_NAME_SYNC_AGENT_MOVE_FILE;
409         int ret = 0;
410
411         ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
412         if (ret == SYNC_AGENT_FSAPI_FALSE) {
413                 dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
414                 dts_fail(api_name);
415         }
416
417         ret = sync_agent_move_file(FILE_SRC, FILE_DST);
418         if (ret == SYNC_AGENT_FSAPI_FALSE) {
419                 sync_agent_delete_file(FILE_SRC);
420                 dts_message(api_name, "sync_agent_move_file returned [%d]", ret);
421                 dts_fail(api_name);
422         } else {
423                 sync_agent_delete_file(FILE_DST);
424                 dts_pass(api_name);
425         }
426 }
427
428 static void utc_sync_agent_framework_sync_agent_move_file_n(void)
429 {
430         char *api_name = API_NAME_SYNC_AGENT_MOVE_FILE;
431         int ret = 0;
432
433         ret = sync_agent_move_file(NOT_EXISTING, FILE_DST);
434         if (ret == SYNC_AGENT_FSAPI_FALSE) {
435                 dts_pass(api_name);
436         } else {
437                 dts_message(api_name, "sync_agent_move_file returned [%d]", ret);
438                 dts_fail(api_name);
439         }
440 }
441
442 static void utc_sync_agent_framework_sync_agent_rename_file_p(void)
443 {
444         char *api_name = API_NAME_SYNC_AGENT_RENAME_FILE;
445         int ret = 0;
446
447         ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
448         if (ret == SYNC_AGENT_FSAPI_FALSE) {
449                 dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
450                 dts_fail(api_name);
451         }
452
453         ret = sync_agent_rename_file(FILE_SRC, FILE_DST);
454         if (ret == SYNC_AGENT_FSAPI_FALSE) {
455                 sync_agent_delete_file(FILE_SRC);
456                 dts_message(api_name, "sync_agent_rename_file returned [%d]", ret);
457                 dts_fail(api_name);
458         } else {
459                 sync_agent_delete_file(FILE_DST);
460                 dts_pass(api_name);
461         }
462 }
463
464 static void utc_sync_agent_framework_sync_agent_rename_file_n(void)
465 {
466         char *api_name = API_NAME_SYNC_AGENT_RENAME_FILE;
467         int ret = 0;
468
469         ret = sync_agent_rename_file(NOT_EXISTING, FILE_DST);
470         if (ret == SYNC_AGENT_FSAPI_FALSE) {
471                 dts_pass(api_name);
472         } else {
473                 dts_message(api_name, "sync_agent_rename_file returned [%d]", ret);
474                 dts_fail(api_name);
475         }
476 }
477
478 static void utc_sync_agent_framework_sync_agent_get_file_list_p(void)
479 {
480         char *api_name = API_NAME_SYNC_AGENT_GET_FILE_LIST;
481         int ret = 0;
482         GSList *list = NULL;
483
484         ret = sync_agent_get_file_list("./", &list);
485         if (ret == SYNC_AGENT_FSAPI_FALSE) {
486                 dts_message(api_name, "sync_agent_get_file_list returned [%d]", ret);
487                 dts_fail(api_name);
488         } else {
489                 dts_pass(api_name);
490         }
491 }
492
493 static void utc_sync_agent_framework_sync_agent_get_file_list_n(void)
494 {
495         char *api_name = API_NAME_SYNC_AGENT_GET_FILE_LIST;
496         int ret = 0;
497         GSList *list = NULL;
498
499         ret = sync_agent_get_file_list(NOT_EXISTING, &list);
500         if (ret == SYNC_AGENT_FSAPI_FALSE) {
501                 dts_pass(api_name);
502         } else {
503                 dts_message(api_name, "sync_agent_get_file_list returned [%d]", ret);
504                 dts_fail(api_name);
505         }
506 }
507
508 static void utc_sync_agent_framework_sync_agent_read_file_p(void)
509 {
510         char *api_name = API_NAME_SYNC_AGENT_READ_FILE;
511         int ret = 0;
512         char *contents = NULL;
513         unsigned long contents_len = 0;
514         bool final = false;
515
516         ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
517         if (ret == SYNC_AGENT_FSAPI_FALSE) {
518                 dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
519                 dts_fail(api_name);
520         }
521
522         ret = sync_agent_read_file(FILE_SRC, &contents, 10, &contents_len, &final);
523         if (ret == SYNC_AGENT_FSAPI_FALSE) {
524                 sync_agent_delete_file(FILE_SRC);
525                 dts_message(api_name, "sync_agent_read_file returned [%d]", ret);
526                 dts_fail(api_name);
527         } else {
528                 sync_agent_delete_file(FILE_SRC);
529                 dts_pass(api_name);
530         }
531 }
532
533 static void utc_sync_agent_framework_sync_agent_read_file_n(void)
534 {
535         char *api_name = API_NAME_SYNC_AGENT_READ_FILE;
536         int ret = 0;
537         char *contents = NULL;
538         unsigned long contents_len = 0;
539         bool final = false;
540
541         ret = sync_agent_read_file(NOT_EXISTING, &contents, 10, &contents_len, &final);
542         if (ret == SYNC_AGENT_FSAPI_FALSE) {
543                 dts_pass(api_name);
544         } else {
545                 dts_message(api_name, "sync_agent_read_file returned [%d]", ret);
546                 dts_fail(api_name);
547         }
548 }
549
550 static void utc_sync_agent_framework_sync_agent_read_whole_file_p(void)
551 {
552         char *api_name = API_NAME_SYNC_AGENT_READ_WHOLE_FILE;
553         int ret = 0;
554         char *contents = NULL;
555         unsigned long contents_len = 0;
556
557         ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
558         if (ret == SYNC_AGENT_FSAPI_FALSE) {
559                 dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
560                 dts_fail(api_name);
561         }
562
563         ret = sync_agent_read_whole_file(FILE_SRC, &contents, &contents_len);
564         if (ret == SYNC_AGENT_FSAPI_FALSE) {
565                 sync_agent_delete_file(FILE_SRC);
566                 dts_message(api_name, "sync_agent_read_whole_file returned [%d]", ret);
567                 dts_fail(api_name);
568         } else {
569                 sync_agent_delete_file(FILE_SRC);
570                 dts_pass(api_name);
571         }
572 }
573
574 static void utc_sync_agent_framework_sync_agent_read_whole_file_n(void)
575 {
576         char *api_name = API_NAME_SYNC_AGENT_READ_WHOLE_FILE;
577         int ret = 0;
578         char *contents = NULL;
579         unsigned long contents_len = 0;
580
581         ret = sync_agent_read_whole_file(NOT_EXISTING, &contents, &contents_len);
582         if (ret == SYNC_AGENT_FSAPI_FALSE) {
583                 dts_pass(api_name);
584         } else {
585                 dts_message(api_name, "sync_agent_read_whole_file returned [%d]", ret);
586                 dts_fail(api_name);
587         }
588 }
589
590 static void utc_sync_agent_framework_sync_agent_free_file_p(void)
591 {
592         char *api_name = API_NAME_SYNC_AGENT_FREE_FILE;
593         int ret = 0;
594         char *contents = NULL;
595         unsigned long contents_len = 0;
596
597         ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
598         if (ret == SYNC_AGENT_FSAPI_FALSE) {
599                 dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
600                 dts_fail(api_name);
601         }
602
603         ret = sync_agent_read_whole_file(FILE_SRC, &contents, &contents_len);
604         if (ret == SYNC_AGENT_FSAPI_FALSE) {
605                 dts_message(api_name, "sync_agent_read_whole_file returned [%d]", ret);
606                 dts_fail(api_name);
607         }
608
609         sync_agent_delete_file(FILE_SRC);
610
611         ret = sync_agent_free_file(&contents);
612         if (ret == SYNC_AGENT_FSAPI_FALSE) {
613                 dts_message(api_name, "sync_agent_free_file returned [%d]", ret);
614                 dts_fail(api_name);
615         } else {
616                 dts_pass(api_name);
617         }
618 }
619
620 static void utc_sync_agent_framework_sync_agent_free_file_n(void)
621 {
622         char *api_name = API_NAME_SYNC_AGENT_FREE_FILE;
623         int ret = 0;
624
625         ret = sync_agent_free_file(NULL);
626         if (ret == SYNC_AGENT_FSAPI_FALSE) {
627                 dts_pass(api_name);
628         } else {
629                 dts_message(api_name, "sync_agent_free_file returned [%d]", ret);
630                 dts_fail(api_name);
631         }
632 }
633
634 static void utc_sync_agent_framework_sync_agent_write_file_p(void)
635 {
636         char *api_name = API_NAME_SYNC_AGENT_WRITE_FILE;
637         int ret = 0;
638
639         ret = sync_agent_write_file(FILE_SRC, "test writing", strlen("test writing"), true, true);
640         if (ret == SYNC_AGENT_FSAPI_FALSE) {
641                 dts_message(api_name, "sync_agent_write_file returned [%d]", ret);
642                 dts_fail(api_name);
643         } else {
644                 sync_agent_delete_file(FILE_SRC);
645                 dts_pass(api_name);
646         }
647 }
648
649 static void utc_sync_agent_framework_sync_agent_write_file_n(void)
650 {
651         char *api_name = API_NAME_SYNC_AGENT_WRITE_FILE;
652         int ret = 0;
653
654         ret = sync_agent_write_file(FILE_SRC, NULL, strlen("test writing"), true, true);
655         if (ret == SYNC_AGENT_FSAPI_FALSE) {
656                 dts_pass(api_name);
657         } else {
658                 dts_message(api_name, "sync_agent_write_file returned [%d]", ret);
659                 dts_fail(api_name);
660         }
661 }
662
663 static void utc_sync_agent_framework_sync_agent_write_whole_file_p(void)
664 {
665         char *api_name = API_NAME_SYNC_AGENT_WRITE_WHOLE_FILE;
666         int ret = 0;
667
668         ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
669         if (ret == SYNC_AGENT_FSAPI_FALSE) {
670                 dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
671                 dts_fail(api_name);
672         } else {
673                 sync_agent_delete_file(FILE_SRC);
674                 dts_pass(api_name);
675         }
676 }
677
678 static void utc_sync_agent_framework_sync_agent_write_whole_file_n(void)
679 {
680         char *api_name = API_NAME_SYNC_AGENT_WRITE_WHOLE_FILE;
681         int ret = 0;
682
683         ret = sync_agent_write_whole_file(FILE_SRC, NULL, strlen("tizen sync-agent framework"), true);
684         if (ret == SYNC_AGENT_FSAPI_FALSE) {
685                 dts_pass(api_name);
686         } else {
687                 dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
688                 dts_fail(api_name);
689         }
690 }
691
692 static void utc_sync_agent_framework_sync_agent_append_file_p(void)
693 {
694         char *api_name = API_NAME_SYNC_AGENT_APPEND_FILE;
695         int ret = 0;
696
697         ret = sync_agent_append_file(FILE_SRC, "test writing", strlen("test writing"), true);
698         if (ret == SYNC_AGENT_FSAPI_FALSE) {
699                 dts_message(api_name, "sync_agent_append_file returned [%d]", ret);
700                 dts_fail(api_name);
701         } else {
702                 sync_agent_delete_file(FILE_SRC);
703                 dts_pass(api_name);
704         }
705 }
706
707 static void utc_sync_agent_framework_sync_agent_append_file_n(void)
708 {
709         char *api_name = API_NAME_SYNC_AGENT_APPEND_FILE;
710         int ret = 0;
711
712         ret = sync_agent_append_file(FILE_SRC, NULL, strlen("test writing"), true);
713         if (ret == SYNC_AGENT_FSAPI_FALSE) {
714                 dts_pass(api_name);
715         } else {
716                 dts_message(api_name, "sync_agent_append_file returned [%d]", ret);
717                 dts_fail(api_name);
718         }
719 }
720
721 static void utc_sync_agent_framework_sync_agent_create_directory_p(void)
722 {
723         char *api_name = API_NAME_SYNC_AGENT_CREATE_DIRECTORY;
724         int ret = 0;
725
726         ret = sync_agent_create_directory(DIR_SRC);
727         if (ret == SYNC_AGENT_FSAPI_FALSE) {
728                 dts_message(api_name, "sync_agent_create_directory returned [%d]", ret);
729                 dts_fail(api_name);
730         } else {
731                 sync_agent_delete_directory(DIR_SRC, true);
732                 dts_pass(api_name);
733         }
734 }
735
736 static void utc_sync_agent_framework_sync_agent_create_directory_n(void)
737 {
738         char *api_name = API_NAME_SYNC_AGENT_CREATE_DIRECTORY;
739         int ret = 0;
740
741         ret = sync_agent_create_directory(NULL);
742         if (ret == SYNC_AGENT_FSAPI_FALSE) {
743                 dts_pass(api_name);
744         } else {
745                 dts_message(api_name, "sync_agent_create_directory returned [%d]", ret);
746                 dts_fail(api_name);
747         }
748 }
749
750 static void utc_sync_agent_framework_sync_agent_delete_directory_p(void)
751 {
752         char *api_name = API_NAME_SYNC_AGENT_DELETE_DIRECTORY;
753         int ret = 0;
754
755         ret = sync_agent_create_directory(DIR_SRC);
756         if (ret == SYNC_AGENT_FSAPI_FALSE) {
757                 dts_message(api_name, "sync_agent_create_directory returned [%d]", ret);
758                 dts_fail(api_name);
759         }
760
761         ret = sync_agent_delete_directory(DIR_SRC, true);
762         if (ret == SYNC_AGENT_FSAPI_FALSE) {
763                 dts_message(api_name, "sync_agent_delete_directory returned [%d]", ret);
764                 dts_fail(api_name);
765         } else {
766                 dts_pass(api_name);
767         }
768 }
769
770 static void utc_sync_agent_framework_sync_agent_delete_directory_n(void)
771 {
772         char *api_name = API_NAME_SYNC_AGENT_DELETE_DIRECTORY;
773         int ret = 0;
774
775         ret = sync_agent_delete_directory(NOT_EXISTING, true);
776         if (ret == SYNC_AGENT_FSAPI_FALSE) {
777                 dts_pass(api_name);
778         } else {
779                 dts_message(api_name, "sync_agent_delete_directory returned [%d]", ret);
780                 dts_fail(api_name);
781         }
782 }
783
784 static void utc_sync_agent_framework_sync_agent_empty_directory_contents_p(void)
785 {
786         char *api_name = API_NAME_SYNC_AGENT_EMPTY_DIRECTORY_CONTENTS;
787         int ret = 0;
788
789         ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
790         if (ret == SYNC_AGENT_FSAPI_FALSE) {
791                 dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
792                 dts_fail(api_name);
793         }
794
795         ret = sync_agent_create_directory(DIR_SRC);
796         if (ret == SYNC_AGENT_FSAPI_FALSE) {
797                 dts_message(api_name, "sync_agent_create_directory returned [%d]", ret);
798                 dts_fail(api_name);
799         }
800
801         ret = sync_agent_copy_file(FILE_SRC, FILE_DST_DIR);
802         if (ret == SYNC_AGENT_FSAPI_FALSE) {
803                 sync_agent_delete_file(FILE_SRC);
804                 sync_agent_delete_directory(DIR_SRC, true);
805                 dts_message(api_name, "sync_agent_copy_file returned [%d]", ret);
806                 dts_fail(api_name);
807         }
808
809         sync_agent_delete_file(FILE_SRC);
810
811         ret = sync_agent_empty_directory_contents(DIR_SRC);
812         if (ret == SYNC_AGENT_FSAPI_FALSE) {
813                 sync_agent_delete_directory(DIR_SRC, true);
814                 dts_message(api_name, "sync_agent_empty_directory_contents returned [%d]", ret);
815                 dts_fail(api_name);
816         } else {
817                 sync_agent_delete_directory(DIR_SRC, true);
818                 dts_pass(api_name);
819         }
820 }
821
822 static void utc_sync_agent_framework_sync_agent_empty_directory_contents_n(void)
823 {
824         char *api_name = API_NAME_SYNC_AGENT_EMPTY_DIRECTORY_CONTENTS;
825         int ret = 0;
826
827         ret = sync_agent_empty_directory_contents(NOT_EXISTING);
828         if (ret == SYNC_AGENT_FSAPI_FALSE) {
829                 dts_pass(api_name);
830         } else {
831                 dts_message(api_name, "sync_agent_empty_directory_contents returned [%d]", ret);
832                 dts_fail(api_name);
833         }
834 }
835
836 static void utc_sync_agent_framework_sync_agent_rename_directory_p(void)
837 {
838         char *api_name = API_NAME_SYNC_AGENT_RENAME_DIRECTORY;
839         int ret = 0;
840
841         ret = sync_agent_create_directory(DIR_SRC);
842         if (ret == SYNC_AGENT_FSAPI_FALSE) {
843                 dts_message(api_name, "sync_agent_create_directory returned [%d]", ret);
844                 dts_fail(api_name);
845         }
846
847         ret = sync_agent_rename_directory(DIR_SRC, DIR_DST);
848         if (ret == SYNC_AGENT_FSAPI_FALSE) {
849                 sync_agent_delete_directory(DIR_SRC, true);
850                 dts_message(api_name, "sync_agent_rename_directory returned [%d]", ret);
851                 dts_fail(api_name);
852         } else {
853                 sync_agent_delete_directory(DIR_DST, true);
854                 dts_pass(api_name);
855         }
856 }
857
858 static void utc_sync_agent_framework_sync_agent_rename_directory_n(void)
859 {
860         char *api_name = API_NAME_SYNC_AGENT_RENAME_DIRECTORY;
861         int ret = 0;
862
863         ret = sync_agent_rename_directory(NOT_EXISTING, DIR_DST);
864         if (ret == SYNC_AGENT_FSAPI_FALSE) {
865                 dts_pass(api_name);
866         } else {
867                 dts_message(api_name, "sync_agent_rename_directory returned [%d]", ret);
868                 dts_fail(api_name);
869         }
870 }
871
872 static void utc_sync_agent_framework_sync_agent_get_directory_list_p(void)
873 {
874         char *api_name = API_NAME_SYNC_AGENT_GET_DIRECTORY_LIST;
875         int ret = 0;
876         GSList *list = NULL;
877
878         ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
879         if (ret == SYNC_AGENT_FSAPI_FALSE) {
880                 dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
881                 dts_fail(api_name);
882         }
883
884         ret = sync_agent_create_directory(DIR_SRC);
885         if (ret == SYNC_AGENT_FSAPI_FALSE) {
886                 dts_message(api_name, "sync_agent_create_directory returned [%d]", ret);
887                 dts_fail(api_name);
888         }
889
890         ret = sync_agent_copy_file(FILE_SRC, FILE_DST_DIR);
891         if (ret == SYNC_AGENT_FSAPI_FALSE) {
892                 sync_agent_delete_file(FILE_SRC);
893                 sync_agent_delete_directory(DIR_SRC, true);
894                 dts_message(api_name, "sync_agent_copy_file returned [%d]", ret);
895                 dts_fail(api_name);
896         }
897
898         sync_agent_delete_file(FILE_SRC);
899
900         ret = sync_agent_get_directory_list(DIR_SRC, &list);
901         if (ret == SYNC_AGENT_FSAPI_FALSE) {
902                 sync_agent_delete_directory(DIR_SRC, true);
903                 dts_message(api_name, "sync_agent_get_directory_list returned [%d]", ret);
904                 dts_fail(api_name);
905         } else {
906                 sync_agent_delete_directory(DIR_SRC, true);
907                 dts_pass(api_name);
908         }
909 }
910
911 static void utc_sync_agent_framework_sync_agent_get_directory_list_n(void)
912 {
913         char *api_name = API_NAME_SYNC_AGENT_GET_DIRECTORY_LIST;
914         int ret = 0;
915         GSList *list = NULL;
916
917         ret = sync_agent_get_directory_list(NOT_EXISTING, &list);
918         if (ret == SYNC_AGENT_FSAPI_FALSE) {
919                 dts_pass(api_name);
920         } else {
921                 dts_message(api_name, "sync_agent_get_directory_list returned [%d]", ret);
922                 dts_fail(api_name);
923         }
924 }
925
926 static void utc_sync_agent_framework_sync_agent_file_md5_validation_p(void)
927 {
928         char *api_name = API_NAME_SYNC_AGENT_FILE_MD5_VALIDATION;
929         int ret = 0;
930         char *md5hash = strdup("DF8F725F131D55A19742C001AB03DC42");
931         bool same = false;
932
933         ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
934         if (ret == SYNC_AGENT_FSAPI_FALSE) {
935                 dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
936                 dts_fail(api_name);
937         }
938
939         ret = sync_agent_file_md5_validation(FILE_SRC, md5hash, &same);
940         if (ret == SYNC_AGENT_FSAPI_FALSE) {
941                 sync_agent_delete_file(FILE_SRC);
942                 dts_message(api_name, "sync_agent_file_md5_validation returned [%d]", ret);
943                 dts_fail(api_name);
944         } else {
945                 sync_agent_delete_file(FILE_SRC);
946                 dts_pass(api_name);
947         }
948 }
949
950 static void utc_sync_agent_framework_sync_agent_file_md5_validation_n(void)
951 {
952         char *api_name = API_NAME_SYNC_AGENT_FILE_MD5_VALIDATION;
953         int ret = 0;
954         char *md5hash = strdup("c88ad98ef5a3368404ff42926adc4eb0");
955         bool same = false;
956
957         ret = sync_agent_file_md5_validation(NOT_EXISTING, md5hash, &same);
958         if (ret == SYNC_AGENT_FSAPI_FALSE) {
959                 dts_pass(api_name);
960         } else {
961                 dts_message(api_name, "sync_agent_file_md5_validation returned [%d]", ret);
962                 dts_fail(api_name);
963         }
964 }