Author: asomers
Date: Sun Jan  7 22:21:07 2018
New Revision: 327683
URL: https://svnweb.freebsd.org/changeset/base/327683

Log:
  geli: convert remaining TAP tests to ATF
  
  MFC after:    2 weeks

Deleted:
  head/tests/sys/geom/class/eli/nokey_test.sh
  head/tests/sys/geom/class/eli/readonly_test.sh
Modified:
  head/ObsoleteFiles.inc
  head/tests/sys/geom/class/eli/Makefile
  head/tests/sys/geom/class/eli/attach_test.sh
  head/tests/sys/geom/class/eli/conf.sh
  head/tests/sys/geom/class/eli/delkey_test.sh
  head/tests/sys/geom/class/eli/init_test.sh
  head/tests/sys/geom/class/eli/kill_test.sh
  head/tests/sys/geom/class/eli/setkey_test.sh

Modified: head/ObsoleteFiles.inc
==============================================================================
--- head/ObsoleteFiles.inc      Sun Jan  7 21:57:52 2018        (r327682)
+++ head/ObsoleteFiles.inc      Sun Jan  7 22:21:07 2018        (r327683)
@@ -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

Modified: head/tests/sys/geom/class/eli/Makefile
==============================================================================
--- head/tests/sys/geom/class/eli/Makefile      Sun Jan  7 21:57:52 2018        
(r327682)
+++ head/tests/sys/geom/class/eli/Makefile      Sun Jan  7 22:21:07 2018        
(r327683)
@@ -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}

Modified: head/tests/sys/geom/class/eli/attach_test.sh
==============================================================================
--- head/tests/sys/geom/class/eli/attach_test.sh        Sun Jan  7 21:57:52 
2018        (r327682)
+++ head/tests/sys/geom/class/eli/attach_test.sh        Sun Jan  7 22:21:07 
2018        (r327683)
@@ -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
 }

Modified: head/tests/sys/geom/class/eli/conf.sh
==============================================================================
--- head/tests/sys/geom/class/eli/conf.sh       Sun Jan  7 21:57:52 2018        
(r327682)
+++ head/tests/sys/geom/class/eli/conf.sh       Sun Jan  7 22:21:07 2018        
(r327683)
@@ -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

Modified: head/tests/sys/geom/class/eli/delkey_test.sh
==============================================================================
--- head/tests/sys/geom/class/eli/delkey_test.sh        Sun Jan  7 21:57:52 
2018        (r327682)
+++ head/tests/sys/geom/class/eli/delkey_test.sh        Sun Jan  7 22:21:07 
2018        (r327683)
@@ -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
 }

Modified: head/tests/sys/geom/class/eli/init_test.sh
==============================================================================
--- head/tests/sys/geom/class/eli/init_test.sh  Sun Jan  7 21:57:52 2018        
(r327682)
+++ head/tests/sys/geom/class/eli/init_test.sh  Sun Jan  7 22:21:07 2018        
(r327683)
@@ -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
 }

Modified: head/tests/sys/geom/class/eli/kill_test.sh
==============================================================================
--- head/tests/sys/geom/class/eli/kill_test.sh  Sun Jan  7 21:57:52 2018        
(r327682)
+++ head/tests/sys/geom/class/eli/kill_test.sh  Sun Jan  7 22:21:07 2018        
(r327683)
@@ -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
 }

Modified: head/tests/sys/geom/class/eli/setkey_test.sh
==============================================================================
--- head/tests/sys/geom/class/eli/setkey_test.sh        Sun Jan  7 21:57:52 
2018        (r327682)
+++ head/tests/sys/geom/class/eli/setkey_test.sh        Sun Jan  7 22:21:07 
2018        (r327683)
@@ -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
 }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to