1 # Copyright (c) 2018 Alan Somers
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
7 # 1. Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # 2. Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
13 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 atf_test_case preserve_props cleanup
30 atf_set "descr" "geli should preserve basic GEOM properties"
31 atf_set "require.user" "root"
36 . $(atf_get_srcdir)/conf.sh
38 atf_check geli onetime /dev/${md}
39 md_secsize=$(diskinfo ${md} | cut -wf 2)
40 md_stripesize=$(diskinfo ${md} | cut -wf 5)
41 eli_secsize=$(diskinfo ${md}.eli | cut -wf 2)
42 eli_stripesize=$(diskinfo ${md}.eli | cut -wf 5)
43 atf_check_equal "$md_secsize" "$eli_secsize"
44 atf_check_equal "$md_stripesize" "$eli_stripesize"
46 preserve_props_cleanup()
48 . $(atf_get_srcdir)/conf.sh
52 atf_test_case preserve_disk_props cleanup
53 preserve_disk_props_head()
55 atf_set "descr" "geli should preserve properties for disks"
56 atf_set "require.user" "root"
57 atf_set "require.config" "disks"
60 preserve_disk_props_body()
62 . $(atf_get_srcdir)/conf.sh
63 disks=`atf_config_get disks`
65 if [ -z "$disk" ]; then
66 atf_skip "Must define disks (see tests(7))"
68 atf_check geli onetime ${disk}
70 disk_ident=$(diskinfo -s ${disk})
71 disk_descr=$(diskinfo -v ${disk} | awk '/Disk descr/ {print $1}')
72 disk_rotrate=$(diskinfo -v ${disk} | awk '/Rotation rate/ {print $1}')
73 disk_zonemode=$(diskinfo -v ${disk} | awk '/Zone Mode/ {print $1}')
74 eli_ident=$(diskinfo -s ${disk}.eli)
75 eli_descr=$(diskinfo -v ${disk}.eli | awk '/Disk descr/ {print $1}')
76 eli_rotrate=$(diskinfo -v ${disk}.eli | awk '/Rotation/ {print $1}')
77 eli_zonemode=$(diskinfo -v ${disk}.eli | awk '/Zone Mode/ {print $1}')
78 atf_check_equal "$disk_ident" "$eli_ident"
79 atf_check_equal "$disk_descr" "$eli_descr"
80 atf_check_equal "$disk_rotrate" "$eli_rotrate"
81 atf_check_equal "$disk_zonemode" "$eli_zonemode"
83 preserve_disk_props_cleanup()
85 . $(atf_get_srcdir)/conf.sh
90 atf_test_case physpath cleanup
93 atf_set "descr" "geli should append /eli to the underlying device's physical path"
94 atf_set "require.user" "root"
99 . $(atf_get_srcdir)/conf.sh
103 # If the underlying device has no physical path, then geli should not
105 atf_check -o empty -e ignore diskinfo -p $md
106 atf_check -s exit:0 geli onetime $md
107 atf_check -o empty -e ignore diskinfo -p $md.eli
108 atf_check -s exit:0 geli kill $md
110 # If the underlying device does have a physical path, then geli should
112 physpath="some/physical/path"
113 atf_check gnop create -z $physpath ${md}
114 atf_check -s exit:0 geli onetime $md.nop
115 atf_check -o match:"^${physpath}/eli$" diskinfo -p $md.nop.eli
119 . $(atf_get_srcdir)/conf.sh
121 if [ -f "$TEST_MDS_FILE" ]; then
123 [ -c /dev/${md}.nop.eli ] && \
124 geli detach $md.nop.eli 2>/dev/null
125 [ -c /dev/${md}.nop ] && \
126 gnop destroy -f $md.nop 2>/dev/null
127 [ -c /dev/${md}.eli ] && \
128 geli detach $md.eli 2>/dev/null
129 mdconfig -d -u $md 2>/dev/null
130 done < $TEST_MDS_FILE
135 atf_init_test_cases()
137 atf_add_test_case physpath
138 atf_add_test_case preserve_props
139 atf_add_test_case preserve_disk_props
146 if [ -f "$MD_DEVS" ]; then
147 while read test_md; do
148 gnop destroy -f ${test_md}.nop 2>/dev/null
149 mdconfig -d -u $test_md 2>/dev/null
154 if [ -f "$PLAINFILES" ]; then
165 disks=`atf_config_get disks`
167 if [ -n "$disk" ]; then
168 geli kill ${disk} 2>/dev/null
174 if ! kldstat -q -m g_nop; then
175 geom nop load || atf_skip "could not load module for geom nop"