All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] test-lib.sh: Dynamic test for the prerequisite SANITY
@ 2015-01-27 15:39 Torsten Bögershausen
  2015-01-27 19:53 ` Chris Packham
  2015-01-27 22:20 ` Junio C Hamano
  0 siblings, 2 replies; 7+ messages in thread
From: Torsten Bögershausen @ 2015-01-27 15:39 UTC (permalink / raw)
  To: git; +Cc: tboegi

The SANITY precondition was not set when running as root,
but this is not 100% reliable for CYGWIN:

A file may be allowed to be deleted when the containing
directory does not have write permissions.

See
https://technet.microsoft.com/en-us/library/bb463216.aspx
"...In UNIX, the write permission bit on a directory permits both
the creation and removal of new files or sub-directories in the directory.
On Windows, the Write_Data access right controls the creation of new
sub-files and the Delete_Child access right controls the deletion. ...."

We may argue that the translation of the POSIX write permission bit
into "Windows access rights" can be improved in CYGWIN.

A dynamic test handles all cases: when the sequence
$ mkdir SANETESTD &&
$ chmod +w SANETESTD &&
$ >SANETESTD/x &&
$ ! rm SANETESTD/x
succeeds the prerequisite SANITY is true.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
---
 t/test-lib.sh | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 93f7cad..887e986 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1038,8 +1038,23 @@ test_lazy_prereq NOT_ROOT '
 
 # When the tests are run as root, permission tests will report that
 # things are writable when they shouldn't be.
+# Special check for CYGWIN (or Windows in general):
+# A file can be deleted, even if the containing directory does'nt
+# have write permissions
 test_lazy_prereq SANITY '
-	test_have_prereq POSIXPERM,NOT_ROOT
+	mkdir SANETESTD &&
+	chmod +w SANETESTD &&
+	>SANETESTD/x &&
+	chmod -w SANETESTD ||
+	error "bug in test sript: cannot prepare SANETESTD"
+
+	! rm SANETESTD/x
+	status=$?
+
+	chmod +w SANETESTD &&
+	rm -rf SANETESTD ||
+	error "bug in test sript: cannot clean SANETESTD"
+	return $status
 '
 
 GIT_UNZIP=${GIT_UNZIP:-unzip}
-- 
2.2.0.rc1.26.g3e3a70d

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-01-29  2:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-27 15:39 [PATCH 2/2] test-lib.sh: Dynamic test for the prerequisite SANITY Torsten Bögershausen
2015-01-27 19:53 ` Chris Packham
2015-01-27 22:20 ` Junio C Hamano
2015-01-28  8:28   ` Torsten Bögershausen
2015-01-28 17:38     ` Junio C Hamano
2015-01-28 19:19       ` Torsten Bögershausen
2015-01-28 20:38         ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.