svn commit: r296766 - in head/contrib/pjdfstest/tests: . ftruncate open truncate

Garrett Cooper ngie at FreeBSD.org
Sat Mar 12 19:41:40 UTC 2016


Author: ngie
Date: Sat Mar 12 19:41:38 2016
New Revision: 296766
URL: https://svnweb.freebsd.org/changeset/base/296766

Log:
  Better handle filesystems mounted with -o noexec
  
  ftruncate/11, open/20, and truncate/11 copy sleep(1) to a temporary file on the
  target filesystem, execute the binary, then expect a result. This doesn't work
  with scenarios where the target binary cannot be executed, e.g. the filesystem
  was mounted with -o noexec.
  
  Ensure the filesystem hasn't been mounted with -o noexec for the testcases
  before executing them.
  
  Differential Revision: https://reviews.freebsd.org/D5622
  MFC after: 1 week
  Reviewed by: markj
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/contrib/pjdfstest/tests/ftruncate/11.t
  head/contrib/pjdfstest/tests/misc.sh
  head/contrib/pjdfstest/tests/open/20.t
  head/contrib/pjdfstest/tests/truncate/11.t

Modified: head/contrib/pjdfstest/tests/ftruncate/11.t
==============================================================================
--- head/contrib/pjdfstest/tests/ftruncate/11.t	Sat Mar 12 19:26:21 2016	(r296765)
+++ head/contrib/pjdfstest/tests/ftruncate/11.t	Sat Mar 12 19:41:38 2016	(r296766)
@@ -8,6 +8,8 @@ dir=`dirname $0`
 
 [ "${os}" = "FreeBSD" ] || quick_exit
 
+requires_exec
+
 echo "1..2"
 
 n0=`namegen`

Modified: head/contrib/pjdfstest/tests/misc.sh
==============================================================================
--- head/contrib/pjdfstest/tests/misc.sh	Sat Mar 12 19:26:21 2016	(r296765)
+++ head/contrib/pjdfstest/tests/misc.sh	Sat Mar 12 19:41:38 2016	(r296766)
@@ -219,3 +219,37 @@ create_file() {
 		expect 0 lchmod ${name} ${3}
 	fi
 }
+
+# Tests for whether or not a filesystem is mounted with a particular option
+# with -o, e.g. `mount -o noexec`.
+#
+# Parameters:
+# - mount_option - noatime, noexec, etc.
+#
+# Returns:
+# - 0 if mounted with the option.
+# - 1 otherwise.
+has_mount_option()
+{
+	local IFS=,
+	local mount_opt
+
+	local mount_option_search=$1
+
+	# XXX: mountpoint is defined in .../tests/sys/pjdfstest/tests/conf
+	for mount_opt in $(mount -d -p | awk '$2 == "'$mountpoint'" { print $4 }'); do
+		if [ "$mount_opt" = "$mount_option_search" ]; then
+			return 0
+		fi
+	done
+	return 1
+}
+
+# Filesystem must be mounted with -o exec
+requires_exec()
+{
+	if has_mount_option noexec; then
+		echo "1..0 # SKIP filesystem mounted with -o noexec"
+		exit 0
+	fi
+}

Modified: head/contrib/pjdfstest/tests/open/20.t
==============================================================================
--- head/contrib/pjdfstest/tests/open/20.t	Sat Mar 12 19:26:21 2016	(r296765)
+++ head/contrib/pjdfstest/tests/open/20.t	Sat Mar 12 19:41:38 2016	(r296766)
@@ -8,6 +8,8 @@ dir=`dirname $0`
 
 [ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit
 
+requires_exec
+
 echo "1..4"
 
 n0=`namegen`

Modified: head/contrib/pjdfstest/tests/truncate/11.t
==============================================================================
--- head/contrib/pjdfstest/tests/truncate/11.t	Sat Mar 12 19:26:21 2016	(r296765)
+++ head/contrib/pjdfstest/tests/truncate/11.t	Sat Mar 12 19:41:38 2016	(r296766)
@@ -8,6 +8,8 @@ dir=`dirname $0`
 
 [ "${os}" = "FreeBSD" ] || quick_exit
 
+requires_exec
+
 echo "1..2"
 
 n0=`namegen`


More information about the svn-src-all mailing list