HALF ECHO LEARN / REFERENCE COLLECTION

v262.2

src/test/test-path-util.c

64,070 bytesGit mode 100644Download original fileLGPL-2.1-or-later

Git blob: 1dc260a46732e57fcf7444793827627b04a23ed2

Lines 1001–1437 of 1,437

        test_path_find_last_component_one("//./aaa///.//./.bbb/..///c.//d.dd///..eeee/.", false, STRV_MAKE("..eeee", "d.dd", "c."), -EINVAL);
 
        test_path_find_last_component_one(NULL, true, NULL, 0);
        test_path_find_last_component_one("", true, NULL, 0);
        test_path_find_last_component_one("/", true, NULL, 0);
        test_path_find_last_component_one(".", true, NULL, 0);
        test_path_find_last_component_one("./", true, NULL, 0);
        test_path_find_last_component_one("./.", true, NULL, 0);
        test_path_find_last_component_one("..", true, STRV_MAKE(".."), 0);
        test_path_find_last_component_one("/..", true, STRV_MAKE(".."), 0);
        test_path_find_last_component_one("./..", true, STRV_MAKE(".."), 0);
        test_path_find_last_component_one("////./././//.", true, NULL, 0);
        test_path_find_last_component_one("a/b/c", true, STRV_MAKE("c", "b", "a"), 0);
        test_path_find_last_component_one("././//.///aa./.bbb//./ccc/././/", true, STRV_MAKE("ccc", ".bbb", "aa."), 0);
        test_path_find_last_component_one("././//.///aa/../.../bbb//./ccc/.", true, STRV_MAKE("ccc", "bbb", "...", "..", "aa"), 0);
        test_path_find_last_component_one("//./aaa///.//./.bbb/..///c.//d.dd///..eeee/.", true, STRV_MAKE("..eeee", "d.dd", "c.", "..", ".bbb", "aaa"), 0);
 
        memset(foo, 'a', sizeof(foo) -1);
        char_array_0(foo);
 
        test_path_find_last_component_one(foo, false, NULL, -EINVAL);
        test_path_find_last_component_one(foo, true, NULL, -EINVAL);
 
        hoge = strjoin(foo, "/a/b/c/");
        assert_se(hoge);
 
        test_path_find_last_component_one(hoge, false, STRV_MAKE("c", "b", "a"), -EINVAL);
        test_path_find_last_component_one(hoge, true, STRV_MAKE("c", "b", "a"), -EINVAL);
}
 
TEST(last_path_component) {
        ASSERT_NULL(last_path_component(NULL));
        ASSERT_STREQ(last_path_component("a/b/c"), "c");
        ASSERT_STREQ(last_path_component("a/b/c/"), "c/");
        ASSERT_STREQ(last_path_component("/"), "/");
        ASSERT_STREQ(last_path_component("//"), "/");
        ASSERT_STREQ(last_path_component("///"), "/");
        ASSERT_STREQ(last_path_component("."), ".");
        ASSERT_STREQ(last_path_component("./."), ".");
        ASSERT_STREQ(last_path_component("././"), "./");
        ASSERT_STREQ(last_path_component("././/"), ".//");
        ASSERT_STREQ(last_path_component("/foo/a"), "a");
        ASSERT_STREQ(last_path_component("/foo/a/"), "a/");
        ASSERT_STREQ(last_path_component(""), "");
        ASSERT_STREQ(last_path_component("a"), "a");
        ASSERT_STREQ(last_path_component("a/"), "a/");
        ASSERT_STREQ(last_path_component("/a"), "a");
        ASSERT_STREQ(last_path_component("/a/"), "a/");
}
 
static void test_path_extract_filename_one(const char *input, const char *output, int ret) {
        _cleanup_free_ char *k = NULL, *k2 = NULL;
        int r;
 
        r = path_extract_filename(input, &k);
        log_info("%s → %s/%s [expected: %s/%s]",
                 strnull(input),
                 strnull(k), r < 0 ? STRERROR(r) : "-",
                 strnull(output), ret < 0 ? STRERROR(ret) : "-");
        ASSERT_STREQ(k, output);
        assert_se(r == ret);
 
        /* Extra safety check: make sure that path_split_prefix_filename() behaves the same */
        r = path_split_prefix_filename(input, NULL, &k2);
        if (r >= 0) {
                ASSERT_STREQ(k2, k);
                assert_se(r == ret);
        }
}
 
