Skip to content

Commit 719c3da

Browse files
committed
test-lib: clarify and tighten SANITY
f400e51 (test-lib.sh: set prerequisite SANITY by testing what we really need, 2015-01-27) improved the way SANITY prerequisite was determined, but made the resulting code (incorrectly) imply that SANITY is all about effects of permission bits of the containing directory has on the files contained in it by the comment it added, its log message and the actual tests. State what SANITY is about more clearly in the comment, and test that a file whose permission bits says should be unreadble truly cannot be read. Signed-off-by: Junio C Hamano <[email protected]>
1 parent f400e51 commit 719c3da

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

t/test-lib.sh

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

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.
1000+
# SANITY is about "can you correctly predict what the filesystem would
1001+
# do by only looking at the permission bits of the files and
1002+
# directories?" A typical example of !SANITY is running the test
1003+
# suite as root, where a test may expect "chmod -r file && cat file"
1004+
# to fail because file is supposed to be unreadable after a successful
1005+
# chmod. In an environment (i.e. combination of what filesystem is
1006+
# being used and who is running the tests) that lacks SANITY, you may
1007+
# be able to delete or create a file when the containing directory
1008+
# doesn't have write permissions, or access a file even if the
1009+
# containing directory doesn't have read or execute permissions.
1010+
10051011
test_lazy_prereq SANITY '
10061012
mkdir SANETESTD.1 SANETESTD.2 &&
10071013
10081014
chmod +w SANETESTD.1 SANETESTD.2 &&
10091015
>SANETESTD.1/x 2>SANETESTD.2/x &&
10101016
chmod -w SANETESTD.1 &&
1017+
chmod -r SANETESTD.1/x &&
10111018
chmod -rx SANETESTD.2 ||
10121019
error "bug in test sript: cannot prepare SANETESTD"
10131020
1021+
! test -r SANETESTD.1/x &&
10141022
! rm SANETESTD.1/x && ! test -f SANETESTD.2/x
10151023
status=$?
10161024

0 commit comments

Comments
 (0)