svn commit: r290967 - user/ngie/more-tests2/sbin/geom/class/tests/mirror
Garrett Cooper
ngie at FreeBSD.org
Tue Nov 17 01:02:46 UTC 2015
Author: ngie
Date: Tue Nov 17 01:02:44 2015
New Revision: 290967
URL: https://svnweb.freebsd.org/changeset/base/290967
Log:
- Use unique gmirror names
- Use attach_md for tracking md(4) devices
- Tear down the mirror in a consolidated cleanup routine
Modified:
user/ngie/more-tests2/sbin/geom/class/tests/mirror/1_test.sh
user/ngie/more-tests2/sbin/geom/class/tests/mirror/2_test.sh
user/ngie/more-tests2/sbin/geom/class/tests/mirror/3_test.sh
user/ngie/more-tests2/sbin/geom/class/tests/mirror/4_test.sh
user/ngie/more-tests2/sbin/geom/class/tests/mirror/5_test.sh
user/ngie/more-tests2/sbin/geom/class/tests/mirror/6_test.sh
user/ngie/more-tests2/sbin/geom/class/tests/mirror/7_test.sh
user/ngie/more-tests2/sbin/geom/class/tests/mirror/conf.sh
Modified: user/ngie/more-tests2/sbin/geom/class/tests/mirror/1_test.sh
==============================================================================
--- user/ngie/more-tests2/sbin/geom/class/tests/mirror/1_test.sh Tue Nov 17 01:01:03 2015 (r290966)
+++ user/ngie/more-tests2/sbin/geom/class/tests/mirror/1_test.sh Tue Nov 17 01:02:44 2015 (r290967)
@@ -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: user/ngie/more-tests2/sbin/geom/class/tests/mirror/2_test.sh
==============================================================================
--- user/ngie/more-tests2/sbin/geom/class/tests/mirror/2_test.sh Tue Nov 17 01:01:03 2015 (r290966)
+++ user/ngie/more-tests2/sbin/geom/class/tests/mirror/2_test.sh Tue Nov 17 01:02:44 2015 (r290967)
@@ -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: user/ngie/more-tests2/sbin/geom/class/tests/mirror/3_test.sh
==============================================================================
--- user/ngie/more-tests2/sbin/geom/class/tests/mirror/3_test.sh Tue Nov 17 01:01:03 2015 (r290966)
+++ user/ngie/more-tests2/sbin/geom/class/tests/mirror/3_test.sh Tue Nov 17 01:02:44 2015 (r290967)
@@ -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: user/ngie/more-tests2/sbin/geom/class/tests/mirror/4_test.sh
==============================================================================
--- user/ngie/more-tests2/sbin/geom/class/tests/mirror/4_test.sh Tue Nov 17 01:01:03 2015 (r290966)
+++ user/ngie/more-tests2/sbin/geom/class/tests/mirror/4_test.sh Tue Nov 17 01:02:44 2015 (r290967)
@@ -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: user/ngie/more-tests2/sbin/geom/class/tests/mirror/5_test.sh
==============================================================================
--- user/ngie/more-tests2/sbin/geom/class/tests/mirror/5_test.sh Tue Nov 17 01:01:03 2015 (r290966)
+++ user/ngie/more-tests2/sbin/geom/class/tests/mirror/5_test.sh Tue Nov 17 01:02:44 2015 (r290967)
@@ -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: user/ngie/more-tests2/sbin/geom/class/tests/mirror/6_test.sh
==============================================================================
--- user/ngie/more-tests2/sbin/geom/class/tests/mirror/6_test.sh Tue Nov 17 01:01:03 2015 (r290966)
+++ user/ngie/more-tests2/sbin/geom/class/tests/mirror/6_test.sh Tue Nov 17 01:02:44 2015 (r290967)
@@ -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: user/ngie/more-tests2/sbin/geom/class/tests/mirror/7_test.sh
==============================================================================
--- user/ngie/more-tests2/sbin/geom/class/tests/mirror/7_test.sh Tue Nov 17 01:01:03 2015 (r290966)
+++ user/ngie/more-tests2/sbin/geom/class/tests/mirror/7_test.sh Tue Nov 17 01:02:44 2015 (r290967)
@@ -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}
Modified: user/ngie/more-tests2/sbin/geom/class/tests/mirror/conf.sh
==============================================================================
--- user/ngie/more-tests2/sbin/geom/class/tests/mirror/conf.sh Tue Nov 17 01:01:03 2015 (r290966)
+++ user/ngie/more-tests2/sbin/geom/class/tests/mirror/conf.sh Tue Nov 17 01:02:44 2015 (r290967)
@@ -1,8 +1,15 @@
#!/bin/sh
# $FreeBSD$
-name="test"
+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
More information about the svn-src-user
mailing list