TEST(path_extract_filename) {
        test_path_extract_filename_one(NULL, NULL, -EINVAL);
        test_path_extract_filename_one("a/b/c", "c", 0);
        test_path_extract_filename_one("a/b/c/", "c", O_DIRECTORY);
        test_path_extract_filename_one("/", NULL, -EADDRNOTAVAIL);
        test_path_extract_filename_one("//", NULL, -EADDRNOTAVAIL);
        test_path_extract_filename_one("///", NULL, -EADDRNOTAVAIL);
        test_path_extract_filename_one("/.", NULL, -EADDRNOTAVAIL);
        test_path_extract_filename_one(".", NULL, -EADDRNOTAVAIL);
        test_path_extract_filename_one("./", NULL, -EADDRNOTAVAIL);
        test_path_extract_filename_one("./.", NULL, -EADDRNOTAVAIL);
        test_path_extract_filename_one("././", NULL, -EADDRNOTAVAIL);
        test_path_extract_filename_one("././/", NULL, -EADDRNOTAVAIL);
        test_path_extract_filename_one("/foo/a", "a", 0);
        test_path_extract_filename_one("/foo/a/", "a", O_DIRECTORY);
        test_path_extract_filename_one("", NULL, -EINVAL);
        test_path_extract_filename_one("a", "a", 0);
        test_path_extract_filename_one("a/", "a", O_DIRECTORY);
        test_path_extract_filename_one("a/././//.", "a", O_DIRECTORY);
        test_path_extract_filename_one("/a", "a", 0);
        test_path_extract_filename_one("/a/", "a", O_DIRECTORY);
        test_path_extract_filename_one("/a//./.", "a", O_DIRECTORY);
        test_path_extract_filename_one("/////////////a/////////////", "a", O_DIRECTORY);
        test_path_extract_filename_one("//./a/.///b./././.c//./d//.", "d", O_DIRECTORY);
        test_path_extract_filename_one("xx/.", "xx", O_DIRECTORY);
        test_path_extract_filename_one("xx/..", NULL, -EINVAL);
        test_path_extract_filename_one("..", NULL, -EINVAL);
        test_path_extract_filename_one("/..", NULL, -EINVAL);
        test_path_extract_filename_one("../", NULL, -EINVAL);
}
 
static void test_path_extract_directory_one(const char *input, const char *output, int ret) {
        _cleanup_free_ char *k = NULL, *k2 = NULL;
        int r;
 
        r = path_extract_directory(input, &k);
        log_info("%s → %s/%s [expected: %s/%s]",
                 strnull(input),
                 strnull(k), r < 0 ? STRERROR(r) : "-",
                 strnull(output), STRERROR(ret));
        ASSERT_STREQ(k, output);
        assert_se(r == ret);
 
        /* Extra safety check: make sure that path_split_prefix_filename() behaves the same.
         * We can’t check the return value from it though as that differs based on the filename component.
         * We can only assert that if path_extract_directory() fails, then
         * path_split_prefix_filename() must also fail. */
        r = path_split_prefix_filename(input, &k2, NULL);
        ASSERT_STREQ(k2, k);
        assert_se(!(ret < 0) || r < 0);
 
        /* Extra safety check: let's make sure that if we split out the filename too (and it works) the
         * joined parts are identical to the original again */
        if (r >= 0) {
                _cleanup_free_ char *f = NULL, *k3 = NULL, *f2 = NULL;
 
                r = path_extract_filename(input, &f);
                if (r >= 0) {
                        _cleanup_free_ char *j = NULL;
 
                        assert_se(j = path_join(k, f));
                        assert_se(path_equal(input, j));
                }
 
                /* And the same, but for path_split_prefix_filename() */
                r = path_split_prefix_filename(input, &k3, &f2);
                if (r >= 0) {
                        ASSERT_STREQ(k3, k);
                        ASSERT_STREQ(f2, f);
                }
        }
}
 
