Skip to content

Commit f400e51

Browse files
tboegigitster
authored andcommitted
test-lib.sh: set prerequisite SANITY by testing what we really need
What we wanted out of the SANITY precondition is that the filesystem behaves sensibly with permission bits settings. - You should not be able to remove a file in a read-only directory, - You should not be able to tell if a file in a directory exists if the directory lacks read or execute permission bits. We used to cheat by approximating that condition with "is the / writable?" test and/or "are we running as root?" test. Neither test is sufficient or appropriate in environments like Cygwin. Signed-off-by: Torsten Bögershausen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eae6953 commit f400e51

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

t/test-lib.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,9 +997,28 @@ test_lazy_prereq NOT_ROOT '
997997
test "$uid" != 0
998998
'
999999

1000-
# When the tests are run as root, permission tests will report that
1001-
# things are writable when they shouldn't be.
1002-
test -w / || test_set_prereq SANITY
1000+
# On a filesystem that lacks SANITY, a file can be deleted even if
1001+
# the containing directory doesn't have write permissions, or a file
1002+
# can be accessed even if the containing directory doesn't have read
1003+
# or execute permissions, causing our tests that validate that Git
1004+
# works sensibly in such situations.
1005+
test_lazy_prereq SANITY '
1006+
mkdir SANETESTD.1 SANETESTD.2 &&
1007+
1008+
chmod +w SANETESTD.1 SANETESTD.2 &&
1009+
>SANETESTD.1/x 2>SANETESTD.2/x &&
1010+
chmod -w SANETESTD.1 &&
1011+
chmod -rx SANETESTD.2 ||
1012+
error "bug in test sript: cannot prepare SANETESTD"
1013+
1014+
! rm SANETESTD.1/x && ! test -f SANETESTD.2/x
1015+
status=$?
1016+
1017+
chmod +rwx SANETESTD.1 SANETESTD.2 &&
1018+
rm -rf SANETESTD.1 SANETESTD.2 ||
1019+
error "bug in test sript: cannot clean SANETESTD"
1020+
return $status
1021+
'
10031022

10041023
GIT_UNZIP=${GIT_UNZIP:-unzip}
10051024
test_lazy_prereq UNZIP '

0 commit comments

Comments
 (0)