]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-fs-util: add more tests for chase_symlinks()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 2 Dec 2017 15:28:50 +0000 (00:28 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 2 Dec 2017 15:28:50 +0000 (00:28 +0900)
src/test/test-fs-util.c

index 81aa9856b7615e55d7d69163460cbff66a0a7562..86d963c4c788124d3c0dc5f664719dde7bdeffca 100644 (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);