git: 96950419f155 - main - tests: don't run atf_* in a subshell

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Mon, 27 Nov 2023 21:16:40 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=96950419f15510287080c557174e0d8409f06956

commit 96950419f15510287080c557174e0d8409f06956
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2023-11-27 21:15:58 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2023-11-27 21:15:59 +0000

    tests: don't run atf_* in a subshell
    
    Shell limitation is that a classic function call via $() is a subshell
    and atf-sh(3) commands won't work as epxected there.  Subsequently,
    atf_skip inside a function won't skip a test.  The test will fail later.
    
    A working approach is to pass desired variable name as argument to
    a function and don't run subshell.
    
    Reviewed by:            ngie
    Differential Revision:  https://reviews.freebsd.org/D42646
    Fixes:                  ea82362219ee715cfbb195b2114e73fdc8599fa5
---
 tests/sys/geom/class/concat/1_test.sh              |  6 ++--
 tests/sys/geom/class/concat/2_test.sh              |  6 ++--
 tests/sys/geom/class/concat/append1.sh             |  6 ++--
 tests/sys/geom/class/concat/append2.sh             | 12 ++++----
 tests/sys/geom/class/eli/attach_test.sh            | 12 ++++----
 tests/sys/geom/class/eli/conf.sh                   | 16 ++++++-----
 tests/sys/geom/class/eli/configure_test.sh         |  2 +-
 tests/sys/geom/class/eli/delkey_test.sh            |  4 +--
 tests/sys/geom/class/eli/detach_test.sh            |  2 +-
 tests/sys/geom/class/eli/init_test.sh              | 10 +++----
 tests/sys/geom/class/eli/kill_test.sh              |  4 +--
 tests/sys/geom/class/eli/misc_test.sh              |  4 +--
 tests/sys/geom/class/eli/onetime_test.sh           |  4 +--
 tests/sys/geom/class/eli/online_resize_test.sh     |  2 +-
 tests/sys/geom/class/eli/resize_test.sh            |  2 +-
 tests/sys/geom/class/eli/setkey_test.sh            |  8 +++---
 tests/sys/geom/class/geom_subr.sh                  | 10 ++++---
 tests/sys/geom/class/mirror/10_test.sh             |  8 +++---
 tests/sys/geom/class/mirror/11_test.sh             |  8 +++---
 tests/sys/geom/class/mirror/12_test.sh             |  8 +++---
 tests/sys/geom/class/mirror/13_test.sh             |  8 +++---
 tests/sys/geom/class/mirror/1_test.sh              |  6 ++--
 tests/sys/geom/class/mirror/2_test.sh              |  6 ++--
 tests/sys/geom/class/mirror/3_test.sh              |  6 ++--
 tests/sys/geom/class/mirror/4_test.sh              |  6 ++--
 tests/sys/geom/class/mirror/5_test.sh              |  6 ++--
 tests/sys/geom/class/mirror/6_test.sh              |  6 ++--
 tests/sys/geom/class/mirror/7_test.sh              |  6 ++--
 tests/sys/geom/class/mirror/8_test.sh              |  4 +--
 tests/sys/geom/class/mirror/9_test.sh              |  6 ++--
 tests/sys/geom/class/mirror/component_selection.sh |  6 ++--
 tests/sys/geom/class/mirror/sync_error.sh          | 10 +++----
 tests/sys/geom/class/raid3/10_test.sh              |  6 ++--
 tests/sys/geom/class/raid3/11_test.sh              |  6 ++--
 tests/sys/geom/class/raid3/12_test.sh              |  6 ++--
 tests/sys/geom/class/raid3/1_test.sh               |  6 ++--
 tests/sys/geom/class/raid3/2_test.sh               |  6 ++--
 tests/sys/geom/class/raid3/3_test.sh               |  6 ++--
 tests/sys/geom/class/raid3/4_test.sh               |  6 ++--
 tests/sys/geom/class/raid3/5_test.sh               |  6 ++--
 tests/sys/geom/class/raid3/6_test.sh               |  6 ++--
 tests/sys/geom/class/raid3/7_test.sh               |  6 ++--
 tests/sys/geom/class/raid3/8_test.sh               |  6 ++--
 tests/sys/geom/class/raid3/9_test.sh               |  6 ++--
 tests/sys/geom/class/shsec/1_test.sh               |  6 ++--
 tests/sys/geom/class/shsec/2_test.sh               |  6 ++--
 tests/sys/geom/class/stripe/1_test.sh              |  6 ++--
 tests/sys/geom/class/stripe/2_test.sh              |  6 ++--
 tests/sys/geom/class/union/union_test.sh           | 32 +++++++++++-----------
 tests/sys/geom/class/uzip/1_test.sh                |  2 +-
 tests/sys/kern/sendfile_test.sh                    | 14 +++++-----
 51 files changed, 179 insertions(+), 175 deletions(-)

diff --git a/tests/sys/geom/class/concat/1_test.sh b/tests/sys/geom/class/concat/1_test.sh
index a35b015e9c24..126768370140 100644
--- a/tests/sys/geom/class/concat/1_test.sh
+++ b/tests/sys/geom/class/concat/1_test.sh
@@ -4,9 +4,9 @@
 
 echo '1..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
+attach_md us0 -t malloc -s 1M || exit 1
+attach_md us1 -t malloc -s 2M || exit 1
+attach_md us2 -t malloc -s 3M || exit 1
 
 gconcat create $name /dev/$us0 /dev/$us1 /dev/$us2 || exit 1
 devwait
diff --git a/tests/sys/geom/class/concat/2_test.sh b/tests/sys/geom/class/concat/2_test.sh
index 7b41932f054a..63e545f12297 100644
--- a/tests/sys/geom/class/concat/2_test.sh
+++ b/tests/sys/geom/class/concat/2_test.sh
@@ -8,9 +8,9 @@ tsize=6
 src=`mktemp $base.XXXXXX` || exit 1
 dst=`mktemp $base.XXXXXX` || 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