TEST(path_extract_directory) {
        test_path_extract_directory_one(NULL, NULL, -EINVAL);
        test_path_extract_directory_one("a/b/c", "a/b", 0);
        test_path_extract_directory_one("a/b/c/", "a/b", 0);
        test_path_extract_directory_one("/", NULL, -EADDRNOTAVAIL);
        test_path_extract_directory_one("//", NULL, -EADDRNOTAVAIL);
        test_path_extract_directory_one("///", NULL, -EADDRNOTAVAIL);
        test_path_extract_directory_one("/.", NULL, -EADDRNOTAVAIL);
        test_path_extract_directory_one(".", NULL, -EADDRNOTAVAIL);
        test_path_extract_directory_one("./", NULL, -EADDRNOTAVAIL);
        test_path_extract_directory_one("./.", NULL, -EADDRNOTAVAIL);
        test_path_extract_directory_one("././", NULL, -EADDRNOTAVAIL);
        test_path_extract_directory_one("././/", NULL, -EADDRNOTAVAIL);
        test_path_extract_directory_one("/foo/a", "/foo", 0);
        test_path_extract_directory_one("/foo/a/", "/foo", 0);
        test_path_extract_directory_one("", NULL, -EINVAL);
        test_path_extract_directory_one("a", NULL, -EDESTADDRREQ);
        test_path_extract_directory_one("a/", NULL, -EDESTADDRREQ);
        test_path_extract_directory_one("a/././//.", NULL, -EDESTADDRREQ);
        test_path_extract_directory_one("/a", "/", 0);
        test_path_extract_directory_one("/a/", "/", 0);
        test_path_extract_directory_one("/a//./.", "/", 0);
        test_path_extract_directory_one("/////////////a/////////////", "/", 0);
        test_path_extract_directory_one("//./a/.///b./././.c//./d//.", "/a/b./.c", 0);
        test_path_extract_directory_one("xx/.", NULL, -EDESTADDRREQ);
        test_path_extract_directory_one("xx/..", NULL, -EINVAL);
        test_path_extract_directory_one("..", NULL, -EINVAL);
        test_path_extract_directory_one("/..", NULL, -EINVAL);
        test_path_extract_directory_one("../", NULL, -EINVAL);
}
 
TEST(filename_is_valid) {
        char foo[NAME_MAX+2];
 
        assert_se(!filename_is_valid(""));
        assert_se(!filename_is_valid("/bar/foo"));
        assert_se(!filename_is_valid("/"));
        assert_se(!filename_is_valid("."));
        assert_se(!filename_is_valid(".."));
        assert_se(!filename_is_valid("bar/foo"));
        assert_se(!filename_is_valid("bar/foo/"));
        assert_se(!filename_is_valid("bar//"));
 
        memset(foo, 'a', sizeof(foo) - 1);
        char_array_0(foo);
 
        assert_se(!filename_is_valid(foo));
 
        assert_se(filename_is_valid("foo_bar-333"));
        assert_se(filename_is_valid("o.o"));
}
 
static void test_path_is_valid_and_safe_one(const char *p, bool ret) {
        log_debug("/* %s(\"%s\") */", __func__, strnull(p));
 
        assert_se(path_is_valid(p) == ret);
        if (ret)
                ret = !streq(p, "..") &&
                        !startswith(p, "../") &&
                        !endswith(p, "/..") &&
                        !strstr(p, "/../");
        assert_se(path_is_safe(p) == ret);
}
 
TEST(path_is_valid_and_safe) {
        char foo[PATH_MAX+2];
        const char *c;
 
        test_path_is_valid_and_safe_one("", false);
        test_path_is_valid_and_safe_one("/bar/foo", true);
        test_path_is_valid_and_safe_one("/bar/foo/", true);
        test_path_is_valid_and_safe_one("/bar/foo/", true);
        test_path_is_valid_and_safe_one("//bar//foo//", true);
        test_path_is_valid_and_safe_one("/", true);
        test_path_is_valid_and_safe_one("/////", true);
        test_path_is_valid_and_safe_one("/////.///.////...///..//.", true);
        test_path_is_valid_and_safe_one(".", true);
        test_path_is_valid_and_safe_one("..", true);
        test_path_is_valid_and_safe_one("bar/foo", true);
        test_path_is_valid_and_safe_one("bar/foo/", true);
        test_path_is_valid_and_safe_one("bar//", true);
 
        memset(foo, 'a', sizeof(foo) -1);
        char_array_0(foo);
 
        test_path_is_valid_and_safe_one(foo, false);
 
        c = strjoina("/xxx/", foo, "/yyy");
        test_path_is_valid_and_safe_one(c, false);
 
        test_path_is_valid_and_safe_one("foo_bar-333", true);
        test_path_is_valid_and_safe_one("o.o", true);
}
 
