Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Jan 2016 06:20:57 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r294658 - stable/9/tools/regression/geom_mirror
Message-ID:  <201601240620.u0O6KvbO019974@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Sun Jan 24 06:20:57 2016
New Revision: 294658
URL: https://svnweb.freebsd.org/changeset/base/294658

Log:
  MFstable/10 r294657:
  
  MFC r293073:
  
  - Use attach_md instead of hardcoding md(4) provider unit numbers
  - Implement a gmirror_test_cleanup function, which in turn calls
    geom_test_cleanup to clean up all md(4) providers allocated in the test
    run.
  - Remove duplicate logic in test scripts for removing md(4) providers.
  - Don't create files in /tmp (outside the kyua sandbox); use the current
    directory instead

Modified:
  stable/9/tools/regression/geom_mirror/conf.sh
  stable/9/tools/regression/geom_mirror/test-1.t
  stable/9/tools/regression/geom_mirror/test-2.t
  stable/9/tools/regression/geom_mirror/test-3.t
  stable/9/tools/regression/geom_mirror/test-4.t
  stable/9/tools/regression/geom_mirror/test-5.t
  stable/9/tools/regression/geom_mirror/test-6.t
  stable/9/tools/regression/geom_mirror/test-7.t
Directory Properties:
  stable/9/   (props changed)
  stable/9/tools/   (props changed)
  stable/9/tools/regression/   (props changed)

Modified: stable/9/tools/regression/geom_mirror/conf.sh
==============================================================================
--- stable/9/tools/regression/geom_mirror/conf.sh	Sun Jan 24 06:19:49 2016	(r294657)
+++ stable/9/tools/regression/geom_mirror/conf.sh	Sun Jan 24 06:20:57 2016	(r294658)
@@ -5,4 +5,11 @@ name="$(mktemp -u mirror.XXXXXX)"
 class="mirror"
 base=`basename $0`
 
+gmirror_test_cleanup()
+{
+	[ -c /dev/$class/$name ] && gmirror destroy $name
+	geom_test_cleanup
+}
+trap gmirror_test_cleanup ABRT EXIT INT TERM
+
 . `dirname $0`/../geom_subr.sh

Modified: stable/9/tools/regression/geom_mirror/test-1.t
==============================================================================
--- stable/9/tools/regression/geom_mirror/test-1.t	Sun Jan 24 06:19:49 2016	(r294657)
+++ stable/9/tools/regression/geom_mirror/test-1.t	Sun Jan 24 06:20:57 2016	(r294658)
@@ -5,15 +5,11 @@
 
 echo "1..1"
 
-us0=45
-us1=`expr $us0 + 1`
-us2=`expr $us0 + 2`
-
-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
+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
 
-gmirror label $name /dev/md${us0} /dev/md${us1} /dev/md${us2} || exit 1
+gmirror label $name /dev/$us0 /dev/$us1 /dev/$us2 || exit 1
 devwait
 
 # Size of created device should be 1MB - 512b.
@@ -25,10 +21,3 @@ if [ $size -eq 1048064 ]; then
 else
 	echo "not ok 1"
 fi
-
-gmirror remove $name md${us0}
-gmirror remove $name md${us1}
-gmirror remove $name md${us2}
-mdconfig -d -u $us0
-mdconfig -d -u $us1
-mdconfig -d -u $us2

Modified: stable/9/tools/regression/geom_mirror/test-2.t
==============================================================================
--- stable/9/tools/regression/geom_mirror/test-2.t	Sun Jan 24 06:19:49 2016	(r294657)
+++ stable/9/tools/regression/geom_mirror/test-2.t	Sun Jan 24 06:20:57 2016	(r294658)
@@ -6,22 +6,19 @@
 echo "1..4"
 
 balance="round-robin"
-us0=45
-us1=`expr $us0 + 1`
-us2=`expr $us0 + 2`
 ddbs=2048
 nblocks1=1024
 nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
-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} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us0 || exit 1
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us1 || exit 1
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us2 || exit 1
+us0=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
+us1=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
+us2=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
 
-gmirror label -b $balance $name /dev/md${us0} /dev/md${us1} /dev/md${us2} || exit 1
+gmirror label -b $balance $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1
 devwait
 
 dd if=${src} of=/dev/mirror/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
@@ -32,28 +29,24 @@ if [ `md5 -q ${src}` != `md5 -q ${dst}` 
 else
 	echo "ok 1"
 fi
-dd if=/dev/md${us0} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+dd if=/dev/${us0} of=${dst} bs=$ddbs count=$nblocks2 >/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} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+dd if=/dev/${us1} of=${dst} bs=$ddbs count=$nblocks2 >/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} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+dd if=/dev/${us2} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
 	echo "not ok 4"
 else
 	echo "ok 4"
 fi
 
