summaryrefslogtreecommitdiff
path: root/src/tests/ecore/ecore_test_ecore_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/ecore/ecore_test_ecore_file.c')
-rw-r--r--src/tests/ecore/ecore_test_ecore_file.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/src/tests/ecore/ecore_test_ecore_file.c b/src/tests/ecore/ecore_test_ecore_file.c
index b897fdd..e41ce02 100644
--- a/src/tests/ecore/ecore_test_ecore_file.c
+++ b/src/tests/ecore/ecore_test_ecore_file.c
@@ -196,9 +196,7 @@ EFL_START_TEST(ecore_test_ecore_file_operations)
196 196
197 src_dir = get_tmp_dir(); 197 src_dir = get_tmp_dir();
198 fail_if(!src_dir); 198 fail_if(!src_dir);
199 strcat(dir, src_dir); 199 snprintf(dir, sizeof(dir), "%s/%s", src_dir, dirs[2]);
200 strcat(dir, "/");
201 strcat(dir, dirs[2]);
202 res = ecore_file_mkpath(dir); 200 res = ecore_file_mkpath(dir);
203 fail_if(res != EINA_TRUE); 201 fail_if(res != EINA_TRUE);
204 res = ecore_file_recursive_rm(src_dir); 202 res = ecore_file_recursive_rm(src_dir);
@@ -265,18 +263,14 @@ EFL_START_TEST(ecore_test_ecore_file_operations)
265 263
266 src_dir = get_tmp_dir(); 264 src_dir = get_tmp_dir();
267 fail_if(!src_dir); 265 fail_if(!src_dir);
268 strcpy(dir, src_dir); 266 snprintf(dir, sizeof(dir), "%s/%s", src_dir, dirs[0]);
269 strcat(dir, "/");
270 strcat(dir, dirs[0]);
271 fail_if(ecore_file_mkdir(dir) != EINA_TRUE); 267 fail_if(ecore_file_mkdir(dir) != EINA_TRUE);
272 268
273 fail_if(ecore_file_mkdirs(NULL) != -1); 269 fail_if(ecore_file_mkdirs(NULL) != -1);
274 for (i = 0; i < 3; i++) 270 for (i = 0; i < 3; i++)
275 { 271 {
276 char tmp[PATH_MAX]; 272 char tmp[PATH_MAX];
277 strcpy(tmp, src_dir); 273 snprintf(tmp, sizeof(tmp), "%s/%s", src_dir, dirs2[i]);
278 strcat(tmp, "/");
279 strcat(tmp, dirs2[i]);
280 dirs2[i] = strdup(tmp); 274 dirs2[i] = strdup(tmp);
281 } 275 }
282 fail_if(ecore_file_mkdirs((const char **)dirs2) != 3); 276 fail_if(ecore_file_mkdirs((const char **)dirs2) != 3);
@@ -403,11 +397,8 @@ EFL_START_TEST(ecore_test_ecore_file_path)
403 397
404 src_dir = getenv("PATH"); 398 src_dir = getenv("PATH");
405 fail_if(!src_dir); 399 fail_if(!src_dir);
406 path = malloc(strlen(src_dir) + strlen(dup_dir) + 1); 400 path = malloc(strlen(src_dir) + strlen(dup_dir) + 2);
407 *path = '\0'; 401 snprintf(path, strlen(src_dir) + strlen(dup_dir) + 2, "%s:%s", src_dir, dirname(dup_dir));
408 strcat(path, src_dir);
409 strcat(path, ":");
410 strcat(path, dirname(dup_dir));
411 ret = setenv("PATH", path, 1); 402 ret = setenv("PATH", path, 1);
412 fail_if(ret != 0); 403 fail_if(ret != 0);
413 free(dup_dir); 404 free(dup_dir);
@@ -416,11 +407,25 @@ EFL_START_TEST(ecore_test_ecore_file_path)
416 ret = ecore_file_init(); 407 ret = ecore_file_init();
417 408
418 res = ecore_file_app_installed(dest_file); 409 res = ecore_file_app_installed(dest_file);
410 if (!res)
411 {
412 /* attempt to mitigate cascading failures */
413 ret = setenv("PATH", src_dir, 1);
414 fail_if(ret != 0);
415 }
419 fail_if(res != EINA_TRUE); 416 fail_if(res != EINA_TRUE);
420 res = ecore_file_app_installed(src_file); 417 res = ecore_file_app_installed(src_file);
418 if (!res)
419 {
420 /* attempt to mitigate cascading failures */
421 ret = setenv("PATH", src_dir, 1);
422 fail_if(ret != 0);
423 }
421 fail_if(res != EINA_TRUE); 424 fail_if(res != EINA_TRUE);
422 list = NULL; 425 list = NULL;
423 list = ecore_file_app_list(); 426 list = ecore_file_app_list();
427 ret = setenv("PATH", src_dir, 1);
428 fail_if(ret != 0);
424 fd = 0; 429 fd = 0;
425 EINA_LIST_FOREACH(list, l, path) 430 EINA_LIST_FOREACH(list, l, path)
426 { 431 {
@@ -433,8 +438,6 @@ EFL_START_TEST(ecore_test_ecore_file_path)
433 fail_if(fd == 0); 438 fail_if(fd == 0);
434 EINA_LIST_FREE(list, dup_dir) 439 EINA_LIST_FREE(list, dup_dir)
435 free(dup_dir); 440 free(dup_dir);
436 ret = setenv("PATH", src_dir, 1);
437 fail_if(ret != 0);
438 441
439 fail_if(ecore_file_remove(src_file) != EINA_TRUE); 442 fail_if(ecore_file_remove(src_file) != EINA_TRUE);
440 443
@@ -468,9 +471,7 @@ EFL_START_TEST(ecore_test_ecore_file_monitor)
468 mon = ecore_file_monitor_add(realp, file_monitor_cb, NULL); 471 mon = ecore_file_monitor_add(realp, file_monitor_cb, NULL);
469 fail_if(mon == NULL); 472 fail_if(mon == NULL);
470 473
471 strcat(file_name, src_dir); 474 snprintf(file_name, sizeof(file_name), "%s/%s", src_dir, file);
472 strcat(file_name, "/");
473 strcat(file_name, file);
474 _writeToFile(file_name, random_text); 475 _writeToFile(file_name, random_text);
475 _writeToFile(file_name, random_text); 476 _writeToFile(file_name, random_text);
476 477
@@ -483,9 +484,7 @@ EFL_START_TEST(ecore_test_ecore_file_monitor)
483 res = ecore_file_remove(file_name); 484 res = ecore_file_remove(file_name);
484 fail_if(res != EINA_TRUE); 485 fail_if(res != EINA_TRUE);
485 486
486 strcat(dir_name, src_dir); 487 snprintf(dir_name, sizeof(dir_name), "%s/%s", src_dir, sub_dir[0]);
487 strcat(dir_name, "/");
488 strcat(dir_name, sub_dir[0]);
489 res = ecore_file_rmdir(dir_name); 488 res = ecore_file_rmdir(dir_name);
490 fail_if(res != EINA_TRUE); 489 fail_if(res != EINA_TRUE);
491 490
@@ -519,9 +518,7 @@ EFL_START_TEST(ecore_test_ecore_file_download)
519 download_file = ecore_file_file_get(download_url); //example.com 518 download_file = ecore_file_file_get(download_url); //example.com
520 fail_if(!download_file); 519 fail_if(!download_file);
521 fail_if(!ecore_file_download_protocol_available("http://")); 520 fail_if(!ecore_file_download_protocol_available("http://"));
522 strcat(dest_name, download_dir); 521 snprintf(dest_name, sizeof(dest_name), "%s/%s", download_dir, download_file);
523 strcat(dest_name, "/");
524 strcat(dest_name, download_file);
525 522
526 res = ecore_file_download("xxyyzz", dest_name, completion_cb, 523 res = ecore_file_download("xxyyzz", dest_name, completion_cb,
527 progress_cb, NULL, &job); 524 progress_cb, NULL, &job);