TEST(hidden_or_backup_file) {
        assert_se(hidden_or_backup_file(".hidden"));
        assert_se(hidden_or_backup_file("..hidden"));
        assert_se(!hidden_or_backup_file("hidden."));
 
        assert_se(hidden_or_backup_file("backup~"));
        assert_se(hidden_or_backup_file(".backup~"));
 
        assert_se(hidden_or_backup_file("lost+found"));
        assert_se(hidden_or_backup_file("aquota.user"));
        assert_se(hidden_or_backup_file("aquota.group"));
 
        assert_se(hidden_or_backup_file("test.ignore"));
        assert_se(hidden_or_backup_file("test.rpmnew"));
        assert_se(hidden_or_backup_file("test.dpkg-old"));
        assert_se(hidden_or_backup_file("test.dpkg-remove"));
        assert_se(hidden_or_backup_file("test.swp"));
 
        assert_se(!hidden_or_backup_file("test.rpmnew."));
        assert_se(!hidden_or_backup_file("test.dpkg-old.foo"));
}
 
TEST(skip_dev_prefix) {
        ASSERT_STREQ(skip_dev_prefix("/"), "/");
        ASSERT_STREQ(skip_dev_prefix("/dev"), "");
        ASSERT_STREQ(skip_dev_prefix("/dev/"), "");
        ASSERT_STREQ(skip_dev_prefix("/dev/foo"), "foo");
        ASSERT_STREQ(skip_dev_prefix("/dev/foo/bar"), "foo/bar");
        ASSERT_STREQ(skip_dev_prefix("//dev"), "");
        ASSERT_STREQ(skip_dev_prefix("//dev//"), "");
        ASSERT_STREQ(skip_dev_prefix("/dev///foo"), "foo");
        ASSERT_STREQ(skip_dev_prefix("///dev///foo///bar"), "foo///bar");
        ASSERT_STREQ(skip_dev_prefix("//foo"), "//foo");
        ASSERT_STREQ(skip_dev_prefix("foo"), "foo");
}
 
TEST(empty_or_root) {
        assert_se(empty_or_root(NULL));
        assert_se(empty_or_root(""));
        assert_se(empty_or_root("/"));
        assert_se(empty_or_root("//"));
        assert_se(empty_or_root("///"));
        assert_se(empty_or_root("/////////////////"));
        assert_se(!empty_or_root("xxx"));
        assert_se(!empty_or_root("/xxx"));
        assert_se(!empty_or_root("/xxx/"));
        assert_se(!empty_or_root("//yy//"));
}
 
TEST(empty_or_root_harder_to_null) {
        const char *p;
 
        p = NULL;
        ASSERT_OK(empty_or_root_harder_to_null(&p));
        ASSERT_NULL(p);
 
        p = "/";
        ASSERT_OK(empty_or_root_harder_to_null(&p));
        ASSERT_NULL(p);
 
        p = "////////";
        ASSERT_OK(empty_or_root_harder_to_null(&p));
        ASSERT_NULL(p);
 
        p = "/../../././//";
        ASSERT_OK(empty_or_root_harder_to_null(&p));
        ASSERT_NULL(p);
 
        p = "/usr";
        ASSERT_OK(empty_or_root_harder_to_null(&p));
        ASSERT_STREQ(p, "/usr");
 
        p = "/usr/../../../";
        ASSERT_OK(empty_or_root_harder_to_null(&p));
        ASSERT_NULL(p);
 
        p = "/usr/";
        ASSERT_OK(empty_or_root_harder_to_null(&p));
        ASSERT_STREQ(p, "/usr/");
 
        p = "///././/../../usr////";
        ASSERT_OK(empty_or_root_harder_to_null(&p));
        ASSERT_STREQ(p, "///././/../../usr////");
}
 