-gmirror remove $name md${us0} md${us1} md${us2}
-mdconfig -d -u $us0
-mdconfig -d -u $us1
-mdconfig -d -u $us2
 rm -f ${src} ${dst}

Modified: stable/9/tools/regression/geom_mirror/test-3.t
==============================================================================
--- stable/9/tools/regression/geom_mirror/test-3.t	Sun Jan 24 06:19:49 2016	(r294657)
+++ stable/9/tools/regression/geom_mirror/test-3.t	Sun Jan 24 06:20:57 2016	(r294658)
@@ -6,22 +6,19 @@
 echo "1..5"
 
 balance="round-robin"
-us0=45
-us1=`expr $us0 + 1`
-us2=`expr $us0 + 2`
 ddbs=2048
 nblocks1=1024
 nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
-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} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us0 || exit 1
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us1 || exit 1
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us2 || exit 1
+us0=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
+us1=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
+us2=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
 
-gmirror label -b $balance $name /dev/md${us0} /dev/md${us1} /dev/md${us2} || exit 1
+gmirror label -b $balance $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1
 devwait
 
 dd if=${src} of=/dev/mirror/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
@@ -33,7 +30,7 @@ else
 	echo "ok 1"
 fi
 
-gmirror remove $name md${us0}
+gmirror remove $name ${us0}
 dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
 	echo "not ok 2"
@@ -41,7 +38,7 @@ else
 	echo "ok 2"
 fi
 
-gmirror remove $name md${us1}
+gmirror remove $name ${us1}
 dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
 	echo "not ok 3"
@@ -49,7 +46,7 @@ else
 	echo "ok 3"
 fi
 
-gmirror remove $name md${us2}
+gmirror remove $name ${us2}
 dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
 	echo "not ok 4"
@@ -64,7 +61,4 @@ else
 	echo "ok 5"
 fi
 
-mdconfig -d -u $us0
-mdconfig -d -u $us1
-mdconfig -d -u $us2
 rm -f ${src} ${dst}

Modified: stable/9/tools/regression/geom_mirror/test-4.t
==============================================================================
--- stable/9/tools/regression/geom_mirror/test-4.t	Sun Jan 24 06:19:49 2016	(r294657)
+++ stable/9/tools/regression/geom_mirror/test-4.t	Sun Jan 24 06:20:57 2016	(r294658)
@@ -6,22 +6,19 @@
 echo "1..5"
 
 balance="load"
-us0=45
-us1=`expr $us0 + 1`
-us2=`expr $us0 + 2`
 ddbs=2048
 nblocks1=1024
 nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
-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} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us0 || exit 1
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us1 || exit 1
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us2 || exit 1
+us0=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
+us1=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
+us2=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
 
-gmirror label -b $balance $name /dev/md${us0} /dev/md${us1} /dev/md${us2} || exit 1
+gmirror label -b $balance $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1
 devwait
 
 dd if=${src} of=/dev/mirror/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
@@ -33,7 +30,7 @@ else
 	echo "ok 1"
 fi
 
-gmirror remove $name md${us0}
+gmirror remove $name ${us0}
 dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
 	echo "not ok 2"
@@ -41,7 +38,7 @@ else
 	echo "ok 2"
 fi
 
-gmirror remove $name md${us1}
+gmirror remove $name ${us1}
 dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
 	echo "not ok 3"
@@ -49,7 +46,7 @@ else
 	echo "ok 3"
 fi
 
-gmirror remove $name md${us2}
+gmirror remove $name ${us2}
 dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
 	echo "not ok 4"
@@ -57,6 +54,8 @@ else
 	echo "ok 4"
 fi
 
+gmirror destroy $name
+
 # mirror/${name} should be removed.
 if [ -c /dev/${name} ]; then
 	echo "not ok 5"
@@ -64,7 +63,4 @@ else
 	echo "ok 5"
 fi
 
-mdconfig -d -u $us0
-mdconfig -d -u $us1
-mdconfig -d -u $us2
 rm -f ${src} ${dst}

Modified: stable/9/tools/regression/geom_mirror/test-5.t
==============================================================================
--- stable/9/tools/regression/geom_mirror/test-5.t	Sun Jan 24 06:19:49 2016	(r294657)
+++ stable/9/tools/regression/geom_mirror/test-5.t	Sun Jan 24 06:20:57 2016	(r294658)
@@ -6,22 +6,19 @@
 echo "1..5"
 
 balance="split"
-us0=45
-us1=`expr $us0 + 1`
-us2=`expr $us0 + 2`
 ddbs=8192
 nblocks1=1024
 nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
