Add utility function to append root to path

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2014-07-26 15:08:42 -04:00
parent 60731f32f1
commit 0c6ea3a4e2
6 changed files with 57 additions and 62 deletions
+15
View File
@@ -162,6 +162,20 @@ static void test_prefixes(void) {
}
}
static void test_path_join(void) {
assert_se(streq(path_join("/root", "/a/b", "/c"), "/root/a/b/c"));
assert_se(streq(path_join("/root", "a/b", "c"), "/root/a/b/c"));
assert_se(streq(path_join("/root", "/a/b", "c"), "/root/a/b/c"));
assert_se(streq(path_join("/root", "/", "c"), "/root//c"));
assert_se(streq(path_join("/root", "/", NULL), "/root/"));
assert_se(streq(path_join(NULL, "/a/b", "/c"), "/a/b/c"));
assert_se(streq(path_join(NULL, "a/b", "c"), "a/b/c"));
assert_se(streq(path_join(NULL, "/a/b", "c"), "/a/b/c"));
assert_se(streq(path_join(NULL, "/", "c"), "//c"));
assert_se(streq(path_join(NULL, "/", NULL), "/"));
}
static void test_fsck_exists(void) {
/* Ensure we use a sane default for PATH. */
unsetenv("PATH");
@@ -225,6 +239,7 @@ int main(int argc, char **argv) {
test_path();
test_find_binary(argv[0]);
test_prefixes();
test_path_join();
test_fsck_exists();
test_make_relative();
test_strv_resolve();