From 2e23c41122c3d638534ac2849239f2c84d68ac9a Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Fri, 29 Dec 2017 16:13:06 +0000 Subject: [PATCH] geli: factor out some common code in the geli tests No functional change. MFC after: 2 weeks Sponsored by: Spectra Logic Corp --- tests/sys/geom/class/eli/conf.sh | 8 ++++++++ tests/sys/geom/class/eli/init_a_test.sh | 4 ---- tests/sys/geom/class/eli/init_test.sh | 5 ----- tests/sys/geom/class/eli/integrity_copy_test.sh | 9 ++------- tests/sys/geom/class/eli/integrity_data_test.sh | 5 +---- tests/sys/geom/class/eli/integrity_hmac_test.sh | 5 +---- tests/sys/geom/class/eli/onetime_a_test.sh | 4 ---- tests/sys/geom/class/eli/onetime_test.sh | 3 --- 8 files changed, 12 insertions(+), 31 deletions(-) diff --git a/tests/sys/geom/class/eli/conf.sh b/tests/sys/geom/class/eli/conf.sh index 117b281c79b9..25eb4badb5b5 100644 --- a/tests/sys/geom/class/eli/conf.sh +++ b/tests/sys/geom/class/eli/conf.sh @@ -23,7 +23,11 @@ for_each_geli_config() { for aalgo in hmac/md5 hmac/sha1 hmac/ripemd160 hmac/sha256 \ hmac/sha384 hmac/sha512; do for secsize in 512 1024 2048 4096 8192; do + bytes=`expr $secsize \* $sectors + 512`b + md=$(attach_md -t malloc -s $bytes) ${func} $cipher $aalgo $secsize + geli detach ${md} 2>/dev/null + mdconfig -d -u ${md} 2>/dev/null done done done @@ -46,7 +50,11 @@ for_each_geli_config_nointegrity() { ealgo=${cipher%%:*} keylen=${cipher##*:} for secsize in 512 1024 2048 4096 8192; do + bytes=`expr $secsize \* $sectors + 512`b + md=$(attach_md -t malloc -s $bytes) ${func} $cipher $aalgo $secsize + geli detach ${md} 2>/dev/null + mdconfig -d -u ${md} 2>/dev/null done done } diff --git a/tests/sys/geom/class/eli/init_a_test.sh b/tests/sys/geom/class/eli/init_a_test.sh index d363766cd43b..9f349f5c908d 100644 --- a/tests/sys/geom/class/eli/init_a_test.sh +++ b/tests/sys/geom/class/eli/init_a_test.sh @@ -15,7 +15,6 @@ do_test() { ealgo=${cipher%%:*} keylen=${cipher##*:} - md=$(attach_md -t malloc -s `expr $secsize \* $sectors + 512`b) geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K $keyfile -s $secsize ${md} 2>/dev/null geli attach -p -k $keyfile ${md} @@ -32,9 +31,6 @@ do_test() { echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}" fi i=$((i+1)) - - geli detach ${md} - mdconfig -d -u ${md} } echo "1..600" diff --git a/tests/sys/geom/class/eli/init_test.sh b/tests/sys/geom/class/eli/init_test.sh index 8dd1775c201e..fa6827975085 100644 --- a/tests/sys/geom/class/eli/init_test.sh +++ b/tests/sys/geom/class/eli/init_test.sh @@ -16,8 +16,6 @@ do_test() { ealgo=${cipher%%:*} keylen=${cipher##*:} - md=$(attach_md -t malloc -s `expr $secsize \* $sectors + 512`b) - geli init -B none -e $ealgo -l $keylen -P -K $keyfile -s $secsize ${md} 2>/dev/null geli attach -p -k $keyfile ${md} @@ -42,9 +40,6 @@ do_test() { echo "not ok $i - ealgo=${ealgo} keylen=${keylen} sec=${secsize}" fi i=$((i+1)) - - geli detach ${md} - mdconfig -d -u ${md} } i=1 diff --git a/tests/sys/geom/class/eli/integrity_copy_test.sh b/tests/sys/geom/class/eli/integrity_copy_test.sh index ab55b0457d4d..485db915f969 100644 --- a/tests/sys/geom/class/eli/integrity_copy_test.sh +++ b/tests/sys/geom/class/eli/integrity_copy_test.sh @@ -4,6 +4,7 @@ . $(dirname $0)/conf.sh base=`basename $0` +sectors=2 keyfile=`mktemp $base.XXXXXX` || exit 1 sector=`mktemp $base.XXXXXX` || exit 1 @@ -16,7 +17,6 @@ do_test() { ealgo=${cipher%%:*} keylen=${cipher##*:} - md=$(attach_md -t malloc -s `expr $secsize \* 2 + 512`b) geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K $keyfile -s $secsize ${md} 2>/dev/null geli attach -p -k $keyfile ${md} @@ -65,18 +65,13 @@ do_test() { # This should be detected as corruption. dd if=/dev/${md} of=${sector} bs=${usecsize} count=1 >/dev/null 2>&1 dd if=${sector} of=/dev/${md} bs=${usecsize} count=1 seek=1 >/dev/null 2>&1 - geli attach -p -k $keyfile ${md} - - dd if=/dev/${md}.eli of=/dev/null bs=${secsize} count=2 >/dev/null 2>&1 + geli attach -p -k $keyfile ${md} 2>/dev/null if [ $? -ne 0 ]; then echo "ok $i - big 2 aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}" else echo "not ok $i - big 2 aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}" fi i=$((i+1)) - - geli detach ${md} - mdconfig -d -u ${md} } diff --git a/tests/sys/geom/class/eli/integrity_data_test.sh b/tests/sys/geom/class/eli/integrity_data_test.sh index 9cabde48bb14..43b3a404e3a6 100644 --- a/tests/sys/geom/class/eli/integrity_data_test.sh +++ b/tests/sys/geom/class/eli/integrity_data_test.sh @@ -4,6 +4,7 @@ . $(dirname $0)/conf.sh base=`basename $0` +sectors=2 keyfile=`mktemp $base.XXXXXX` || exit 1 sector=`mktemp $base.XXXXXX` || exit 1 @@ -16,7 +17,6 @@ do_test() { ealgo=${cipher%%:*} keylen=${cipher##*:} - md=$(attach_md -t malloc -s `expr $secsize \* 2 + 512`b) geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K $keyfile -s $secsize ${md} 2>/dev/null # Corrupt 8 bytes of data. @@ -32,9 +32,6 @@ do_test() { echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}" fi i=$((i+1)) - - geli detach ${md} - mdconfig -d -u ${md} } i=1 diff --git a/tests/sys/geom/class/eli/integrity_hmac_test.sh b/tests/sys/geom/class/eli/integrity_hmac_test.sh index 6dd5ffbcf78c..284d080b684d 100644 --- a/tests/sys/geom/class/eli/integrity_hmac_test.sh +++ b/tests/sys/geom/class/eli/integrity_hmac_test.sh @@ -4,6 +4,7 @@ . $(dirname $0)/conf.sh base=`basename $0` +sectors=2 keyfile=`mktemp $base.XXXXXX` || exit 1 sector=`mktemp $base.XXXXXX` || exit 1 @@ -16,7 +17,6 @@ do_test() { ealgo=${cipher%%:*} keylen=${cipher##*:} - md=$(attach_md -t malloc -s `expr $secsize \* 2 + 512`b) geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K $keyfile -s $secsize ${md} 2>/dev/null # Corrupt 8 bytes of HMAC. @@ -32,9 +32,6 @@ do_test() { echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}" fi i=$((i+1)) - - geli detach ${md} - mdconfig -d -u ${md} } diff --git a/tests/sys/geom/class/eli/onetime_a_test.sh b/tests/sys/geom/class/eli/onetime_a_test.sh index f0d3892a128a..1398bd53b685 100644 --- a/tests/sys/geom/class/eli/onetime_a_test.sh +++ b/tests/sys/geom/class/eli/onetime_a_test.sh @@ -16,7 +16,6 @@ do_test() { ealgo=${cipher%%:*} keylen=${cipher##*:} - md=$(attach_md -t malloc -s `expr $secsize \* $sectors + 512`b) geli onetime -a $aalgo -e $ealgo -l $keylen -s $secsize ${md} 2>/dev/null secs=`diskinfo /dev/${md}.eli | awk '{print $4}'` @@ -32,9 +31,6 @@ do_test() { echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}" fi i=$((i+1)) - - geli detach ${md} - mdconfig -d -u ${md} } i=1 diff --git a/tests/sys/geom/class/eli/onetime_test.sh b/tests/sys/geom/class/eli/onetime_test.sh index 37f5cba0d908..524df2c7a604 100644 --- a/tests/sys/geom/class/eli/onetime_test.sh +++ b/tests/sys/geom/class/eli/onetime_test.sh @@ -15,7 +15,6 @@ do_test() { keylen=${cipher##*:} rnd=`mktemp $base.XXXXXX` || exit 1 - md=$(attach_md -t malloc -s `expr $secsize \* $sectors`b) geli onetime -e $ealgo -l $keylen -s $secsize ${md} 2>/dev/null @@ -41,9 +40,7 @@ do_test() { fi i=$((i+1)) - geli detach ${md} rm -f $rnd - mdconfig -d -u ${md} } i=1