diff options
author | pierre lamot <pierre.lamot@openwide.fr> | 2014-12-11 14:09:06 +0100 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2015-02-05 16:38:06 +0100 |
commit | 66c0f3261dab904fce533b0f7d30b1b374abd658 (patch) | |
tree | 0b509a9faf38659d2478bd434efe64cb1ff5ba3d | |
parent | 019b9e55c96705aa9d15d186e3f8a8c5966e4e73 (diff) | |
download | efl-66c0f3261dab904fce533b0f7d30b1b374abd658.tar.gz |
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.c | 33 |
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() return tmp_file; } +int +_compare_path(const char *filePathA, const char *filePathB) +{ + char realFilePathA[MAXSIZE]; + char realFilePathB[MAXSIZE]; +#ifdef _WIN32 + GetFullPathName(filePathA, MAXSIZE, realFilePathA, NULL); + GetFullPathName(filePathB, MAXSIZE, realFilePathB, NULL); +#else + realpath(filePathA, realFilePathA); + realpath(filePathB, realFilePathB); +#endif + return strcmp(realFilePathA, realFilePathB); +} + +#define assert_path_eq(X, Y) \ + do { \ + const char* _ck_x = (X); \ + const char* _ck_y = (Y); \ + ck_assert_msg(0 == _compare_path(_ck_y, _ck_x), \ + "Assertion '%s' failed: %s==\"%s\", %s==\"%s\"", #X"=="#Y, #X, _ck_x, #Y, _ck_y); \ + } while (0) + static void file_monitor_cb(void *data EINA_UNUSED, Ecore_File_Monitor *em EINA_UNUSED, Ecore_File_Event event, const char *path) @@ -204,8 +227,8 @@ START_TEST(ecore_test_ecore_file_operations) res = ecore_file_symlink(src_file, dest_file); fail_if(res != EINA_TRUE); - ck_assert_str_eq(ecore_file_readlink(dest_file), src_file); - ck_assert_str_eq(ecore_file_realpath(dest_file), src_file); + assert_path_eq(ecore_file_readlink(dest_file), src_file); + assert_path_eq(ecore_file_realpath(dest_file), src_file); res = ecore_file_unlink(dest_file); fail_if(res != EINA_TRUE); @@ -218,8 +241,8 @@ START_TEST(ecore_test_ecore_file_operations) res = ecore_file_exists(src_file); fail_if(res != EINA_FALSE); - ck_assert_str_eq(ecore_file_dir_get(dest_file), tmpdir); - ck_assert_str_eq(ecore_file_realpath(dest_file), dest_file); + assert_path_eq(ecore_file_dir_get(dest_file), tmpdir); + assert_path_eq(ecore_file_realpath(dest_file), dest_file); fail_if(ecore_file_mod_time(dest_file) == 0); fail_if(ecore_file_can_read(dest_file) != EINA_TRUE); fail_if(ecore_file_can_write(dest_file) != EINA_TRUE); @@ -263,7 +286,7 @@ START_TEST(ecore_test_ecore_file_monitor) _writeToFile(file_name, random_text); _writeToFile(file_name, random_text); - ck_assert_str_eq(ecore_file_monitor_path_get(mon), realp); + assert_path_eq(ecore_file_monitor_path_get(mon), realp); ret = ecore_file_mksubdirs(src_dir, sub_dir); fail_if(ret != 1); |