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

Re: t5539 broken under Mac OS X

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 15, 2015, 20:29 UTC
Message-ID
<xmqqwq4n6b4c.fsf@gitster.dls.corp.google.com>
In-Reply-To
<064010B3-BC58-42F2-B5C0-DAADAA59B87D@gmail.com>
"Kyle J. McKay" <mackyle@gmail.com> writes:
Show 8 quoted lines
> I ran into this problem.  It seems like (at least on older Mac OS X)  
> that the root directory is created like so:
>
>    drwxrwxr-t  39 root  admin  /
>
> And since the first (and likely only user) on Mac OS X is a member of  
> the admin group, the SANITY test fails and complains even though  
> you're not running as root (the failure message is misleading).

The design choice Mac OS X makes around filesystems may deserve the !SANITY label ;-) but we may want to tighten the check for SANITY, or better yet, rethink the interaction between POSIXPERM and SANITY.

What we want to express with SANITY is:
	On this system, if the user who is running the test
        does not have write permission to a file, write to such a
        file would fail.

So running our tests as a non-root admin user should be labeled as being sane. We just use a more expedient "if you can write into the root directory, you must be root, asit is crazy to allow non-root user to 'mv /etc /foo && mkdir /etc && write /etc/passwd'" heuristics which is old-school.

This should not be the final patch (I think it should become a lazy prereq as it does a lot more), but just for testing, how does this look?

 t/test-lib.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index bb1402d..cdafab5 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1033,7 +1033,16 @@ test_lazy_prereq 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
+if test_have_prereq POSIXPERM &&
+	! test -w / &&
+	>sanitytest &&
+	chmod a= sanitytest &&
+	! (>sanitytest) 2>/dev/null &&
+	chmod +w sanitytest &&
+	rm -f sanitytest
+then
+	test_set_prereq SANITY
+fi
 
 GIT_UNZIP=${GIT_UNZIP:-unzip}
 test_lazy_prereq UNZIP '
Previous: Kyle J. McKayNext: Jeff King
Message 6 of 33 in “t5539 broken under Mac OS X”
  1. Torsten BögershausenJan 14, 2015
  2. Junio C HamanoJan 14, 2015
  3. Torsten BögershausenJan 14, 2015
  4. Jeff KingJan 14, 2015
  5. Kyle J. McKayJan 15, 2015
  6. Junio C HamanoJan 15, 2015
  7. Jeff KingJan 15, 2015
  8. Junio C HamanoJan 15, 2015
  9. Jeff KingJan 15, 2015
  10. Junio C HamanoJan 16, 2015
  11. t/lib-httpd: switch SANITY check for NOT_ROOTJeff King, Jan 16, 2015
  12. Kyle J. McKayJan 16, 2015
  13. Jeff KingJan 16, 2015
  14. Jeff KingJan 16, 2015
  15. Junio C HamanoJan 16, 2015
  16. Junio C HamanoJan 16, 2015
  17. Torsten BögershausenJan 17, 2015
  18. Junio C HamanoJan 21, 2015
  19. Torsten BögershausenJan 22, 2015
  20. Junio C HamanoJan 22, 2015
  21. Torsten BögershausenJan 23, 2015
  22. Junio C HamanoFeb 12, 2015
  23. Torsten BögershausenFeb 14, 2015
  24. Junio C HamanoFeb 15, 2015
  25. Torsten BögershausenJan 23, 2015
  26. Junio C HamanoJan 23, 2015
  27. Johannes SchindelinJan 24, 2015
  28. Kyle J. McKayJan 16, 2015
  29. Kyle J. McKayJan 16, 2015
  30. Achim GratzJan 16, 2015
  31. Erik Faye-LundJan 27, 2015
  32. Junio C HamanoJan 27, 2015
  33. Erik Faye-LundJan 27, 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.