Skip to content

Commit 5c1d764

Browse files
committed
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.
1 parent 44d3372 commit 5c1d764

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/util/path.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#include "futils.h"
33
#include "fs_path.h"
44

5+
#ifndef GIT_WIN32
6+
# include <unistd.h>
7+
#endif
8+
59
static char *path_save;
610

711
void test_path__initialize(void)
@@ -757,7 +761,7 @@ void test_path__validate_current_user_ownership(void)
757761
cl_git_fail(git_fs_path_owner_is_current_user(&is_cur, "c:\\path\\does\\not\\exist"));
758762
#else
759763
cl_git_pass(git_fs_path_owner_is_current_user(&is_cur, "/"));
760-
cl_assert_equal_i(is_cur, 0);
764+
cl_assert_equal_i(is_cur, (geteuid() == 0));
761765

762766
cl_git_fail(git_fs_path_owner_is_current_user(&is_cur, "/path/does/not/exist"));
763767
#endif

0 commit comments

Comments
 (0)