Commit 5c1d7649 by Edward Thomson

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.
parent 44d3372e
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "futils.h" #include "futils.h"
#include "fs_path.h" #include "fs_path.h"
#ifndef GIT_WIN32
# include <unistd.h>
#endif
static char *path_save; static char *path_save;
void test_path__initialize(void) void test_path__initialize(void)
...@@ -757,7 +761,7 @@ void test_path__validate_current_user_ownership(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")); cl_git_fail(git_fs_path_owner_is_current_user(&is_cur, "c:\\path\\does\\not\\exist"));
#else #else
cl_git_pass(git_fs_path_owner_is_current_user(&is_cur, "/")); 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")); cl_git_fail(git_fs_path_owner_is_current_user(&is_cur, "/path/does/not/exist"));
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment