summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorasomers <asomers@FreeBSD.org>2018-03-10 03:34:27 +0000
committerasomers <asomers@FreeBSD.org>2018-03-10 03:34:27 +0000
commita804ad249fd8400062f1e51eecc7b4675258b0f3 (patch)
tree85d44ee8338e0c19a9015afb3937632efc15f77f /tests
parentba9783a1436a2178e824662c2ecff3544e63b1c9 (diff)
downloadFreeBSD-src-a804ad249fd8400062f1e51eecc7b4675258b0f3.zip
FreeBSD-src-a804ad249fd8400062f1e51eecc7b4675258b0f3.tar.gz
MFC r329273, r329275, r329277, r329284, r329344
r329273: geli: append "/eli" to the underlying provider's physical path If the underlying provider's physical path is null, then the geli device's physical path will be, too. Otherwise, it will append "/eli". This will make geli work better with zfsd(8). PR: 224962 Differential Revision: https://reviews.freebsd.org/D13979 r329275: gpart: append partition name to the underlying provider's physical path If the underlying provider's physical path is null, then the gpart device's physical path will be, too. Otherwise, it will append the partition name, such as "/p1" or "/s1/a". This will make gpart work better with zfsd(8). PR: 224965 Differential Revision: https://reviews.freebsd.org/D14010 r329277: Add mtree entry for 329275 X-MFC-With: 329275 Sponsored by: Spectra Logic Corp r329284: zfsd: Allow zfsd to work on any type of GEOM provider cddl/usr.sbin/zfsd/zfsd_event.cc Remove the check for da and ada devices. This way zfsd can work on md, geli, glabel, gstripe, etc devices. geli in particular is useful combined with ZFS. gnop is also useful for simulating drive pulls in the ZFSD test suite. Also, eliminate the DevfsEvent class entirely. Move its responsibilities into GeomEvent. We can get everything we need to know just from listening to GEOM events. lib/libdevdctl/event.cc Fix GeomEvent::DevName for CREATE events. Oddly, the relevant field is named "cdev" for CREATE events but "devname" for disk events. Relnotes: Yes (probably worth mentioning the geli part) Sponsored by: Spectra Logic Corp r329344: Optimize zfsd for the happy case If there are no damaged pools, then ignore all GEOM events. We only use them to fix damaged pools. However, still pay attention to ZFS events. X-MFC-With: 329284 Sponsored by: Spectra Logic Corp
Diffstat (limited to 'tests')
-rw-r--r--tests/sys/geom/class/Makefile3
-rw-r--r--tests/sys/geom/class/eli/Makefile1
-rw-r--r--tests/sys/geom/class/eli/misc_test.sh177
-rw-r--r--tests/sys/geom/class/part/Makefile10
-rw-r--r--tests/sys/geom/class/part/misc.sh187
5 files changed, 376 insertions, 2 deletions
diff --git a/tests/sys/geom/class/Makefile b/tests/sys/geom/class/Makefile
index b633fd0..950a03e 100644
--- a/tests/sys/geom/class/Makefile
+++ b/tests/sys/geom/class/Makefile
@@ -7,10 +7,9 @@ TESTSDIR= ${TESTSBASE}/sys/geom/class
TESTS_SUBDIRS+= concat
TESTS_SUBDIRS+= eli
TESTS_SUBDIRS+= gate
-# XXX: might not work due to geom(4) changes; more investigation's needed
-#TESTS_SUBDIRS+= gpt
TESTS_SUBDIRS+= mirror
TESTS_SUBDIRS+= nop
+TESTS_SUBDIRS+= part
TESTS_SUBDIRS+= raid3
TESTS_SUBDIRS+= shsec
TESTS_SUBDIRS+= stripe
diff --git a/tests/sys/geom/class/eli/Makefile b/tests/sys/geom/class/eli/Makefile
index 2acf3c4..6e34b3e 100644
--- a/tests/sys/geom/class/eli/Makefile
+++ b/tests/sys/geom/class/eli/Makefile
@@ -14,6 +14,7 @@ ATF_TESTS_SH+= detach_test
ATF_TESTS_SH+= init_test
ATF_TESTS_SH+= integrity_test
ATF_TESTS_SH+= kill_test
+ATF_TESTS_SH+= misc_test
ATF_TESTS_SH+= onetime_test
ATF_TESTS_SH+= resize_test
ATF_TESTS_SH+= setkey_test
diff --git a/tests/sys/geom/class/eli/misc_test.sh b/tests/sys/geom/class/eli/misc_test.sh
new file mode 100644
index 0000000..2dd60a4
--- /dev/null
+++ b/tests/sys/geom/class/eli/misc_test.sh
@@ -0,0 +1,177 @@
+# Copyright (c) 2018 Alan Somers
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+atf_test_case preserve_props cleanup
+preserve_props_head()
+{
+ atf_set "descr" "geli should preserve basic GEOM properties"
+ atf_set "require.user" "root"
+ atf_set "timeout" 15
+}
+preserve_props_body()
+{
+ . $(atf_get_srcdir)/conf.sh
+ md=$(attach_md -s1m)
+ atf_check geli onetime /dev/${md}
+ md_secsize=$(diskinfo ${md} | cut -wf 2)
+ md_stripesize=$(diskinfo ${md} | cut -wf 5)
+ eli_secsize=$(diskinfo ${md}.eli | cut -wf 2)
+ eli_stripesize=$(diskinfo ${md}.eli | cut -wf 5)
+ atf_check_equal "$md_secsize" "$eli_secsize"
+ atf_check_equal "$md_stripesize" "$eli_stripesize"
+}
+preserve_props_cleanup()
+{
+ . $(atf_get_srcdir)/conf.sh
+ geli_test_cleanup
+}
+
+atf_test_case preserve_disk_props cleanup
+preserve_disk_props_head()
+{
+ atf_set "descr" "geli should preserve properties for disks"
+ atf_set "require.user" "root"
+ atf_set "require.config" "disks"
+ atf_set "timeout" 15
+}
+preserve_disk_props_body()
+{
+ . $(atf_get_srcdir)/conf.sh
+ disks=`atf_config_get disks`
+ disk=${disks%% *}
+ if [ -z "$disk" ]; then
+ atf_skip "Must define disks (see tests(7))"
+ fi
+ atf_check geli onetime ${disk}
+
+ disk_ident=$(diskinfo -s ${disk})
+ disk_descr=$(diskinfo -v ${disk} | awk '/Disk descr/ {print $1}')
+ disk_rotrate=$(diskinfo -v ${disk} | awk '/Rotation rate/ {print $1}')
+ disk_zonemode=$(diskinfo -v ${disk} | awk '/Zone Mode/ {print $1}')
+ eli_ident=$(diskinfo -s ${disk}.eli)
+ eli_descr=$(diskinfo -v ${disk}.eli | awk '/Disk descr/ {print $1}')
+ eli_rotrate=$(diskinfo -v ${disk}.eli | awk '/Rotation/ {print $1}')
+ eli_zonemode=$(diskinfo -v ${disk}.eli | awk '/Zone Mode/ {print $1}')
+ atf_check_equal "$disk_ident" "$eli_ident"
+ atf_check_equal "$disk_descr" "$eli_descr"
+ atf_check_equal "$disk_rotrate" "$eli_rotrate"
+ atf_check_equal "$disk_zonemode" "$eli_zonemode"
+}
+preserve_disk_props_cleanup()
+{
+ . $(atf_get_srcdir)/conf.sh
+ disk_cleanup
+ geli_test_cleanup
+}
+
+atf_test_case physpath cleanup
+physpath_head()
+{
+ atf_set "descr" "geli should append /eli to the underlying device's physical path"
+ atf_set "require.user" "root"
+ atf_set "timeout" 15
+}
+physpath_body()
+{
+ . $(atf_get_srcdir)/conf.sh
+ load_gnop
+
+ md=$(attach_md -s1m)
+ # If the underlying device has no physical path, then geli should not
+ # create one.
+ atf_check -o empty -e ignore diskinfo -p $md
+ atf_check -s exit:0 geli onetime $md
+ atf_check -o empty -e ignore diskinfo -p $md.eli
+ atf_check -s exit:0 geli kill $md
+
+ # If the underlying device does have a physical path, then geli should
+ # append "/eli"
+ physpath="some/physical/path"
+ atf_check gnop create -z $physpath ${md}
+ atf_check -s exit:0 geli onetime $md.nop
+ atf_check -o match:"^${physpath}/eli$" diskinfo -p $md.nop.eli
+}
+physpath_cleanup()
+{
+ . $(atf_get_srcdir)/conf.sh
+
+ if [ -f "$TEST_MDS_FILE" ]; then
+ while read md; do
+ [ -c /dev/${md}.nop.eli ] && \
+ geli detach $md.nop.eli 2>/dev/null
+ [ -c /dev/${md}.nop ] && \
+ gnop destroy -f $md.nop 2>/dev/null
+ [ -c /dev/${md}.eli ] && \
+ geli detach $md.eli 2>/dev/null
+ mdconfig -d -u $md 2>/dev/null
+ done < $TEST_MDS_FILE
+ fi
+ true
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case physpath
+ atf_add_test_case preserve_props
+ atf_add_test_case preserve_disk_props
+}
+
+
+common_cleanup()
+{
+
+ if [ -f "$MD_DEVS" ]; then
+ while read test_md; do
+ gnop destroy -f ${test_md}.nop 2>/dev/null
+ mdconfig -d -u $test_md 2>/dev/null
+ done < $MD_DEVS
+ rm $MD_DEVS
+ fi
+
+ if [ -f "$PLAINFILES" ]; then
+ while read f; do
+ rm -f ${f}
+ done < ${PLAINFILES}
+ rm ${PLAINFILES}
+ fi
+ true
+}
+
+disk_cleanup()
+{
+ disks=`atf_config_get disks`
+ disk=${disks%% *}
+ if [ -n "$disk" ]; then
+ geli kill ${disk} 2>/dev/null
+ fi
+}
+
+load_gnop()
+{
+ if ! kldstat -q -m g_nop; then
+ geom nop load || atf_skip "could not load module for geom nop"
+ fi
+}
diff --git a/tests/sys/geom/class/part/Makefile b/tests/sys/geom/class/part/Makefile
new file mode 100644
index 0000000..21ecbec
--- /dev/null
+++ b/tests/sys/geom/class/part/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+PACKAGE= tests
+
+TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T}
+
+# TODO: port the perl tests in tools/regression/geom_gpt
+ATF_TESTS_SH+= misc
+
+.include <bsd.test.mk>
diff --git a/tests/sys/geom/class/part/misc.sh b/tests/sys/geom/class/part/misc.sh
new file mode 100644
index 0000000..3574579
--- /dev/null
+++ b/tests/sys/geom/class/part/misc.sh
@@ -0,0 +1,187 @@
+# Copyright (c) 2018 Alan Somers
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+MD_DEVS="md.devs"
+
+atf_test_case blank_physpath cleanup
+blank_physpath_head()
+{
+ atf_set "descr" "gpart shouldn't add physical paths to underlying providers that have none"
+ atf_set "require.user" "root"
+}
+blank_physpath_body()
+{
+ load_gnop
+ load_gpart
+ md=$(alloc_md)
+ atf_check -o empty -e ignore diskinfo -p ${md}
+ atf_check -s exit:0 -o ignore gpart create -s bsd ${md}
+ atf_check -s exit:0 -o ignore gpart add -t freebsd-ufs ${md}
+ atf_check -o empty -e ignore diskinfo -p ${md}a
+}
+blank_physpath_cleanup()
+{
+ common_cleanup
+}
+
+
+atf_test_case bsd_physpath cleanup
+bsd_physpath_head()
+{
+ atf_set "descr" "BSD partitions should append /X to the underlying device's physical path"
+ atf_set "require.user" "root"
+}
+bsd_physpath_body()
+{
+ load_gnop
+ load_gpart
+ md=$(alloc_md)
+ physpath="some/physical/path"
+ atf_check gnop create -z $physpath /dev/${md}
+ atf_check -s exit:0 -o ignore gpart create -s bsd ${md}.nop
+ atf_check -s exit:0 -o ignore gpart add -t freebsd-ufs ${md}.nop
+ gpart_physpath=$(diskinfo -p ${md}.nopa)
+ atf_check_equal "${physpath}/a" "$gpart_physpath"
+}
+bsd_physpath_cleanup()
+{
+ common_cleanup
+}
+
+atf_test_case gpt_physpath cleanup
+gpt_physpath_head()
+{
+ atf_set "descr" "GPT partitions should append /pX to the underlying device's physical path"
+ atf_set "require.user" "root"
+}
+gpt_physpath_body()
+{
+ load_gnop
+ load_gpart
+ md=$(alloc_md)
+ physpath="some/physical/path"
+ atf_check gnop create -z $physpath /dev/${md}
+ atf_check -s exit:0 -o ignore gpart create -s gpt ${md}.nop
+ atf_check -s exit:0 -o ignore gpart add -t efi ${md}.nop
+ gpart_physpath=$(diskinfo -p ${md}.nopp1)
+ atf_check_equal "${physpath}/p1" "$gpart_physpath"
+}
+gpt_physpath_cleanup()
+{
+ common_cleanup
+}
+
+atf_test_case mbr_physpath cleanup
+mbr_physpath_head()
+{
+ atf_set "descr" "MBR partitions should append /sX to the underlying device's physical path"
+ atf_set "require.user" "root"
+}
+mbr_physpath_body()
+{
+ load_gnop
+ load_gpart
+ md=$(alloc_md)
+ physpath="some/physical/path"
+ atf_check gnop create -z $physpath /dev/${md}
+ atf_check -s exit:0 -o ignore gpart create -s mbr ${md}.nop
+ atf_check -s exit:0 -o ignore gpart add -t freebsd ${md}.nop
+ gpart_physpath=$(diskinfo -p ${md}.nops1)
+ atf_check_equal "${physpath}/s1" "$gpart_physpath"
+}
+mbr_physpath_cleanup()
+{
+ common_cleanup
+}
+
+atf_test_case mbr_bsd_physpath cleanup
+mbr_bsd_physpath_head()
+{
+ atf_set "descr" "BSD partitions nested within MBR partitions should append /sX/Y to the underlying device's physical path"
+ atf_set "require.user" "root"
+}
+mbr_bsd_physpath_body()
+{
+ load_gnop
+ load_gpart
+ md=$(alloc_md)
+ physpath="some/physical/path"
+ atf_check gnop create -z $physpath /dev/${md}
+ atf_check -s exit:0 -o ignore gpart create -s mbr ${md}.nop
+ atf_check -s exit:0 -o ignore gpart add -t freebsd ${md}.nop
+ atf_check -s exit:0 -o ignore gpart create -s bsd ${md}.nops1
+ atf_check -s exit:0 -o ignore gpart add -t freebsd-ufs ${md}.nops1
+ gpart_physpath=$(diskinfo -p ${md}.nops1a)
+ atf_check_equal "${physpath}/s1/a" "$gpart_physpath"
+}
+mbr_bsd_physpath_cleanup()
+{
+ common_cleanup
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case blank_physpath
+ atf_add_test_case bsd_physpath
+ atf_add_test_case gpt_physpath
+ atf_add_test_case mbr_physpath
+ atf_add_test_case mbr_bsd_physpath
+}
+
+alloc_md()
+{
+ local md
+
+ md=$(mdconfig -a -t swap -s 1M) || atf_fail "mdconfig -a failed"
+ echo ${md} >> $MD_DEVS
+ echo ${md}
+}
+
+common_cleanup()
+{
+ if [ -f "$MD_DEVS" ]; then
+ while read test_md; do
+ gnop destroy -f ${test_md}.nop 2>/dev/null
+ mdconfig -d -u $test_md 2>/dev/null
+ done < $MD_DEVS
+ rm $MD_DEVS
+ fi
+ true
+}
+
+load_gpart()
+{
+ if ! kldstat -q -m g_part; then
+ geom part load || atf_skip "could not load module for geom part"
+ fi
+}
+
+load_gnop()
+{
+ if ! kldstat -q -m g_nop; then
+ geom nop load || atf_skip "could not load module for geom nop"
+ fi
+}
OpenPOWER on IntegriCloud