summaryrefslogtreecommitdiff
path: root/src/tests/ecore/ecore_test_ecore_file.c
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-01-19 18:15:20 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-01-19 18:18:29 +0900
commit0402b5fd125081c1f7a8d02e4849fe037cc101f6 (patch)
tree43d20d5c1c5c20c2d29b9048e13ef09a5b2269c5 /src/tests/ecore/ecore_test_ecore_file.c
parentd9460afcdcbba84f6e866e16d648a06130fa9e8c (diff)
Ecore: Remove all temporary files after running make check
Diffstat (limited to '')
-rw-r--r--src/tests/ecore/ecore_test_ecore_file.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/tests/ecore/ecore_test_ecore_file.c b/src/tests/ecore/ecore_test_ecore_file.c
index 28ffb83e5a..91003621c2 100644
--- a/src/tests/ecore/ecore_test_ecore_file.c
+++ b/src/tests/ecore/ecore_test_ecore_file.c
@@ -32,8 +32,8 @@ _writeToFile(const char *filePath, char *text)
32 fclose(f); 32 fclose(f);
33} 33}
34 34
35Eina_Tmpstr* 35static Eina_Tmpstr*
36get_tmp_dir() 36get_tmp_dir(void)
37{ 37{
38 Eina_Tmpstr *tmp_dir; 38 Eina_Tmpstr *tmp_dir;
39 39
@@ -47,18 +47,19 @@ get_tmp_dir()
47 return tmp_dir; 47 return tmp_dir;
48} 48}
49 49
50Eina_Tmpstr* 50static Eina_Tmpstr*
51get_tmp_file() 51get_tmp_file(void)
52{ 52{
53 Eina_Tmpstr *tmp_file; 53 Eina_Tmpstr *tmp_file;
54 54
55 Eina_Bool created = eina_file_mkstemp("EcoreFileTestXXXXXX", &tmp_file); 55 int fd = eina_file_mkstemp("EcoreFileTestXXXXXX", &tmp_file);
56 56
57 if (!created) 57 if (fd < 0)
58 { 58 {
59 return NULL; 59 return NULL;
60 } 60 }
61 61
62 close(fd);
62 return tmp_file; 63 return tmp_file;
63} 64}
64 65
@@ -135,7 +136,6 @@ START_TEST(ecore_test_ecore_file_operations)
135 const char *src_dir, *src_file, *dest_file; 136 const char *src_dir, *src_file, *dest_file;
136 const char *not_exist_file; 137 const char *not_exist_file;
137 const char *tmpdir = NULL; 138 const char *tmpdir = NULL;
138 char *dup_dir;
139 char *random_text = "This is random test String"; 139 char *random_text = "This is random test String";
140 char *escaped_text = "This\\ is\\ random\\ test\\ String"; 140 char *escaped_text = "This\\ is\\ random\\ test\\ String";
141 char *exe_cmd = "test.sh --opt1=a --opt2=b"; 141 char *exe_cmd = "test.sh --opt1=a --opt2=b";
@@ -164,6 +164,8 @@ START_TEST(ecore_test_ecore_file_operations)
164 fail_if(res != EINA_FALSE); 164 fail_if(res != EINA_FALSE);
165 res = ecore_file_remove(src_file); 165 res = ecore_file_remove(src_file);
166 fail_if(res != EINA_TRUE); 166 fail_if(res != EINA_TRUE);
167 res = ecore_file_exists(src_file);
168 fail_if(res != EINA_FALSE);
167 169
168 res = ecore_file_is_dir(src_dir); 170 res = ecore_file_is_dir(src_dir);
169 fail_if(res != EINA_TRUE); 171 fail_if(res != EINA_TRUE);
@@ -173,6 +175,8 @@ START_TEST(ecore_test_ecore_file_operations)
173 fail_if(res != EINA_FALSE); 175 fail_if(res != EINA_FALSE);
174 res = ecore_file_remove(src_dir); 176 res = ecore_file_remove(src_dir);
175 fail_if(res != EINA_TRUE); 177 fail_if(res != EINA_TRUE);
178 res = ecore_file_is_dir(src_dir);
179 fail_if(res != EINA_FALSE);
176 180
177 src_dir = get_tmp_dir(); 181 src_dir = get_tmp_dir();
178 fail_if(!src_dir); 182 fail_if(!src_dir);
@@ -235,8 +239,7 @@ START_TEST(ecore_test_ecore_file_operations)
235 fail_if(ecore_file_can_read(dest_file) != EINA_TRUE); 239 fail_if(ecore_file_can_read(dest_file) != EINA_TRUE);
236 fail_if(ecore_file_can_write(dest_file) != EINA_TRUE); 240 fail_if(ecore_file_can_write(dest_file) != EINA_TRUE);
237 fail_if(ecore_file_can_exec(dest_file) != EINA_FALSE); 241 fail_if(ecore_file_can_exec(dest_file) != EINA_FALSE);
238 res = ecore_file_remove(dest_file); 242 fail_if(ecore_file_remove(dest_file) != EINA_TRUE);
239 fail_if(res != EINA_TRUE);
240 243
241 ck_assert_str_eq(ecore_file_app_exe_get(exe_cmd), exe); 244 ck_assert_str_eq(ecore_file_app_exe_get(exe_cmd), exe);
242 ck_assert_str_eq(ecore_file_escape_name(random_text), escaped_text); 245 ck_assert_str_eq(ecore_file_escape_name(random_text), escaped_text);
@@ -250,10 +253,6 @@ START_TEST(ecore_test_ecore_file_operations)
250 fail_if(fd < 0); 253 fail_if(fd < 0);
251 fail_if(close(fd) != 0); 254 fail_if(close(fd) != 0);
252 fail_if(ecore_file_can_exec(src_file) != EINA_TRUE); 255 fail_if(ecore_file_can_exec(src_file) != EINA_TRUE);
253 dup_dir = strdup(src_file);
254 fail_if(!dup_dir);
255 dest_file = basename(dup_dir);
256 dup_dir = strdup(src_file);
257 256
258 src_dir = get_tmp_dir(); 257 src_dir = get_tmp_dir();
259 fail_if(!src_dir); 258 fail_if(!src_dir);
@@ -279,6 +278,8 @@ START_TEST(ecore_test_ecore_file_operations)
279 fail_if(ecore_file_mksubdirs(NULL, dirs) != -1); 278 fail_if(ecore_file_mksubdirs(NULL, dirs) != -1);
280 fail_if(ecore_file_mksubdirs("", dirs) != -1); 279 fail_if(ecore_file_mksubdirs("", dirs) != -1);
281 fail_if(ecore_file_mksubdirs(src_file, dirs) != 0); 280 fail_if(ecore_file_mksubdirs(src_file, dirs) != 0);
281 fail_if(ecore_file_remove(src_file) != EINA_TRUE);
282 fail_if(ecore_file_recursive_rm(src_dir) != EINA_TRUE);
282 283
283 src_dir = get_tmp_dir(); 284 src_dir = get_tmp_dir();
284 fail_if(!src_dir); 285 fail_if(!src_dir);
@@ -306,6 +307,7 @@ START_TEST(ecore_test_ecore_file_operations)
306 fail_if(ecore_file_can_write(src_file) != EINA_FALSE); 307 fail_if(ecore_file_can_write(src_file) != EINA_FALSE);
307 fail_if(ecore_file_can_exec(src_file) != EINA_FALSE); 308 fail_if(ecore_file_can_exec(src_file) != EINA_FALSE);
308 fail_if(ecore_file_cp(src_file, src_file) != EINA_FALSE); 309 fail_if(ecore_file_cp(src_file, src_file) != EINA_FALSE);
310 fail_if(ecore_file_remove(src_file) != EINA_TRUE);
309 311
310 src_file = get_tmp_file(); 312 src_file = get_tmp_file();
311 fail_if(!src_file); 313 fail_if(!src_file);
@@ -316,6 +318,7 @@ START_TEST(ecore_test_ecore_file_operations)
316 fail_if(ecore_file_can_read(src_file) != EINA_FALSE); 318 fail_if(ecore_file_can_read(src_file) != EINA_FALSE);
317 fail_if(ecore_file_can_write(src_file) != EINA_TRUE); 319 fail_if(ecore_file_can_write(src_file) != EINA_TRUE);
318 fail_if(ecore_file_can_exec(src_file) != EINA_FALSE); 320 fail_if(ecore_file_can_exec(src_file) != EINA_FALSE);
321 fail_if(ecore_file_remove(src_file) != EINA_TRUE);
319 322
320 src_file = get_tmp_file(); 323 src_file = get_tmp_file();
321 fail_if(!src_file); 324 fail_if(!src_file);
@@ -326,15 +329,21 @@ START_TEST(ecore_test_ecore_file_operations)
326 fail_if(ecore_file_can_read(src_file) != EINA_FALSE); 329 fail_if(ecore_file_can_read(src_file) != EINA_FALSE);
327 fail_if(ecore_file_can_write(src_file) != EINA_FALSE); 330 fail_if(ecore_file_can_write(src_file) != EINA_FALSE);
328 fail_if(ecore_file_can_exec(src_file) != EINA_TRUE); 331 fail_if(ecore_file_can_exec(src_file) != EINA_TRUE);
332 fail_if(ecore_file_remove(src_file) != EINA_TRUE);
329 333
330 fail_if(ecore_file_unlink(not_exist_file) != EINA_FALSE); 334 fail_if(ecore_file_unlink(not_exist_file) != EINA_FALSE);
331 fail_if(ecore_file_remove(not_exist_file) != EINA_FALSE); 335 fail_if(ecore_file_remove(not_exist_file) != EINA_FALSE);
332 fail_if(ecore_file_cp(not_exist_file, "test_file") != EINA_FALSE); 336 fail_if(ecore_file_cp(not_exist_file, "test_file") != EINA_FALSE);
333 fail_if(ecore_file_mv(not_exist_file, "test_file") != EINA_FALSE); 337 fail_if(ecore_file_mv(not_exist_file, "test_file") != EINA_FALSE);
334 338
339 chdir(eina_environment_tmp_get());
335 fail_if(ecore_file_mkpath(src_dir) != EINA_TRUE); 340 fail_if(ecore_file_mkpath(src_dir) != EINA_TRUE);
341 fail_if(ecore_file_rmdir(src_dir) != EINA_TRUE);
336 fail_if(ecore_file_mkpath(NULL) != EINA_FALSE); 342 fail_if(ecore_file_mkpath(NULL) != EINA_FALSE);
337 fail_if(ecore_file_mkpaths(dirs) != 4); 343 fail_if(ecore_file_mkpaths(dirs) != 4);
344 for (i = 0; dirs[i]; i++)
345 if (ecore_file_is_dir(dirs[i]))
346 fail_if(ecore_file_recursive_rm(dirs[i]) != EINA_TRUE);
338 fail_if(ecore_file_mkpaths(NULL) != -1); 347 fail_if(ecore_file_mkpaths(NULL) != -1);
339 348
340 fail_if(ecore_file_dir_get(NULL) != NULL); 349 fail_if(ecore_file_dir_get(NULL) != NULL);
@@ -402,6 +411,8 @@ START_TEST(ecore_test_ecore_file_path)
402 free(dup_dir); 411 free(dup_dir);
403 ret = setenv("PATH", src_dir, 1); 412 ret = setenv("PATH", src_dir, 1);
404 fail_if(ret != 0); 413 fail_if(ret != 0);
414
415 fail_if(ecore_file_remove(src_file) != EINA_TRUE);
405} 416}
406END_TEST 417END_TEST
407 418