TEST(path_startswith_set) {
        ASSERT_STREQ(PATH_STARTSWITH_SET("/foo/bar", "/foo/quux", "/foo/bar", "/zzz"), "");
        ASSERT_STREQ(PATH_STARTSWITH_SET("/foo/bar", "/foo/quux", "/foo/", "/zzz"), "bar");
        ASSERT_STREQ(PATH_STARTSWITH_SET("/foo/bar", "/foo/quux", "/foo", "/zzz"), "bar");
        ASSERT_STREQ(PATH_STARTSWITH_SET("/foo/bar", "/foo/quux", "/", "/zzz"), "foo/bar");
        ASSERT_STREQ(PATH_STARTSWITH_SET("/foo/bar", "/foo/quux", "", "/zzz"), NULL);
 
        ASSERT_STREQ(PATH_STARTSWITH_SET("/foo/bar2", "/foo/quux", "/foo/bar", "/zzz"), NULL);
        ASSERT_STREQ(PATH_STARTSWITH_SET("/foo/bar2", "/foo/quux", "/foo/", "/zzz"), "bar2");
        ASSERT_STREQ(PATH_STARTSWITH_SET("/foo/bar2", "/foo/quux", "/foo", "/zzz"), "bar2");
        ASSERT_STREQ(PATH_STARTSWITH_SET("/foo/bar2", "/foo/quux", "/", "/zzz"), "foo/bar2");
        ASSERT_STREQ(PATH_STARTSWITH_SET("/foo/bar2", "/foo/quux", "", "/zzz"), NULL);
 
        ASSERT_STREQ(PATH_STARTSWITH_SET("/foo2/bar", "/foo/quux", "/foo/bar", "/zzz"), NULL);
        ASSERT_STREQ(PATH_STARTSWITH_SET("/foo2/bar", "/foo/quux", "/foo/", "/zzz"), NULL);
        ASSERT_STREQ(PATH_STARTSWITH_SET("/foo2/bar", "/foo/quux", "/foo", "/zzz"), NULL);
        ASSERT_STREQ(PATH_STARTSWITH_SET("/foo2/bar", "/foo/quux", "/", "/zzz"), "foo2/bar");
        ASSERT_STREQ(PATH_STARTSWITH_SET("/foo2/bar", "/foo/quux", "", "/zzz"), NULL);
}
 
TEST(path_startswith_strv) {
        ASSERT_STREQ(path_startswith_strv("/foo/bar", STRV_MAKE("/foo/quux", "/foo/bar", "/zzz")), "");
        ASSERT_STREQ(path_startswith_strv("/foo/bar", STRV_MAKE("/foo/quux", "/foo/", "/zzz")), "bar");
        ASSERT_STREQ(path_startswith_strv("/foo/bar", STRV_MAKE("/foo/quux", "/foo", "/zzz")), "bar");
        ASSERT_STREQ(path_startswith_strv("/foo/bar", STRV_MAKE("/foo/quux", "/", "/zzz")), "foo/bar");
        ASSERT_STREQ(path_startswith_strv("/foo/bar", STRV_MAKE("/foo/quux", "", "/zzz")), NULL);
 
        ASSERT_STREQ(path_startswith_strv("/foo/bar2", STRV_MAKE("/foo/quux", "/foo/bar", "/zzz")), NULL);
        ASSERT_STREQ(path_startswith_strv("/foo/bar2", STRV_MAKE("/foo/quux", "/foo/", "/zzz")), "bar2");
        ASSERT_STREQ(path_startswith_strv("/foo/bar2", STRV_MAKE("/foo/quux", "/foo", "/zzz")), "bar2");
        ASSERT_STREQ(path_startswith_strv("/foo/bar2", STRV_MAKE("/foo/quux", "/", "/zzz")), "foo/bar2");
        ASSERT_STREQ(path_startswith_strv("/foo/bar2", STRV_MAKE("/foo/quux", "", "/zzz")), NULL);
 
        ASSERT_STREQ(path_startswith_strv("/foo2/bar", STRV_MAKE("/foo/quux", "/foo/bar", "/zzz")), NULL);
        ASSERT_STREQ(path_startswith_strv("/foo2/bar", STRV_MAKE("/foo/quux", "/foo/", "/zzz")), NULL);
        ASSERT_STREQ(path_startswith_strv("/foo2/bar", STRV_MAKE("/foo/quux", "/foo", "/zzz")), NULL);
        ASSERT_STREQ(path_startswith_strv("/foo2/bar", STRV_MAKE("/foo/quux", "/", "/zzz")), "foo2/bar");
        ASSERT_STREQ(path_startswith_strv("/foo2/bar", STRV_MAKE("/foo/quux", "", "/zzz")), NULL);
}
 
static void test_path_glob_can_match_one(const char *pattern, const char *prefix, const char *expected) {
        _cleanup_free_ char *result = NULL;
 
        log_debug("%s(%s, %s, %s)", __func__, pattern, prefix, strnull(expected));
 
        assert_se(path_glob_can_match(pattern, prefix, &result) == !!expected);
        ASSERT_STREQ(result, expected);
}
 
