[PATCH] t0070: Use precondition CANNOTWRITE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



POSIX like file systems allows to create a file when the user has
write permissions to the directory.

Filesystems like VFAT or NTFS allow to create files regardless of
the write permissions of the directory.

Therefore "mktemp to unwritable directory" in t0700 will always fail on
Windows using NTFS.
This TC has been disabled for MINGW, and needs to be disabled for CYGWIN.

Use the precondition CANNOTWRITE which is probing the file system and
works for MINGW, CYGWIN and even for Linux using VFAT.

Signed-off-by: Torsten Bögershausen <tboegi@xxxxxx>
---
 t/t0070-fundamental.sh | 19 ++++++++++++-------
 t/test-lib.sh          | 12 ++++++++++++
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/t/t0070-fundamental.sh b/t/t0070-fundamental.sh
index da2c504..a907445 100755
--- a/t/t0070-fundamental.sh
+++ b/t/t0070-fundamental.sh
@@ -17,13 +17,18 @@ test_expect_success 'mktemp to nonexistent directory prints filename' '
 	grep "doesnotexist/test" err
 '
 
-test_expect_success POSIXPERM 'mktemp to unwritable directory prints filename' '
-	mkdir cannotwrite &&
-	chmod -w cannotwrite &&
-	test_when_finished "chmod +w cannotwrite" &&
-	test_must_fail test-mktemp cannotwrite/testXXXXXX 2>err &&
-	grep "cannotwrite/test" err
-'
+if test_have_prereq CANNOTWRITE
+then
+	test_expect_success 'mktemp to unwritable directory prints filename' '
+		mkdir cannotwrite &&
+		chmod -w cannotwrite &&
+		test_when_finished "chmod +w cannotwrite" &&
+		test_must_fail test-mktemp cannotwrite/testXXXXXX 2>err &&
+		grep "cannotwrite/test" err
+	'
+else
+	say "Skipping mktemp to unwritable directory prints filename"
+fi
 
 test_expect_success 'check for a bug in the regex routines' '
 	# if this test fails, re-build git with NO_REGEX=1
diff --git a/t/test-lib.sh b/t/test-lib.sh
index ca6bdef..1342630 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -770,6 +770,18 @@ test_lazy_prereq AUTOIDENT '
 	git var GIT_AUTHOR_IDENT
 '
 
+test_lazy_prereq CANNOTWRITE '
+	chmod -w .
+	>e || :
+	chmod +w .
+	case "$(echo *)" in
+	e)
+		false ;;
+	*)
+		true ;;
+	esac
+'
+
 # 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
-- 
1.8.2.411.g65a544e

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]