From owner-svn-src-head@freebsd.org Sun Jan 7 22:21:09 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 21E12E62495; Sun, 7 Jan 2018 22:21:09 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F029F7BDCE; Sun, 7 Jan 2018 22:21:08 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3ACEC2724A; Sun, 7 Jan 2018 22:21:08 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w07ML8i2092796; Sun, 7 Jan 2018 22:21:08 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w07ML7AE092788; Sun, 7 Jan 2018 22:21:07 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201801072221.w07ML7AE092788@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sun, 7 Jan 2018 22:21:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327683 - in head: . tests/sys/geom/class/eli X-SVN-Group: head X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in head: . tests/sys/geom/class/eli X-SVN-Commit-Revision: 327683 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 22:21:09 -0000 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 }