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 @@ -1,22 +1,22 @@ #!/bin/sh . `dirname $0`/conf.sh 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 # Size of created device should be 1MB + 2MB + 3MB. size=`diskinfo /dev/concat/${name} | awk '{print $3}'` if [ $size -eq 6291456 ]; then echo "ok - Size is 6291456" else echo "not ok - Size is 6291456" fi 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 @@ -1,29 +1,29 @@ #!/bin/sh . `dirname $0`/conf.sh echo '1..1' 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 gconcat create $name /dev/$us0 /dev/$us1 /dev/$us2 || exit 1 devwait dd if=${src} of=/dev/concat/${name} bs=1m count=$tsize >/dev/null 2>&1 dd if=/dev/concat/${name} of=${dst} bs=1m count=$tsize >/dev/null 2>&1 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then echo "not ok - md5 checksum comparison" else echo "ok - md5 checksum comparison" fi rm -f ${src} ${dst} 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 @@ -1,46 +1,46 @@ #!/bin/sh # A basic regression test for gconcat append using "gconcat create", # i.e., manual mode. gconcat_check_size() { local actual expected name name=$1 expected=$2 actual=$(diskinfo /dev/concat/${name} | awk '{print $3}') if [ $actual -eq $expected ]; then echo "ok - Size is ${actual}" else echo "not ok - Size is ${actual}" fi } . `dirname $0`/conf.sh 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 # We should have a 2MB device. Add another disk and verify that the # reported size of the concat device grows accordingly. gconcat_check_size "${name}" $((2 * 1024 * 1024)) gconcat append $name /dev/$us2 || exit 1 gconcat_check_size "${name}" $((3 * 1024 * 1024)) # Write some data and make sure that we can read it back. tmpfile=$(mktemp) || exit 1 dd if=/dev/random of=$tmpfile bs=1M count=3 || exit 1 dd if=$tmpfile of=/dev/concat/${name} || exit 1 if cmp -s $tmpfile /dev/concat/${name}; then echo "ok - Data matches what was written" else echo "not ok - Data matches what was written" fi 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 @@ -1,77 +1,77 @@ #!/bin/sh # A basic regression test for gconcat append using "gconcat label", # i.e., automatic mode. gconcat_check_size() { local actual expected name name=$1 expected=$2 actual=$(diskinfo /dev/concat/${name} | awk '{print $3}') if [ $actual -eq $expected ]; then echo "ok - Size is ${actual}" else echo "not ok - Size is ${actual}" fi } . `dirname $0`/conf.sh echo '1..4' ss=512 f1=$(mktemp) || exit 1 truncate -s $((1024 * 1024 + $ss)) $f1 f2=$(mktemp) || exit 1 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 # We should have a 2MB device. Add another disk and verify that the # reported size of the concat device grows accordingly. A sector from # each disk is reserved for the metadata sector. gconcat_check_size "${name}" $((2 * 1024 * 1024)) gconcat append $name /dev/$us2 || exit 1 gconcat_check_size "${name}" $((3 * 1024 * 1024)) copy=$(mktemp) || exit 1 dd if=/dev/random of=$copy bs=1M count=3 || exit 1 dd if=$copy of=/dev/concat/${name} || exit 1 # Stop the concat device and destroy the backing providers. gconcat stop ${name} || exit 1 detach_md $us0 detach_md $us1 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 # Make sure that the if [ -c /dev/concat/${name} ]; then echo "ok - concat device was instantiated" else echo "not ok - concat device was instantiated" fi if cmp -s $copy /dev/concat/${name}; then echo "ok - Data was persisted across gconcat stop" else echo "not ok - Data was persisted across gconcat stop" fi 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 @@ -1,129 +1,129 @@ . $(atf_get_srcdir)/conf.sh atf_test_case attach_d cleanup attach_d_head() { atf_set "descr" "geli attach -d will cause the provider to detach on last close" atf_set "require.user" "root" } 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 atf_check geli init -B none -P -K keyfile ${md} atf_check geli attach -d -p -k keyfile ${md} # Be sure it doesn't detach on read. atf_check dd if=/dev/${md}.eli of=/dev/null status=none sleep 1 if [ ! -c /dev/${md}.eli ]; then atf_fail "Detached on last close of a reader" fi # It should detach on last close of a writer true > /dev/${md}.eli sleep 1 if [ -c /dev/${md}.eli ]; then atf_fail "Did not detach on last close of a writer" fi } attach_d_cleanup() { geli_test_cleanup } atf_test_case attach_r cleanup attach_r_head() { atf_set "descr" "geli attach -r will create a readonly provider" atf_set "require.user" "root" } 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} atf_check geli attach -r -p -k keyfile ${md} atf_check -o match:"^Flags: .*READ-ONLY" geli list ${md}.eli # Verify that writes are verbotten atf_check -s not-exit:0 -e match:"Read-only" \ dd if=/dev/zero of=/dev/${md}.eli count=1 } attach_r_cleanup() { geli_test_cleanup } atf_test_case attach_multiple cleanup attach_multiple_head() { atf_set "descr" "geli attach can attach multiple providers" atf_set "require.user" "root" } 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} atf_check geli init -B none -P -K keyfile ${md1} atf_check geli init -B none -P -K keyfile ${md2} atf_check geli attach -p -k keyfile ${md0} ${md1} ${md2} # verify that it did create all 3 geli devices atf_check -s exit:0 test -c /dev/${md0}.eli atf_check -s exit:0 test -c /dev/${md1}.eli atf_check -s exit:0 test -c /dev/${md2}.eli } attach_multiple_cleanup() { geli_test_cleanup } atf_test_case nokey cleanup nokey_head() { atf_set "descr" "geli attach fails if called with no key component" atf_set "require.user" "root" } 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} atf_check -s not-exit:0 -e match:"No key components given" \ geli attach -p ${md} 2>/dev/null } nokey_cleanup() { geli_test_cleanup } atf_init_test_cases() { atf_add_test_case attach_d atf_add_test_case attach_r atf_add_test_case attach_multiple atf_add_test_case nokey } 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 @@ -1,92 +1,94 @@ #!/bin/sh class="eli" base=$(atf_get ident) 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 # `func` usage should be: # func for_each_geli_config() { func=$1 backing_filename=$2 # Double the sector size to allow for the HMACs' storage space. osecsize=$(( $MAX_SECSIZE * 2 )) # geli needs 512B for the label. bytes=`expr $osecsize \* $sectors + 512`b if [ -n "$backing_filename" ]; then # 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 \ aes-cbc:128 aes-cbc:192 aes-cbc:256 \ camellia-cbc:128 camellia-cbc:192 camellia-cbc:256; do ealgo=${cipher%%:*} keylen=${cipher##*:} for aalgo in hmac/sha1 hmac/ripemd160 hmac/sha256 \ hmac/sha384 hmac/sha512; do for secsize in 512 1024 2048 4096 $MAX_SECSIZE; do ${func} $cipher $aalgo $secsize geli detach ${md} 2>/dev/null done done done } # Execute `func` for each combination of cipher, and sectorsize, with no hmac # `func` usage should be: # func for_each_geli_config_nointegrity() { func=$1 # 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 ealgo=${cipher%%:*} keylen=${cipher##*:} for secsize in 512 1024 2048 4096 $MAX_SECSIZE; do ${func} $cipher $secsize geli detach ${md} 2>/dev/null done done } geli_test_cleanup() { if [ -f "$TEST_MDS_FILE" ]; then while read md; do [ -c /dev/${md}.eli ] && \ geli detach $md.eli 2>/dev/null mdconfig -d -u $md 2>/dev/null done < $TEST_MDS_FILE fi true } geli_test_setup() { geom_atf_test_setup } ATF_TEST=true . `dirname $0`/../geom_subr.sh 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 @@ -1,59 +1,59 @@ . $(atf_get_srcdir)/conf.sh atf_test_case configure_b_B cleanup configure_b_B_head() { atf_set "descr" "geli configure -b will set the BOOT flag" atf_set "require.user" "root" } 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} atf_check -s exit:0 -o match:'flags: 0x200$' geli dump ${md} atf_check geli init -B none -b -P -K /dev/null ${md} atf_check -s exit:0 -o match:'flags: 0x202$' geli dump ${md} atf_check geli configure -B ${md} atf_check -s exit:0 -o match:'flags: 0x200$' geli dump ${md} atf_check geli configure -b ${md} atf_check -s exit:0 -o match:'flags: 0x202$' geli dump ${md} atf_check geli attach -p -k /dev/null ${md} atf_check -s exit:0 -o match:'^Flags: .*BOOT' geli list ${md}.eli atf_check geli configure -B ${md} atf_check -o not-match:'^Flags: .*BOOT' geli list ${md}.eli atf_check -s exit:0 -o match:'flags: 0x200$' geli dump ${md} atf_check geli configure -b ${md} atf_check -s exit:0 -o match:'^Flags: .*BOOT' geli list ${md}.eli atf_check -s exit:0 -o match:'flags: 0x202$' geli dump ${md} atf_check geli detach ${md} } configure_b_B_cleanup() { geli_test_cleanup } atf_init_test_cases() { atf_add_test_case configure_b_B } 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 @@ -1,113 +1,113 @@ #!/bin/sh . $(atf_get_srcdir)/conf.sh atf_test_case delkey cleanup delkey_head() { atf_set "descr" "geli delkey can destroy the master key" atf_set "require.user" "root" } 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 atf_check dd if=/dev/random of=keyfile3 bs=512 count=16 status=none atf_check dd if=/dev/random of=keyfile4 bs=512 count=16 status=none atf_check geli init -B none -P -K keyfile1 ${md} atf_check geli attach -p -k keyfile1 ${md} atf_check -s exit:0 -o ignore geli setkey -n 1 -P -K keyfile2 ${md} # Remove key 0 for attached provider. atf_check geli delkey -n 0 ${md} atf_check geli detach ${md} # We cannot use keyfile1 anymore. atf_check -s not-exit:0 -e match:"Wrong key" \ geli attach -p -k keyfile1 ${md} # Attach with key 1. atf_check geli attach -p -k keyfile2 ${md} # We cannot remove last key without -f option (for attached provider). atf_check -s not-exit:0 -e match:"This is the last Master Key" \ geli delkey -n 1 ${md} # Remove last key for attached provider. atf_check geli delkey -f -n 1 ${md} # If there are no valid keys, but provider is attached, we can save situation. atf_check -s exit:0 -o ignore geli setkey -n 0 -P -K keyfile3 ${md} atf_check geli detach ${md} # We cannot use keyfile2 anymore. atf_check -s not-exit:0 -e match:"Wrong key" \ geli attach -p -k keyfile2 ${md} # Attach with key 0. atf_check geli attach -p -k keyfile3 ${md} # Setup key 1. atf_check -s exit:0 -o ignore geli setkey -n 1 -P -K keyfile4 ${md} atf_check geli detach ${md} # Remove key 1 for detached provider. atf_check geli delkey -n 1 ${md} # We cannot use keyfile4 anymore. atf_check -s not-exit:0 -e match:"Wrong key" \ geli attach -p -k keyfile4 ${md} # We cannot remove last key without -f option (for detached provider). atf_check -s not-exit:0 -e match:"This is the last Master Key" \ geli delkey -n 0 ${md} # Remove last key for detached provider. atf_check geli delkey -f -n 0 ${md} # We cannot use keyfile3 anymore. atf_check -s not-exit:0 -e match:"No valid keys" \ geli attach -p -k keyfile3 ${md} } delkey_cleanup() { geli_test_cleanup } atf_test_case delkey_readonly cleanup delkey_readonly_head() { atf_set "descr" "geli delkey cannot work on a read-only provider" atf_set "require.user" "root" } 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} atf_check geli attach -r -p -k keyfile ${md} atf_check -s not-exit:0 -e match:"read-only" geli delkey -n 0 ${md} # Even with -f (force) it should still fail atf_check -s not-exit:0 -e match:"read-only" geli delkey -f -n 0 ${md} } delkey_readonly_cleanup() { geli_test_cleanup } atf_init_test_cases() { atf_add_test_case delkey atf_add_test_case delkey_readonly } 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 @@ -1,46 +1,46 @@ . $(atf_get_srcdir)/conf.sh atf_test_case detach_l cleanup detach_l_head() { atf_set "descr" "geli detach -l will cause a provider to detach on last close" atf_set "require.user" "root" } 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 atf_check geli init -B none -P -K keyfile ${md} atf_check geli attach -p -k keyfile ${md} # Be sure it doesn't detach before 'detach -l'. atf_check dd if=/dev/${md}.eli of=/dev/null status=none sleep 1 if [ ! -c /dev/${md}.eli ]; then atf_fail "provider detached on last close without detach -l" fi atf_check geli detach -l ${md} if [ ! -c /dev/${md}.eli ]; then atf_fail "Provider detached before last close" fi atf_check dd if=/dev/${md}.eli of=/dev/null status=none sleep 1 if [ -c /dev/${md}.eli ]; then atf_fail "Provider did not detach on last close" fi } detach_l_cleanup() { geli_test_cleanup } atf_init_test_cases() { atf_add_test_case detach_l } 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 @@ -1,379 +1,379 @@ #!/bin/sh . $(atf_get_srcdir)/conf.sh init_test() { cipher=$1 secsize=$2 ealgo=${cipher%%:*} keylen=${cipher##*:} atf_check -s exit:0 -e ignore \ geli init -B none -e $ealgo -l $keylen -P -K keyfile \ -s $secsize ${md} atf_check geli attach -p -k keyfile ${md} atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${sectors} \ status=none md_rnd=`dd if=rnd bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? md_edev=`dd if=/dev/${md} bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? if [ ${md_rnd} != ${md_ddev} ]; then atf_fail "Miscompare for ealgo=${ealgo} keylen=${keylen} sec=${secsize}" fi if [ ${md_rnd} == ${md_edev} ]; then atf_fail "Data was not encrypted for ealgo=${ealgo} keylen=${keylen} sec=${secsize}" fi } atf_test_case init cleanup init_head() { atf_set "descr" "Basic I/O with geli" atf_set "require.user" "root" atf_set "timeout" 600 } init_body() { geli_test_setup sectors=32 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none atf_check dd if=/dev/random of=rnd bs=$MAX_SECSIZE count=${sectors} \ status=none for_each_geli_config_nointegrity init_test } init_cleanup() { geli_test_cleanup } atf_test_case init_B cleanup init_B_head() { atf_set "descr" "init -B can select an alternate backup metadata file" atf_set "require.user" "root" } init_B_body() { geli_test_setup sectors=100 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 atf_check -s exit:0 -o ignore geli init -B none -P -K keyfile ${md} if [ -f /var/backups/${md}.eli ]; then atf_fail "geli created a backup file even with -B none" fi # no -B rm -f /var/backups/${md}.eli atf_check -s exit:0 -o ignore geli init -P -K keyfile ${md} if [ ! -f /var/backups/${md}.eli ]; then atf_fail "geli did not create a backup file" fi atf_check geli clear ${md} atf_check -s not-exit:0 -e ignore geli attach -p -k keyfile ${md} atf_check -s exit:0 -o ignore geli restore /var/backups/${md}.eli ${md} atf_check -s exit:0 -o ignore geli attach -p -k keyfile ${md} atf_check geli detach ${md} rm -f /var/backups/${md}.eli # -B file rm -f backupfile atf_check -s exit:0 -o ignore \ geli init -B backupfile -P -K keyfile ${md} if [ ! -f backupfile ]; then atf_fail "geli init -B did not create a backup file" fi atf_check geli clear ${md} atf_check -s not-exit:0 -e ignore geli attach -p -k keyfile ${md} atf_check geli restore backupfile ${md} atf_check geli attach -p -k keyfile ${md} } init_B_cleanup() { geli_test_cleanup } atf_test_case init_J cleanup init_J_head() { atf_set "descr" "init -J accepts a passfile" atf_set "require.user" "root" } 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 dd if=/dev/random bs=512 count=16 status=none | sha1 > passfile0 atf_check_equal 0 $? dd if=/dev/random bs=512 count=16 status=none | sha1 > passfile1 atf_check_equal 0 $? for iter in -1 0 64; do atf_check -s not-exit:0 -e ignore \ geli init -i ${iter} -B none -J passfile0 -P ${md} atf_check -s not-exit:0 -e ignore \ geli init -i ${iter} -B none -J passfile0 -P -K keyfile0 ${md} atf_check geli init -i ${iter} -B none -J passfile0 -K keyfile0 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -k keyfile0 -p ${md} atf_check -s not-exit:0 -e ignore \ geli attach -j passfile0 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -j keyfile0 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -k passfile0 -p ${md} atf_check -s not-exit:0 -e ignore \ geli attach -j keyfile0 -k passfile0 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -j keyfile0 -k keyfile0 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -j passfile0 -k passfile0 ${md} atf_check -s exit:0 -e ignore \ geli attach -j passfile0 -k keyfile0 ${md} atf_check -s exit:0 -e ignore geli detach ${md} atf_check -s exit:0 -e ignore -x \ "cat keyfile0 | geli attach -j passfile0 -k - ${md}" atf_check -s exit:0 -e ignore geli detach ${md} atf_check -s exit:0 -e ignore -x \ "cat passfile0 | geli attach -j - -k keyfile0 ${md}" atf_check -s exit:0 -e ignore geli detach ${md} atf_check -s not-exit:0 -e ignore \ geli init -i ${iter} -B none -J passfile0 -J passfile1 -P ${md} atf_check -s not-exit:0 -e ignore \ geli init -i ${iter} -B none -J passfile0 -J passfile1 -P -K keyfile0 -K keyfile1 ${md} atf_check -s exit:0 -e ignore \ geli init -i ${iter} -B none -J passfile0 -J passfile1 -K keyfile0 -K keyfile1 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -k keyfile0 -p ${md} atf_check -s not-exit:0 -e ignore \ geli attach -k keyfile1 -p ${md} atf_check -s not-exit:0 -e ignore \ geli attach -j passfile0 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -j passfile1 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -k keyfile0 -k keyfile1 -p ${md} atf_check -s not-exit:0 -e ignore \ geli attach -j passfile0 -j passfile1 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -k keyfile0 -j passfile0 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -k keyfile0 -j passfile1 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -k keyfile1 -j passfile0 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -k keyfile1 -j passfile1 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -k keyfile0 -j passfile0 -j passfile1 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -k keyfile1 -j passfile0 -j passfile1 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -k keyfile0 -k keyfile1 -j passfile0 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -k keyfile0 -k keyfile1 -j passfile1 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -k keyfile1 -k keyfile0 -j passfile0 -j passfile1 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -k keyfile0 -k keyfile1 -j passfile1 -j passfile0 ${md} atf_check -s not-exit:0 -e ignore \ geli attach -k keyfile1 -k keyfile0 -j passfile1 -j passfile0 ${md} atf_check -s exit:0 -e ignore \ geli attach -j passfile0 -j passfile1 -k keyfile0 -k keyfile1 ${md} atf_check -s exit:0 -e ignore geli detach ${md} atf_check -s exit:0 -e ignore -x \ "cat passfile0 | geli attach -j - -j passfile1 -k keyfile0 -k keyfile1 ${md}" atf_check -s exit:0 -e ignore geli detach ${md} atf_check -s exit:0 -e ignore -x \ "cat passfile1 | geli attach -j passfile0 -j - -k keyfile0 -k keyfile1 ${md}" atf_check -s exit:0 -e ignore geli detach ${md} atf_check -s exit:0 -e ignore -x \ "cat keyfile0 | geli attach -j passfile0 -j passfile1 -k - -k keyfile1 ${md}" atf_check -s exit:0 -e ignore geli detach ${md} atf_check -s exit:0 -e ignore -x \ "cat keyfile1 | geli attach -j passfile0 -j passfile1 -k keyfile0 -k - ${md}" atf_check -s exit:0 -e ignore geli detach ${md} atf_check -s exit:0 -e ignore -x \ "cat keyfile0 keyfile1 | geli attach -j passfile0 -j passfile1 -k - ${md}" atf_check -s exit:0 -e ignore geli detach ${md} atf_check -s exit:0 -e ignore -x \ "cat passfile0 passfile1 | awk '{printf \"%s\", \$0}' | geli attach -j - -k keyfile0 -k keyfile1 ${md}" atf_check -s exit:0 -e ignore geli detach ${md} done } init_J_cleanup() { geli_test_cleanup } init_a_test() { cipher=$1 aalgo=$2 secsize=$3 ealgo=${cipher%%:*} keylen=${cipher##*:} atf_check -s exit:0 -e ignore \ geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K keyfile \ -s $secsize ${md} atf_check geli attach -p -k keyfile ${md} atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${sectors} status=none md_rnd=`dd if=rnd bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? if [ ${md_rnd} != ${md_ddev} ]; then atf_fail "Miscompare for aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}" fi } atf_test_case init_a cleanup init_a_head() { atf_set "descr" "I/O with geli and HMACs" atf_set "require.user" "root" atf_set "timeout" 3600 } init_a_body() { geli_test_setup sectors=100 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none atf_check dd if=/dev/random of=rnd bs=$MAX_SECSIZE count=${sectors} \ status=none for_each_geli_config init_a_test true } init_a_cleanup() { geli_test_cleanup } init_alias_test() { ealgo=$1 keylen=$2 expected_ealgo=$3 expected_keylen=$4 atf_check geli init -B none -e $ealgo -l $keylen -P -K keyfile ${md} atf_check geli attach -p -k keyfile ${md} real_ealgo=`geli list ${md}.eli | awk '/EncryptionAlgorithm/ {print $2}'` real_keylen=`geli list ${md}.eli | awk '/KeyLength/ {print $2}'` if [ "${real_ealgo}" != "${expected_ealgo}" ]; then atf_fail "expected ${expected_ealgo} but got ${real_ealgo}" fi if [ "${real_keylen}" != "${expected_keylen}" ]; then atf_fail "expected ${expected_keylen} but got ${real_keylen}" fi atf_check geli detach ${md} } atf_test_case init_alias cleanup init_alias_head() { atf_set "descr" "geli init accepts cipher aliases" atf_set "require.user" "root" } 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 \ camellia:0:CAMELLIA-CBC:128 camellia:128:CAMELLIA-CBC:128 \ camellia:256:CAMELLIA-CBC:256 ; do ealgo=`echo $spec | cut -d : -f 1` keylen=`echo $spec | cut -d : -f 2` expected_ealgo=`echo $spec | cut -d : -f 3` expected_keylen=`echo $spec | cut -d : -f 4` init_alias_test $ealgo $keylen $expected_ealgo $expected_keylen done } init_alias_cleanup() { geli_test_cleanup } atf_test_case init_i_P cleanup init_i_P_head() { atf_set "descr" "geli: Options -i and -P are mutually exclusive" atf_set "require.user" "root" } 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 atf_check -s not-exit:0 -e "match:Options -i and -P are mutually exclusive"\ geli init -B none -i 64 -P -K keyfile $md } init_i_P_cleanup() { geli_test_cleanup } atf_test_case nokey cleanup nokey_head() { atf_set "descr" "geli init fails if called with no key component" atf_set "require.user" "root" } 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} } nokey_cleanup() { geli_test_cleanup } atf_init_test_cases() { atf_add_test_case init atf_add_test_case init_B atf_add_test_case init_J atf_add_test_case init_a atf_add_test_case init_alias atf_add_test_case init_i_P atf_add_test_case nokey } 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 @@ -1,101 +1,101 @@ . $(atf_get_srcdir)/conf.sh atf_test_case kill cleanup kill_head() { atf_set "descr" "geli kill will wipe a provider's metadata" atf_set "require.user" "root" } 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 atf_check geli init -B none -P -K keyfile1 ${md} atf_check geli attach -p -k keyfile1 ${md} atf_check -s exit:0 -o ignore geli setkey -n 1 -P -K keyfile2 ${md} # Kill attached provider. atf_check geli kill ${md} sleep 1 # Provider should be automatically detached. if [ -c /dev/${md}.eli ]; then atf_fail "Provider did not detach when killed" fi # We cannot use keyfile1 anymore. atf_check -s not-exit:0 -e match:"Cannot read metadata" \ geli attach -p -k keyfile1 ${md} # We cannot use keyfile2 anymore. atf_check -s not-exit:0 -e match:"Cannot read metadata" \ geli attach -p -k keyfile2 ${md} atf_check geli init -B none -P -K keyfile1 ${md} atf_check -s exit:0 -o ignore \ geli setkey -n 1 -p -k keyfile1 -P -K keyfile2 ${md} # Should be possible to attach with keyfile1. atf_check geli attach -p -k keyfile1 ${md} atf_check geli detach ${md} # Should be possible to attach with keyfile2. atf_check geli attach -p -k keyfile2 ${md} atf_check geli detach ${md} # Kill detached provider. atf_check geli kill ${md} # We cannot use keyfile1 anymore. atf_check -s not-exit:0 -e match:"Cannot read metadata" \ geli attach -p -k keyfile1 ${md} # We cannot use keyfile2 anymore. atf_check -s not-exit:0 -e match:"Cannot read metadata" \ geli attach -p -k keyfile2 ${md} } kill_cleanup() { geli_test_cleanup } atf_test_case kill_readonly cleanup kill_readonly_head() { atf_set "descr" "geli kill will not destroy the keys of a readonly provider" atf_set "require.user" "root" } 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} # Attach read-only atf_check geli attach -r -p -k keyfile ${md} atf_check geli kill ${md} # The provider will be detached atf_check [ ! -c /dev/${md}.eli ] # But its keys should not be destroyed atf_check geli attach -p -k keyfile ${md} } kill_readonly_cleanup() { geli_test_cleanup } atf_init_test_cases() { atf_add_test_case kill atf_add_test_case kill_readonly } 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 @@ -1,206 +1,206 @@ # SPDX-License-Identifier: BSD-2-Clause # # Copyright (c) 2018 Alan Somers # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # . $(atf_get_srcdir)/conf.sh atf_test_case preserve_props cleanup preserve_props_head() { atf_set "descr" "geli should preserve basic GEOM properties" atf_set "require.user" "root" atf_set "timeout" 15 } 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) eli_secsize=$(diskinfo ${md}.eli | cut -wf 2) eli_stripesize=$(diskinfo ${md}.eli | cut -wf 5) atf_check_equal "$md_secsize" "$eli_secsize" atf_check_equal "$md_stripesize" "$eli_stripesize" } preserve_props_cleanup() { geli_test_cleanup } atf_test_case preserve_disk_props cleanup preserve_disk_props_head() { atf_set "descr" "geli should preserve properties for disks" atf_set "require.user" "root" atf_set "require.config" "disks" atf_set "timeout" 15 } preserve_disk_props_body() { geli_test_setup disks=`atf_config_get disks` disk=${disks%% *} if [ -z "$disk" ]; then atf_skip "Must define disks (see tests(7))" fi atf_check geli onetime ${disk} disk_ident=$(diskinfo -s ${disk}) disk_descr=$(diskinfo -v ${disk} | awk '/Disk descr/ {print $1}') disk_rotrate=$(diskinfo -v ${disk} | awk '/Rotation rate/ {print $1}') disk_zonemode=$(diskinfo -v ${disk} | awk '/Zone Mode/ {print $1}') eli_ident=$(diskinfo -s ${disk}.eli) eli_descr=$(diskinfo -v ${disk}.eli | awk '/Disk descr/ {print $1}') eli_rotrate=$(diskinfo -v ${disk}.eli | awk '/Rotation/ {print $1}') eli_zonemode=$(diskinfo -v ${disk}.eli | awk '/Zone Mode/ {print $1}') atf_check_equal "$disk_ident" "$eli_ident" atf_check_equal "$disk_descr" "$eli_descr" atf_check_equal "$disk_rotrate" "$eli_rotrate" atf_check_equal "$disk_zonemode" "$eli_zonemode" } preserve_disk_props_cleanup() { disk_cleanup geli_test_cleanup } atf_test_case physpath cleanup physpath_head() { atf_set "descr" "geli should append /eli to the underlying device's physical path" atf_set "require.user" "root" atf_set "timeout" 15 } physpath_body() { geli_test_setup if ! error_message=$(geom_load_class_if_needed nop); then 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 atf_check -s exit:0 geli onetime $md atf_check -o empty -e ignore diskinfo -p $md.eli atf_check -s exit:0 geli kill $md # If the underlying device does have a physical path, then geli should # append "/eli" physpath="some/physical/path" atf_check gnop create -z $physpath ${md} atf_check -s exit:0 geli onetime $md.nop atf_check -o match:"^${physpath}/eli$" diskinfo -p $md.nop.eli } physpath_cleanup() { if [ -f "$TEST_MDS_FILE" ]; then while read md; do [ -c /dev/${md}.nop.eli ] && \ geli detach $md.nop.eli 2>/dev/null [ -c /dev/${md}.nop ] && \ gnop destroy -f $md.nop 2>/dev/null [ -c /dev/${md}.eli ] && \ geli detach $md.eli 2>/dev/null mdconfig -d -u $md 2>/dev/null done < $TEST_MDS_FILE fi true } unaligned_io_test() { cipher=$1 secsize=$2 ealgo=${cipher%%:*} keylen=${cipher##*:} atf_check -s exit:0 -e ignore \ geli init -B none -e $ealgo -l $keylen -P -K keyfile \ -s $secsize ${md} atf_check geli attach -p -k keyfile ${md} atf_check $(atf_get_srcdir)/unaligned_io /dev/${md}.eli } atf_test_case unaligned_io cleanup unaligned_io_head() { atf_set "descr" "regression test for PR 271766" atf_set "require.user" "root" } unaligned_io_body() { geli_test_setup sectors=4 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none for_each_geli_config_nointegrity unaligned_io_test } unaligned_io_cleanup() { geli_test_cleanup } atf_init_test_cases() { atf_add_test_case physpath atf_add_test_case preserve_props atf_add_test_case preserve_disk_props atf_add_test_case unaligned_io } common_cleanup() { if [ -f "$MD_DEVS" ]; then while read test_md; do gnop destroy -f ${test_md}.nop 2>/dev/null mdconfig -d -u $test_md 2>/dev/null done < $MD_DEVS rm $MD_DEVS fi if [ -f "$PLAINFILES" ]; then while read f; do rm -f ${f} done < ${PLAINFILES} rm ${PLAINFILES} fi true } disk_cleanup() { disks=`atf_config_get disks` disk=${disks%% *} if [ -n "$disk" ]; then geli kill ${disk} 2>/dev/null fi } 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 @@ -1,182 +1,182 @@ . $(atf_get_srcdir)/conf.sh onetime_test() { cipher=$1 secsize=$2 ealgo=${cipher%%:*} keylen=${cipher##*:} atf_check -s exit:0 -o ignore -e ignore \ geli onetime -e $ealgo -l $keylen -s $secsize ${md} atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${sectors} status=none md_rnd=`dd if=rnd bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? md_edev=`dd if=/dev/${md} bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? if [ ${md_rnd} != ${md_ddev} ]; then atf_fail "geli did not return the original data" fi if [ ${md_rnd} == ${md_edev} ]; then atf_fail "geli did not encrypt the data" fi } atf_test_case onetime cleanup onetime_head() { atf_set "descr" "geli onetime can create temporary providers" atf_set "require.user" "root" atf_set "timeout" 1800 } onetime_body() { geli_test_setup sectors=100 dd if=/dev/random of=rnd bs=${MAX_SECSIZE} count=${sectors} status=none for_each_geli_config_nointegrity onetime_test } onetime_cleanup() { geli_test_cleanup } onetime_a_test() { cipher=$1 aalgo=$2 secsize=$3 ealgo=${cipher%%:*} keylen=${cipher##*:} atf_check -s exit:0 -o ignore -e ignore \ geli onetime -a $aalgo -e $ealgo -l $keylen -s $secsize ${md} atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${sectors} status=none md_rnd=`dd if=rnd bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? if [ ${md_rnd} != ${md_ddev} ]; then atf_fail "Miscompare for aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}" fi } atf_test_case onetime_a cleanup onetime_a_head() { atf_set "descr" "geli onetime with HMACs" atf_set "require.user" "root" atf_set "timeout" 1800 } onetime_a_body() { geli_test_setup sectors=8 atf_check dd if=/dev/random of=rnd bs=$MAX_SECSIZE count=$sectors \ status=none for_each_geli_config onetime_a_test } onetime_a_cleanup() { geli_test_cleanup } atf_test_case onetime_d cleanup onetime_d_head() { atf_set "descr" "geli onetime -d will create providers that detach on last close" atf_set "require.user" "root" } 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 atf_fail "Provider not created, or immediately detached" fi # Be sure it doesn't detach on read. atf_check dd if=/dev/${md}.eli of=/dev/null status=none sleep 1 if [ ! -c /dev/${md}.eli ]; then atf_fail "Provider detached when a reader closed" fi # It should detach when a writer closes true > /dev/${md}.eli sleep 1 if [ -c /dev/${md}.eli ]; then atf_fail "Provider didn't detach on last close of a writer" fi } onetime_d_cleanup() { geli_test_cleanup } atf_test_case onetime_null cleanup onetime_null_head() { atf_set "descr" "geli onetime can use the null cipher" atf_set "require.user" "root" } onetime_null_body() { geli_test_setup sectors=100 dd if=/dev/random of=rnd bs=${MAX_SECSIZE} count=${sectors} status=none secsize=512 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} atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${sectors} status=none md_rnd=`dd if=rnd bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? md_edev=`dd if=/dev/${md} bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? if [ ${md_rnd} != ${md_ddev} ]; then atf_fail "geli did not return the original data" fi if [ ${md_rnd} != ${md_edev} ]; then atf_fail "geli encrypted the data even with the null cipher" fi } onetime_null_cleanup() { geli_test_cleanup } atf_init_test_cases() { atf_add_test_case onetime atf_add_test_case onetime_a atf_add_test_case onetime_d atf_add_test_case onetime_null } 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 @@ -1,191 +1,191 @@ #!/bin/sh . $(atf_get_srcdir)/conf.sh atf_test_case online_resize cleanup online_resize_head() { atf_set "descr" "online resize of geli providers" atf_set "require.user" "root" } online_resize_body() { geli_test_setup ( echo "m 512 none 10485248 1 1 20971008 1 1 31456768 1 1" echo "m 4096 none 10481664 1 1 20967424 1 1 31453184 1 1" echo "m 512 HMAC/SHA256 5242368 1 1 10485248 1 1 15728128 1 1" echo "m 4096 HMAC/SHA256 9318400 1 1 18640896 1 1 27959296 1 1" echo "p 512 none 11258999068425728 [0-9] 20971520 22517998136851968 [0-9] 41943040 33776997205278208 [0-9] 62914560" echo "p 4096 none 11258999068422144 [0-9] 2621440 22517998136848384 [0-9] 5242880 33776997205274624 [0-9] 7864320" echo "p 512 HMAC/SHA256 5629499534212608 [0-9] 20971520 11258999068425728 [0-9] 41943040 16888498602638848 [0-9] 62914560" echo "p 4096 HMAC/SHA256 10007999171932160 [0-9] 20971520 20015998343868416 [0-9] 41943040 30023997515800576 [0-9] 62914560" ) | while read prefix sector auth esize10 ka10 kt10 esize20 ka20 kt20 esize30 ka30 kt30; do if [ "${auth}" = "none" ]; then aalgo="" eflags="0x200" dflags="0x0" else aalgo="-a ${auth}" eflags="0x210" dflags="0x10" fi if [ "${prefix}" = "m" ]; then psize10="10485760" psize20="20971520" psize30="31457280" else psize10="11258999068426240" psize20="22517998136852480" 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} atf_check -s exit:0 -o ignore gpart add -t freebsd-ufs -s 10${prefix} ${md} echo secret >tmp.key atf_check geli init ${aalgo} -s ${sector} -Bnone -PKtmp.key ${md}p1 # Autoresize is set by default. atf_check -s exit:0 -o match:"flags: ${eflags}$" geli dump ${md}p1 atf_check geli configure -R ${md}p1 atf_check -s exit:0 -o match:"flags: ${dflags}$" geli dump ${md}p1 atf_check geli configure -r ${md}p1 atf_check -s exit:0 -o match:"flags: ${eflags}$" geli dump ${md}p1 atf_check geli init -R ${aalgo} -s ${sector} -Bnone -PKtmp.key ${md}p1 atf_check -s exit:0 -o match:"flags: ${dflags}$" geli dump ${md}p1 atf_check geli configure -r ${md}p1 atf_check -s exit:0 -o match:"flags: ${eflags}$" geli dump ${md}p1 atf_check geli configure -R ${md}p1 atf_check -s exit:0 -o match:"flags: ${dflags}$" geli dump ${md}p1 atf_check geli init ${aalgo} -s ${sector} -Bnone -PKtmp.key ${md}p1 atf_check geli attach -pk tmp.key ${md}p1 atf_check -s exit:0 -o match:'^Flags: .*AUTORESIZE' geli list ${md}p1.eli atf_check geli configure -R ${md}p1 atf_check -s exit:0 -o match:"flags: ${dflags}$" geli dump ${md}p1 atf_check -o not-match:'^Flags: .*AUTORESIZE' geli list ${md}p1.eli atf_check geli configure -r ${md}p1 atf_check -s exit:0 -o match:"flags: ${eflags}$" geli dump ${md}p1 atf_check -s exit:0 -o match:'^Flags: .*AUTORESIZE' geli list ${md}p1.eli atf_check geli configure -R ${md}p1 atf_check -s exit:0 -o match:"provsize: ${psize10}$" geli dump ${md}p1 atf_check -s exit:0 -o match:resized gpart resize -i 1 -s 20${prefix} ${md} # Autoresize turned off - we lose metadata. atf_check -s exit:1 -o empty -e ignore geli dump ${md}p1 atf_check geli detach ${md}p1.eli # When we recover previous size, the metadata should be there. atf_check -s exit:0 -o match:resized gpart resize -i 1 -s 10${prefix} ${md} atf_check -s exit:0 -o match:"flags: ${dflags}$" geli dump ${md}p1 atf_check geli configure -r ${md}p1 atf_check geli attach -pk tmp.key ${md}p1 atf_check -s exit:0 -o match:"^[[:space:]]${esize10}[[:space:]]+# mediasize in bytes" diskinfo -v ${md}p1.eli atf_check -s exit:0 -o match:"^KeysAllocated: ${ka10}$" geli list ${md}p1.eli atf_check -s exit:0 -o match:"^KeysTotal: ${kt10}$" geli list ${md}p1.eli atf_check -s exit:0 -o match:resized gpart resize -i 1 -s 20${prefix} ${md} atf_check -s exit:0 -o match:"provsize: ${psize20}$" geli dump ${md}p1 atf_check -s exit:0 -o match:"^[[:space:]]${esize20}[[:space:]]+# mediasize in bytes" diskinfo -v ${md}p1.eli atf_check -s exit:0 -o match:"^KeysAllocated: ${ka20}$" geli list ${md}p1.eli atf_check -s exit:0 -o match:"^KeysTotal: ${kt20}$" geli list ${md}p1.eli atf_check -s exit:0 -o match:"flags: ${eflags}$" geli dump ${md}p1 atf_check -s exit:0 -o match:'^Flags: .*AUTORESIZE' geli list ${md}p1.eli if [ "${prefix}" = "m" ]; then atf_check -s exit:1 -o empty -e match:"^${esize20} bytes transferred " dd if=/dev/random of=/dev/${md}p1.eli bs=1m atf_check -s exit:0 -o empty -e match:"^${esize20} bytes transferred " dd if=/dev/${md}p1.eli of=/dev/null bs=1m fi atf_check -s exit:0 -o match:resized gpart resize -i 1 -s 30${prefix} ${md} atf_check -s exit:0 -o match:"provsize: ${psize30}$" geli dump ${md}p1 atf_check -s exit:0 -o match:"^[[:space:]]${esize30}[[:space:]]+# mediasize in bytes" diskinfo -v ${md}p1.eli atf_check -s exit:0 -o match:"^KeysAllocated: ${ka30}$" geli list ${md}p1.eli atf_check -s exit:0 -o match:"^KeysTotal: ${kt30}$" geli list ${md}p1.eli atf_check -s exit:0 -o match:"flags: ${eflags}$" geli dump ${md}p1 atf_check -s exit:0 -o match:'^Flags: .*AUTORESIZE' geli list ${md}p1.eli if [ "${prefix}" = "m" ]; then atf_check -s exit:1 -o empty -e match:"^${esize30} bytes transferred " dd if=/dev/random of=/dev/${md}p1.eli bs=1m atf_check -s exit:0 -o empty -e match:"^${esize30} bytes transferred " dd if=/dev/${md}p1.eli of=/dev/null bs=1m fi atf_check geli detach ${md}p1.eli # Make sure that the old metadata is removed. atf_check -s exit:0 -o match:resized gpart resize -i 1 -s 20${prefix} ${md} atf_check -s exit:1 -o empty -e ignore geli dump ${md}p1 atf_check -s exit:0 -o match:resized gpart resize -i 1 -s 10${prefix} ${md} atf_check -s exit:1 -o empty -e ignore geli dump ${md}p1 # Test geli with onetime keys. if [ "${auth}" = "none" ]; then osize10="${psize10}" osize20="${psize20}" osize30="${psize30}" else osize10="${esize10}" osize20="${esize20}" osize30="${esize30}" if [ "${sector}" -eq 512 ]; then osize10=$((osize10+sector)) osize20=$((osize20+sector)) osize30=$((osize30+sector)) fi fi atf_check geli onetime ${aalgo} -s ${sector} ${md}p1 atf_check -s exit:0 -o match:"^[[:space:]]${osize10}[[:space:]]+# mediasize in bytes" diskinfo -v ${md}p1.eli atf_check -s exit:0 -o match:'^Flags: .*AUTORESIZE' geli list ${md}p1.eli atf_check -s exit:0 -o match:resized gpart resize -i 1 -s 20${prefix} ${md} atf_check -s exit:0 -o match:"^[[:space:]]${osize20}[[:space:]]+# mediasize in bytes" diskinfo -v ${md}p1.eli atf_check -s exit:0 -o match:resized gpart resize -i 1 -s 30${prefix} ${md} atf_check -s exit:0 -o match:"^[[:space:]]${osize30}[[:space:]]+# mediasize in bytes" diskinfo -v ${md}p1.eli atf_check geli detach ${md}p1.eli atf_check -s exit:0 -o match:resized gpart resize -i 1 -s 10${prefix} ${md} atf_check geli onetime -R ${aalgo} -s ${sector} ${md}p1 atf_check -s exit:0 -o match:"^[[:space:]]${osize10}[[:space:]]+# mediasize in bytes" diskinfo -v ${md}p1.eli atf_check -o not-match:'^Flags: .*AUTORESIZE' geli list ${md}p1.eli atf_check -s exit:0 -o match:resized gpart resize -i 1 -s 20${prefix} ${md} atf_check -s exit:0 -o match:"^[[:space:]]${osize10}[[:space:]]+# mediasize in bytes" diskinfo -v ${md}p1.eli atf_check -s exit:0 -o match:resized gpart resize -i 1 -s 30${prefix} ${md} atf_check -s exit:0 -o match:"^[[:space:]]${osize10}[[:space:]]+# mediasize in bytes" diskinfo -v ${md}p1.eli atf_check geli detach ${md}p1.eli atf_check -s exit:0 -o match:resized gpart resize -i 1 -s 10${prefix} ${md} atf_check geli onetime ${aalgo} -s ${sector} ${md}p1 atf_check -s exit:0 -o match:"^[[:space:]]${osize10}[[:space:]]+# mediasize in bytes" diskinfo -v ${md}p1.eli atf_check -s exit:0 -o match:'^Flags: .*AUTORESIZE' geli list ${md}p1.eli atf_check geli configure -R ${md}p1 atf_check -o not-match:'^Flags: .*AUTORESIZE' geli list ${md}p1.eli atf_check -s exit:0 -o match:resized gpart resize -i 1 -s 20${prefix} ${md} atf_check -s exit:0 -o match:"^[[:space:]]${osize10}[[:space:]]+# mediasize in bytes" diskinfo -v ${md}p1.eli atf_check geli configure -r ${md}p1 atf_check -s exit:0 -o match:'^Flags: .*AUTORESIZE' geli list ${md}p1.eli atf_check -s exit:0 -o match:resized gpart resize -i 1 -s 30${prefix} ${md} atf_check -s exit:0 -o match:"^[[:space:]]${osize30}[[:space:]]+# mediasize in bytes" diskinfo -v ${md}p1.eli done } online_resize_cleanup() { if [ -f "$TEST_MDS_FILE" ]; then while read md; do atf_check -s ignore -e ignore -o ignore geli detach ${md}p1.eli atf_check -s ignore -e ignore -o ignore gpart delete -i 1 ${md} atf_check -s ignore -e ignore -o ignore gpart destroy ${md} done < $TEST_MDS_FILE fi geli_test_cleanup } atf_init_test_cases() { atf_add_test_case online_resize } 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 @@ -1,88 +1,88 @@ #!/bin/sh . $(atf_get_srcdir)/conf.sh atf_test_case resize cleanup resize_head() { atf_set "descr" "geli resize will resize a geli provider" atf_set "require.user" "root" } resize_body() { geli_test_setup 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} atf_check -s exit:0 -o ignore gpart add -t freebsd-ufs -s 10m ${md} echo secret >tmp.key atf_check geli init -Bnone -PKtmp.key ${md}a atf_check geli attach -pk tmp.key ${md}a atf_check -s exit:0 -o ignore newfs -U ${md}a.eli atf_check -s exit:7 -o ignore fsck_ffs -Ffy ${md}a.eli # Doing a backup, resize & restore must be forced (with -f) as geli # verifies that the provider size in the metadata matches the consumer. atf_check geli backup ${md}a tmp.meta atf_check geli detach ${md}a.eli atf_check -s exit:0 -o match:resized gpart resize -i1 -s 20m ${md} atf_check -s not-exit:0 -e ignore geli attach -pktmp.key ${md}a atf_check -s not-exit:0 -e ignore geli restore tmp.meta ${md}a atf_check geli restore -f tmp.meta ${md}a atf_check geli attach -pktmp.key ${md}a atf_check -s exit:0 -o ignore growfs -y ${md}a.eli atf_check -s exit:7 -o ignore fsck_ffs -Ffy ${md}a.eli # Now do the resize properly atf_check geli detach ${md}a.eli atf_check -s exit:0 -o match:resized gpart resize -i1 -s 30m ${md} atf_check geli resize -s20m ${md}a atf_check -s not-exit:0 -e match:"Inconsistent provider.*metadata" \ geli resize -s20m ${md}a atf_check geli attach -pktmp.key ${md}a atf_check -s exit:0 -o ignore growfs -y ${md}a.eli atf_check -s exit:7 -o ignore fsck_ffs -Ffy ${md}a.eli atf_check geli detach ${md}a.eli atf_check -s exit:0 -o ignore gpart destroy -F $md # Verify that the man page example works, changing ada0 to $md, # 1g to 20m, 2g to 30m and keyfile to tmp.key, and adding -B none # to geli init. atf_check -s exit:0 -o ignore gpart create -s GPT $md atf_check -s exit:0 -o ignore gpart add -s 20m -t freebsd-ufs -i 1 $md atf_check geli init -B none -K tmp.key -P ${md}p1 atf_check -s exit:0 -o match:resized gpart resize -s 30m -i 1 $md atf_check geli resize -s 20m ${md}p1 atf_check geli attach -k tmp.key -p ${md}p1 } resize_cleanup() { if [ -f "$TEST_MDS_FILE" ]; then while read md; do [ -c /dev/${md}a.eli ] && \ geli detach ${md}a.eli 2>/dev/null [ -c /dev/${md}p1.eli ] && \ geli detach ${md}p1.eli [ -c /dev/${md}.eli ] && \ geli detach ${md}.eli 2>/dev/null mdconfig -d -u $md 2>/dev/null done < $TEST_MDS_FILE fi } atf_init_test_cases() { atf_add_test_case resize } 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 @@ -1,221 +1,221 @@ #!/bin/sh . $(atf_get_srcdir)/conf.sh atf_test_case setkey cleanup setkey_head() { atf_set "descr" "geli setkey can change the key for an existing provider" atf_set "require.user" "root" } 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` atf_check_equal 0 $? 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 atf_check dd if=/dev/random of=keyfile3 bs=512 count=16 status=none atf_check dd if=/dev/random of=keyfile4 bs=512 count=16 status=none atf_check dd if=/dev/random of=keyfile5 bs=512 count=16 status=none atf_check geli init -B none -P -K keyfile1 ${md} atf_check geli attach -p -k keyfile1 ${md} atf_check \ dd if=rnd of=/dev/${md}.eli bs=512 count=${sectors} status=none hash2=`dd if=/dev/${md}.eli bs=512 count=${sectors} 2>/dev/null | md5` atf_check_equal 0 $? # Change current key (0) for attached provider. atf_check -s exit:0 -o ignore geli setkey -P -K keyfile2 ${md} atf_check geli detach ${md} # We cannot use keyfile1 anymore. atf_check -s not-exit:0 -e match:"Wrong key" \ geli attach -p -k keyfile1 ${md} # Attach with new key. atf_check geli attach -p -k keyfile2 ${md} hash3=`dd if=/dev/${md}.eli bs=512 count=${sectors} 2>/dev/null | md5` atf_check_equal 0 $? # Change key 1 for attached provider. atf_check -s exit:0 -o ignore geli setkey -n 1 -P -K keyfile3 ${md} atf_check geli detach ${md} # Attach with key 1. atf_check geli attach -p -k keyfile3 ${md} hash4=`dd if=/dev/${md}.eli bs=512 count=${sectors} 2>/dev/null | md5` atf_check_equal 0 $? atf_check geli detach ${md} # Change current (1) key for detached provider. atf_check -s exit:0 -o ignore geli setkey -p -k keyfile3 -P -K keyfile4 ${md} # We cannot use keyfile3 anymore. atf_check -s not-exit:0 -e match:"Wrong key" \ geli attach -p -k keyfile3 ${md} # Attach with key 1. atf_check geli attach -p -k keyfile4 ${md} hash5=`dd if=/dev/${md}.eli bs=512 count=${sectors} 2>/dev/null | md5` atf_check_equal 0 $? atf_check geli detach ${md} # Change key 0 for detached provider. atf_check -s exit:0 -o ignore geli setkey -n 0 -p -k keyfile4 -P -K keyfile5 ${md} # We cannot use keyfile2 anymore. atf_check -s not-exit:0 -e match:"Wrong key" \ geli attach -p -k keyfile2 ${md} 2>/dev/null # Attach with key 0. atf_check geli attach -p -k keyfile5 ${md} hash6=`dd if=/dev/${md}.eli bs=512 count=${sectors} 2>/dev/null | md5` atf_check_equal 0 $? atf_check geli detach ${md} atf_check_equal ${hash1} ${hash2} atf_check_equal ${hash1} ${hash3} atf_check_equal ${hash1} ${hash4} atf_check_equal ${hash1} ${hash5} atf_check_equal ${hash1} ${hash6} } setkey_cleanup() { geli_test_cleanup } atf_test_case setkey_passphrase cleanup setkey_passphrase_head() { atf_set "descr" "geli setkey can change the passphrase for a provider" atf_set "require.user" "root" } 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` atf_check_equal 0 $? atf_check dd if=/dev/random of=pass1 bs=512 count=1 status=none atf_check dd if=/dev/random of=pass2 bs=512 count=1 status=none atf_check dd if=/dev/random of=pass3 bs=512 count=1 status=none atf_check geli init -B none -J pass1 ${md} atf_check geli attach -j pass1 ${md} atf_check \ dd if=rnd of=/dev/${md}.eli bs=512 count=${sectors} status=none hash2=`dd if=/dev/${md}.eli bs=512 count=${sectors} 2>/dev/null | md5` atf_check_equal 0 $? atf_check geli detach ${md} # Change from passphrase 1 to passphrase 2 for the detached provider. atf_check -s exit:0 -o ignore geli setkey -j pass1 -J pass2 ${md} # Make sure that we can attach with passphrase 2 but not with # passphrase 1. atf_check -s not-exit:0 -e match:"Wrong key" \ geli attach -j pass1 ${md} atf_check -s exit:0 geli attach -j pass2 ${md} hash3=`dd if=/dev/${md}.eli bs=512 count=${sectors} 2>/dev/null | md5` # Change from passphrase 2 to passphrase 3 for the attached provider. atf_check -s exit:0 -o ignore geli setkey -j pass2 -J pass3 ${md} hash4=`dd if=/dev/${md}.eli bs=512 count=${sectors} 2>/dev/null | md5` atf_check geli detach ${md} # Make sure that we cannot attach with passphrase 2 anymore. atf_check -s not-exit:0 -e match:"Wrong key" \ geli attach -j pass2 ${md} atf_check_equal ${hash1} ${hash2} atf_check_equal ${hash1} ${hash3} atf_check_equal ${hash1} ${hash4} } setkey_passphrase_cleanup() { geli_test_cleanup } atf_test_case setkey_readonly cleanup setkey_readonly_head() { atf_set "descr" "geli setkey cannot change the keys of a readonly provider" atf_set "require.user" "root" } 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} atf_check geli attach -r -p -k keyfile ${md} atf_check -s not-exit:0 -e match:"read-only" \ geli setkey -n 1 -P -K /dev/null ${md} } setkey_readonly_cleanup() { geli_test_cleanup } atf_test_case nokey cleanup nokey_head() { atf_set "descr" "geli setkey can change the key for an existing provider" atf_set "require.user" "root" } 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 atf_check geli init -B none -P -K keyfile1 ${md} # Try to set the key for a detached device without providing any # components for the old key. atf_check -s not-exit:0 -e match:"No key components given" \ geli setkey -n 0 -p -P -K keyfile2 ${md} # Try to set the key for a detached device without providing any # components for the new key atf_check -s not-exit:0 -e match:"No key components given" \ geli setkey -n 0 -p -k keyfile1 -P ${md} # Try to set a new key for an attached device with no components atf_check geli attach -p -k keyfile1 ${md} atf_check -s not-exit:0 -e match:"No key components given" \ geli setkey -n 0 -P ${md} } nokey_cleanup() { geli_test_cleanup } atf_init_test_cases() { atf_add_test_case setkey atf_add_test_case setkey_passphrase atf_add_test_case setkey_readonly atf_add_test_case nokey } 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 @@ -1,81 +1,83 @@ #!/bin/sh TEST_MDS_FILE="${TMPDIR}/test_mds.$(basename $0)" devwait() { while :; do if [ -c /dev/${class}/${name} ]; then return fi sleep 0.2 done } 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() { local test_md unit test_md=$1 unit=${test_md#md} mdconfig -d -u $unit || exit sed -i '' "/^${test_md}$/d" $TEST_MDS_FILE || exit } geom_test_cleanup() { local test_md if [ -f "$TEST_MDS_FILE" ]; then while read test_md; do # The "#" tells the TAP parser this is a comment echo "# Removing test memory disk: $test_md" mdconfig -d -u $test_md done < $TEST_MDS_FILE rm -f "$TEST_MDS_FILE" fi } geom_load_class_if_needed() { local class=$1 # If the geom class isn't already loaded, try loading it. if ! kldstat -q -m g_${class}; then if ! geom ${class} load; then echo "could not load module for geom class=${class}" return 1 fi fi return 0 } geom_atf_test_setup() { if ! error_message=$(geom_load_class_if_needed $class); then atf_skip "$error_message" fi } geom_tap_test_setup() { if ! error_message=$(geom_load_class_if_needed $class); then echo "1..0 # SKIP $error_message" exit 0 fi } : ${ATF_TEST=false} if ! $ATF_TEST; then geom_tap_test_setup fi 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 @@ -1,68 +1,68 @@ #!/bin/sh # Test handling of read errors. . $(dirname $0)/conf.sh echo 1..3 set -e ddbs=2048 regreadfp="debug.fail_point.g_mirror_regular_request_read" m1=$(mktemp $base.XXXXXX) 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 devwait syncwait tmp1=$(mktemp $base.XXXXXX) tmp2=$(mktemp $base.XXXXXX) EIO=5 # gmirror should retry a failed read from the other mirror. sysctl ${regreadfp}="1*return(${EIO})[pid $(gmirror_worker_pid)]" dd if=/dev/mirror/$name of=$tmp1 iseek=256 bs=$ddbs count=1 >/dev/null 2>&1 dd if=/dev/$us1 of=$tmp2 iseek=256 bs=$ddbs count=1 >/dev/null 2>&1 sysctl ${regreadfp}='off' if cmp -s $tmp1 $tmp2; then echo "ok 1" else echo "not ok 1" fi # Make sure that one of the mirrors was marked broken. genid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*genid: /{print $2}') genid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*genid: /{print $2}') if [ $genid1 -eq $(($genid2 + 1)) -o $genid2 -eq $(($genid1 + 1)) ]; then echo "ok 2" else echo "not ok 2" 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. if [ $(gmirror status -s $name | wc -l) -eq 1 ]; then echo "ok 3" else echo "not ok 3" fi rm -f $m1 $m2 $tmp1 $tmp2 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 @@ -1,83 +1,83 @@ #!/bin/sh # Test handling of read errors. . $(dirname $0)/conf.sh echo 1..4 set -e ddbs=2048 regreadfp="debug.fail_point.g_mirror_regular_request_read" m1=$(mktemp $base.XXXXXX) 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 devwait syncwait tmp1=$(mktemp $base.XXXXXX) tmp2=$(mktemp $base.XXXXXX) ENXIO=6 # gmirror has special handling for ENXIO. It does not mark the failed component # as broken, allowing it to rejoin the mirror automatically when it appears. sysctl ${regreadfp}="1*return(${ENXIO})[pid $(gmirror_worker_pid)]" dd if=/dev/mirror/$name of=$tmp1 iseek=512 bs=$ddbs count=1 >/dev/null 2>&1 dd if=/dev/$us1 of=$tmp2 iseek=512 bs=$ddbs count=1 >/dev/null 2>&1 sysctl ${regreadfp}='off' if cmp -s $tmp1 $tmp2; then echo "ok 1" else echo "not ok 1" fi # Verify that the genids still match after ENXIO. genid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*genid: /{print $2}') genid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*genid: /{print $2}') if [ $genid1 -eq $genid2 ]; then echo "ok 2" else echo "not ok 2" fi # Trigger a syncid bump. dd if=/dev/zero of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1 # The ENXIO+write should have caused a syncid bump. syncid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*syncid: /{print $2}') syncid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*syncid: /{print $2}') if [ $syncid1 -eq $(($syncid2 + 1)) -o $syncid2 -eq $(($syncid1 + 1)) ]; then echo "ok 3" else echo "not ok 3" 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. if [ $(gmirror status -s $name | wc -l) -eq 2 ]; then echo "ok 4" else echo "not ok 4" fi syncwait rm -f $m1 $m2 $tmp1 $tmp2 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 @@ -1,67 +1,67 @@ #!/bin/sh # Test handling of write errors. . $(dirname $0)/conf.sh echo 1..3 set -e ddbs=2048 regwritefp="debug.fail_point.g_mirror_regular_request_write" m1=$(mktemp $base.XXXXXX) 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 tmp1=$(mktemp $base.XXXXXX) tmp2=$(mktemp $base.XXXXXX) dd if=/dev/random of=$tmp1 bs=$ddbs count=1 >/dev/null 2>&1 EIO=5 # gmirror should kick one of the mirrors out after hitting EIO. sysctl ${regwritefp}="1*return(${EIO})[pid $(gmirror_worker_pid)]" dd if=$tmp1 of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1 dd if=/dev/mirror/$name of=$tmp2 bs=$ddbs count=1 >/dev/null 2>&1 sysctl ${regwritefp}='off' if cmp -s $tmp1 $tmp2; then echo "ok 1" else echo "not ok 1" fi # Make sure that one of the mirrors was marked broken. genid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*genid: /{print $2}') genid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*genid: /{print $2}') if [ $genid1 -eq $(($genid2 + 1)) -o $genid2 -eq $(($genid1 + 1)) ]; then echo "ok 2" else echo "not ok 2" 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. if [ $(gmirror status -s $name | wc -l) -eq 1 ]; then echo "ok 3" else echo "not ok 3" fi rm -f $m1 $m2 $tmp1 $tmp2 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 @@ -1,80 +1,80 @@ #!/bin/sh # Test handling of write errors. . $(dirname $0)/conf.sh echo 1..4 set -e ddbs=2048 regwritefp="debug.fail_point.g_mirror_regular_request_write" m1=$(mktemp $base.XXXXXX) 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 tmp1=$(mktemp $base.XXXXXX) tmp2=$(mktemp $base.XXXXXX) dd if=/dev/random of=$tmp1 bs=$ddbs count=1 >/dev/null 2>&1 ENXIO=6 # gmirror has special handling for ENXIO. It does not mark the failed component # as broken, allowing it to rejoin the mirror automatically when it appears. sysctl ${regwritefp}="1*return(${ENXIO})[pid $(gmirror_worker_pid)]" dd if=$tmp1 of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1 dd if=/dev/mirror/$name of=$tmp2 bs=$ddbs count=1 >/dev/null 2>&1 sysctl ${regwritefp}='off' if cmp -s $tmp1 $tmp2; then echo "ok 1" else echo "not ok 1" fi # Verify that the genids still match after ENXIO. genid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*genid: /{print $2}') genid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*genid: /{print $2}') if [ $genid1 -eq $genid2 ]; then echo "ok 2" else echo "not ok 2" fi # The ENXIO should have caused a syncid bump. syncid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*syncid: /{print $2}') syncid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*syncid: /{print $2}') if [ $syncid1 -eq $(($syncid2 + 1)) -o $syncid2 -eq $(($syncid1 + 1)) ]; then echo "ok 3" else echo "not ok 3" 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. if [ $(gmirror status -s $name | wc -l) -eq 2 ]; then echo "ok 4" else echo "not ok 4" fi syncwait rm -f $m1 $m2 $tmp1 $tmp2 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 @@ -1,22 +1,22 @@ #!/bin/sh . `dirname $0`/conf.sh 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 # Size of created device should be 1MB - 512b. size=`diskinfo /dev/mirror/${name} | awk '{print $3}'` if [ $size -eq 1048064 ]; then echo "ok 1" else echo "not ok 1" fi 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 @@ -1,51 +1,51 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..4" balance="round-robin" ddbs=2048 nblocks1=1024 nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)` 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 -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 dd if=${src} of=/dev/mirror/${name} 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 echo "not ok 1" else echo "ok 1" fi 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/${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/${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 rm -f ${src} ${dst} 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 @@ -1,63 +1,63 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..5" balance="round-robin" ddbs=2048 nblocks1=1024 nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)` 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 -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 dd if=${src} of=/dev/mirror/${name} 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 echo "not ok 1" else echo "ok 1" fi 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" else echo "ok 2" fi 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" else echo "ok 3" fi 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" else echo "ok 4" fi # mirror/${name} should be removed. if [ -c /dev/${name} ]; then echo "not ok 5" else echo "ok 5" fi rm -f ${src} ${dst} 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 @@ -1,65 +1,65 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..5" balance="load" ddbs=2048 nblocks1=1024 nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)` 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 -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 dd if=${src} of=/dev/mirror/${name} 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 echo "not ok 1" else echo "ok 1" fi 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" else echo "ok 2" fi 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" else echo "ok 3" fi 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" else echo "ok 4" fi gmirror destroy $name # mirror/${name} should be removed. if [ -c /dev/${name} ]; then echo "not ok 5" else echo "ok 5" fi rm -f ${src} ${dst} 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 @@ -1,63 +1,63 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..5" balance="split" ddbs=8192 nblocks1=1024 nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)` 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 -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 dd if=${src} of=/dev/mirror/${name} 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 echo "not ok 1" else echo "ok 1" fi 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" else echo "ok 2" fi 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" else echo "ok 3" fi 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" else echo "ok 4" fi # mirror/${name} should be removed. if [ -c /dev/${name} ]; then echo "not ok 5" else echo "ok 5" fi rm -f ${src} ${dst} 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 @@ -1,44 +1,44 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..2" balance="split" ddbs=8192 nblocks1=1024 nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)` 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 -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 dd if=${src} of=/dev/mirror/${name} 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 echo "not ok 1" else echo "ok 1" fi # Connect disk to the mirror. gmirror insert ${name} ${us2} # Wait for synchronization. sleep 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 rm -f ${src} ${dst} 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 @@ -1,63 +1,63 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..5" balance="prefer" ddbs=2048 nblocks1=1024 nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)` 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 -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 dd if=${src} of=/dev/mirror/${name} 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 echo "not ok 1" else echo "ok 1" fi 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" else echo "ok 2" fi 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" else echo "ok 3" fi 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" else echo "ok 4" fi # mirror/${name} should be removed. if [ -c /dev/${name} ]; then echo "not ok 5" else echo "ok 5" fi rm -f ${src} ${dst} 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 @@ -1,55 +1,55 @@ #!/bin/sh # Regression test for r317712. . `dirname $0`/conf.sh if ! [ -c /dev/mdctl ]; then echo "1..0 # SKIP no /dev/mdctl to create md devices" exit 0 fi echo 1..1 ddbs=2048 m1=`mktemp $base.XXXXXX` || exit 1 m2=`mktemp $base.XXXXXX` || exit 1 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=$(mdconfig -t vnode -f $m1) || exit 1 us1=$(mdconfig -t vnode -f $m2) || exit 1 gmirror label $name /dev/$us0 /dev/$us1 || exit 1 devwait # Ensure that the mirrors are marked dirty, and then disconnect them. # We need to have the gmirror provider open when destroying the MDs since # gmirror will automatically mark the mirrors clean when the provider is closed. exec 9>/dev/mirror/$name dd if=/dev/zero bs=$ddbs count=1 >&9 2>/dev/null mdconfig -d -u ${us0#md} -o force || exit 1 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 # the mirror metadata is wiped; otherwise the metadata blocks will fail # the comparison. It would be nice to do this with a "gmirror verify" # command instead. gmirror destroy $name if cmp -s ${m1} ${m2}; then echo "ok 1" else echo "not ok 1" fi rm -f $m1 $m2 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 @@ -1,57 +1,57 @@ #!/bin/sh # Regression test for r306743. . `dirname $0`/conf.sh echo 1..1 ddbs=2048 m1=`mktemp $base.XXXXXX` || exit 1 m2=`mktemp $base.XXXXXX` || exit 1 m3=`mktemp $base.XXXXXX` || exit 1 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 # Break one of the mirrors by forcing a single metadata write error. # When dd closes the mirror provider, gmirror will attempt to mark the mirrors # clean, and will kick one of the mirrors out upon hitting the error. sysctl debug.fail_point.g_mirror_metadata_write="1*return(5)[pid $(gmirror_worker_pid)]" || exit 1 dd if=/dev/random of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1 sysctl debug.fail_point.g_mirror_metadata_write='off' || exit 1 # Replace the broken mirror, and then stop the gmirror. gmirror forget $name || exit 1 gmirror insert $name /dev/$us2 || exit 1 syncwait gmirror stop $name || exit 1 # Restart the gmirror on the original two mirrors. One of them is broken, # so we should end up with a degraded gmirror. gmirror activate $name /dev/$us0 /dev/$us1 || exit 1 devwait dd if=/dev/random of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1 # Re-add the replacement mirror and verify the two mirrors are synchronized. # Destroy the gmirror first so that the mirror metadata is wiped; otherwise # the metadata blocks will fail the comparison. It would be nice to do this # with a "gmirror verify" command instead. gmirror activate $name /dev/$us2 || exit 1 syncwait gmirror destroy $name || exit 1 if cmp -s $m1 $m3; then echo "ok 1" else echo "not ok 1" fi rm -f $m1 $m2 $m3 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 @@ -1,139 +1,139 @@ ATF_TEST=true class=mirror . $(atf_get_srcdir)/conf.sh atf_test_case run_latest_genid cleanup run_latest_genid_head() { atf_set "descr" \ "Ensure that we properly select components (latest genid) during STARTING." atf_set "require.user" "root" } run_latest_genid_body() { geom_atf_test_setup if ! error_message=$(geom_load_class_if_needed nop); then atf_skip "$error_message" fi f1=$(mktemp ${base}.XXXXXX) f2=$(mktemp ${base}.XXXXXX) f3=$(mktemp ${base}.XXXXXX) rnd1=$(mktemp ${base}.XXXXXX) rnd2=$(mktemp ${base}.XXXXXX) atf_check truncate -s 2M $f1 atf_check truncate -s 2M $f2 atf_check truncate -s 2M $f3 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 atf_check gnop create $md2 atf_check gnop create $md3 # Hardcode component names so that the non-.nop device isn't tasted # instead. atf_check gmirror label -h $name ${md1}.nop devwait atf_check gmirror insert -h $name ${md2}.nop atf_check gmirror insert -h $name ${md3}.nop syncwait # Fail mirror 3, writing known contents to mirror 1+2 block 1 atf_check -s exit:0 -e empty -o empty \ gnop configure -w 100 ${md3}.nop atf_check -s exit:0 dd if="$rnd1" bs=512 count=1 oseek=1 conv=notrunc \ of=/dev/mirror/$name status=none disconnectwait nop "${md3}.nop" # Should have two mirrors remaining after md3 was evicted atf_check [ $(gmirror status -s $name | wc -l) -eq 2 ] atf_check -s exit:0 -o match:"DEGRADED ${md1}.nop \(ACTIVE\)" \ gmirror status -s $name atf_check -s exit:0 -o match:"DEGRADED ${md2}.nop \(ACTIVE\)" \ gmirror status -s $name # Repeat: # Fail mirror 2, writing known contents to mirror 1 block 2 atf_check -s exit:0 -e empty -o empty \ gnop configure -w 100 ${md2}.nop atf_check -s exit:0 dd if="$rnd2" bs=512 count=2 oseek=1 conv=notrunc \ of=/dev/mirror/$name status=none disconnectwait nop "${md2}.nop" # Should have one mirror remaining after md2 was evicted atf_check [ $(gmirror status -s $name | wc -l) -eq 1 ] atf_check -s exit:0 -o match:"DEGRADED ${md1}.nop \(ACTIVE\)" \ gmirror status -s $name # Stop the mirror and remove the pieces so gmirror can't see them. atf_check gmirror stop $name atf_check gnop destroy ${md1}.nop atf_check gnop destroy ${md2}.nop atf_check gnop destroy ${md3}.nop # Rebuild; spin up "disk" with lowest genid atf_check gnop create $md3 md3gen=$(gmirror dump /dev/${md3}.nop | grep genid | cut -d: -f2) # Assert gmirror is referencing this component for now: atf_check [ $(consumerrefs nop ${md3}.nop) = "r1w1e1" ] # Adding newer genid should kick out old component atf_check gnop create $md2 md2gen=$(gmirror dump /dev/${md2}.nop | grep genid | cut -d: -f2) atf_check [ $md2gen -gt $md3gen ] disconnectwait nop "${md3}.nop" # Can't test this because 'status' doesn't exist until RUNNING: #atf_check [ $(gmirror status -s $name | wc -l) -eq 1 ] # But as a substitute, assert gmirror has dropped reference to staler # component in favor of newer component: atf_check [ $(consumerrefs nop ${md2}.nop) = "r1w1e1" ] # ditto atf_check gnop create $md1 md1gen=$(gmirror dump /dev/${md1}.nop | grep genid | cut -d: -f2) atf_check [ $md1gen -gt $md2gen ] disconnectwait nop "${md2}.nop" # Assert gmirror has dropped reference to stale component in favor of # newer component: atf_check [ $(consumerrefs nop ${md1}.nop) = "r1w1e1" ] # gmirror won't start the mirror automatically with only one component # ($md0) of configured three, so this waits out the # kern.geom.mirror.timeout: devwait atf_check [ $(gmirror status -s $name | wc -l) -eq 1 ] atf_check -s exit:0 -o match:"DEGRADED ${md1}.nop \(ACTIVE\)" \ gmirror status -s $name } run_latest_genid_cleanup() { . $(atf_get_srcdir)/conf.sh if [ -f "$TEST_MDS_FILE" ]; then while read test_md; do echo "# Removing test gnop: ${test_md}.nop" gnop destroy -f "${test_md}.nop" 2>/dev/null || : done < "$TEST_MDS_FILE" fi gmirror_test_cleanup } atf_init_test_cases() { atf_add_test_case run_latest_genid } 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 @@ -1,108 +1,108 @@ ATF_TEST=true . $(atf_get_srcdir)/conf.sh REG_READ_FP=debug.fail_point.g_mirror_regular_request_read atf_test_case sync_read_error_2_disks cleanup sync_read_error_2_disks_head() { atf_set "descr" \ "Ensure that we properly handle read errors during synchronization." atf_set "require.user" "root" } sync_read_error_2_disks_body() { geom_atf_test_setup f1=$(mktemp ${base}.XXXXXX) f2=$(mktemp ${base}.XXXXXX) 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 atf_check -s ignore -e empty -o not-empty sysctl ${REG_READ_FP}="1*return(5)[pid $(gmirror_worker_pid)]" # If a read error occurs while synchronizing and the mirror contains # a single active disk, gmirror has no choice but to fail the # synchronization and kick the new disk out of the mirror. atf_check gmirror insert $name $md2 sleep 0.1 syncwait atf_check [ $(gmirror status -s $name | wc -l) -eq 1 ] atf_check -s exit:0 -o match:"DEGRADED $md1 \(ACTIVE\)" \ gmirror status -s $name } sync_read_error_2_disks_cleanup() { atf_check -s ignore -e ignore -o ignore sysctl ${REG_READ_FP}='off' gmirror_test_cleanup } atf_test_case sync_read_error_3_disks cleanup sync_read_error_3_disks_head() { atf_set "descr" \ "Ensure that we properly handle read errors during synchronization." atf_set "require.user" "root" } sync_read_error_3_disks_body() { geom_atf_test_setup f1=$(mktemp ${base}.XXXXXX) f2=$(mktemp ${base}.XXXXXX) f3=$(mktemp ${base}.XXXXXX) atf_check dd if=/dev/random bs=1M count=32 of=$f1 status=none 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 atf_check gmirror insert $name $md2 syncwait atf_check -s exit:0 -e empty -o not-empty sysctl ${REG_READ_FP}="1*return(5)[pid $(gmirror_worker_pid)]" # If a read error occurs while synchronizing a new disk, and we have # multiple active disks, we retry the read after an error. The disk # which returned the read error is kicked out of the mirror. atf_check gmirror insert $name $md3 syncwait atf_check [ $(gmirror status -s $name | wc -l) -eq 2 ] atf_check -s exit:0 -o match:"DEGRADED $md3 \(ACTIVE\)" \ gmirror status -s $name # Make sure that the two active disks are identical. Destroy the # mirror first so that the metadata sectors are wiped. if $(gmirror status -s $name | grep -q $md1); then active=$md1 else active=$md2 fi atf_check gmirror destroy $name atf_check cmp /dev/$active /dev/$md3 } sync_read_error_3_disks_cleanup() { atf_check -s ignore -e ignore -o ignore sysctl ${REG_READ_FP}='off' gmirror_test_cleanup } atf_init_test_cases() { atf_add_test_case sync_read_error_2_disks atf_add_test_case sync_read_error_3_disks } 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 @@ -1,31 +1,31 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..1" ddbs=2048 nblocks1=1024 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 graid3 label -r $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1 devwait dd if=${src} of=/dev/raid3/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 dd if=/dev/raid3/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then echo "not ok 1" else echo "ok 1" fi rm -f ${src} ${dst} 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 @@ -1,31 +1,31 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..1" ddbs=2048 nblocks1=1024 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 graid3 label -w $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1 devwait dd if=${src} of=/dev/raid3/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 dd if=/dev/raid3/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then echo "not ok 1" else echo "ok 1" fi rm -f ${src} ${dst} 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 @@ -1,37 +1,37 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..1" 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 dd if=/dev/random of=/dev/${us2} count=$nblocks1 >/dev/null 2>&1 graid3 label -w $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1 devwait # Wait for synchronization. sleep 2 graid3 stop $name # Break one component. dd if=/dev/random of=/dev/${us1} count=$nblocks2 >/dev/null 2>&1 # Provoke retaste of the rest components. true > /dev/${us0} true > /dev/${us2} sleep 1 dd if=/dev/raid3/${name} of=/dev/null bs=1k count=$nblocks3 >/dev/null 2>&1 ec=$? if [ $ec -eq 0 ]; then echo "not ok 1" else echo "ok 1" fi 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 @@ -1,27 +1,27 @@ #!/bin/sh . `dirname $0`/conf.sh 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 # Size of created device should be 2MB - 1024B. mediasize=`diskinfo /dev/raid3/${name} | awk '{print $3}'` if [ $mediasize -eq 2096128 ]; then echo "ok 1" else echo "not ok 1" fi sectorsize=`diskinfo /dev/raid3/${name} | awk '{print $2}'` if [ $sectorsize -eq 1024 ]; then echo "ok 2" else echo "not ok 2" fi 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 @@ -1,31 +1,31 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..1" ddbs=2048 nblocks1=1024 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 graid3 label $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1 devwait dd if=${src} of=/dev/raid3/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 dd if=/dev/raid3/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then echo "not ok 1" else echo "ok 1" fi rm -f ${src} ${dst} 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 @@ -1,35 +1,35 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..1" ddbs=2048 nblocks1=1024 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 graid3 label $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1 devwait dd if=${src} of=/dev/raid3/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 # # Reading without one DATA component (so with parity). # graid3 remove -n 1 $name dd if=/dev/raid3/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then echo "not ok 1" else echo "ok 1" fi rm -f ${src} ${dst} 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 @@ -1,35 +1,35 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..1" ddbs=2048 nblocks1=1024 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 graid3 label $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1 devwait # # Writing without one DATA component. # graid3 remove -n 1 $name dd if=${src} of=/dev/raid3/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 dd if=/dev/raid3/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then echo "not ok 1" else echo "ok 1" fi rm -f ${src} ${dst} 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 @@ -1,35 +1,35 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..1" ddbs=2048 nblocks1=1024 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 graid3 label $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1 devwait # # Writing without PARITY component. # graid3 remove -n 2 $name dd if=${src} of=/dev/raid3/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 dd if=/dev/raid3/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then echo "not ok 1" else echo "ok 1" fi rm -f ${src} ${dst} 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 @@ -1,39 +1,39 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..1" ddbs=2048 nblocks1=1024 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 graid3 label $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1 devwait dd if=${src} of=/dev/raid3/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 # # Rebuild of DATA component. # graid3 remove -n 1 $name dd if=/dev/zero of=/dev/${us1} bs=512 count=`expr $nblocks1 + 1` >/dev/null 2>&1 graid3 insert -n 1 $name md${us1} sleep 1 dd if=/dev/raid3/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then echo "not ok 1" else echo "ok 1" fi rm -f ${src} ${dst} 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 @@ -1,42 +1,42 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..1" ddbs=2048 nblocks1=1024 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 graid3 label $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1 devwait dd if=${src} of=/dev/raid3/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 # # Rebuild of PARITY component. # graid3 remove -n 2 $name dd if=/dev/zero of=/dev/${us2} bs=512 count=`expr $nblocks1 + 1` >/dev/null 2>&1 graid3 insert -n 2 $name md${us2} sleep 1 # Remove DATA component, so PARITY component can be used while reading. graid3 remove -n 1 $name dd if=/dev/zero of=/dev/${us1} bs=512 count=`expr $nblocks1 + 1` >/dev/null 2>&1 dd if=/dev/raid3/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then echo "not ok 1" else echo "ok 1" fi rm -f ${src} ${dst} 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 @@ -1,38 +1,38 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..1" ddbs=2048 nblocks1=1024 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 graid3 label $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1 devwait # # Writing without DATA component and rebuild of DATA component. # graid3 remove -n 1 $name dd if=/dev/zero of=/dev/${us1} bs=512 count=`expr $nblocks1 + 1` >/dev/null 2>&1 dd if=${src} of=/dev/raid3/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 graid3 insert -n 1 $name md${us1} sleep 1 dd if=/dev/raid3/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then echo "not ok 1" else echo "ok 1" fi rm -f ${src} ${dst} diff --git a/tests/sys/geom/class/raid3/9_test.sh b/tests/sys/geom/class/raid3/9_test.sh index dc26ff53b6ce..880b2a20c817 100644 --- a/tests/sys/geom/class/raid3/9_test.sh +++ b/tests/sys/geom/class/raid3/9_test.sh @@ -1,41 +1,41 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..1" ddbs=2048 nblocks1=1024 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 graid3 label $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1 devwait # # Writing without PARITY component and rebuild of PARITY component. # graid3 remove -n 2 $name dd if=/dev/zero of=/dev/${us2} bs=512 count=`expr $nblocks1 + 1` >/dev/null 2>&1 dd if=${src} of=/dev/raid3/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 graid3 insert -n 2 $name md${us2} sleep 1 # Remove DATA component, so PARITY component can be used while reading. graid3 remove -n 1 $name dd if=/dev/zero of=/dev/${us1} bs=512 count=`expr $nblocks1 + 1` >/dev/null 2>&1 dd if=/dev/raid3/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then echo "not ok 1" else echo "ok 1" fi rm -f ${src} ${dst} diff --git a/tests/sys/geom/class/shsec/1_test.sh b/tests/sys/geom/class/shsec/1_test.sh index f1e6ab4137a1..93e1c02e7cf9 100644 --- a/tests/sys/geom/class/shsec/1_test.sh +++ b/tests/sys/geom/class/shsec/1_test.sh @@ -1,27 +1,27 @@ #!/bin/sh . `dirname $0`/conf.sh 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 # Size of created device should be 1MB - 512B. mediasize=`diskinfo /dev/shsec/${name} | awk '{print $3}'` if [ $mediasize -eq 1048064 ]; then echo "ok 1" else echo "not ok 1" fi sectorsize=`diskinfo /dev/shsec/${name} | awk '{print $2}'` if [ $sectorsize -eq 512 ]; then echo "ok 2" else echo "not ok 2" fi diff --git a/tests/sys/geom/class/shsec/2_test.sh b/tests/sys/geom/class/shsec/2_test.sh index b16084218eed..4f4ab3404ee0 100644 --- a/tests/sys/geom/class/shsec/2_test.sh +++ b/tests/sys/geom/class/shsec/2_test.sh @@ -1,51 +1,51 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..4" nblocks1=1024 nblocks2=`expr $nblocks1 + 1` src=`mktemp $base.XXXXXX` || exit 1 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 dd if=${src} of=/dev/shsec/${name} count=$nblocks1 >/dev/null 2>&1 dd if=/dev/shsec/${name} of=${dst} count=$nblocks1 >/dev/null 2>&1 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then echo "not ok 1" else echo "ok 1" fi dd if=/dev/${us0} of=${dst} count=$nblocks1 >/dev/null 2>&1 if [ `md5 -q ${src}` = `md5 -q ${dst}` ]; then echo "not ok 2" else echo "ok 2" fi dd if=/dev/${us1} of=${dst} count=$nblocks1 >/dev/null 2>&1 if [ `md5 -q ${src}` = `md5 -q ${dst}` ]; then echo "not ok 3" else echo "ok 3" fi dd if=/dev/${us2} of=${dst} count=$nblocks1 >/dev/null 2>&1 if [ `md5 -q ${src}` = `md5 -q ${dst}` ]; then echo "not ok 4" else echo "ok 4" fi rm -f ${src} ${dst} diff --git a/tests/sys/geom/class/stripe/1_test.sh b/tests/sys/geom/class/stripe/1_test.sh index 9878baa30e86..a717866a0c5c 100644 --- a/tests/sys/geom/class/stripe/1_test.sh +++ b/tests/sys/geom/class/stripe/1_test.sh @@ -1,22 +1,22 @@ #!/bin/sh . `dirname $0`/conf.sh 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 # Size of created device should be 1MB * 3. size=`diskinfo /dev/stripe/${name} | awk '{print $3}'` if [ $size -eq 3145728 ]; then echo "ok 1" else echo "not ok 1" fi diff --git a/tests/sys/geom/class/stripe/2_test.sh b/tests/sys/geom/class/stripe/2_test.sh index 3558cf99146b..c4b1f2344629 100644 --- a/tests/sys/geom/class/stripe/2_test.sh +++ b/tests/sys/geom/class/stripe/2_test.sh @@ -1,29 +1,29 @@ #!/bin/sh . `dirname $0`/conf.sh echo "1..1" tsize=3 src=`mktemp $base.XXXXXX` || exit 1 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 dd if=${src} of=/dev/stripe/${name} bs=1m count=$tsize >/dev/null 2>&1 dd if=/dev/stripe/${name} of=${dst} bs=1m count=$tsize >/dev/null 2>&1 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then echo "not ok 1" else echo "ok 1" fi rm -f ${src} ${dst} diff --git a/tests/sys/geom/class/union/union_test.sh b/tests/sys/geom/class/union/union_test.sh index 1872847bdf58..9d02cae83e8a 100644 --- a/tests/sys/geom/class/union/union_test.sh +++ b/tests/sys/geom/class/union/union_test.sh @@ -1,338 +1,338 @@ # SPDX-License-Identifier: BSD-2-Clause # # Copyright (c) 2023 The FreeBSD Foundation # # This software was developed1 by Yan-Hao Wang # under sponsorship from the FreeBSD Foundation. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # . $(atf_get_srcdir)/conf.sh atf_test_case create cleanup create_head() { atf_set "descr" "Test gunion create and destroy" atf_set "require.user" "root" } 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" guniondev="${upperdev}-${lowerdev}.union" atf_check -o inline:"/dev/${guniondev}\n" ls "/dev/${guniondev}" atf_check -o ignore fsck -p -f "/dev/${guniondev}" atf_check gunion destroy "$guniondev" atf_check -s not-exit:0 -o ignore -e ignore ls "/dev/${guniondev}" } create_cleanup() { gunion_test_cleanup } atf_test_case basic cleanup basic_head() { atf_set "descr" "Check gunion doesn't affect lowerdev status and lowerdev can't be mounted when being in a gunion" atf_set "require.user" "root" } 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 mount "/dev/${lowerdev}" lowermnt echo "lower file" > lower_file cp lower_file lowermnt/lower_file sync umount lowermnt gunion create "$upperdev" "$lowerdev" guniondev="${upperdev}-${lowerdev}.union" atf_check -s not-exit:0 -o ignore -e ignore mount "/dev/${lowerdev}" lowermnt mount "/dev/${guniondev}" gunionmnt echo "update lower file" >> gunionmnt/lower_file echo "gunion file" > gunion_file cp gunion_file gunionmnt/gunion_file sync umount gunionmnt gunion destroy "$guniondev" mount "/dev/${lowerdev}" lowermnt checksum lowermnt/lower_file lower_file atf_check -s not-exit:0 -o ignore -e ignore ls lowermnt/gunion_file } basic_cleanup() { gunion_test_cleanup } atf_test_case commit cleanup commit_head() { atf_set "descr" "Test basic gunion commit without option" atf_set "require.user" "root" } 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 mount "/dev/${lowerdev}" lowermnt echo "lower file" > lower_file cp lower_file lowermnt/lower_file sync umount lowermnt gunion create "$upperdev" "$lowerdev" guniondev="${upperdev}-${lowerdev}.union" mount "/dev/${guniondev}" gunionmnt checksum gunionmnt/lower_file lower_file echo "update lower file" >> lower_file cp -f lower_file gunionmnt/lower_file echo "gunion file" > gunion_file cp gunion_file gunionmnt/gunion_file sync umount gunionmnt atf_check gunion commit "$guniondev" gunion destroy "$guniondev" atf_check -o ignore fsck -p -f "/dev/${lowerdev}" mount "/dev/${lowerdev}" lowermnt checksum lowermnt/lower_file lower_file checksum lowermnt/gunion_file gunion_file } commit_cleanup() { gunion_test_cleanup } atf_test_case offset cleanup offset_head() { atf_set "descr" "Test gunion create with -o offset option" atf_set "require.user" "root" } 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" gpt_entry_1=$(gpart show "/dev/${lowerdev}") mkdir gunionmnt secsize="$(diskinfo "/dev/${lowerdev}" | awk '{print $2}')" p1_start_sector="$(gpart show -p "/dev/${lowerdev}" | grep ${lowerdev}p1 | awk '{print $1}')" offset_size="$((secsize * p1_start_sector))" gunion create -o "$offset_size" "$upperdev" "$lowerdev" guniondev="${upperdev}-${lowerdev}.union" atf_check -o ignore fsck -p -f "/dev/${guniondev}" atf_check mount "/dev/${guniondev}" gunionmnt umount gunionmnt gunion destroy "$guniondev" gpt_entry_2=$(gpart show "/dev/${lowerdev}") atf_check_equal "$gpt_entry_1" "$gpt_entry_2" } offset_cleanup() { gunion_test_cleanup } atf_test_case size cleanup size_head() { atf_set "descr" "Test gunion create with -s size option" atf_set "require.user" "root" } 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" guniondev="${upperdev}-${lowerdev}.union" echo "$guniondev" > guniondev size="$(diskinfo "/dev/$guniondev" | awk '{print $3}')" atf_check_equal "2097152" "$size" # 2 MB = 2097152 bytes } size_cleanup() { gunion_test_cleanup } atf_test_case secsize cleanup secsize_head() { atf_set "descr" "Test gunion create with -S secsize option" atf_set "require.user" "root" } 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" gunion create -S 1024 "$upperdev" "$lowerdev" guniondev="${upperdev}-${lowerdev}.union" echo "$guniondev" > guniondev secsize="$(diskinfo "/dev/${guniondev}" | awk '{print $2}')" atf_check_equal "1024" "$secsize" } secsize_cleanup() { gunion_test_cleanup } atf_test_case gunionname cleanup gunionname_head() { atf_set "descr" "Test gunion create with -Z gunionname option" atf_set "require.user" "root" } 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" echo "gunion1.union" > guniondev atf_check -o inline:"/dev/gunion1.union\n" ls /dev/gunion1.union } gunionname_cleanup() { gunion_test_cleanup } atf_test_case revert cleanup revert_head() { atf_set "descr" "Test gunion revert" atf_set "require.user" "root" } 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 mount "/dev/${lowerdev}" lowermnt echo "lower file" > lower_file cp lower_file lowermnt/lower_file sync umount lowermnt atf_check gunion create "$upperdev" "$lowerdev" guniondev="${upperdev}-${lowerdev}.union" mount "/dev/${guniondev}" gunionmnt echo "update lower file" >> gunionmnt/lower_file echo "gunion file" > gunion_file cp gunion_file gunionmnt/gunion_file sync umount gunionmnt atf_check gunion revert "$guniondev" mount "/dev/${guniondev}" gunionmnt checksum gunionmnt/lower_file lower_file atf_check -s not-exit:0 -o ignore -e ignore ls gunionmnt/gunion_file umount gunionmnt gunion destroy "$guniondev" } revert_cleanup() { gunion_test_cleanup } atf_init_test_cases() { atf_add_test_case create atf_add_test_case basic atf_add_test_case commit atf_add_test_case offset atf_add_test_case size atf_add_test_case secsize atf_add_test_case gunionname atf_add_test_case revert } checksum() { src=$1 work=$2 if [ ! -e "$src" ]; then atf_fail "file not exist" fi if [ ! -e "$work" ]; then atf_fail "file not exist" fi src_checksum=$(md5 -q "$src") work_checksum=$(md5 -q "$work") if [ "$work_checksum" != "$src_checksum" ]; then atf_fail "md5 checksum didn't match with ${src} and ${work}" fi } diff --git a/tests/sys/geom/class/uzip/1_test.sh b/tests/sys/geom/class/uzip/1_test.sh index 40c9fb44809d..066cacc158b4 100644 --- a/tests/sys/geom/class/uzip/1_test.sh +++ b/tests/sys/geom/class/uzip/1_test.sh @@ -1,33 +1,33 @@ #!/bin/sh testsdir=$(dirname $0) . $testsdir/conf.sh # Check host endianness ret=$(echo I | tr -d "[:space:]" | od -to2 | head -n1 | awk '{print $2}' | cut -c6) if [ "$ret" = "1" ]; then # Little endian UUE=$testsdir/1_endian_little.img.uzip.uue elif [ "$ret" = "0" ]; then # Big endian UUE=$testsdir/1_endian_big.img.uzip.uue else echo "Couldn't detect host endianness" exit 2 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 #cat "${mntpoint}/etalon.txt" diff -I '\$FreeBSD.*\$' -u $testsdir/etalon/etalon.txt "${mntpoint}/etalon.txt" if [ $? -eq 0 ]; then echo "ok 1" else echo "not ok 1" fi diff --git a/tests/sys/kern/sendfile_test.sh b/tests/sys/kern/sendfile_test.sh index 2e9779d6779c..03d87292f3a3 100755 --- a/tests/sys/kern/sendfile_test.sh +++ b/tests/sys/kern/sendfile_test.sh @@ -1,168 +1,168 @@ # SPDX-License-Identifier: BSD-2-Clause # # Copyright (c) 2020 Netflix, Inc. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # These tests exercise a few basic cases for the sendfile() syscall: # - successful operation. # - sendfile() starts an async disk read but that async I/O fails. # - sendfile() fails to read an indirect block and thus cannot # even start an async I/O. # # In all cases we request some read ahead in addition to # the data to be sent to the socket. # MD_DEVS="md.devs" MNT=mnt FILE=$MNT/file HELPER="$(atf_get_srcdir)/sendfile_helper" BSIZE=4096 atf_test_case io_success cleanup io_success_head() { atf_set "descr" "sendfile where all disk I/O succeeds" atf_set "require.user" "root" atf_set "timeout" 15 } io_success_body() { if [ "$(atf_config_get qemu false)" = "true" ]; then 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 } io_success_cleanup() { common_cleanup } atf_test_case io_fail_sync cleanup io_fail_sync_head() { atf_set "descr" "sendfile where we fail to start async I/O" atf_set "require.user" "root" atf_set "timeout" 15 } io_fail_sync_body() { if [ "$(atf_config_get qemu false)" = "true" ]; then 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 atf_check -s exit:3 -e ignore $HELPER $FILE $((12 * $BSIZE)) $BSIZE 0x10000 } io_fail_sync_cleanup() { common_cleanup } atf_test_case io_fail_async cleanup io_fail_async_head() { atf_set "descr" "sendfile where an async I/O fails" atf_set "require.user" "root" atf_set "timeout" 15 } io_fail_async_body() { if [ "$(atf_config_get qemu false)" = "true" ]; then 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 atf_check -s exit:2 -e ignore $HELPER $FILE 0 $BSIZE 0x10000 } io_fail_async_cleanup() { common_cleanup } atf_init_test_cases() { atf_add_test_case io_success atf_add_test_case io_fail_sync atf_add_test_case io_fail_async } 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() { us=$1 atf_check mkdir $MNT atf_check -o ignore -e ignore newfs -b $BSIZE -U -j /dev/${us} atf_check mount /dev/${us} $MNT atf_check -e ignore dd if=/dev/zero of=$FILE bs=1m count=1 atf_check umount $MNT load_gnop atf_check gnop create /dev/${us} atf_check mount /dev/${us}.nop $MNT atf_check -o ignore ls -l $MNT/file } common_cleanup() { umount -f $MNT if [ -f "$MD_DEVS" ]; then while read test_md; do gnop destroy -f ${test_md}.nop 2>/dev/null mdconfig -d -u $test_md 2>/dev/null done < $MD_DEVS rm $MD_DEVS fi true } load_gnop() { if ! kldstat -q -m g_nop; then geom nop load || atf_skip "could not load module for geom nop" fi }