TEST(path_glob_can_match) {
        test_path_glob_can_match_one("/foo/hoge/aaa", "/foo/hoge/aaa/bbb", NULL);
        test_path_glob_can_match_one("/foo/hoge/aaa", "/foo/hoge/aaa", "/foo/hoge/aaa");
        test_path_glob_can_match_one("/foo/hoge/aaa", "/foo/hoge", "/foo/hoge/aaa");
        test_path_glob_can_match_one("/foo/hoge/aaa", "/foo", "/foo/hoge/aaa");
        test_path_glob_can_match_one("/foo/hoge/aaa", "/", "/foo/hoge/aaa");
 
        test_path_glob_can_match_one("/foo/*/aaa", "/foo/hoge/aaa/bbb", NULL);
        test_path_glob_can_match_one("/foo/*/aaa", "/foo/hoge/aaa", "/foo/hoge/aaa");
        test_path_glob_can_match_one("/foo/*/aaa", "/foo/hoge", "/foo/hoge/aaa");
        test_path_glob_can_match_one("/foo/*/aaa", "/foo", "/foo/*/aaa");
        test_path_glob_can_match_one("/foo/*/aaa", "/", "/foo/*/aaa");
 
        test_path_glob_can_match_one("/foo/*/*/aaa", "/foo/xxx/yyy/aaa/bbb", NULL);
        test_path_glob_can_match_one("/foo/*/*/aaa", "/foo/xxx/yyy/aaa", "/foo/xxx/yyy/aaa");
        test_path_glob_can_match_one("/foo/*/*/aaa", "/foo/xxx/yyy", "/foo/xxx/yyy/aaa");
        test_path_glob_can_match_one("/foo/*/*/aaa", "/foo/xxx", "/foo/xxx/*/aaa");
        test_path_glob_can_match_one("/foo/*/*/aaa", "/foo", "/foo/*/*/aaa");
        test_path_glob_can_match_one("/foo/*/*/aaa", "/", "/foo/*/*/aaa");
 
        test_path_glob_can_match_one("/foo/*/aaa/*", "/foo/xxx/aaa/bbb/ccc", NULL);
        test_path_glob_can_match_one("/foo/*/aaa/*", "/foo/xxx/aaa/bbb", "/foo/xxx/aaa/bbb");
        test_path_glob_can_match_one("/foo/*/aaa/*", "/foo/xxx/ccc", NULL);
        test_path_glob_can_match_one("/foo/*/aaa/*", "/foo/xxx/aaa", "/foo/xxx/aaa/*");
        test_path_glob_can_match_one("/foo/*/aaa/*", "/foo/xxx", "/foo/xxx/aaa/*");
        test_path_glob_can_match_one("/foo/*/aaa/*", "/foo", "/foo/*/aaa/*");
        test_path_glob_can_match_one("/foo/*/aaa/*", "/", "/foo/*/aaa/*");
}
 
TEST(print_MAX) {
        log_info("PATH_MAX=%zu\n"
                 "FILENAME_MAX=%zu\n"
                 "NAME_MAX=%zu",
                 (size_t) PATH_MAX,
                 (size_t) FILENAME_MAX,
                 (size_t) NAME_MAX);
 
        assert_cc(FILENAME_MAX == PATH_MAX);
}
 
TEST(path_implies_directory) {
        assert_se(!path_implies_directory(NULL));
        assert_se(!path_implies_directory(""));
        assert_se(path_implies_directory("/"));
        assert_se(path_implies_directory("////"));
        assert_se(path_implies_directory("////.///"));
        assert_se(path_implies_directory("////./"));
        assert_se(path_implies_directory("////."));
        assert_se(path_implies_directory("."));
        assert_se(path_implies_directory("./"));
        assert_se(path_implies_directory("/."));
        assert_se(path_implies_directory(".."));
        assert_se(path_implies_directory("../"));
        assert_se(path_implies_directory("/.."));
        assert_se(!path_implies_directory("a"));
        assert_se(!path_implies_directory("ab"));
        assert_se(path_implies_directory("ab/"));
        assert_se(!path_implies_directory("ab/a"));
        assert_se(path_implies_directory("ab/a/"));
        assert_se(path_implies_directory("ab/a/.."));
        assert_se(path_implies_directory("ab/a/."));
        assert_se(path_implies_directory("ab/a//"));
}
 
DEFINE_TEST_MAIN(LOG_DEBUG);