diff options
author | ngie <ngie@FreeBSD.org> | 2016-01-03 06:02:56 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2016-01-03 06:02:56 +0000 |
commit | 56891f5bbd867c34df21e1c84d3eaaf2346a5980 (patch) | |
tree | 9ec89193da3573b8781742b335c781e4ff238a8b /tools/regression | |
parent | 3db696df034ec3362db176d4fd02070207ec600c (diff) | |
download | FreeBSD-src-56891f5bbd867c34df21e1c84d3eaaf2346a5980.zip FreeBSD-src-56891f5bbd867c34df21e1c84d3eaaf2346a5980.tar.gz |
- 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
MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'tools/regression')
-rw-r--r-- | tools/regression/geom_mirror/conf.sh | 7 | ||||
-rw-r--r-- | tools/regression/geom_mirror/test-1.t | 19 | ||||
-rw-r--r-- | tools/regression/geom_mirror/test-2.t | 25 | ||||
-rw-r--r-- | tools/regression/geom_mirror/test-3.t | 24 | ||||
-rw-r--r-- | tools/regression/geom_mirror/test-4.t | 26 | ||||
-rw-r--r-- | tools/regression/geom_mirror/test-5.t | 24 | ||||
-rw-r--r-- | tools/regression/geom_mirror/test-6.t | 25 | ||||
-rw-r--r-- | tools/regression/geom_mirror/test-7.t | 24 |
8 files changed, 67 insertions, 107 deletions
diff --git a/tools/regression/geom_mirror/conf.sh b/tools/regression/geom_mirror/conf.sh index 5e7e15a..d8595f1 100644 --- a/tools/regression/geom_mirror/conf.sh +++ b/tools/regression/geom_mirror/conf.sh @@ -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 diff --git a/tools/regression/geom_mirror/test-1.t b/tools/regression/geom_mirror/test-1.t index b07a8d1..af82a14 100644 --- a/tools/regression/geom_mirror/test-1.t +++ b/tools/regression/geom_mirror/test-1.t @@ -5,15 +5,11 @@ echo "1..1" -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 - -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 diff --git a/tools/regression/geom_mirror/test-2.t b/tools/regression/geom_mirror/test-2.t index 3fb0822..5605c44 100644 --- a/tools/regression/geom_mirror/test-2.t +++ b/tools/regression/geom_mirror/test-2.t @@ -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}` ]; then 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} diff --git a/tools/regression/geom_mirror/test-3.t b/tools/regression/geom_mirror/test-3.t index 5bdd2ab..b7f8525 100644 --- a/tools/regression/geom_mirror/test-3.t +++ b/tools/regression/geom_mirror/test-3.t @@ -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} diff --git a/tools/regression/geom_mirror/test-4.t b/tools/regression/geom_mirror/test-4.t index 0786bdb..6efcc02 100644 --- a/tools/regression/geom_mirror/test-4.t +++ b/tools/regression/geom_mirror/test-4.t @@ -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} diff --git a/tools/regression/geom_mirror/test-5.t b/tools/regression/geom_mirror/test-5.t index 5b0a5ed..3a176b5 100644 --- a/tools/regression/geom_mirror/test-5.t +++ b/tools/regression/geom_mirror/test-5.t @@ -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} diff --git a/tools/regression/geom_mirror/test-6.t b/tools/regression/geom_mirror/test-6.t index ec86d06..68036e9 100644 --- a/tools/regression/geom_mirror/test-6.t +++ b/tools/regression/geom_mirror/test-6.t @@ -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} diff --git a/tools/regression/geom_mirror/test-7.t b/tools/regression/geom_mirror/test-7.t index c911c03..f5bf71a 100644 --- a/tools/regression/geom_mirror/test-7.t +++ b/tools/regression/geom_mirror/test-7.t @@ -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} |