-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} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us0 || exit 1
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us1 || exit 1
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us2 || exit 1
+us0=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
+us1=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
+us2=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
 
-gmirror label -b $balance -s `expr $ddbs / 2` $name /dev/md${us0} /dev/md${us1} /dev/md${us2} || exit 1
+gmirror label -b $balance -s `expr $ddbs / 2` $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1
 devwait
 
 dd if=${src} of=/dev/mirror/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
@@ -33,7 +30,7 @@ else
 	echo "ok 1"
 fi
 
-gmirror remove $name md${us0}
+gmirror remove $name ${us0}
 dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
 	echo "not ok 2"
@@ -41,7 +38,7 @@ else
 	echo "ok 2"
 fi
 
-gmirror remove $name md${us1}
+gmirror remove $name ${us1}
 dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
 	echo "not ok 3"
@@ -49,7 +46,7 @@ else
 	echo "ok 3"
 fi
 
-gmirror remove $name md${us2}
+gmirror remove $name ${us2}
 dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
 	echo "not ok 4"
@@ -64,7 +61,4 @@ else
 	echo "ok 5"
 fi
 
-mdconfig -d -u $us0
-mdconfig -d -u $us1
-mdconfig -d -u $us2
 rm -f ${src} ${dst}

Modified: stable/9/tools/regression/geom_mirror/test-6.t
==============================================================================
--- stable/9/tools/regression/geom_mirror/test-6.t	Sun Jan 24 06:19:49 2016	(r294657)
+++ stable/9/tools/regression/geom_mirror/test-6.t	Sun Jan 24 06:20:57 2016	(r294658)
@@ -6,26 +6,23 @@
 echo "1..2"
 
 balance="split"
-us0=45
-us1=`expr $us0 + 1`
-us2=`expr $us0 + 2`
 ddbs=8192
 nblocks1=1024
 nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
-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} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us0 || exit 1
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us1 || exit 1
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us2 || exit 1
+us0=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
+us1=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
+us2=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
 
-gmirror label -b $balance -s `expr $ddbs / 2` $name /dev/md${us0} /dev/md${us1} || exit 1
+gmirror label -b $balance -s `expr $ddbs / 2` $name /dev/${us0} /dev/${us1} || exit 1
 devwait
 
 dd if=${src} of=/dev/mirror/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
-dd if=/dev/zero of=/dev/md${us2} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+dd if=/dev/zero of=/dev/${us2} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 
 dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
@@ -35,18 +32,14 @@ else
 fi
 
 # Connect disk to the mirror.
-gmirror insert ${name} md${us2}
+gmirror insert ${name} ${us2}
 # Wait for synchronization.
 sleep 1
-dd if=/dev/md${us2} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+dd if=/dev/${us2} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
 	echo "not ok 2"
 else
 	echo "ok 2"
 fi
 
-gmirror remove $name md${us0} md${us1} md${us2}
-mdconfig -d -u $us0
-mdconfig -d -u $us1
-mdconfig -d -u $us2
 rm -f ${src} ${dst}

Modified: stable/9/tools/regression/geom_mirror/test-7.t
==============================================================================
--- stable/9/tools/regression/geom_mirror/test-7.t	Sun Jan 24 06:19:49 2016	(r294657)
+++ stable/9/tools/regression/geom_mirror/test-7.t	Sun Jan 24 06:20:57 2016	(r294658)
@@ -6,22 +6,19 @@
 echo "1..5"
 
 balance="prefer"
-us0=45
-us1=`expr $us0 + 1`
-us2=`expr $us0 + 2`
 ddbs=2048
 nblocks1=1024
 nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
-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} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us0 || exit 1
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us1 || exit 1
-mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us2 || exit 1
+us0=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
+us1=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
+us2=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
 
-gmirror label -b $balance $name /dev/md${us0} /dev/md${us1} /dev/md${us2} || exit 1
+gmirror label -b $balance $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1
 devwait
 
 dd if=${src} of=/dev/mirror/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
@@ -33,7 +30,7 @@ else
 	echo "ok 1"
 fi
 
-gmirror remove $name md${us0}
+gmirror remove $name ${us0}
 dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
 	echo "not ok 2"
@@ -41,7 +38,7 @@ else
 	echo "ok 2"
 fi
 
-gmirror remove $name md${us1}
+gmirror remove $name ${us1}
 dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
 	echo "not ok 3"
@@ -49,7 +46,7 @@ else
 	echo "ok 3"
 fi
 
-gmirror remove $name md${us2}
+gmirror remove $name ${us2}
 dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
 	echo "not ok 4"
@@ -64,7 +61,4 @@ else
 	echo "ok 5"
 fi
 
-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?201601240620.u0O6KvbO019974>