geli: convert remaining TAP tests to ATF
MFC after: 2 weeks
This commit is contained in:
parent
08ca9706de
commit
339093aef3
@ -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
|
||||
|
@ -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}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
@ -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
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user