summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Schmidt <s.schmidt@samsung.com>2014-11-10 11:38:10 +0100
committerStefan Schmidt <s.schmidt@samsung.com>2014-11-10 11:38:10 +0100
commit2f9d5d19feae2db64b5bdb5ec28df94c9e5bdb5d (patch)
tree6b660c09bb1cf346419cd71abbde5458b136f1ef
parent1721c8e0437a3030dc9dbf8b43d1c0f65b007a18 (diff)
Revert "Ecore File: Added test case for Ecore File Monitor"
This breaks make check and distcheck when run more than once. I first look seems to indicate that the hardcoded /tmp/rootDir is not removed during shutdown and fials to be created the next time as it is already present. When removing it manually another problem with the subdir popped up. No time to fix this just before I want to do the release so this gets reverted. Please fix this up and submit it again for 1.13. Thanks. This reverts commit cb84017a3f4ae6b3c13ee9fe7c0dca04a16aa43c.
-rw-r--r--src/tests/ecore/ecore_test_ecore_file.c98
1 files changed, 4 insertions, 94 deletions
diff --git a/src/tests/ecore/ecore_test_ecore_file.c b/src/tests/ecore/ecore_test_ecore_file.c
index dfeb72de0d..ede09c171a 100644
--- a/src/tests/ecore/ecore_test_ecore_file.c
+++ b/src/tests/ecore/ecore_test_ecore_file.c
@@ -17,47 +17,11 @@
17void 17void
18_writeToFile(char *filePath, char *text) 18_writeToFile(char *filePath, char *text)
19{ 19{
20 FILE *f = fopen(filePath, "r+"); 20 FILE *f = fopen(filePath, "w");
21 if(f == NULL) 21 fail_if(!f);
22 {
23 f = fopen(filePath, "w");
24 }
25 fail_if(f == NULL);
26 fprintf(f, "%s\n", text); 22 fprintf(f, "%s\n", text);
27 fclose(f); 23 fclose(f);
28} 24}
29
30static void
31file_monitor_cb(void *data EINA_UNUSED, Ecore_File_Monitor *em EINA_UNUSED,
32 Ecore_File_Event event, const char *path)
33{
34 switch (event)
35 {
36 case ECORE_FILE_EVENT_NONE:
37 case ECORE_FILE_EVENT_CREATED_FILE:
38 fprintf(stderr, "File created in %s", path);
39 break;
40 case ECORE_FILE_EVENT_DELETED_FILE:
41 fprintf(stderr, "File deleted in %s", path);
42 break;
43 case ECORE_FILE_EVENT_MODIFIED:
44 fprintf(stderr, "File modified in %s", path);
45 break;
46 case ECORE_FILE_EVENT_CLOSED:
47 fprintf(stderr, "File closed in %s", path);
48 break;
49 case ECORE_FILE_EVENT_DELETED_DIRECTORY:
50 fprintf(stderr, "Directory deleted in %s", path);
51 break;
52 case ECORE_FILE_EVENT_CREATED_DIRECTORY:
53 fprintf(stderr, "Directory created in %s", path);
54 break;
55 case ECORE_FILE_EVENT_DELETED_SELF:
56 fprintf(stderr, "Path %s deleted", path);
57 break;
58 }
59}
60
61START_TEST(ecore_test_ecore_file_init) 25START_TEST(ecore_test_ecore_file_init)
62{ 26{
63 int ret; 27 int ret;
@@ -78,7 +42,7 @@ START_TEST(ecore_test_ecore_file_operations)
78 const char *destFile = "/tmp/EcoreFileDest.txt"; 42 const char *destFile = "/tmp/EcoreFileDest.txt";
79 char *randomText = "This is random test String"; 43 char *randomText = "This is random test String";
80 char dir[MAXSIZE] = {'\0'}; 44 char dir[MAXSIZE] = {'\0'};
81 unsigned int ret; 45 int ret;
82 Eina_Bool res; 46 Eina_Bool res;
83 Eina_List *list; 47 Eina_List *list;
84 48
@@ -131,8 +95,6 @@ START_TEST(ecore_test_ecore_file_operations)
131 95
132 ret = ecore_file_size(srcFile); 96 ret = ecore_file_size(srcFile);
133 fail_if(ret != strlen(randomText)+1); 97 fail_if(ret != strlen(randomText)+1);
134 ret = ecore_file_is_dir(srcFile);
135 fail_if(ret != EINA_FALSE);
136 98
137 res = ecore_file_cp(srcFile, destFile); 99 res = ecore_file_cp(srcFile, destFile);
138 fail_if(res != EINA_TRUE); 100 fail_if(res != EINA_TRUE);
@@ -145,7 +107,6 @@ START_TEST(ecore_test_ecore_file_operations)
145 res = ecore_file_symlink(srcFile, destFile); 107 res = ecore_file_symlink(srcFile, destFile);
146 fail_if(res != EINA_TRUE); 108 fail_if(res != EINA_TRUE);
147 ck_assert_str_eq(ecore_file_readlink(destFile), srcFile); 109 ck_assert_str_eq(ecore_file_readlink(destFile), srcFile);
148 ck_assert_str_eq(ecore_file_realpath(destFile), srcFile);
149 res = ecore_file_unlink(destFile); 110 res = ecore_file_unlink(destFile);
150 fail_if(res != EINA_TRUE); 111 fail_if(res != EINA_TRUE);
151 112
@@ -172,59 +133,8 @@ START_TEST(ecore_test_ecore_file_operations)
172} 133}
173END_TEST 134END_TEST
174 135
175START_TEST(ecore_test_ecore_file_monitor)
176{
177 Ecore_File_Monitor *mon;
178 char *path = "/tmp/rootDir/";
179 char *file = "/tmp/rootDir/EcoreFileDest.txt";
180 const char *subDir[] = {"subdir"};
181 char dirName[MAXSIZE] = {'\0'};
182 char *randomText = "This is random test String";
183 char *realp;
184 Eina_Bool res;
185 int ret;
186
187 ret = ecore_file_init();
188 fail_if(ret != 1);
189
190 res = ecore_file_mkdir(path);
191 fail_if(res != EINA_TRUE);
192
193 realp = ecore_file_realpath(path);
194 fail_if(!realp);
195 mon = ecore_file_monitor_add(realp, file_monitor_cb, NULL);
196 fail_if(mon == NULL);
197
198 _writeToFile(file, randomText);
199 _writeToFile(file, randomText);
200
201 ck_assert_str_eq(ecore_file_monitor_path_get(mon), realp);
202
203 ret = ecore_file_mksubdirs(path, subDir);
204 fail_if(ret != 1);
205
206 res = ecore_file_remove(file);
207 fail_if(res != EINA_TRUE);
208
209 strcat(dirName, path);
210 strcat(dirName, subDir[0]);
211 res = ecore_file_rmdir(dirName);
212 fail_if(res != EINA_TRUE);
213
214 res = ecore_file_recursive_rm(path);
215 fail_if(res != EINA_TRUE);
216
217 ecore_file_monitor_del(mon);
218
219 ret = ecore_file_shutdown();
220 fail_if(ret != 0);
221
222}
223END_TEST
224
225void ecore_test_ecore_file(TCase *tc) 136void ecore_test_ecore_file(TCase *tc)
226{ 137{
227 tcase_add_test(tc, ecore_test_ecore_file_init); 138 tcase_add_test(tc, ecore_test_ecore_file_init);
228 tcase_add_test(tc, ecore_test_ecore_file_operations); 139 tcase_add_test(tc, ecore_test_ecore_file_operations);
229 tcase_add_test(tc, ecore_test_ecore_file_monitor);
230} 140}