Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Jan 2016 21:25:27 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r293441 - head/tools/regression/geom_shsec
Message-ID:  <201601082125.u08LPROW089710@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Fri Jan  8 21:25:27 2016
New Revision: 293441
URL: https://svnweb.freebsd.org/changeset/base/293441

Log:
  - Add a geom_shsec specific cleanup function and trap on that function at
    exit so things are cleaned up properly
  - Use attach_md for attaching md(4) devices
  - Don't hardcode /tmp for temporary files, which violates the kyua sandbox
  
  MFC after: 3 weeks
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/tools/regression/geom_shsec/conf.sh
  head/tools/regression/geom_shsec/test-1.t
  head/tools/regression/geom_shsec/test-2.t

Modified: head/tools/regression/geom_shsec/conf.sh
==============================================================================
--- head/tools/regression/geom_shsec/conf.sh	Fri Jan  8 21:07:34 2016	(r293440)
+++ head/tools/regression/geom_shsec/conf.sh	Fri Jan  8 21:25:27 2016	(r293441)
@@ -5,4 +5,11 @@ name="$(mktemp -u shsec.XXXXXX)"
 class="shsec"
 base=`basename $0`
 
+shsec_test_cleanup()
+{
+	[ -c /dev/$class/$name ] && gshsec stop $name
+	geom_test_cleanup
+}
+trap shsec_test_cleanup ABRT EXIT INT TERM
+
 . `dirname $0`/../geom_subr.sh

Modified: head/tools/regression/geom_shsec/test-1.t
==============================================================================
--- head/tools/regression/geom_shsec/test-1.t	Fri Jan  8 21:07:34 2016	(r293440)
+++ head/tools/regression/geom_shsec/test-1.t	Fri Jan  8 21:25:27 2016	(r293441)
@@ -5,15 +5,11 @@
 
 echo "1..2"
 
-us0=45
-us1=`expr $us0 + 1`
-us2=`expr $us0 + 2`
+us0=$(attach_md -t malloc -s 1M) || exit 1
+us1=$(attach_md -t malloc -s 2M) || exit 1
+us2=$(attach_md -t malloc -s 3M) || exit 1
 
-mdconfig -a -t malloc -s 1M -u $us0 || exit 1
-mdconfig -a -t malloc -s 2M -u $us1 || exit 1
-mdconfig -a -t malloc -s 3M -u $us2 || exit 1
-
-gshsec label $name /dev/md${us0} /dev/md${us1} /dev/md${us2} 2>/dev/null || exit 1
+gshsec label $name /dev/${us0} /dev/${us1} /dev/${us2} 2>/dev/null || exit 1
 devwait
 
 # Size of created device should be 1MB - 512B.
@@ -30,8 +26,3 @@ if [ $sectorsize -eq 512 ]; then
 else
 	echo "not ok 2"
 fi
-
-gshsec stop $name
-mdconfig -d -u $us0
-mdconfig -d -u $us1
-mdconfig -d -u $us2

Modified: head/tools/regression/geom_shsec/test-2.t
==============================================================================
--- head/tools/regression/geom_shsec/test-2.t	Fri Jan  8 21:07:34 2016	(r293440)
+++ head/tools/regression/geom_shsec/test-2.t	Fri Jan  8 21:25:27 2016	(r293441)
@@ -5,21 +5,18 @@
 
 echo "1..4"
 
-us0=45
-us1=`expr $us0 + 1`
-us2=`expr $us0 + 2`
 nblocks1=1024
 nblocks2=`expr $nblocks1 + 1`
-src=`mktemp /tmp/$base.XXXXXX` || exit 1
-dst=`mktemp /tmp/$base.XXXXXX` || exit 1
+src=`mktemp $base.XXXXXX` || exit 1
+dst=`mktemp $base.XXXXXX` || exit 1
 
 dd if=/dev/random of=${src} count=$nblocks1 >/dev/null 2>&1
 
-mdconfig -a -t malloc -s $nblocks2 -u $us0 || exit 1
-mdconfig -a -t malloc -s $nblocks2 -u $us1 || exit 1
-mdconfig -a -t malloc -s $nblocks2 -u $us2 || exit 1
+us0=$(attach_md -t malloc -s $nblocks2) || exit 1
+us1=$(attach_md -t malloc -s $nblocks2) || exit 1
+us2=$(attach_md -t malloc -s $nblocks2) || exit 1
 
-gshsec label $name /dev/md${us0} /dev/md${us1} /dev/md${us2} || exit 1
+gshsec label $name /dev/$us0 /dev/$us1 /dev/$us2 || exit 1
 devwait
 
 dd if=${src} of=/dev/shsec/${name} count=$nblocks1 >/dev/null 2>&1
@@ -31,29 +28,25 @@ else
 	echo "ok 1"
 fi
 
-dd if=/dev/md${us0} of=${dst} count=$nblocks1 >/dev/null 2>&1
+dd if=/dev/${us0} of=${dst} count=$nblocks1 >/dev/null 2>&1
 if [ `md5 -q ${src}` = `md5 -q ${dst}` ]; then
 	echo "not ok 2"
 else
 	echo "ok 2"
 fi
 
-dd if=/dev/md${us1} of=${dst} count=$nblocks1 >/dev/null 2>&1
+dd if=/dev/${us1} of=${dst} count=$nblocks1 >/dev/null 2>&1
 if [ `md5 -q ${src}` = `md5 -q ${dst}` ]; then
 	echo "not ok 3"
 else
 	echo "ok 3"
 fi
 
-dd if=/dev/md${us2} of=${dst} count=$nblocks1 >/dev/null 2>&1
+dd if=/dev/${us2} of=${dst} count=$nblocks1 >/dev/null 2>&1
 if [ `md5 -q ${src}` = `md5 -q ${dst}` ]; then
 	echo "not ok 4"
 else
 	echo "ok 4"
 fi
 
-gshsec stop $name
-mdconfig -d -u $us0
-mdconfig -d -u $us1
-mdconfig -d -u $us2
 rm -f ${src} ${dst}



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