diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2023-02-27 21:49:13 +0000 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2023-02-27 21:52:33 +0000 |
commit | 5c1d7649100175fef2c74ec66e7cb1e57440d89d (patch) | |
tree | 8cccd7717a91e4ca5c123d6ebf9045b2ef83c384 /tests/util/path.c | |
parent | 44d3372e4097d01a279fa51bbc2e0c8672ef25f7 (diff) | |
download | libgit2-5c1d7649100175fef2c74ec66e7cb1e57440d89d.tar.gz |
fs_path: let root run the ownership tests
The `git_fs_path_owner_is_current_user` expects the root dir on unix
(`/`) to be owned by a non-current user. This makes sense unless root
(or euid == 0) is running the tests, which often happens during distro
build / packaging scripts. Allow them to run the tests.
Diffstat (limited to 'tests/util/path.c')
-rw-r--r-- | tests/util/path.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/util/path.c b/tests/util/path.c index 2c39e0887..02ec42fce 100644 --- a/tests/util/path.c +++ b/tests/util/path.c @@ -2,6 +2,10 @@ #include "futils.h" #include "fs_path.h" +#ifndef GIT_WIN32 +# include <unistd.h> +#endif + static char *path_save; void test_path__initialize(void) @@ -757,7 +761,7 @@ void test_path__validate_current_user_ownership(void) cl_git_fail(git_fs_path_owner_is_current_user(&is_cur, "c:\\path\\does\\not\\exist")); #else cl_git_pass(git_fs_path_owner_is_current_user(&is_cur, "/")); - cl_assert_equal_i(is_cur, 0); + cl_assert_equal_i(is_cur, (geteuid() == 0)); cl_git_fail(git_fs_path_owner_is_current_user(&is_cur, "/path/does/not/exist")); #endif |