+attach_md us0 -t malloc -s 1M || exit 1
+attach_md us1 -t malloc -s 2M || exit 1
+attach_md us2 -t malloc -s 3M || exit 1
 
 dd if=/dev/random of=${src} bs=1m count=$tsize >/dev/null 2>&1
 
diff --git a/tests/sys/geom/class/concat/append1.sh b/tests/sys/geom/class/concat/append1.sh
index 08d6250fd190..b6ac3772022b 100644
--- a/tests/sys/geom/class/concat/append1.sh
+++ b/tests/sys/geom/class/concat/append1.sh
@@ -22,9 +22,9 @@ gconcat_check_size()
 
 echo '1..3'
 
-us0=$(attach_md -t malloc -s 1M) || exit 1
-us1=$(attach_md -t malloc -s 1M) || exit 1
-us2=$(attach_md -t malloc -s 1M) || exit 1
+attach_md us0 -t malloc -s 1M || exit 1
+attach_md us1 -t malloc -s 1M || exit 1
+attach_md us2 -t malloc -s 1M || exit 1
 
 gconcat create $name /dev/$us0 /dev/$us1 || exit 1
 devwait
diff --git a/tests/sys/geom/class/concat/append2.sh b/tests/sys/geom/class/concat/append2.sh
index 84a1f12350ba..d008e976cf57 100644
--- a/tests/sys/geom/class/concat/append2.sh
+++ b/tests/sys/geom/class/concat/append2.sh
@@ -31,9 +31,9 @@ truncate -s $((1024 * 1024 + $ss)) $f2
 f3=$(mktemp) || exit 1
 truncate -s $((1024 * 1024 + $ss)) $f3
 
-us0=$(attach_md -f $f1 -S $ss) || exit 1
-us1=$(attach_md -f $f2 -S $ss) || exit 1
-us2=$(attach_md -f $f3 -S $ss) || exit 1
+attach_md us0 -f $f1 -S $ss || exit 1
+attach_md us1 -f $f2 -S $ss || exit 1
+attach_md us2 -f $f3 -S $ss || exit 1
 
 gconcat label $name /dev/$us0 /dev/$us1 || exit 1
 devwait
@@ -57,9 +57,9 @@ detach_md $us2
 
 # Re-create the providers and verify that the concat device comes
 # back and that the data is still there.
-us0=$(attach_md -f $f1 -S $ss) || exit 1
-us1=$(attach_md -f $f2 -S $ss) || exit 1
-us2=$(attach_md -f $f3 -S $ss) || exit 1
+attach_md us0 -f $f1 -S $ss || exit 1
+attach_md us1 -f $f2 -S $ss || exit 1
+attach_md us2 -f $f3 -S $ss || exit 1
 
 devwait
 
diff --git a/tests/sys/geom/class/eli/attach_test.sh b/tests/sys/geom/class/eli/attach_test.sh
index bdb39a806fca..eb59234f014b 100644
--- a/tests/sys/geom/class/eli/attach_test.sh
+++ b/tests/sys/geom/class/eli/attach_test.sh
@@ -12,7 +12,7 @@ attach_d_body()
 	geli_test_setup
 
 	sectors=100
-	md=$(attach_md -t malloc -s `expr $sectors + 1`)
+	attach_md md -t malloc -s `expr $sectors + 1`
 
 	atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
 
@@ -50,7 +50,7 @@ attach_r_body()
 	geli_test_setup
 
 	sectors=100
-	md=$(attach_md -t malloc -s `expr $sectors + 1`)
+	attach_md md -t malloc -s `expr $sectors + 1`
 	atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
 
 	atf_check geli init -B none -P -K keyfile ${md}
@@ -78,9 +78,9 @@ attach_multiple_body()
 	geli_test_setup
 
 	sectors=100
-	md0=$(attach_md -t malloc -s `expr $sectors + 1`)
-	md1=$(attach_md -t malloc -s `expr $sectors + 1`)
-	md2=$(attach_md -t malloc -s `expr $sectors + 1`)
+	attach_md md0 -t malloc -s `expr $sectors + 1`
+	attach_md md1 -t malloc -s `expr $sectors + 1`
+	attach_md md2 -t malloc -s `expr $sectors + 1`
 	atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
 
 	atf_check geli init -B none -P -K keyfile ${md0}
@@ -108,7 +108,7 @@ nokey_body()
 	geli_test_setup
 
 	sectors=100
-	md=$(attach_md -t malloc -s `expr $sectors + 1`)
+	attach_md md -t malloc -s `expr $sectors + 1`
 	atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
 
 	atf_check geli init -B none -P -K keyfile ${md}
diff --git a/tests/sys/geom/class/eli/conf.sh b/tests/sys/geom/class/eli/conf.sh
index a21e645f1637..05ee4e9bb550 100644
--- a/tests/sys/geom/class/eli/conf.sh
+++ b/tests/sys/geom/class/eli/conf.sh
@@ -6,12 +6,14 @@ MAX_SECSIZE=8192
 
 attach_md()
 {
-	local test_md
+	local _md
+	local rv=$1
+	shift
 
 	[ -c /dev/mdctl ] || atf_skip "no /dev/mdctl to create md devices"
-	test_md=$(mdconfig -a "$@") || atf_fail "failed to allocate md(4)"
-	echo $test_md >> $TEST_MDS_FILE || exit
-	echo $test_md
+	_md=$(mdconfig -a "$@") || atf_fail "failed to allocate md(4)"
+	echo $_md >> $TEST_MDS_FILE || exit
+	eval "${rv}='${_md}'"
 }
 
 # Execute `func` for each combination of cipher, sectorsize, and hmac algo
