summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpierre lamot <pierre.lamot@openwide.fr>2014-12-11 14:09:06 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-02-05 16:38:06 +0100
commit66c0f3261dab904fce533b0f7d30b1b374abd658 (patch)
tree0b509a9faf38659d2478bd434efe64cb1ff5ba3d
parent019b9e55c96705aa9d15d186e3f8a8c5966e4e73 (diff)
ecore: fix path comparison in Ecore_File test suite.
The Ecore_File test suite was comparing path with strcmp, which can lead to incorect comparison in some case (comparing realpath and expected path for instance) This patch adds a function to compare paths within this tests. Paths are compared by getting the "realpath" of each operand Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/tests/ecore/ecore_test_ecore_file.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/tests/ecore/ecore_test_ecore_file.c b/src/tests/ecore/ecore_test_ecore_file.c
index 515ff54b59..8b3c567c76 100644
--- a/src/tests/ecore/ecore_test_ecore_file.c
+++ b/src/tests/ecore/ecore_test_ecore_file.c
@@ -55,6 +55,29 @@ get_tmp_file()
55 return tmp_file; 55 return tmp_file;
56} 56}
57 57
58int
59_compare_path(const char *filePathA, const char *filePathB)
60{
61 char realFilePathA[MAXSIZE];
62 char realFilePathB[MAXSIZE];
63#ifdef _WIN32
64 GetFullPathName(filePathA, MAXSIZE, realFilePathA, NULL);
65 GetFullPathName(filePathB, MAXSIZE, realFilePathB, NULL);
66#else
67 realpath(filePathA, realFilePathA);
68 realpath(filePathB, realFilePathB);
69#endif
70 return strcmp(realFilePathA, realFilePathB);
71}
72
73#define assert_path_eq(X, Y) \
74 do { \
75 const char* _ck_x = (X); \
76 const char* _ck_y = (Y); \
77 ck_assert_msg(0 == _compare_path(_ck_y, _ck_x), \
78 "Assertion '%s' failed: %s==\"%s\", %s==\"%s\"", #X"=="#Y, #X, _ck_x, #Y, _ck_y); \
79 } while (0)
80
58static void 81static void
59file_monitor_cb(void *data EINA_UNUSED, Ecore_File_Monitor *em EINA_UNUSED, 82file_monitor_cb(void *data EINA_UNUSED, Ecore_File_Monitor *em EINA_UNUSED,
60 Ecore_File_Event event, const char *path) 83 Ecore_File_Event event, const char *path)
@@ -204,8 +227,8 @@ START_TEST(ecore_test_ecore_file_operations)
204 227
205 res = ecore_file_symlink(src_file, dest_file); 228 res = ecore_file_symlink(src_file, dest_file);
206 fail_if(res != EINA_TRUE); 229 fail_if(res != EINA_TRUE);
207 ck_assert_str_eq(ecore_file_readlink(dest_file), src_file); 230 assert_path_eq(ecore_file_readlink(dest_file), src_file);
208 ck_assert_str_eq(ecore_file_realpath(dest_file), src_file); 231 assert_path_eq(ecore_file_realpath(dest_file), src_file);
209 res = ecore_file_unlink(dest_file); 232 res = ecore_file_unlink(dest_file);
210 fail_if(res != EINA_TRUE); 233 fail_if(res != EINA_TRUE);
211 234
@@ -218,8 +241,8 @@ START_TEST(ecore_test_ecore_file_operations)
218 res = ecore_file_exists(src_file); 241 res = ecore_file_exists(src_file);
219 fail_if(res != EINA_FALSE); 242 fail_if(res != EINA_FALSE);
220 243
221 ck_assert_str_eq(ecore_file_dir_get(dest_file), tmpdir); 244 assert_path_eq(ecore_file_dir_get(dest_file), tmpdir);
222 ck_assert_str_eq(ecore_file_realpath(dest_file), dest_file); 245 assert_path_eq(ecore_file_realpath(dest_file), dest_file);
223 fail_if(ecore_file_mod_time(dest_file) == 0); 246 fail_if(ecore_file_mod_time(dest_file) == 0);
224 fail_if(ecore_file_can_read(dest_file) != EINA_TRUE); 247 fail_if(ecore_file_can_read(dest_file) != EINA_TRUE);
225 fail_if(ecore_file_can_write(dest_file) != EINA_TRUE); 248 fail_if(ecore_file_can_write(dest_file) != EINA_TRUE);
@@ -263,7 +286,7 @@ START_TEST(ecore_test_ecore_file_monitor)
263 _writeToFile(file_name, random_text); 286 _writeToFile(file_name, random_text);
264 _writeToFile(file_name, random_text); 287 _writeToFile(file_name, random_text);
265 288
266 ck_assert_str_eq(ecore_file_monitor_path_get(mon), realp); 289 assert_path_eq(ecore_file_monitor_path_get(mon), realp);
267 290
268 ret = ecore_file_mksubdirs(src_dir, sub_dir); 291 ret = ecore_file_mksubdirs(src_dir, sub_dir);
269 fail_if(ret != 1); 292 fail_if(ret != 1);