eina: Eina_File - add test case for path resolution.

Summary:
This is a follow-up to the 7cbf22212f
revert commit. It's a bit late, as the issue has already been fixed with
the later 7143bd7fb5 commit.

This test checks eina_file_sanitize "../" case with absolute paths (i.e.
that start with "/"), and should fail prior the revert mentioned above.

Should come up with more tests like this one.

Reviewers: stefan_schmidt, cedric

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D1937

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
Daniel Hirt 2015-02-05 15:01:12 +01:00 committed by Cedric BAIL
parent e1eff60c80
commit d503dbeed1
1 changed files with 25 additions and 1 deletions

View File

@ -474,6 +474,30 @@ START_TEST(eina_test_file_thread)
}
END_TEST
static const struct {
const char *test;
const char *result;
} sanitize[] = {
{ "/home/mydir/../myfile", "/home/myfile" }
};
START_TEST(eina_test_file_path)
{
unsigned int i;
char *path;
fail_if(!eina_init());
for (i = 0; i < sizeof (sanitize) / sizeof (sanitize[0]); i++)
{
path = eina_file_path_sanitize(sanitize[i].test);
fail_if(strcmp(path, sanitize[i].result));
}
eina_shutdown();
}
END_TEST
void
eina_test_file(TCase *tc)
{
@ -483,5 +507,5 @@ eina_test_file(TCase *tc)
tcase_add_test(tc, eina_file_map_new_test);
tcase_add_test(tc, eina_test_file_virtualize);
tcase_add_test(tc, eina_test_file_thread);
tcase_add_test(tc, eina_test_file_path);
}