{"thread":{"id":"24630","subject":"[PATCH] tests: A new test prereq for testing chmod -w as root","startedAt":"2010-08-04T15:00:26Z","lastAt":"2010-08-09T19:02:13Z","messageCount":7,"participants":["Ævar Arnfjörð Bjarmason","Junio C Hamano","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"147114","messageId":"1280934026-25658-1-git-send-email-avarab@gmail.com","threadId":"24630","inReplyTo":null,"subject":"[PATCH] tests: A new test prereq for testing chmod -w as root","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-08-04T15:00:26Z","receivedAt":"2010-08-04T15:00:26Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Some tests depend on not being able to read files after chmod -w. This\ndoesn't work when running the tests as root.\n\nChange test-lib.sh to test if this works, and if so it sets a new\nCHMOD_0000 test prerequisite. The tests that use this previously\nfailed when run under root.\n\nThere was already a test for this in t3600-rm.sh added by Junio C\nHamano in 2283645b85 in 2006. That check now uses the new CHMOD_0000\nprerequisite.\n\nThere are also two other prerequisites, \"POSIXPERM_AND_CHMOD_0000\" and\n\"SYMLINKS_AND_CHMOD_0000\". They're being used for tests that failed\nand already depended on POSIXPERM or SYMLINKS. They're possibly\nredundant, but I don't have access to a system without POSIX\npermissions or symlinks so I couldn't test that.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t0001-init.sh             |    2 +-\n t/t0004-unwritable.sh       |    8 ++++----\n t/t1004-read-tree-m-u-wf.sh |    2 +-\n t/t3600-rm.sh               |   16 ----------------\n t/t3700-add.sh              |   10 +++++-----\n t/t7300-clean.sh            |    7 +++----\n t/t7508-status.sh           |    2 +-\n t/test-lib.sh               |   14 ++++++++++++++\n 8 files changed, 29 insertions(+), 32 deletions(-)\n\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 7c0a698..7c62582 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -301,7 +301,7 @@ test_expect_success 'init notices EEXIST (2)' '\n \t)\n '\n \n-test_expect_success POSIXPERM 'init notices EPERM' '\n+test_expect_success POSIXPERM_AND_CHMOD_0000 'init notices EPERM' '\n \trm -fr newdir &&\n \t(\n \t\tmkdir newdir &&\ndiff --git a/t/t0004-unwritable.sh b/t/t0004-unwritable.sh\nindex 2342ac5..1299f52 100755\n--- a/t/t0004-unwritable.sh\n+++ b/t/t0004-unwritable.sh\n@@ -15,7 +15,7 @@ test_expect_success setup '\n \n '\n \n-test_expect_success POSIXPERM 'write-tree should notice unwritable repository' '\n+test_expect_success POSIXPERM_AND_CHMOD_0000 'write-tree should notice unwritable repository' '\n \n \t(\n \t\tchmod a-w .git/objects .git/objects/?? &&\n@@ -27,7 +27,7 @@ test_expect_success POSIXPERM 'write-tree should notice unwritable repository' '\n \n '\n \n-test_expect_success POSIXPERM 'commit should notice unwritable repository' '\n+test_expect_success POSIXPERM_AND_CHMOD_0000 'commit should notice unwritable repository' '\n \n \t(\n \t\tchmod a-w .git/objects .git/objects/?? &&\n@@ -39,7 +39,7 @@ test_expect_success POSIXPERM 'commit should notice unwritable repository' '\n \n '\n \n-test_expect_success POSIXPERM 'update-index should notice unwritable repository' '\n+test_expect_success POSIXPERM_AND_CHMOD_0000 'update-index should notice unwritable repository' '\n \n \t(\n \t\techo 6O >file &&\n@@ -52,7 +52,7 @@ test_expect_success POSIXPERM 'update-index should notice unwritable repository'\n \n '\n \n-test_expect_success POSIXPERM 'add should notice unwritable repository' '\n+test_expect_success POSIXPERM_AND_CHMOD_0000 'add should notice unwritable repository' '\n \n \t(\n \t\techo b >file &&\ndiff --git a/t/t1004-read-tree-m-u-wf.sh b/t/t1004-read-tree-m-u-wf.sh\nindex f19b4a2..ceb0fd4 100755\n--- a/t/t1004-read-tree-m-u-wf.sh\n+++ b/t/t1004-read-tree-m-u-wf.sh\n@@ -177,7 +177,7 @@ test_expect_success SYMLINKS 'funny symlink in work tree' '\n \n '\n \n-test_expect_success SYMLINKS 'funny symlink in work tree, un-unlink-able' '\n+test_expect_success SYMLINKS_AND_CHMOD_0000 'funny symlink in work tree, un-unlink-able' '\n \n \trm -fr a b &&\n \tgit reset --hard &&\ndiff --git a/t/t3600-rm.sh b/t/t3600-rm.sh\nindex b514cbb..b26cabd 100755\n--- a/t/t3600-rm.sh\n+++ b/t/t3600-rm.sh\n@@ -28,22 +28,6 @@ embedded' &&\n      git commit -m 'add files with tabs and newlines'\n \"\n \n-# Determine rm behavior\n-# Later we will try removing an unremovable path to make sure\n-# git rm barfs, but if the test is run as root that cannot be\n-# arranged.\n-: >test-file\n-chmod a-w .\n-rm -f test-file 2>/dev/null\n-if test -f test-file\n-then\n-\ttest_set_prereq RO_DIR\n-else\n-\tskip_all='skipping removal failure test (perhaps running as root?)'\n-fi\n-chmod 775 .\n-rm -f test-file\n-\n test_expect_success \\\n     'Pre-check that foo exists and is in index before git rm foo' \\\n     '[ -f foo ] && git ls-files --error-unmatch foo'\ndiff --git a/t/t3700-add.sh b/t/t3700-add.sh\nindex 7d7140d..a0f3e7c 100755\n--- a/t/t3700-add.sh\n+++ b/t/t3700-add.sh\n@@ -179,7 +179,7 @@ test_expect_success 'git add --refresh' '\n \ttest -z \"`git diff-index HEAD -- foo`\"\n '\n \n-test_expect_success POSIXPERM 'git add should fail atomically upon an unreadable file' '\n+test_expect_success POSIXPERM_AND_CHMOD_0000 'git add should fail atomically upon an unreadable file' '\n \tgit reset --hard &&\n \tdate >foo1 &&\n \tdate >foo2 &&\n@@ -190,7 +190,7 @@ test_expect_success POSIXPERM 'git add should fail atomically upon an unreadable\n \n rm -f foo2\n \n-test_expect_success POSIXPERM 'git add --ignore-errors' '\n+test_expect_success POSIXPERM_AND_CHMOD_0000 'git add --ignore-errors' '\n \tgit reset --hard &&\n \tdate >foo1 &&\n \tdate >foo2 &&\n@@ -201,7 +201,7 @@ test_expect_success POSIXPERM 'git add --ignore-errors' '\n \n rm -f foo2\n \n-test_expect_success POSIXPERM 'git add (add.ignore-errors)' '\n+test_expect_success POSIXPERM_AND_CHMOD_0000 'git add (add.ignore-errors)' '\n \tgit config add.ignore-errors 1 &&\n \tgit reset --hard &&\n \tdate >foo1 &&\n@@ -212,7 +212,7 @@ test_expect_success POSIXPERM 'git add (add.ignore-errors)' '\n '\n rm -f foo2\n \n-test_expect_success POSIXPERM 'git add (add.ignore-errors = false)' '\n+test_expect_success POSIXPERM_AND_CHMOD_0000 'git add (add.ignore-errors = false)' '\n \tgit config add.ignore-errors 0 &&\n \tgit reset --hard &&\n \tdate >foo1 &&\n@@ -223,7 +223,7 @@ test_expect_success POSIXPERM 'git add (add.ignore-errors = false)' '\n '\n rm -f foo2\n \n-test_expect_success POSIXPERM '--no-ignore-errors overrides config' '\n+test_expect_success POSIXPERM_AND_CHMOD_0000 '--no-ignore-errors overrides config' '\n        git config add.ignore-errors 1 &&\n        git reset --hard &&\n        date >foo1 &&\ndiff --git a/t/t7300-clean.sh b/t/t7300-clean.sh\nindex 7d8ed68..5533973 100755\n--- a/t/t7300-clean.sh\n+++ b/t/t7300-clean.sh\n@@ -388,16 +388,15 @@ test_expect_success 'core.excludesfile' '\n \n '\n \n-test_expect_success 'removal failure' '\n+test_expect_success CHMOD_0000 'removal failure' '\n \n \tmkdir foo &&\n \ttouch foo/bar &&\n \t(exec <foo/bar &&\n \t chmod 0 foo &&\n-\t test_must_fail git clean -f -d)\n-\n+\t test_must_fail git clean -f -d &&\n+\t chmod 755 foo)\n '\n-chmod 755 foo\n \n test_expect_success 'nested git work tree' '\n \trm -fr foo bar &&\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex a72fe3a..4f85db5 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -793,7 +793,7 @@ test_expect_success 'commit --dry-run submodule summary (--amend)' '\n \ttest_cmp expect output\n '\n \n-test_expect_success POSIXPERM 'status succeeds in a read-only repository' '\n+test_expect_success POSIXPERM_AND_CHMOD_0000 'status succeeds in a read-only repository' '\n \t(\n \t\tchmod a-w .git &&\n \t\t# make dir1/tracked stat-dirty\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex e8f21d5..41052fb 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -886,3 +886,17 @@ test -z \"$NO_PYTHON\" && test_set_prereq PYTHON\n # test whether the filesystem supports symbolic links\n ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS\n rm -f y\n+\n+# test whether we can make read-only files\n+mkdir hla\n+chmod -w hla\n+touch hla/gh >/dev/null 2>&1\n+if ! test -f hla/gh\n+then\n+    test_set_prereq CHMOD_0000\n+    # A hack around not being able to supply more than one\n+    # prerequisite in the test_* functions.\n+    test_have_prereq POSIXPERM && test_set_prereq POSIXPERM_AND_CHMOD_0000\n+    test_have_prereq SYMLINKS  && test_set_prereq SYMLINKS_AND_CHMOD_0000\n+fi\n+rm -rf hla\n-- \n1.7.1\n"},{"id":"147128","messageId":"7veieefaym.fsf@alter.siamese.dyndns.org","threadId":"24630","inReplyTo":"1280934026-25658-1-git-send-email-avarab@gmail.com","subject":"Re: [PATCH] tests: A new test prereq for testing chmod -w as root","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-04T19:13:05Z","receivedAt":"2010-08-04T19:13:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> Some tests depend on not being able to read files after chmod -w. This\n> doesn't work when running the tests as root.\n\nObviously you meant s/read/write/ or \"chmod -r\" ;-)\n\nWe discussed this prerequisite in the past as \"SANITY\", in the dual sense\nthat (1) nobody sane should be running tests as root and (2) for root many\nnormal assumptions programs make do not hold.  If we throw out the former\nby saying that it is safe to run tests under fakeroot, we would need\nsomething like this patch to cover the latter.  The patch is a step in the\nright direction.\n\nHaving said that.\n\nI wonder if we want to be so specific, as your patch does, to single out\n\"you can write even to a-w file\" aspect of rootness, or just want to cover\nthe rootness more broadly so that other rooty conditions like \"if you can\nread even an a-r file, then the assumptions the test makes will not hold\"\nand \"if you can kill other's processes, ...ditto...\" can also be covered\nwith a single prerequisite token.\n\nAlso I think there was a discussion and proposed patch to support more\nthan one prerequisite tokens, concatenated with \",\" or something, like:\n\n    test_expect_success POSIXPERM,SANITY 'notice unwritable repo' '\n        ... test that depends on posixperm and not running\n        ... as root comes here\n    '\n\nso that you don't have to invent permutations of prerequisite tokens.\n\nThanks.\n"},{"id":"147133","messageId":"AANLkTikgVF5JGi2Aacpsv=KE5uXGuzmyEVXgVPrTfkdh@mail.gmail.com","threadId":"24630","inReplyTo":"7veieefaym.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] tests: A new test prereq for testing chmod -w as root","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-08-04T20:30:28Z","receivedAt":"2010-08-04T20:30:28Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Wed, Aug 4, 2010 at 19:13, Junio C Hamano <gitster@pobox.com> wrote:\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>\n>> Some tests depend on not being able to read files after chmod -w. This\n>> doesn't work when running the tests as root.\n>\n> Obviously you meant s/read/write/ or \"chmod -r\" ;-)\n\nYeah. I'll fix that in a future submission. Pending the question of\nwhether there's any interest.\n\n> We discussed this prerequisite in the past as \"SANITY\", in the dual sense\n> that (1) nobody sane should be running tests as root and (2) for root many\n> normal assumptions programs make do not hold.  If we throw out the former\n> by saying that it is safe to run tests under fakeroot, we would need\n> something like this patch to cover the latter.  The patch is a step in the\n> right direction.\n\nI sometimes run stuff like this as root, although obviously not often\nenough to have bumped into this before with Git. But sometimes you\ndon't care about user seperation, e.g. inside a virtual machine.\n\nWhen I bumped into this I was writing a script to run in cron that\nwould build and install pu daily in /usr/local if tests passed. Since\nI needed root to install there I was running the whole script as root,\nit was easier than giving the script permission to sudo or granularly\nadjusting the permissions of /usr/local.\n\nIn any case, seemingly randomly breaking if the tests are run as root\nis a bad thing which should be fixed.\n\n> I wonder if we want to be so specific, as your patch does, to single out\n> \"you can write even to a-w file\" aspect of rootness, or just want to cover\n> the rootness more broadly so that other rooty conditions like \"if you can\n> read even an a-r file, then the assumptions the test makes will not hold\"\n> and \"if you can kill other's processes, ...ditto...\" can also be covered\n> with a single prerequisite token.\n\nWell, in practice it was the one and only thing that broke under\nroot. And it's something that can be compartmentalized easily and\ntested for without cheating and checking if UID == 0.\n\n> Also I think there was a discussion and proposed patch to support more\n> than one prerequisite tokens, concatenated with \",\" or something, like:\n>\n>    test_expect_success POSIXPERM,SANITY 'notice unwritable repo' '\n>        ... test that depends on posixperm and not running\n>        ... as root comes here\n>    '\n>\n> so that you don't have to invent permutations of prerequisite tokens.\n\nI almost implemented something like that when rolling this series. Do\nyou happen to have the Message-ID of the thread or some pertinent\nsearch keywords? Maybe I'll resurrect it. We're using that sort of\nthing in a couple of places.\n\nI didn't implement it because I was worried about handling the 'FOO &&\nBAR' and 'FOO || BAR' cases, and combinations thereof. That's probably\noverthinking it though, AND-ing them together seems to be good enough,\nand simple to do.\n"},{"id":"147134","messageId":"20100804204015.GA2920@burratino","threadId":"24630","inReplyTo":"7veieefaym.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] tests: A new test prereq for testing chmod -w as root","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-04T20:40:15Z","receivedAt":"2010-08-04T20:40:15Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Ævar,\n\nJunio C Hamano wrote:\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n>> Some tests depend on not being able to read files after chmod -w. This\n>> doesn't work when running the tests as root.\n>\n> Obviously you meant s/read/write/ or \"chmod -r\" ;-)\n> \n> We discussed this prerequisite in the past as \"SANITY\"\n[...]\n> Also I think there was a discussion and proposed patch to support more\n> than one prerequisite tokens, concatenated with \",\" or something\n\nThanks for picking up this topic.  Here’s some related work:\n\n - Incomplete series using space-separated test prerequisites:\n   http://thread.gmane.org/gmane.comp.version-control.git/145427\n\n - Why that series is incomplete:\n   http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=104;bug=579273\n\n - Comma-separated test prerequisites:\n   http://thread.gmane.org/gmane.comp.version-control.git/116729/focus=118434\n\n - Earlier.\n   http://thread.gmane.org/gmane.comp.version-control.git/116729/focus=118385\n\n>     test_expect_success POSIXPERM,SANITY\n\nLast time I looked, IFS=, as used by Hannes looked like a sane\napproach.  I noticed too late and did not follow up; sorry about that.\n"},{"id":"147354","messageId":"1281132549-11587-1-git-send-email-avarab@gmail.com","threadId":"24630","inReplyTo":"1280934026-25658-1-git-send-email-avarab@gmail.com","subject":"[PATCH v2] tests: A SANITY test prereq for testing if we're root","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-08-06T22:09:09Z","receivedAt":"2010-08-06T22:09:09Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Some tests depend on not being able to write to files after chmod\n-w. This doesn't work when running the tests as root.\n\nChange test-lib.sh to test if this works, and if so it sets a new\nSANITY test prerequisite. The tests that use this previously failed\nwhen run under root.\n\nThere was already a test for this in t3600-rm.sh, added by Junio C\nHamano in 2283645 in 2006. That check now uses the new SANITY\nprerequisite.\n\nSome of this was resurrected from the \"Tests in Cygwin\" thread in May\n2009:\n\n    http://thread.gmane.org/gmane.comp.version-control.git/116729/focus=118385\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n\nHere's a buch improved v2 of this patch. It goes on top of the\njust-submitted \"tests: Better prerequisite handling & documentation\"\nseries (<1281129565-26124-1-git-send-email-avarab@gmail.com>).\n\nIt uses the SANITY prerequisite suggested by Junio in 2009, and uses a\nsimpler `test -w /' test to check if we're the superuser.\n\n t/README                    |    5 +++++\n t/t0001-init.sh             |    2 +-\n t/t0004-unwritable.sh       |    8 ++++----\n t/t1004-read-tree-m-u-wf.sh |    2 +-\n t/t3600-rm.sh               |   16 ----------------\n t/t3700-add.sh              |   10 +++++-----\n t/t7300-clean.sh            |    7 +++----\n t/t7508-status.sh           |    2 +-\n t/test-lib.sh               |    4 ++++\n 9 files changed, 24 insertions(+), 32 deletions(-)\n\ndiff --git a/t/README b/t/README\nindex dc07939..28effb4 100644\n--- a/t/README\n+++ b/t/README\n@@ -523,6 +523,11 @@ use these, and \"test_set_prereq\" for how to define your own.\n    The filesystem we're on supports symbolic links. E.g. a FAT\n    filesystem doesn't support these. See 704a3143 for details.\n \n+ - SANITY\n+\n+   Test is not run by root user, and an attempt to write to an\n+   unwritable file is expected to fail correctly.\n+\n Tips for Writing Tests\n ----------------------\n \ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 7c0a698..7a75999 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -301,7 +301,7 @@ test_expect_success 'init notices EEXIST (2)' '\n \t)\n '\n \n-test_expect_success POSIXPERM 'init notices EPERM' '\n+test_expect_success POSIXPERM,SANITY 'init notices EPERM' '\n \trm -fr newdir &&\n \t(\n \t\tmkdir newdir &&\ndiff --git a/t/t0004-unwritable.sh b/t/t0004-unwritable.sh\nindex 2342ac5..385b126 100755\n--- a/t/t0004-unwritable.sh\n+++ b/t/t0004-unwritable.sh\n@@ -15,7 +15,7 @@ test_expect_success setup '\n \n '\n \n-test_expect_success POSIXPERM 'write-tree should notice unwritable repository' '\n+test_expect_success POSIXPERM,SANITY 'write-tree should notice unwritable repository' '\n \n \t(\n \t\tchmod a-w .git/objects .git/objects/?? &&\n@@ -27,7 +27,7 @@ test_expect_success POSIXPERM 'write-tree should notice unwritable repository' '\n \n '\n \n-test_expect_success POSIXPERM 'commit should notice unwritable repository' '\n+test_expect_success POSIXPERM,SANITY 'commit should notice unwritable repository' '\n \n \t(\n \t\tchmod a-w .git/objects .git/objects/?? &&\n@@ -39,7 +39,7 @@ test_expect_success POSIXPERM 'commit should notice unwritable repository' '\n \n '\n \n-test_expect_success POSIXPERM 'update-index should notice unwritable repository' '\n+test_expect_success POSIXPERM,SANITY 'update-index should notice unwritable repository' '\n \n \t(\n \t\techo 6O >file &&\n@@ -52,7 +52,7 @@ test_expect_success POSIXPERM 'update-index should notice unwritable repository'\n \n '\n \n-test_expect_success POSIXPERM 'add should notice unwritable repository' '\n+test_expect_success POSIXPERM,SANITY 'add should notice unwritable repository' '\n \n \t(\n \t\techo b >file &&\ndiff --git a/t/t1004-read-tree-m-u-wf.sh b/t/t1004-read-tree-m-u-wf.sh\nindex f19b4a2..eb8e3d4 100755\n--- a/t/t1004-read-tree-m-u-wf.sh\n+++ b/t/t1004-read-tree-m-u-wf.sh\n@@ -177,7 +177,7 @@ test_expect_success SYMLINKS 'funny symlink in work tree' '\n \n '\n \n-test_expect_success SYMLINKS 'funny symlink in work tree, un-unlink-able' '\n+test_expect_success SYMLINKS,SANITY 'funny symlink in work tree, un-unlink-able' '\n \n \trm -fr a b &&\n \tgit reset --hard &&\ndiff --git a/t/t3600-rm.sh b/t/t3600-rm.sh\nindex b514cbb..b26cabd 100755\n--- a/t/t3600-rm.sh\n+++ b/t/t3600-rm.sh\n@@ -28,22 +28,6 @@ embedded' &&\n      git commit -m 'add files with tabs and newlines'\n \"\n \n-# Determine rm behavior\n-# Later we will try removing an unremovable path to make sure\n-# git rm barfs, but if the test is run as root that cannot be\n-# arranged.\n-: >test-file\n-chmod a-w .\n-rm -f test-file 2>/dev/null\n-if test -f test-file\n-then\n-\ttest_set_prereq RO_DIR\n-else\n-\tskip_all='skipping removal failure test (perhaps running as root?)'\n-fi\n-chmod 775 .\n-rm -f test-file\n-\n test_expect_success \\\n     'Pre-check that foo exists and is in index before git rm foo' \\\n     '[ -f foo ] && git ls-files --error-unmatch foo'\ndiff --git a/t/t3700-add.sh b/t/t3700-add.sh\nindex 7d7140d..ec71083 100755\n--- a/t/t3700-add.sh\n+++ b/t/t3700-add.sh\n@@ -179,7 +179,7 @@ test_expect_success 'git add --refresh' '\n \ttest -z \"`git diff-index HEAD -- foo`\"\n '\n \n-test_expect_success POSIXPERM 'git add should fail atomically upon an unreadable file' '\n+test_expect_success POSIXPERM,SANITY 'git add should fail atomically upon an unreadable file' '\n \tgit reset --hard &&\n \tdate >foo1 &&\n \tdate >foo2 &&\n@@ -190,7 +190,7 @@ test_expect_success POSIXPERM 'git add should fail atomically upon an unreadable\n \n rm -f foo2\n \n-test_expect_success POSIXPERM 'git add --ignore-errors' '\n+test_expect_success POSIXPERM,SANITY 'git add --ignore-errors' '\n \tgit reset --hard &&\n \tdate >foo1 &&\n \tdate >foo2 &&\n@@ -201,7 +201,7 @@ test_expect_success POSIXPERM 'git add --ignore-errors' '\n \n rm -f foo2\n \n-test_expect_success POSIXPERM 'git add (add.ignore-errors)' '\n+test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors)' '\n \tgit config add.ignore-errors 1 &&\n \tgit reset --hard &&\n \tdate >foo1 &&\n@@ -212,7 +212,7 @@ test_expect_success POSIXPERM 'git add (add.ignore-errors)' '\n '\n rm -f foo2\n \n-test_expect_success POSIXPERM 'git add (add.ignore-errors = false)' '\n+test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors = false)' '\n \tgit config add.ignore-errors 0 &&\n \tgit reset --hard &&\n \tdate >foo1 &&\n@@ -223,7 +223,7 @@ test_expect_success POSIXPERM 'git add (add.ignore-errors = false)' '\n '\n rm -f foo2\n \n-test_expect_success POSIXPERM '--no-ignore-errors overrides config' '\n+test_expect_success POSIXPERM,SANITY '--no-ignore-errors overrides config' '\n        git config add.ignore-errors 1 &&\n        git reset --hard &&\n        date >foo1 &&\ndiff --git a/t/t7300-clean.sh b/t/t7300-clean.sh\nindex 7d8ed68..fe8abf6 100755\n--- a/t/t7300-clean.sh\n+++ b/t/t7300-clean.sh\n@@ -388,16 +388,15 @@ test_expect_success 'core.excludesfile' '\n \n '\n \n-test_expect_success 'removal failure' '\n+test_expect_success SANITY 'removal failure' '\n \n \tmkdir foo &&\n \ttouch foo/bar &&\n \t(exec <foo/bar &&\n \t chmod 0 foo &&\n-\t test_must_fail git clean -f -d)\n-\n+\t test_must_fail git clean -f -d &&\n+\t chmod 755 foo)\n '\n-chmod 755 foo\n \n test_expect_success 'nested git work tree' '\n \trm -fr foo bar &&\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex a72fe3a..ee0e573 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -793,7 +793,7 @@ test_expect_success 'commit --dry-run submodule summary (--amend)' '\n \ttest_cmp expect output\n '\n \n-test_expect_success POSIXPERM 'status succeeds in a read-only repository' '\n+test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '\n \t(\n \t\tchmod a-w .git &&\n \t\t# make dir1/tracked stat-dirty\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 4e0a1c3..ace67a7 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -894,3 +894,7 @@ test -z \"$NO_PYTHON\" && test_set_prereq PYTHON\n # test whether the filesystem supports symbolic links\n ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS\n rm -f y\n+\n+# When the tests are run as root, permission tests will report that\n+# things are writable when they shouldn't be.\n+test -w / || test_set_prereq SANITY\n-- \n1.7.1\n"},{"id":"147517","messageId":"7vd3tr7mkj.fsf@alter.siamese.dyndns.org","threadId":"24630","inReplyTo":"1281132549-11587-1-git-send-email-avarab@gmail.com","subject":"Re: [PATCH v2] tests: A SANITY test prereq for testing if we're root","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-09T16:55:24Z","receivedAt":"2010-08-09T16:55:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> + - SANITY\n> +\n> +   Test is not run by root user, and an attempt to write to an\n> +   unwritable file is expected to fail correctly.\n\nAs I said in the previous round, I am indeed in favor of having a single\n\"running as root---code that expects that the normal UNIXy permission\nbased protection to apply, aka 'running in sane environment', will not\nwork correctly\" prerequisite token, rather than having separate \"can I\nexpect an unwritable file to be unwritable?\"  \"can I expect an unreadble\nfile to be unreadable?\" bits.  The name of the token _might_ be subject to\ndebate (I am fine with either SANITY or NOROOT), but the explanation\nshould mention this is defined to be a bit more broad than \"unWRITABLE\", I\nthink.  \"test -w /\" is a traditional way to approximately check if you are\nrunning as root (technically, it only checks if you are running with\nunduly high privilege---your sysadm _could_ have done \"chmod 2775 /\" and\nmade it owned by the admin group).\n\nBut that is just a nitpick on the wording we could fix if necessary.\n\nThanks.\n"},{"id":"147531","messageId":"AANLkTi=68=ffWqmXyMckJuSvbW4Wk9-7JWR-S9nheOEA@mail.gmail.com","threadId":"24630","inReplyTo":"7vd3tr7mkj.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] tests: A SANITY test prereq for testing if we're root","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-08-09T19:02:13Z","receivedAt":"2010-08-09T19:02:13Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Mon, Aug 9, 2010 at 16:55, Junio C Hamano <gitster@pobox.com> wrote:\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>\n>> + - SANITY\n>> +\n>> +   Test is not run by root user, and an attempt to write to an\n>> +   unwritable file is expected to fail correctly.\n>\n> As I said in the previous round, I am indeed in favor of having a single\n> \"running as root---code that expects that the normal UNIXy permission\n> based protection to apply, aka 'running in sane environment', will not\n> work correctly\" prerequisite token, rather than having separate \"can I\n> expect an unwritable file to be unwritable?\"  \"can I expect an unreadble\n> file to be unreadable?\" bits.\n\nI probably shouldn't have used your docs as-is, you're right. It could\nbe explained better.\n\n> The name of the token _might_ be subject to debate (I am fine with\n> either SANITY or NOROOT), but the explanation should mention this is\n> defined to be a bit more broad than \"unWRITABLE\", I think.\n\nNOROOT is better I think,.\n\n> \"test -w /\" is a traditional way to approximately check if you are\n> running as root (technically, it only checks if you are running with\n> unduly high privilege---your sysadm _could_ have done \"chmod 2775 /\"\n> and made it owned by the admin group).\n\nInitially I wrote it as:\n\n     # test whether the filesystem supports symbolic links\n     ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS\n     rm -f y\n    +\n    +# test whether we can make read-only files\n    +mkdir hla\n    +chmod -w hla\n    +touch hla/gh >/dev/null 2>&1\n    +test -f hla/gh || test_set_prereq SANITY\n    +rm -rf hla\n\nBut then I saw your old \"test -w /\" implementation and figured it was\ngood enough without doing all this work on setup. I can submit another\npatch with that fixup if you like, maybe it'll prevent odd failures on\nsomeone's odd system.\n"}]}