Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 May 2017 23:04:48 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r319007 - in stable/10: contrib/netbsd-tests/fs/tmpfs tests/sys/fs/tmpfs
Message-ID:  <201705272304.v4RN4mKT057308@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Sat May 27 23:04:48 2017
New Revision: 319007
URL: https://svnweb.freebsd.org/changeset/base/319007

Log:
  MFC r318546:
  
  sys/fs/tmpfs/vnd_test: make md(4) allocation dynamic
  
  The previous logic was flawed in the sense that it assumed that /dev/md3
  was always available. This was a caveat I noted in r306038, that I hadn't
  gotten around to solving before now.
  
  Cache the device for the mountpoint after executing mdmfs, then use the
  cached value in basic_cleanup(..) when unmounting/disconnecting the md(4)
  device.
  
  Apply sed expressions to use reuse logic in the NetBSD code that could
  also be applied to FreeBSD, just with different tools.

Modified:
  stable/10/contrib/netbsd-tests/fs/tmpfs/t_vnd.sh
  stable/10/tests/sys/fs/tmpfs/Makefile
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/netbsd-tests/fs/tmpfs/t_vnd.sh
==============================================================================
--- stable/10/contrib/netbsd-tests/fs/tmpfs/t_vnd.sh	Sat May 27 23:04:40 2017	(r319006)
+++ stable/10/contrib/netbsd-tests/fs/tmpfs/t_vnd.sh	Sat May 27 23:04:48 2017	(r319007)
@@ -28,6 +28,10 @@
 # Verifies that vnd works with files stored in tmpfs.
 #
 
+# Begin FreeBSD
+MD_DEVICE_FILE=md.device
+# End FreeBSD
+
 atf_test_case basic cleanup
 basic_head() {
 	atf_set "descr" "Verifies that vnd works with files stored in tmpfs"
@@ -41,7 +45,10 @@ basic_body() {
 	# Begin FreeBSD
 	if true; then
 		atf_check -s eq:0 -o empty -e empty mkdir mnt
-		atf_check -s eq:0 -o empty -e empty mdmfs -F disk.img md3 mnt
+		atf_check -s eq:0 -o empty -e empty mdmfs -F disk.img md mnt
+		md_dev=$(df mnt | awk 'NR != 1 { print $1 }' | xargs basename)
+		atf_check test -c /dev/$md_dev # Sanity check
+		echo -n $md_dev > $TMPDIR/$MD_DEVICE_FILE
 	else
 	# End FreeBSD
 	atf_check -s eq:0 -o empty -e empty vndconfig /dev/vnd3 disk.img
@@ -67,31 +74,23 @@ basic_body() {
 	done
 
 	atf_check -s eq:0 -o empty -e empty umount mnt
-	# Begin FreeBSD
-	if true; then
-		atf_check -s eq:0 -o empty -e empty mdconfig -d -u 3
-	else
-	# End FreeBSD
 	atf_check -s eq:0 -o empty -e empty vndconfig -u /dev/vnd3
-	# Begin FreeBSD
-	fi
-	# End FreeBSD
 
 	test_unmount
 	touch done
 }
 basic_cleanup() {
+	# Begin FreeBSD
+	if md_dev=$(cat $TMPDIR/$MD_DEVICE_FILE); then
+		echo "Will try disconnecting $md_dev"
+	else
+		echo "$MD_DEVICE_FILE doesn't exist in $TMPDIR; returning early"
+		return 0
+	fi
+	# End FreeBSD
 	if [ ! -f done ]; then
 		umount mnt 2>/dev/null 1>&2
-		# Begin FreeBSD
-		if true; then
-			[ ! -c /dev/md3 ] || mdconfig -d -u 3
-		else
-		# End FreeBSD
 		vndconfig -u /dev/vnd3 2>/dev/null 1>&2
-		# Begin FreeBSD
-		fi
-		# End FreeBSD
 	fi
 }
 

Modified: stable/10/tests/sys/fs/tmpfs/Makefile
==============================================================================
--- stable/10/tests/sys/fs/tmpfs/Makefile	Sat May 27 23:04:40 2017	(r319006)
+++ stable/10/tests/sys/fs/tmpfs/Makefile	Sat May 27 23:04:48 2017	(r319007)
@@ -54,6 +54,9 @@ ATF_TESTS_SH_SED_mount_test=		\
 ATF_TESTS_SH_SED_readdir_test=		-e 's,mknod fifo p,mkfifo fifo,g'
 ATF_TESTS_SH_SED_sizes_test=		-e 's,-o -s,-o size=,g'
 ATF_TESTS_SH_SED_statvfs_test=		-e 's,-o -s,-o size=,g'
+ATF_TESTS_SH_SED_vnd_test=		\
+					-e 's,vndconfig -u /dev/vnd3,mdconfig -d -u $$md_dev,g' \
+					-e 's,/dev/vnd3,/dev/$$md_dev,g'
 ATF_TESTS_SH_SED_vnode_leak_test=	-e 's,-o -s,-o size=,g'
 
 .include <netbsd-tests.test.mk>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705272304.v4RN4mKT057308>