aboutsummaryrefslogtreecommitdiff
path: root/t/test-lib.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-03-05 13:12:52 -0800
committerJunio C Hamano <gitster@pobox.com>2015-03-05 13:12:52 -0800
commit8fd37b3862f6a567db3830bf0b50def231a76c41 (patch)
tree68e4944e0c8d3fac8c6cc928d630e27de601fdab /t/test-lib.sh
parent8004647a217c26f708bce2aa26ed94a4a0ed575d (diff)
parentf400e51c13eb4143e420d41d9b415d4f5ddbdb85 (diff)
downloadgit-8fd37b3862f6a567db3830bf0b50def231a76c41.tar.gz
git-8fd37b3862f6a567db3830bf0b50def231a76c41.tar.xz
Merge branch 'jk/sanity' into maint
The tests that wanted to see that file becomes unreadable after running "chmod a-r file", and the tests that wanted to make sure it is not run as root, we used "can we write into the / directory?" as a cheap substitute, but on some platforms that is not a good heuristics. The tests and their prerequisites have been updated to check what they really require. * jk/sanity: test-lib.sh: set prerequisite SANITY by testing what we really need tests: correct misuses of POSIXPERM t/lib-httpd: switch SANITY check for NOT_ROOT
Diffstat (limited to 't/test-lib.sh')
-rw-r--r--t/test-lib.sh30
1 files changed, 27 insertions, 3 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh
index bb1402de9..c09677802 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1031,9 +1031,33 @@ test_lazy_prereq USR_BIN_TIME '
test -x /usr/bin/time
'
-# When the tests are run as root, permission tests will report that
-# things are writable when they shouldn't be.
-test -w / || test_set_prereq SANITY
+test_lazy_prereq NOT_ROOT '
+ uid=$(id -u) &&
+ 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.
+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 -rx SANETESTD.2 ||
+ error "bug in test sript: cannot prepare SANETESTD"
+
+ ! rm SANETESTD.1/x && ! test -f SANETESTD.2/x
+ status=$?
+
+ chmod +rwx SANETESTD.1 SANETESTD.2 &&
+ rm -rf SANETESTD.1 SANETESTD.2 ||
+ error "bug in test sript: cannot clean SANETESTD"
+ return $status
+'
GIT_UNZIP=${GIT_UNZIP:-unzip}
test_lazy_prereq UNZIP '