aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2020-07-24 18:19:25 +0000
committerAlan Somers <asomers@FreeBSD.org>2020-07-24 18:19:25 +0000
commit1f6cd7e2e894f7f21eacabcdff167d8b63bdc5d6 (patch)
tree49be8338a480bcb8eedbbb891c6248d65be4dcee /tests
parenta146c36a278b3f2b66a0dbeeaf1f3c6568f94b3f (diff)
Notes
Diffstat (limited to 'tests')
-rw-r--r--tests/sys/geom/class/eli/Makefile1
-rwxr-xr-xtests/sys/geom/class/eli/reentrancy_test.sh69
2 files changed, 70 insertions, 0 deletions
diff --git a/tests/sys/geom/class/eli/Makefile b/tests/sys/geom/class/eli/Makefile
index b5ab81b08f42..bab4587c0f14 100644
--- a/tests/sys/geom/class/eli/Makefile
+++ b/tests/sys/geom/class/eli/Makefile
@@ -16,6 +16,7 @@ ATF_TESTS_SH+= integrity_test
ATF_TESTS_SH+= kill_test
ATF_TESTS_SH+= misc_test
ATF_TESTS_SH+= onetime_test
+ATF_TESTS_SH+= reentrancy_test
ATF_TESTS_SH+= resize_test
ATF_TESTS_SH+= setkey_test
diff --git a/tests/sys/geom/class/eli/reentrancy_test.sh b/tests/sys/geom/class/eli/reentrancy_test.sh
new file mode 100755
index 000000000000..1efd4ea01ac7
--- /dev/null
+++ b/tests/sys/geom/class/eli/reentrancy_test.sh
@@ -0,0 +1,69 @@
+# $FreeBSD$
+
+# Test various operations for geli-on-geli providers, to ensure that geli is
+# reentrant.
+
+. $(atf_get_srcdir)/conf.sh
+
+init_test()
+{
+ cipher=$1
+ aalgo=$2
+ secsize=$3
+ ealgo=${cipher%%:*}
+ keylen=${cipher##*:}
+
+ atf_check dd if=/dev/random of=testdata bs=$secsize count=1 status=none
+ atf_check dd if=/dev/random of=keyfile bs=$secsize count=16 status=none
+
+ # Create the lower geli device
+ 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}
+ # Create the upper geli device
+ atf_check -s exit:0 -e ignore \
+ geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K keyfile \
+ -s $secsize ${md}.eli
+ atf_check geli attach -p -k keyfile ${md}.eli
+ echo ${md} > layered_md_device
+
+ # Ensure we can read and write.
+ atf_check dd if=testdata of=/dev/${md}.eli.eli bs=$secsize count=1 \
+ status=none
+ atf_check dd if=/dev/${md}.eli.eli of=cmpdata bs=$secsize count=1 \
+ status=none
+ atf_check cmp -s testdata cmpdata
+
+ geli detach ${md}.eli 2>/dev/null
+}
+
+atf_test_case init cleanup
+init_head()
+{
+ atf_set "descr" "Initialize a geli provider on top of another"
+ atf_set "require.user" "root"
+ atf_set "timeout" 600
+}
+init_body()
+{
+ sectors=2
+ geli_test_setup
+
+ for_each_geli_config init_test
+}
+init_cleanup()
+{
+ if [ -f layered_md_device ]; then
+ while read provider; do
+ [ -c /dev/${md}.eli.eli ] && \
+ geli detach $md.eli.eli 2>/dev/null
+ done < layered_md_device
+ fi
+ geli_test_cleanup
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case init
+}