git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] test-lib.sh: Dynamic test for the prerequisite SANITY

From
Torsten Bögershausen <tboegi@web.de>
Date
Jan 27, 2015, 15:39 UTC
Message-ID
<54C7B115.7020405@web.de>

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
Next: Chris Packham
Message 1 of 7 in “test-lib.sh: Dynamic test for the prerequisite SANITY”
  1. 2/2 test-lib.sh: Dynamic test for the prerequisite SANITYTorsten Bögershausen, Jan 27, 2015
  2. Chris PackhamJan 27, 2015
  3. Junio C HamanoJan 27, 2015
  4. Torsten BögershausenJan 28, 2015
  5. Junio C HamanoJan 28, 2015
  6. Torsten BögershausenJan 28, 2015
  7. Junio C HamanoJan 28, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.