test-fs-util: add more tests for chase_symlinks()

This commit is contained in:
Yu Watanabe
2017-12-03 00:28:50 +09:00
parent cd76d4c2fe
commit 95f35cccf0
+20
View File
@@ -168,6 +168,26 @@ static void test_chase_symlinks(void) {
assert_se(r > 0 && path_equal(result, "/etc"));
result = mfree(result);
r = chase_symlinks("/../.././//../../etc", NULL, 0, &result);
assert_se(r > 0);
assert_se(streq(result, "/etc"));
result = mfree(result);
r = chase_symlinks("/../.././//../../test-chase.fsldajfl", NULL, CHASE_NONEXISTENT, &result);
assert_se(r == 0);
assert_se(streq(result, "/test-chase.fsldajfl"));
result = mfree(result);
r = chase_symlinks("/../.././//../../etc", "/", CHASE_PREFIX_ROOT, &result);
assert_se(r > 0);
assert_se(streq(result, "/etc"));
result = mfree(result);
r = chase_symlinks("/../.././//../../test-chase.fsldajfl", "/", CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &result);
assert_se(r == 0);
assert_se(streq(result, "/test-chase.fsldajfl"));
result = mfree(result);
r = chase_symlinks("/etc/machine-id/foo", NULL, 0, &result);
assert_se(r == -ENOTDIR);
result = mfree(result);