diff options
Diffstat (limited to 't/helper/test-path-utils.c')
| -rw-r--r-- | t/helper/test-path-utils.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c index bf0e23ed50..086238c826 100644 --- a/t/helper/test-path-utils.c +++ b/t/helper/test-path-utils.c @@ -1,3 +1,6 @@ +#define USE_THE_REPOSITORY_VARIABLE +#define DISABLE_SIGN_COMPARE_WARNINGS + #include "test-tool.h" #include "abspath.h" #include "environment.h" @@ -38,7 +41,7 @@ static void normalize_argv_string(const char **var, const char *input) *var = input; if (*var && (**var == '<' || **var == '(')) - die("Bad value: %s\n", input); + die("Bad value: %s", input); } struct test_data { @@ -78,12 +81,12 @@ static int test_function(struct test_data *data, char *(*func)(char *input), if (!strcmp(to, data[i].to)) continue; if (!data[i].alternative) - error("FAIL: %s(%s) => '%s' != '%s'\n", + error("FAIL: %s(%s) => '%s' != '%s'", funcname, data[i].from, to, data[i].to); else if (!strcmp(to, data[i].alternative)) continue; else - error("FAIL: %s(%s) => '%s' != '%s', '%s'\n", + error("FAIL: %s(%s) => '%s' != '%s', '%s'", funcname, data[i].from, to, data[i].to, data[i].alternative); failed = 1; @@ -320,6 +323,19 @@ int cmd__path_utils(int argc, const char **argv) return 0; } + if (argc >= 2 && !strcmp(argv[1], "readlink")) { + struct strbuf target = STRBUF_INIT; + while (argc > 2) { + if (strbuf_readlink(&target, argv[2], 0) < 0) + die_errno("cannot read link at '%s'", argv[2]); + puts(target.buf); + argc--; + argv++; + } + strbuf_release(&target); + return 0; + } + if (argc >= 2 && !strcmp(argv[1], "absolute_path")) { while (argc > 2) { puts(absolute_path(argv[2])); @@ -501,6 +517,25 @@ int cmd__path_utils(int argc, const char **argv) return !!res; } + if (argc > 1 && !strcmp(argv[1], "is_path_owned_by_current_user")) { + int res = 0; + + for (int i = 2; i < argc; i++) { + struct strbuf buf = STRBUF_INIT; + + if (is_path_owned_by_current_user(argv[i], &buf)) + printf("'%s' is owned by current SID\n", argv[i]); + else { + printf("'%s' is not owned by current SID: %s\n", argv[i], buf.buf); + res = 1; + } + + strbuf_release(&buf); + } + + return res; + } + fprintf(stderr, "%s: unknown function name: %s\n", argv[0], argv[1] ? argv[1] : "(there was none)"); return 1; |
