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:			ea82362219
This commit is contained in:
Gleb Smirnoff 2023-11-27 13:15:58 -08:00
parent 1d723c1e56
commit 96950419f1
51 changed files with 179 additions and 175 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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}

View file

@ -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

View file

@ -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}

View file

@ -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}

View file

@ -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

View file

@ -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}

View file

@ -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}

View file

@ -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

View file

@ -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}

View file

@ -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}

View file

@ -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}

View file

@ -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

View file

@ -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()

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
gshsec label $name /dev/${us0} /dev/${us1} /dev/${us2} 2>/dev/null || exit 1
devwait

View file

@ -11,9 +11,9 @@ dst=`mktemp $base.XXXXXX` || exit 1
dd if=/dev/random of=${src} count=$nblocks1 >/dev/null 2>&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
attach_md us0 -t malloc -s $nblocks2 || exit 1
attach_md us1 -t malloc -s $nblocks2 || exit 1
attach_md us2 -t malloc -s $nblocks2 || exit 1
gshsec label $name /dev/$us0 /dev/$us1 /dev/$us2 || exit 1
devwait

View file

@ -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
gstripe create -s 16384 $name /dev/$us0 /dev/$us1 /dev/$us2 || exit 1
devwait

View file

@ -10,9 +10,9 @@ dst=`mktemp $base.XXXXXX` || exit 1
dd if=/dev/random of=${src} bs=1m count=$tsize >/dev/null 2>&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
gstripe create -s 8192 $name /dev/$us0 /dev/$us1 /dev/$us2 || exit 1
devwait

View file

@ -39,8 +39,8 @@ create_body()
{
gunion_test_setup
upperdev="$(attach_md -s 1m)"
lowerdev="$(attach_md -s 1m)"
attach_md upperdev -s 1m
attach_md lowerdev -s 1m
newfs -U "/dev/${lowerdev}"
atf_check gunion create "$upperdev" "$lowerdev"
@ -66,8 +66,8 @@ basic_body()
{
gunion_test_setup
upperdev="$(attach_md -s 1m)"
lowerdev="$(attach_md -s 1m)"
attach_md upperdev -s 1m
attach_md lowerdev -s 1m
newfs -U "/dev/${lowerdev}"
mkdir lowermnt
mkdir gunionmnt
@ -109,8 +109,8 @@ commit_body()
{
gunion_test_setup
upperdev="$(attach_md -s 1m)"
lowerdev="$(attach_md -s 1m)"
attach_md upperdev -s 1m
attach_md lowerdev -s 1m
newfs -U "/dev/${lowerdev}"
mkdir lowermnt
mkdir gunionmnt
@ -155,8 +155,8 @@ offset_body()
{
gunion_test_setup
upperdev="$(attach_md -s 1m)"
lowerdev="$(attach_md -s 1m)"
attach_md upperdev -s 1m
attach_md lowerdev -s 1m
gpart create -s GPT "/dev/${lowerdev}"
gpart add -t freebsd-ufs "$lowerdev"
newfs "/dev/${lowerdev}p1"
@ -193,8 +193,8 @@ size_body()
{
gunion_test_setup
upperdev="$(attach_md -s 2m)"
lowerdev="$(attach_md -s 1m)"
attach_md upperdev -s 2m
attach_md lowerdev -s 1m
newfs -U "/dev/${lowerdev}"
gunion create -s 2m "$upperdev" "$lowerdev"
@ -219,8 +219,8 @@ secsize_body()
{
gunion_test_setup
upperdev="$(attach_md -s 1m)"
lowerdev="$(attach_md -s 1m)"
attach_md upperdev -s 1m
attach_md lowerdev -s 1m
newfs -S 512 -U "/dev/${lowerdev}"
lower_secsize="$(diskinfo "/dev/${lowerdev}" | awk '{print $2}')"
atf_check_equal "512" "$lower_secsize"
@ -247,8 +247,8 @@ gunionname_body()
{
gunion_test_setup
upperdev="$(attach_md -s 1m)"
lowerdev="$(attach_md -s 1m)"
attach_md upperdev -s 1m
attach_md lowerdev -s 1m
newfs -U "/dev/${lowerdev}"
gunion create -Z gunion1 "$upperdev" "$lowerdev"
@ -270,8 +270,8 @@ revert_body()
{
gunion_test_setup
upperdev="$(attach_md -s 1m)"
lowerdev="$(attach_md -s 1m)"
attach_md upperdev -s 1m
attach_md lowerdev -s 1m
newfs -U "/dev/${lowerdev}"
mkdir lowermnt
mkdir gunionmnt

View file

@ -19,7 +19,7 @@ fi
echo "1..1"
uudecode $UUE
us0=$(attach_md -f $(basename $UUE .uue)) || exit 1
attach_md us0 -f $(basename $UUE .uue) || exit 1
sleep 1
mount -o ro /dev/${us0}.uzip "${mntpoint}" || exit 1

View file

@ -54,7 +54,7 @@ io_success_body()
atf_skip "Sendfile(4) unimplemented. https://github.com/qemu-bsd-user/qemu-bsd-user/issues/25"
fi
md=$(alloc_md)
alloc_md md
common_body_setup $md
atf_check $HELPER $FILE 0 0x10000 0x10000
@ -77,7 +77,7 @@ io_fail_sync_body()
atf_skip "Sendfile(4) unimplemented. https://github.com/qemu-bsd-user/qemu-bsd-user/issues/25"
fi
md=$(alloc_md)
alloc_md md
common_body_setup $md
atf_check gnop configure -r 100 -e 5 ${md}.nop
@ -101,7 +101,7 @@ io_fail_async_body()
atf_skip "Sendfile(4) unimplemented. https://github.com/qemu-bsd-user/qemu-bsd-user/issues/25"
fi
md=$(alloc_md)
alloc_md md
common_body_setup $md
atf_check gnop configure -r 100 -e 5 ${md}.nop
@ -122,12 +122,12 @@ atf_init_test_cases()
alloc_md()
{
local md
local _md
[ -c /dev/mdctl ] || atf_skip "no /dev/mdctl to create md devices"
md=$(mdconfig -a -t swap -s 256M) || atf_fail "mdconfig -a failed"
echo ${md} >> $MD_DEVS
echo ${md}
_md=$(mdconfig -a -t swap -s 256M) || atf_fail "mdconfig -a failed"
echo ${_md} >> $MD_DEVS
eval "${1}='${_md}'"
}
common_body_setup()