diff options
-rw-r--r-- | ObsoleteFiles.inc | 3 | ||||
-rw-r--r-- | tests/sys/geom/class/eli/Makefile | 4 | ||||
-rwxr-xr-x | tests/sys/geom/class/eli/attach_test.sh | 55 | ||||
-rw-r--r-- | tests/sys/geom/class/eli/conf.sh | 3 | ||||
-rw-r--r-- | tests/sys/geom/class/eli/delkey_test.sh | 28 | ||||
-rw-r--r-- | tests/sys/geom/class/eli/init_test.sh | 23 | ||||
-rw-r--r-- | tests/sys/geom/class/eli/kill_test.sh | 31 | ||||
-rw-r--r-- | tests/sys/geom/class/eli/nokey_test.sh | 65 | ||||
-rw-r--r-- | tests/sys/geom/class/eli/readonly_test.sh | 94 | ||||
-rw-r--r-- | tests/sys/geom/class/eli/setkey_test.sh | 66 |
10 files changed, 206 insertions, 166 deletions
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index a3c7f9828297..149587d76d2f 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -38,6 +38,9 @@ # xargs -n1 | sort | uniq -d; # done +# 20180107: Convert remaining geli(8) tests to ATF +OLD_FILES+=tests/sys/geom/class/eli/nokey_test.sh +OLD_FILES+=tests/sys/geom/class/eli/readonly_test.sh # 20180106: Convert most geli(8) tests to ATF OLD_FILES+=tests/sys/geom/class/eli/attach_d_test.sh OLD_FILES+=tests/sys/geom/class/eli/configure_b_B_test.sh diff --git a/tests/sys/geom/class/eli/Makefile b/tests/sys/geom/class/eli/Makefile index 654f6f303ff0..2acf3c4c569a 100644 --- a/tests/sys/geom/class/eli/Makefile +++ b/tests/sys/geom/class/eli/Makefile @@ -18,10 +18,6 @@ ATF_TESTS_SH+= onetime_test ATF_TESTS_SH+= resize_test ATF_TESTS_SH+= setkey_test -TAP_TESTS_SH+= nokey_test -TAP_TESTS_SH+= readonly_test - - ${PACKAGE}FILES+= conf.sh .for t in ${TAP_TESTS_SH} diff --git a/tests/sys/geom/class/eli/attach_test.sh b/tests/sys/geom/class/eli/attach_test.sh index 83215e968510..42230059ac2d 100755 --- a/tests/sys/geom/class/eli/attach_test.sh +++ b/tests/sys/geom/class/eli/attach_test.sh @@ -39,7 +39,62 @@ 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() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_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() +{ + . $(atf_get_srcdir)/conf.sh + 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() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_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() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + atf_init_test_cases() { atf_add_test_case attach_d + atf_add_test_case attach_r + atf_add_test_case nokey } diff --git a/tests/sys/geom/class/eli/conf.sh b/tests/sys/geom/class/eli/conf.sh index d1dde228afad..04f75b7abf69 100644 --- a/tests/sys/geom/class/eli/conf.sh +++ b/tests/sys/geom/class/eli/conf.sh @@ -3,7 +3,6 @@ class="eli" base=$(atf_get ident) -[ -z "$base" ] && base=`basename $0` # for TAP compatibility MAX_SECSIZE=8192 TEST_MDS_FILE=md.devs @@ -85,7 +84,5 @@ geli_test_cleanup() fi true } -# TODO: remove the trap statement once all TAP tests are converted -trap geli_test_cleanup ABRT EXIT INT TERM . `dirname $0`/../geom_subr.sh diff --git a/tests/sys/geom/class/eli/delkey_test.sh b/tests/sys/geom/class/eli/delkey_test.sh index 99453f1d0b26..9542e0166a9f 100644 --- a/tests/sys/geom/class/eli/delkey_test.sh +++ b/tests/sys/geom/class/eli/delkey_test.sh @@ -80,7 +80,35 @@ 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() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_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() +{ + . $(atf_get_srcdir)/conf.sh + 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/init_test.sh b/tests/sys/geom/class/eli/init_test.sh index e43c7c4c30df..b07d8532deb4 100644 --- a/tests/sys/geom/class/eli/init_test.sh +++ b/tests/sys/geom/class/eli/init_test.sh @@ -358,6 +358,28 @@ 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() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_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() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + atf_init_test_cases() { atf_add_test_case init @@ -366,4 +388,5 @@ atf_init_test_cases() 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 336629a7a0ab..ef7f06893cda 100644 --- a/tests/sys/geom/class/eli/kill_test.sh +++ b/tests/sys/geom/class/eli/kill_test.sh @@ -65,7 +65,38 @@ 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() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_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() +{ + . $(atf_get_srcdir)/conf.sh + 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/nokey_test.sh b/tests/sys/geom/class/eli/nokey_test.sh deleted file mode 100644 index 282979bd4556..000000000000 --- a/tests/sys/geom/class/eli/nokey_test.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -. $(dirname $0)/conf.sh - -base=`basename $0` -sectors=100 -keyfile=`mktemp $base.XXXXXX` || exit 1 -md=$(attach_md -t malloc -s `expr $sectors + 1`) - -echo "1..8" - -geli init -B none -P ${md} 2>/dev/null -if [ $? -ne 0 ]; then - echo "ok 1" -else - echo "not ok 1" -fi - -dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1 - -geli init -B none -P -K ${keyfile} ${md} 2>/dev/null -if [ $? -eq 0 ]; then - echo "ok 2" -else - echo "not ok 2" -fi -geli attach -p ${md} 2>/dev/null -if [ $? -ne 0 ]; then - echo "ok 3" -else - echo "not ok 3" -fi -geli attach -p -k ${keyfile} ${md} 2>/dev/null -if [ $? -eq 0 ]; then - echo "ok 4" -else - echo "not ok 4" -fi -geli setkey -n 0 -P ${md} 2>/dev/null -if [ $? -ne 0 ]; then - echo "ok 5" -else - echo "not ok 5" -fi -geli detach ${md} 2>/dev/null -if [ $? -eq 0 ]; then - echo "ok 6" -else - echo "not ok 6" -fi -geli setkey -n 0 -p -P -K ${keyfile} ${md} 2>/dev/null -if [ $? -ne 0 ]; then - echo "ok 7" -else - echo "not ok 7" -fi -geli setkey -n 0 -p -k ${keyfile} -P ${md} 2>/dev/null -if [ $? -ne 0 ]; then - echo "ok 8" -else - echo "not ok 8" -fi - -rm -f $keyfile diff --git a/tests/sys/geom/class/eli/readonly_test.sh b/tests/sys/geom/class/eli/readonly_test.sh deleted file mode 100644 index 2d69d14769e6..000000000000 --- a/tests/sys/geom/class/eli/readonly_test.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -. $(dirname $0)/conf.sh - -base=`basename $0` -sectors=100 -keyfile=`mktemp $base.XXXXXX` || exit 1 -md=$(attach_md -t malloc -s `expr $sectors + 1`) - -echo "1..11" - -dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1 - -geli init -B none -P -K $keyfile ${md} -if [ $? -eq 0 ]; then - echo "ok 1" -else - echo "not ok 1" -fi - -geli attach -r -p -k $keyfile ${md} -if [ $? -eq 0 ]; then - echo "ok 2" -else - echo "not ok 2" -fi - -sh -c "true >/dev/${md}.eli" 2>/dev/null -if [ $? -ne 0 ]; then - echo "ok 3" -else - echo "not ok 3" -fi - -geli kill ${md} -if [ $? -eq 0 ]; then - echo "ok 4" -else - echo "not ok 4" -fi - -# kill should detach provider... -if [ ! -c /dev/${md}.eli ]; then - echo "ok 5" -else - echo "not ok 5" -fi - -# ...but not destroy the metadata. -geli attach -r -p -k $keyfile ${md} -if [ $? -eq 0 ]; then - echo "ok 6" -else - echo "not ok 6" -fi - -geli setkey -n 1 -P -K /dev/null ${md} 2>/dev/null -if [ $? -ne 0 ]; then - echo "ok 7" -else - echo "not ok 7" -fi - -geli delkey -n 0 ${md} 2>/dev/null -if [ $? -ne 0 ]; then - echo "ok 8" -else - echo "not ok 8" -fi - -geli delkey -f -n 0 ${md} 2>/dev/null -if [ $? -ne 0 ]; then - echo "ok 9" -else - echo "not ok 9" -fi - -geli list ${md}.eli | egrep '^Flags: .*READ-ONLY' >/dev/null -if [ $? -eq 0 ]; then - echo "ok 10" -else - echo "not ok 10" -fi - -geli detach ${md} -if [ $? -eq 0 ]; then - echo "ok 11" -else - echo "not ok 11" -fi - -mdconfig -d -u ${md} -rm -f $keyfile diff --git a/tests/sys/geom/class/eli/setkey_test.sh b/tests/sys/geom/class/eli/setkey_test.sh index 7829f41f1efd..bd5e2dcedd8e 100644 --- a/tests/sys/geom/class/eli/setkey_test.sh +++ b/tests/sys/geom/class/eli/setkey_test.sh @@ -92,7 +92,73 @@ setkey_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() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_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() +{ + . $(atf_get_srcdir)/conf.sh + 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() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_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() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + atf_init_test_cases() { atf_add_test_case setkey + atf_add_test_case setkey_readonly + atf_add_test_case nokey } |