File tree Expand file tree Collapse file tree 4 files changed +42
-9
lines changed
Expand file tree Collapse file tree 4 files changed +42
-9
lines changed Original file line number Diff line number Diff line change 3737 test_done
3838fi
3939
40- if ! test_have_prereq SANITY ; then
40+ if ! test_have_prereq NOT_ROOT ; then
4141 test_skip_or_die $GIT_TEST_HTTPD \
4242 " Cannot run httpd tests as root"
4343fi
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ test_expect_success POSIXPERM 'run_command reports EACCES' '
3434 grep "fatal: cannot exec.*hello.sh" err
3535'
3636
37- test_expect_success POSIXPERM ' unreadable directory in PATH' '
37+ test_expect_success POSIXPERM,SANITY ' unreadable directory in PATH' '
3838 mkdir local-command &&
3939 test_when_finished "chmod u+rwx local-command && rm -fr local-command" &&
4040 git config alias.nitfol "!echo frotz" &&
Original file line number Diff line number Diff line change @@ -98,8 +98,16 @@ test_foobar_foobar() {
9898 '
9999}
100100
101- if ! test_have_prereq POSIXPERM || ! [ -w / ]; then
102- skip_all=" Dangerous test skipped. Read this test if you want to execute it"
101+ if ! test -w /
102+ then
103+ skip_all=" Test requiring writable / skipped. Read this test if you want to run it"
104+ test_done
105+ fi
106+
107+ if test -e /refs || test -e /objects || test -e /info || test -e /hooks ||
108+ test -e /.git || test -e /foo || test -e /me
109+ then
110+ skip_all=" Skip test that clobbers existing files in /"
103111 test_done
104112fi
105113
@@ -108,8 +116,9 @@ if [ "$IKNOWWHATIAMDOING" != "YES" ]; then
108116 test_done
109117fi
110118
111- if [ " $UID " = 0 ]; then
112- skip_all=" No you can't run this with root"
119+ if ! test_have_prereq NOT_ROOT
120+ then
121+ skip_all=" No you can't run this as root"
113122 test_done
114123fi
115124
Original file line number Diff line number Diff line change @@ -1031,9 +1031,33 @@ test_lazy_prereq USR_BIN_TIME '
10311031 test -x /usr/bin/time
10321032'
10331033
1034- # When the tests are run as root, permission tests will report that
1035- # things are writable when they shouldn't be.
1036- test -w / || test_set_prereq SANITY
1034+ test_lazy_prereq NOT_ROOT '
1035+ uid=$(id -u) &&
1036+ test "$uid" != 0
1037+ '
1038+
1039+ # On a filesystem that lacks SANITY, a file can be deleted even if
1040+ # the containing directory doesn't have write permissions, or a file
1041+ # can be accessed even if the containing directory doesn't have read
1042+ # or execute permissions, causing our tests that validate that Git
1043+ # works sensibly in such situations.
1044+ test_lazy_prereq SANITY '
1045+ mkdir SANETESTD.1 SANETESTD.2 &&
1046+
1047+ chmod +w SANETESTD.1 SANETESTD.2 &&
1048+ >SANETESTD.1/x 2>SANETESTD.2/x &&
1049+ chmod -w SANETESTD.1 &&
1050+ chmod -rx SANETESTD.2 ||
1051+ error "bug in test sript: cannot prepare SANETESTD"
1052+
1053+ ! rm SANETESTD.1/x && ! test -f SANETESTD.2/x
1054+ status=$?
1055+
1056+ chmod +rwx SANETESTD.1 SANETESTD.2 &&
1057+ rm -rf SANETESTD.1 SANETESTD.2 ||
1058+ error "bug in test sript: cannot clean SANETESTD"
1059+ return $status
1060+ '
10371061
10381062GIT_UNZIP=${GIT_UNZIP:- unzip}
10391063test_lazy_prereq UNZIP '
You can’t perform that action at this time.
0 commit comments