@@ -30,9 +32,9 @@ for_each_geli_config() {
 		# Use a file-backed md(4) device, so we can deliberatly corrupt
 		# it without detaching the geli device first.
 		truncate -s $bytes backing_file
-		md=$(attach_md -t vnode -f backing_file)
+		attach_md md -t vnode -f backing_file
 	else
-		md=$(attach_md -t malloc -s $bytes)
+		attach_md md -t malloc -s $bytes
 	fi
 
 	for cipher in aes-xts:128 aes-xts:256 \
@@ -58,7 +60,7 @@ for_each_geli_config_nointegrity() {
 
 	# geli needs 512B for the label.
 	bytes=`expr $MAX_SECSIZE \* $sectors + 512`b
-	md=$(attach_md -t malloc -s $bytes)
+	attach_md md -t malloc -s $bytes
 	for cipher in aes-xts:128 aes-xts:256 \
 	    aes-cbc:128 aes-cbc:192 aes-cbc:256 \
 	    camellia-cbc:128 camellia-cbc:192 camellia-cbc:256; do
diff --git a/tests/sys/geom/class/eli/configure_test.sh b/tests/sys/geom/class/eli/configure_test.sh
index 6814fde1c301..4185b68c13ec 100644
--- a/tests/sys/geom/class/eli/configure_test.sh
+++ b/tests/sys/geom/class/eli/configure_test.sh
@@ -12,7 +12,7 @@ configure_b_B_body()
 	geli_test_setup
 
 	sectors=100
-	md=$(attach_md -t malloc -s `expr $sectors + 1`)
+	attach_md md -t malloc -s `expr $sectors + 1`
 
 	atf_check geli init -B none -P -K /dev/null ${md}
 
diff --git a/tests/sys/geom/class/eli/delkey_test.sh b/tests/sys/geom/class/eli/delkey_test.sh
index 374e14740580..2d03a6555ab3 100644
--- a/tests/sys/geom/class/eli/delkey_test.sh
+++ b/tests/sys/geom/class/eli/delkey_test.sh
@@ -13,7 +13,7 @@ delkey_body()
 	geli_test_setup
 
 	sectors=100
-	md=$(attach_md -t malloc -s `expr $sectors + 1`)
+	attach_md md -t malloc -s `expr $sectors + 1`
 
 	atf_check dd if=/dev/random of=keyfile1 bs=512 count=16 status=none
 	atf_check dd if=/dev/random of=keyfile2 bs=512 count=16 status=none
@@ -91,7 +91,7 @@ delkey_readonly_body()
 	geli_test_setup
 
 	sectors=100
-	md=$(attach_md -t malloc -s `expr $sectors + 1`)
+	attach_md md -t malloc -s `expr $sectors + 1`
 	atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
 
 	atf_check geli init -B none -P -K keyfile ${md}
diff --git a/tests/sys/geom/class/eli/detach_test.sh b/tests/sys/geom/class/eli/detach_test.sh
index c8952a0c739f..6acae8dea732 100644
--- a/tests/sys/geom/class/eli/detach_test.sh
+++ b/tests/sys/geom/class/eli/detach_test.sh
@@ -12,7 +12,7 @@ detach_l_body()
 	geli_test_setup
 
 	sectors=100
-	md=$(attach_md -t malloc -s `expr $sectors + 1`)
+	attach_md md -t malloc -s `expr $sectors + 1`
 
 	atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
 
diff --git a/tests/sys/geom/class/eli/init_test.sh b/tests/sys/geom/class/eli/init_test.sh
index 8d4e9363ea05..534fc724d05d 100644
--- a/tests/sys/geom/class/eli/init_test.sh
+++ b/tests/sys/geom/class/eli/init_test.sh
@@ -68,7 +68,7 @@ init_B_body()
 
 	atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
 
-	md=$(attach_md -t malloc -s $sectors)
+	attach_md md -t malloc -s $sectors
 
 	# -B none
 	rm -f /var/backups/${md}.eli
@@ -118,7 +118,7 @@ init_J_body()
 	geli_test_setup
 
 	sectors=100
-	md=$(attach_md -t malloc -s `expr $sectors + 1`)
+	attach_md md -t malloc -s `expr $sectors + 1`
 
 	atf_check dd if=/dev/random of=keyfile0 bs=512 count=16 status=none
 	atf_check dd if=/dev/random of=keyfile1 bs=512 count=16 status=none
@@ -303,7 +303,7 @@ init_alias_body()
 {
 	geli_test_setup
 
-	md=$(attach_md -t malloc -s 1024k)
+	attach_md md -t malloc -s 1024k
 	atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
 
 	for spec in aes:0:AES-XTS:128 aes:128:AES-XTS:128 aes:256:AES-XTS:256 \
@@ -334,7 +334,7 @@ init_i_P_body()
 	geli_test_setup
 
 	sectors=100
-	md=$(attach_md -t malloc -s `expr $sectors + 1`)
+	attach_md md -t malloc -s `expr $sectors + 1`
 
 	atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
 
@@ -357,7 +357,7 @@ nokey_body()
 	geli_test_setup
 
 	sectors=100
-	md=$(attach_md -t malloc -s `expr $sectors + 1`)
+	attach_md md -t malloc -s `expr $sectors + 1`
 
 	atf_check -s not-exit:0 -e match:"No key components given" \
 		geli init -B none -P ${md}
diff --git a/tests/sys/geom/class/eli/kill_test.sh b/tests/sys/geom/class/eli/kill_test.sh
index 422627f1f70c..eeaa440f11a9 100644
--- a/tests/sys/geom/class/eli/kill_test.sh
+++ b/tests/sys/geom/class/eli/kill_test.sh
@@ -12,7 +12,7 @@ kill_body()
 	geli_test_setup
 
 	sectors=100
-	md=$(attach_md -t malloc -s `expr $sectors + 1`)
+	attach_md md -t malloc -s `expr $sectors + 1`
 
 	atf_check dd if=/dev/random of=keyfile1 bs=512 count=16 status=none
 	atf_check dd if=/dev/random of=keyfile2 bs=512 count=16 status=none
@@ -76,7 +76,7 @@ kill_readonly_body()
 	geli_test_setup
 
 	sectors=100
-	md=$(attach_md -t malloc -s `expr $sectors + 1`)
+	attach_md md -t malloc -s `expr $sectors + 1`
 	atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
 
 	atf_check geli init -B none -P -K keyfile ${md}
diff --git a/tests/sys/geom/class/eli/misc_test.sh b/tests/sys/geom/class/eli/misc_test.sh
index 2e1b1936f3a0..1cbeb0491ffd 100644
--- a/tests/sys/geom/class/eli/misc_test.sh
+++ b/tests/sys/geom/class/eli/misc_test.sh
@@ -37,7 +37,7 @@ preserve_props_body()
 {
 	geli_test_setup
 
-	md=$(attach_md -s1m)
+	attach_md md -s1m
 	atf_check geli onetime /dev/${md}
 	md_secsize=$(diskinfo ${md} | cut -wf 2)
 	md_stripesize=$(diskinfo ${md} | cut -wf 5)
@@ -103,7 +103,7 @@ physpath_body()
 		atf_skip "$error_message"
 	fi
 
-	md=$(attach_md -s1m)
+	attach_md md -s1m
 	# If the underlying device has no physical path, then geli should not
 	# create one.
 	atf_check -o empty -e ignore diskinfo -p $md
diff --git a/tests/sys/geom/class/eli/onetime_test.sh b/tests/sys/geom/class/eli/onetime_test.sh
index 214533e1cb91..65306840384a 100644
--- a/tests/sys/geom/class/eli/onetime_test.sh
+++ b/tests/sys/geom/class/eli/onetime_test.sh
@@ -103,7 +103,7 @@ onetime_d_body()
 	geli_test_setup
 
 	sectors=100
-	md=$(attach_md -t malloc -s $sectors)
+	attach_md md -t malloc -s $sectors
 
 	atf_check geli onetime -d ${md}
 	if [ ! -c /dev/${md}.eli ]; then
@@ -147,7 +147,7 @@ onetime_null_body()
 	ealgo=${cipher%%:*}
 	keylen=${cipher##*:}
 
-	md=$(attach_md -t malloc -s 100k)
+	attach_md md -t malloc -s 100k
 
 	atf_check -s exit:0 -o ignore -e ignore \
 		geli onetime -e null -s ${secsize} ${md}
diff --git a/tests/sys/geom/class/eli/online_resize_test.sh b/tests/sys/geom/class/eli/online_resize_test.sh
index e137a7305122..ef6fe85c63d0 100755
--- a/tests/sys/geom/class/eli/online_resize_test.sh
+++ b/tests/sys/geom/class/eli/online_resize_test.sh
@@ -42,7 +42,7 @@ online_resize_body()
 			psize30="33776997205278720"
 		fi
 
-		md=$(attach_md -t malloc -s40${prefix})
+		attach_md md -t malloc -s40${prefix}
 
 		# Initialise
 		atf_check -s exit:0 -o ignore gpart create -s GPT ${md}
diff --git a/tests/sys/geom/class/eli/resize_test.sh b/tests/sys/geom/class/eli/resize_test.sh
index c6f9e459e934..832bfeee5c92 100644
--- a/tests/sys/geom/class/eli/resize_test.sh
+++ b/tests/sys/geom/class/eli/resize_test.sh
@@ -15,7 +15,7 @@ resize_body()
 	BLK=512
 	BLKS_PER_MB=2048
 
-	md=$(attach_md -t malloc -s40m)
+	attach_md md -t malloc -s40m
 
 	# Initialise
 	atf_check -s exit:0 -o ignore gpart create -s BSD ${md}
diff --git a/tests/sys/geom/class/eli/setkey_test.sh b/tests/sys/geom/class/eli/setkey_test.sh
index 34fb8221ab04..92387a8a8ab6 100644
--- a/tests/sys/geom/class/eli/setkey_test.sh
+++ b/tests/sys/geom/class/eli/setkey_test.sh
@@ -13,7 +13,7 @@ setkey_body()
 	geli_test_setup
 
 	sectors=100
-	md=$(attach_md -t malloc -s `expr $sectors + 1`)
+	attach_md md -t malloc -s `expr $sectors + 1`
 
 	atf_check dd if=/dev/random of=rnd bs=512 count=${sectors} status=none
 	hash1=`dd if=rnd bs=512 count=${sectors} status=none | md5`
@@ -103,7 +103,7 @@ setkey_passphrase_body()
 	geli_test_setup
 
 	sectors=100
-	md=$(attach_md -t malloc -s `expr $sectors + 1`)
+	attach_md md -t malloc -s `expr $sectors + 1`
 
 	atf_check dd if=/dev/random of=rnd bs=512 count=${sectors} status=none
 	hash1=`dd if=rnd bs=512 count=${sectors} status=none | md5`
@@ -161,7 +161,7 @@ setkey_readonly_body()
 	geli_test_setup
 
 	sectors=100
-	md=$(attach_md -t malloc -s `expr $sectors + 1`)
+	attach_md md -t malloc -s `expr $sectors + 1`
 	atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
 
 	atf_check geli init -B none -P -K keyfile ${md}
@@ -186,7 +186,7 @@ nokey_body()
 	geli_test_setup
 
 	sectors=100
-	md=$(attach_md -t malloc -s `expr $sectors + 1`)
+	attach_md md -t malloc -s `expr $sectors + 1`
 	atf_check dd if=/dev/random of=keyfile1 bs=512 count=16 status=none
 	atf_check dd if=/dev/random of=keyfile2 bs=512 count=16 status=none
 
diff --git a/tests/sys/geom/class/geom_subr.sh b/tests/sys/geom/class/geom_subr.sh
index f8eca4c6b220..8e3b12d5f620 100644
--- a/tests/sys/geom/class/geom_subr.sh
+++ b/tests/sys/geom/class/geom_subr.sh
@@ -14,12 +14,14 @@ devwait()
 
 attach_md()
 {
-	local test_md
+	local _md
+	local rv=$1
+	shift
 
 	[ -c /dev/mdctl ] || atf_skip "no /dev/mdctl to create md devices"
-	test_md=$(mdconfig -a "$@") || exit
-	echo $test_md >> $TEST_MDS_FILE || exit
-	echo $test_md
+	_md=$(mdconfig -a "$@") || exit
+	echo $_md >> $TEST_MDS_FILE || exit
+	eval "${rv}='${_md}'"
 }
 
 detach_md()
diff --git a/tests/sys/geom/class/mirror/10_test.sh b/tests/sys/geom/class/mirror/10_test.sh
index 775eb7f99591..351689d1e185 100644
--- a/tests/sys/geom/class/mirror/10_test.sh
+++ b/tests/sys/geom/class/mirror/10_test.sh
@@ -16,8 +16,8 @@ m2=$(mktemp $base.XXXXXX)
 dd if=/dev/random of=$m1 bs=$ddbs count=1024 >/dev/null 2>&1
 dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&1
 
-us0=$(attach_md -t vnode -f $m1)
-us1=$(attach_md -t vnode -f $m2)
+attach_md us0 -t vnode -f $m1
+attach_md us1 -t vnode -f $m2
 
 gmirror label $name /dev/$us0
 gmirror insert $name /dev/$us1
@@ -52,10 +52,10 @@ fi
 # Force a retaste of the disconnected component.
 if [ $(gmirror status -s $name | awk '{print $3}') = $us0 ]; then
 	detach_md $us1
-	us1=$(attach_md -t vnode -f $m2)
+	attach_md us1 -t vnode -f $m2
 else
 	detach_md $us0
-	us0=$(attach_md -t vnode -f $m1)
+	attach_md us0 -t vnode -f $m1
 fi
 
 # Make sure that the component wasn't re-added to the gmirror.
diff --git a/tests/sys/geom/class/mirror/11_test.sh b/tests/sys/geom/class/mirror/11_test.sh
index 7d4324e383e9..0e498ae03d15 100644
--- a/tests/sys/geom/class/mirror/11_test.sh
+++ b/tests/sys/geom/class/mirror/11_test.sh
@@ -16,8 +16,8 @@ m2=$(mktemp $base.XXXXXX)
 dd if=/dev/random of=$m1 bs=$ddbs count=1024 >/dev/null 2>&1
 dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&1
 
-us0=$(attach_md -t vnode -f $m1)
-us1=$(attach_md -t vnode -f $m2)
+attach_md us0 -t vnode -f $m1
+attach_md us1 -t vnode -f $m2
 
 gmirror label $name /dev/$us0
 gmirror insert $name /dev/$us1
@@ -65,10 +65,10 @@ fi
 # Force a retaste of the disconnected component.
 if [ $(gmirror status -s $name | awk '{print $3}') = $us0 ]; then
 	detach_md $us1
-	us1=$(attach_md -t vnode -f $m2)
+	attach_md us1 -t vnode -f $m2
 else
 	detach_md $us0
-	us0=$(attach_md -t vnode -f $m1)
+	attach_md us0 -t vnode -f $m1
 fi
 
 # Make sure that the retaste caused the mirror to automatically be re-added.
diff --git a/tests/sys/geom/class/mirror/12_test.sh b/tests/sys/geom/class/mirror/12_test.sh
index 36132269bc81..4f24dd081fef 100644
--- a/tests/sys/geom/class/mirror/12_test.sh
+++ b/tests/sys/geom/class/mirror/12_test.sh
@@ -16,8 +16,8 @@ m2=$(mktemp $base.XXXXXX)
 dd if=/dev/zero of=$m1 bs=$ddbs count=1024 >/dev/null 2>&1
 dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&1
 
-us0=$(attach_md -t vnode -f $m1)
-us1=$(attach_md -t vnode -f $m2)
+attach_md us0 -t vnode -f $m1
+attach_md us1 -t vnode -f $m2
 
 gmirror label $name /dev/$us0 /dev/$us1
 devwait
@@ -51,10 +51,10 @@ fi
 # Force a retaste of the disconnected component.
 if [ $(gmirror status -s $name | awk '{print $3}') = $us0 ]; then
 	detach_md $us1
-	us1=$(attach_md -t vnode -f $m2)
+	attach_md us1 -t vnode -f $m2
 else
 	detach_md $us0
-	us0=$(attach_md -t vnode -f $m1)
+	attach_md us0 -t vnode -f $m1
 fi
 
 # Make sure that the component wasn't re-added to the gmirror.
diff --git a/tests/sys/geom/class/mirror/13_test.sh b/tests/sys/geom/class/mirror/13_test.sh
index 1ff004e3ba54..c312a1b7a795 100644
--- a/tests/sys/geom/class/mirror/13_test.sh
+++ b/tests/sys/geom/class/mirror/13_test.sh
@@ -16,8 +16,8 @@ m2=$(mktemp $base.XXXXXX)
 dd if=/dev/random of=$m1 bs=$ddbs count=1024 >/dev/null 2>&1
 dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&1
 
-us0=$(attach_md -t vnode -f $m1)
-us1=$(attach_md -t vnode -f $m2)
+attach_md us0 -t vnode -f $m1
+attach_md us1 -t vnode -f $m2
 
 gmirror label $name /dev/$us0 /dev/$us1
 devwait
@@ -62,10 +62,10 @@ fi
 # Force a retaste of the disconnected component.
 if [ $(gmirror status -s $name | awk '{print $3}') = $us0 ]; then
 	detach_md $us1
-	us1=$(attach_md -t vnode -f $m2)
+	attach_md us1 -t vnode -f $m2
 else
 	detach_md $us0
-	us0=$(attach_md -t vnode -f $m1)
+	attach_md us0 -t vnode -f $m1
 fi
 
 # Make sure that the retaste caused the mirror to automatically be re-added.
diff --git a/tests/sys/geom/class/mirror/1_test.sh b/tests/sys/geom/class/mirror/1_test.sh
index bcd903e0d3f8..929aa1c6ddcf 100644
--- a/tests/sys/geom/class/mirror/1_test.sh
+++ b/tests/sys/geom/class/mirror/1_test.sh
@@ -4,9 +4,9 @@
 
 echo "1..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
+attach_md us0 -t malloc -s 1M || exit 1
+attach_md us1 -t malloc -s 2M || exit 1
+attach_md us2 -t malloc -s 3M || exit 1
 
 gmirror label $name /dev/$us0 /dev/$us1 /dev/$us2 || exit 1
 devwait
diff --git a/tests/sys/geom/class/mirror/2_test.sh b/tests/sys/geom/class/mirror/2_test.sh
index 7bb813502047..31bb426d05d7 100644
--- a/tests/sys/geom/class/mirror/2_test.sh
+++ b/tests/sys/geom/class/mirror/2_test.sh
@@ -13,9 +13,9 @@ dst=`mktemp $base.XXXXXX` || exit 1
 
 dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&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
+attach_md us0 -t malloc -s `expr $nblocks1 + 1` || exit 1
+attach_md us1 -t malloc -s `expr $nblocks1 + 1` || exit 1
+attach_md us2 -t malloc -s `expr $nblocks1 + 1` || exit 1
 
 gmirror label -b $balance $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1
 devwait
diff --git a/tests/sys/geom/class/mirror/3_test.sh b/tests/sys/geom/class/mirror/3_test.sh
index 83993d32df2f..dd2ca8f028fd 100644
--- a/tests/sys/geom/class/mirror/3_test.sh
+++ b/tests/sys/geom/class/mirror/3_test.sh
@@ -13,9 +13,9 @@ dst=`mktemp $base.XXXXXX` || exit 1
 
 dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&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
+attach_md us0 -t malloc -s `expr $nblocks1 + 1` || exit 1
+attach_md us1 -t malloc -s `expr $nblocks1 + 1` || exit 1
+attach_md us2 -t malloc -s `expr $nblocks1 + 1` || exit 1
 
 gmirror label -b $balance $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1
 devwait
diff --git a/tests/sys/geom/class/mirror/4_test.sh b/tests/sys/geom/class/mirror/4_test.sh
index 46222fbecb2c..a5f469a2d95e 100644
--- a/tests/sys/geom/class/mirror/4_test.sh
+++ b/tests/sys/geom/class/mirror/4_test.sh
@@ -13,9 +13,9 @@ dst=`mktemp $base.XXXXXX` || exit 1
 
 dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&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
+attach_md us0 -t malloc -s `expr $nblocks1 + 1` || exit 1
+attach_md us1 -t malloc -s `expr $nblocks1 + 1` || exit 1
+attach_md us2 -t malloc -s `expr $nblocks1 + 1` || exit 1
 
 gmirror label -b $balance $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1
 devwait
diff --git a/tests/sys/geom/class/mirror/5_test.sh b/tests/sys/geom/class/mirror/5_test.sh
index 7bdb122255e4..43062dc1feea 100644
--- a/tests/sys/geom/class/mirror/5_test.sh
+++ b/tests/sys/geom/class/mirror/5_test.sh
@@ -13,9 +13,9 @@ dst=`mktemp $base.XXXXXX` || exit 1
 
 dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&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
+attach_md us0 -t malloc -s `expr $nblocks1 + 1` || exit 1
+attach_md us1 -t malloc -s `expr $nblocks1 + 1` || exit 1
+attach_md us2 -t malloc -s `expr $nblocks1 + 1` || exit 1
 
 gmirror label -b $balance -s `expr $ddbs / 2` $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1
 devwait
diff --git a/tests/sys/geom/class/mirror/6_test.sh b/tests/sys/geom/class/mirror/6_test.sh
index 0baa511d0689..f37a45404642 100644
--- a/tests/sys/geom/class/mirror/6_test.sh
+++ b/tests/sys/geom/class/mirror/6_test.sh
@@ -13,9 +13,9 @@ dst=`mktemp $base.XXXXXX` || exit 1
 
 dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&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
+attach_md us0 -t malloc -s `expr $nblocks1 + 1` || exit 1
+attach_md us1 -t malloc -s `expr $nblocks1 + 1` || exit 1
+attach_md us2 -t malloc -s `expr $nblocks1 + 1` || exit 1
 
 gmirror label -b $balance -s `expr $ddbs / 2` $name /dev/${us0} /dev/${us1} || exit 1
 devwait
diff --git a/tests/sys/geom/class/mirror/7_test.sh b/tests/sys/geom/class/mirror/7_test.sh
index 2eded509a337..5f93f2fc4943 100644
--- a/tests/sys/geom/class/mirror/7_test.sh
+++ b/tests/sys/geom/class/mirror/7_test.sh
@@ -13,9 +13,9 @@ dst=`mktemp $base.XXXXXX` || exit 1
 
 dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&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
+attach_md us0 -t malloc -s `expr $nblocks1 + 1` || exit 1
+attach_md us1 -t malloc -s `expr $nblocks1 + 1` || exit 1
+attach_md us2 -t malloc -s `expr $nblocks1 + 1` || exit 1
 
 gmirror label -b $balance $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1
 devwait
diff --git a/tests/sys/geom/class/mirror/8_test.sh b/tests/sys/geom/class/mirror/8_test.sh
index 5b3e5c3543a1..baea157a0ba8 100644
--- a/tests/sys/geom/class/mirror/8_test.sh
+++ b/tests/sys/geom/class/mirror/8_test.sh
@@ -34,11 +34,11 @@ mdconfig -d -u ${us1#md} -o force || exit 1
 exec 9>&-
 
 dd if=/dev/random of=$m1 bs=$ddbs count=1 conv=notrunc >/dev/null 2>&1
-us0=$(attach_md -t vnode -f $m1) || exit 1
+attach_md us0 -t vnode -f $m1 || exit 1
 devwait # This will take kern.geom.mirror.timeout seconds.
 
 # Re-attach the second mirror and wait for it to synchronize.
-us1=$(attach_md -t vnode -f $m2) || exit 1
+attach_md us1 -t vnode -f $m2 || exit 1
 syncwait
 
 # Verify the two mirrors are identical. Destroy the gmirror first so that
diff --git a/tests/sys/geom/class/mirror/9_test.sh b/tests/sys/geom/class/mirror/9_test.sh
index a350ce9dfe3a..6bcb26860615 100644
--- a/tests/sys/geom/class/mirror/9_test.sh
+++ b/tests/sys/geom/class/mirror/9_test.sh
@@ -15,9 +15,9 @@ dd if=/dev/zero of=$m1 bs=$ddbs count=1024 >/dev/null 2>&1
 dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&1
 dd if=/dev/zero of=$m3 bs=$ddbs count=1024 >/dev/null 2>&1
 
-us0=$(attach_md -t vnode -f $m1) || exit 1
-us1=$(attach_md -t vnode -f $m2) || exit 1
-us2=$(attach_md -t vnode -f $m3) || exit 1
+attach_md us0 -t vnode -f $m1 || exit 1
+attach_md us1 -t vnode -f $m2 || exit 1
+attach_md us2 -t vnode -f $m3 || exit 1
 
 gmirror label $name /dev/$us0 /dev/$us1 || exit 1
 devwait
diff --git a/tests/sys/geom/class/mirror/component_selection.sh b/tests/sys/geom/class/mirror/component_selection.sh
index 7c7020eb6e6b..b5c8cec78c61 100755
--- a/tests/sys/geom/class/mirror/component_selection.sh
+++ b/tests/sys/geom/class/mirror/component_selection.sh
@@ -29,9 +29,9 @@ run_latest_genid_body()
 	dd if=/dev/urandom bs=512 count=1 of="$rnd1"
 	dd if=/dev/urandom bs=512 count=1 of="$rnd2"
 
-	md1=$(attach_md -t vnode -f ${f1})
-	md2=$(attach_md -t vnode -f ${f2})
-	md3=$(attach_md -t vnode -f ${f3})
+	attach_md md1 -t vnode -f ${f1}
+	attach_md md2 -t vnode -f ${f2}
+	attach_md md3 -t vnode -f ${f3}
 
 	# Use a gnop for md1 just for consistency; it's not used for anything.
 	atf_check gnop create $md1
diff --git a/tests/sys/geom/class/mirror/sync_error.sh b/tests/sys/geom/class/mirror/sync_error.sh
index 6b59dbe4fd4c..c51418151f0a 100644
--- a/tests/sys/geom/class/mirror/sync_error.sh
+++ b/tests/sys/geom/class/mirror/sync_error.sh
@@ -21,8 +21,8 @@ sync_read_error_2_disks_body()
 	atf_check dd if=/dev/zero bs=1M count=32 of=$f1 status=none
 	atf_check truncate -s 32M $f2 
 
-	md1=$(attach_md -t vnode -f ${f1})
-	md2=$(attach_md -t vnode -f ${f2})
+	attach_md md1 -t vnode -f ${f1}
+	attach_md md2 -t vnode -f ${f2}
 
 	atf_check gmirror label $name $md1
 	devwait
@@ -64,9 +64,9 @@ sync_read_error_3_disks_body()
 	atf_check truncate -s 32M $f2
 	atf_check truncate -s 32M $f3
 
-	md1=$(attach_md -t vnode -f ${f1})
-	md2=$(attach_md -t vnode -f ${f2})
-	md3=$(attach_md -t vnode -f ${f3})
+	attach_md md1 -t vnode -f ${f1}
+	attach_md md2 -t vnode -f ${f2}
+	attach_md md3 -t vnode -f ${f3}
 
 	atf_check gmirror label $name $md1
 	devwait
diff --git a/tests/sys/geom/class/raid3/10_test.sh b/tests/sys/geom/class/raid3/10_test.sh
index da141c5992ae..ec7c47253465 100644
--- a/tests/sys/geom/class/raid3/10_test.sh
+++ b/tests/sys/geom/class/raid3/10_test.sh
@@ -10,9 +10,9 @@ nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
 src=`mktemp $base.XXXXXX` || exit 1
 dst=`mktemp $base.XXXXXX` || 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
+attach_md us0 -t malloc -s $(expr $nblocks1 + 1) || exit 1
+attach_md us1 -t malloc -s $(expr $nblocks1 + 1) || exit 1
+attach_md us2 -t malloc -s $(expr $nblocks1 + 1) || exit 1
 
 dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 
diff --git a/tests/sys/geom/class/raid3/11_test.sh b/tests/sys/geom/class/raid3/11_test.sh
index 56a126a91cb4..73aa1cc7f982 100644
--- a/tests/sys/geom/class/raid3/11_test.sh
+++ b/tests/sys/geom/class/raid3/11_test.sh
@@ -10,9 +10,9 @@ nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
 src=`mktemp $base.XXXXXX` || exit 1
 dst=`mktemp $base.XXXXXX` || 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
+attach_md us0 -t malloc -s $(expr $nblocks1 + 1) || exit 1
+attach_md us1 -t malloc -s $(expr $nblocks1 + 1) || exit 1
+attach_md us2 -t malloc -s $(expr $nblocks1 + 1) || exit 1
 
 dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 
diff --git a/tests/sys/geom/class/raid3/12_test.sh b/tests/sys/geom/class/raid3/12_test.sh
index 5224521223a8..4284ac616ac1 100644
--- a/tests/sys/geom/class/raid3/12_test.sh
+++ b/tests/sys/geom/class/raid3/12_test.sh
@@ -8,9 +8,9 @@ nblocks1=9
 nblocks2=`expr $nblocks1 - 1`
 nblocks3=`expr $nblocks2 / 2`
 
-us0=$(attach_md -t malloc -s $nblocks1) || exit 1
-us1=$(attach_md -t malloc -s $nblocks1) || exit 1
-us2=$(attach_md -t malloc -s $nblocks1) || exit 1
+attach_md us0 -t malloc -s $nblocks1 || exit 1
+attach_md us1 -t malloc -s $nblocks1 || exit 1
+attach_md us2 -t malloc -s $nblocks1 || exit 1
 
 dd if=/dev/random of=/dev/${us0} count=$nblocks1 >/dev/null 2>&1
 dd if=/dev/random of=/dev/${us1} count=$nblocks1 >/dev/null 2>&1
diff --git a/tests/sys/geom/class/raid3/1_test.sh b/tests/sys/geom/class/raid3/1_test.sh
index 638439c9ab9f..1df627114135 100644
--- a/tests/sys/geom/class/raid3/1_test.sh
+++ b/tests/sys/geom/class/raid3/1_test.sh
@@ -4,9 +4,9 @@
 
 echo "1..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
+attach_md us0 -t malloc -s 1M || exit 1
+attach_md us1 -t malloc -s 2M || exit 1
+attach_md us2 -t malloc -s 3M || exit 1
 
 graid3 label $name /dev/${us0} /dev/${us1} /dev/${us2} 2>/dev/null || exit 1
 devwait
diff --git a/tests/sys/geom/class/raid3/2_test.sh b/tests/sys/geom/class/raid3/2_test.sh
index f8642160c6fc..db16542f77ed 100644
--- a/tests/sys/geom/class/raid3/2_test.sh
+++ b/tests/sys/geom/class/raid3/2_test.sh
@@ -10,9 +10,9 @@ nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
 src=`mktemp $base.XXXXXX` || exit 1
 dst=`mktemp $base.XXXXXX` || 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
+attach_md us0 -t malloc -s $(expr $nblocks1 + 1) || exit 1
+attach_md us1 -t malloc -s $(expr $nblocks1 + 1) || exit 1
+attach_md us2 -t malloc -s $(expr $nblocks1 + 1) || exit 1
 
 dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 
diff --git a/tests/sys/geom/class/raid3/3_test.sh b/tests/sys/geom/class/raid3/3_test.sh
index 656a9ad04328..64d7d5caaaf3 100644
--- a/tests/sys/geom/class/raid3/3_test.sh
+++ b/tests/sys/geom/class/raid3/3_test.sh
@@ -10,9 +10,9 @@ nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
 src=`mktemp $base.XXXXXX` || exit 1
 dst=`mktemp $base.XXXXXX` || 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
+attach_md us0 -t malloc -s $(expr $nblocks1 + 1) || exit 1
+attach_md us1 -t malloc -s $(expr $nblocks1 + 1) || exit 1
+attach_md us2 -t malloc -s $(expr $nblocks1 + 1) || exit 1
 
 dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 
diff --git a/tests/sys/geom/class/raid3/4_test.sh b/tests/sys/geom/class/raid3/4_test.sh
index 698044f0c425..749729407368 100644
--- a/tests/sys/geom/class/raid3/4_test.sh
+++ b/tests/sys/geom/class/raid3/4_test.sh
@@ -10,9 +10,9 @@ nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
 src=`mktemp $base.XXXXXX` || exit 1
 dst=`mktemp $base.XXXXXX` || 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
+attach_md us0 -t malloc -s $(expr $nblocks1 + 1) || exit 1
+attach_md us1 -t malloc -s $(expr $nblocks1 + 1) || exit 1
+attach_md us2 -t malloc -s $(expr $nblocks1 + 1) || exit 1
 
 dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 
diff --git a/tests/sys/geom/class/raid3/5_test.sh b/tests/sys/geom/class/raid3/5_test.sh
index 66cfa9e58b8b..76d90cb60754 100644
--- a/tests/sys/geom/class/raid3/5_test.sh
+++ b/tests/sys/geom/class/raid3/5_test.sh
@@ -10,9 +10,9 @@ nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
 src=`mktemp $base.XXXXXX` || exit 1
 dst=`mktemp $base.XXXXXX` || 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
+attach_md us0 -t malloc -s $(expr $nblocks1 + 1) || exit 1
+attach_md us1 -t malloc -s $(expr $nblocks1 + 1) || exit 1
+attach_md us2 -t malloc -s $(expr $nblocks1 + 1) || exit 1
 
 dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 
diff --git a/tests/sys/geom/class/raid3/6_test.sh b/tests/sys/geom/class/raid3/6_test.sh
index 562c6f021e88..4c1d3288b82b 100644
--- a/tests/sys/geom/class/raid3/6_test.sh
+++ b/tests/sys/geom/class/raid3/6_test.sh
@@ -10,9 +10,9 @@ nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
 src=`mktemp $base.XXXXXX` || exit 1
 dst=`mktemp $base.XXXXXX` || 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
+attach_md us0 -t malloc -s $(expr $nblocks1 + 1) || exit 1
+attach_md us1 -t malloc -s $(expr $nblocks1 + 1) || exit 1
+attach_md us2 -t malloc -s $(expr $nblocks1 + 1) || exit 1
 
 dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 
diff --git a/tests/sys/geom/class/raid3/7_test.sh b/tests/sys/geom/class/raid3/7_test.sh
index e2aeb783890f..53933c96cd99 100644
--- a/tests/sys/geom/class/raid3/7_test.sh
+++ b/tests/sys/geom/class/raid3/7_test.sh
@@ -10,9 +10,9 @@ nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
 src=`mktemp $base.XXXXXX` || exit 1
 dst=`mktemp $base.XXXXXX` || 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
+attach_md us0 -t malloc -s $(expr $nblocks1 + 1) || exit 1
+attach_md us1 -t malloc -s $(expr $nblocks1 + 1) || exit 1
+attach_md us2 -t malloc -s $(expr $nblocks1 + 1) || exit 1
 
 dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
 
diff --git a/tests/sys/geom/class/raid3/8_test.sh b/tests/sys/geom/class/raid3/8_test.sh
index bd3463a465f2..4c31ec0d4b1c 100644
--- a/tests/sys/geom/class/raid3/8_test.sh
+++ b/tests/sys/geom/class/raid3/8_test.sh
@@ -10,9 +10,9 @@ nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
 src=`mktemp $base.XXXXXX` || exit 1
 dst=`mktemp $base.XXXXXX` || exit 1
 
*** 247 LINES SKIPPED ***