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 37
37
test_done
38
38
fi
39
39
40
- if ! test_have_prereq SANITY ; then
40
+ if ! test_have_prereq NOT_ROOT ; then
41
41
test_skip_or_die $GIT_TEST_HTTPD \
42
42
" Cannot run httpd tests as root"
43
43
fi
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ test_expect_success POSIXPERM 'run_command reports EACCES' '
34
34
grep "fatal: cannot exec.*hello.sh" err
35
35
'
36
36
37
- test_expect_success POSIXPERM ' unreadable directory in PATH' '
37
+ test_expect_success POSIXPERM,SANITY ' unreadable directory in PATH' '
38
38
mkdir local-command &&
39
39
test_when_finished "chmod u+rwx local-command && rm -fr local-command" &&
40
40
git config alias.nitfol "!echo frotz" &&
Original file line number Diff line number Diff line change @@ -98,8 +98,16 @@ test_foobar_foobar() {
98
98
'
99
99
}
100
100
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 /"
103
111
test_done
104
112
fi
105
113
@@ -108,8 +116,9 @@ if [ "$IKNOWWHATIAMDOING" != "YES" ]; then
108
116
test_done
109
117
fi
110
118
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"
113
122
test_done
114
123
fi
115
124
Original file line number Diff line number Diff line change @@ -1031,9 +1031,33 @@ test_lazy_prereq USR_BIN_TIME '
1031
1031
test -x /usr/bin/time
1032
1032
'
1033
1033
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
+ '
1037
1061
1038
1062
GIT_UNZIP=${GIT_UNZIP:- unzip}
1039
1063
test_lazy_prereq UNZIP '
You can’t perform that action at this time.
0 commit comments