summaryrefslogtreecommitdiff
path: root/t/test-lib.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-01-19 14:09:37 -0800
committerJunio C Hamano <gitster@pobox.com>2016-01-19 14:18:20 -0800
commit719c3da2f183cfc751bb801a2c903f2eb015d131 (patch)
tree66ff582e6f3ae336f03f05577082f06199c2906d /t/test-lib.sh
parentf400e51c13eb4143e420d41d9b415d4f5ddbdb85 (diff)
downloadgit-719c3da2f183cfc751bb801a2c903f2eb015d131.tar.gz
test-lib: clarify and tighten SANITYjk/sanity
f400e51c (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 <gitster@pobox.com>
Diffstat (limited to 't/test-lib.sh')
-rw-r--r--t/test-lib.sh18
1 files changed, 13 insertions, 5 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 446d8d5a1d..68c31aedb8 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -997,20 +997,28 @@ test_lazy_prereq NOT_ROOT '
test "$uid" != 0
'
-# On a filesystem that lacks SANITY, a file can be deleted even if
-# the containing directory doesn't have write permissions, or a file
-# can be accessed even if the containing directory doesn't have read
-# or execute permissions, causing our tests that validate that Git
-# works sensibly in such situations.
+# SANITY is about "can you correctly predict what the filesystem would
+# do by only looking at the permission bits of the files and
+# directories?" A typical example of !SANITY is running the test
+# suite as root, where a test may expect "chmod -r file && cat file"
+# to fail because file is supposed to be unreadable after a successful
+# chmod. In an environment (i.e. combination of what filesystem is
+# being used and who is running the tests) that lacks SANITY, you may
+# be able to delete or create a file when the containing directory
+# doesn't have write permissions, or access a file even if the
+# containing directory doesn't have read or execute permissions.
+
test_lazy_prereq SANITY '
mkdir SANETESTD.1 SANETESTD.2 &&
chmod +w SANETESTD.1 SANETESTD.2 &&
>SANETESTD.1/x 2>SANETESTD.2/x &&
chmod -w SANETESTD.1 &&
+ chmod -r SANETESTD.1/x &&
chmod -rx SANETESTD.2 ||
error "bug in test sript: cannot prepare SANETESTD"
+ ! test -r SANETESTD.1/x &&
! rm SANETESTD.1/x && ! test -f SANETESTD.2/x
status=$?