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_get_srcdir)/conf.sh
29 atf_test_case preserve_props cleanup
32 atf_set "descr" "geli should preserve basic GEOM properties"
33 atf_set "require.user" "root"
41 atf_check geli onetime /dev/${md}
42 md_secsize=$(diskinfo ${md} | cut -wf 2)
43 md_stripesize=$(diskinfo ${md} | cut -wf 5)
44 eli_secsize=$(diskinfo ${md}.eli | cut -wf 2)
45 eli_stripesize=$(diskinfo ${md}.eli | cut -wf 5)
46 atf_check_equal "$md_secsize" "$eli_secsize"
47 atf_check_equal "$md_stripesize" "$eli_stripesize"
49 preserve_props_cleanup()
54 atf_test_case preserve_disk_props cleanup
55 preserve_disk_props_head()
57 atf_set "descr" "geli should preserve properties for disks"
58 atf_set "require.user" "root"
59 atf_set "require.config" "disks"
62 preserve_disk_props_body()
66 disks=`atf_config_get disks`
68 if [ -z "$disk" ]; then
69 atf_skip "Must define disks (see tests(7))"
71 atf_check geli onetime ${disk}
73 disk_ident=$(diskinfo -s ${disk})
74 disk_descr=$(diskinfo -v ${disk} | awk '/Disk descr/ {print $1}')
75 disk_rotrate=$(diskinfo -v ${disk} | awk '/Rotation rate/ {print $1}')
76 disk_zonemode=$(diskinfo -v ${disk} | awk '/Zone Mode/ {print $1}')
77 eli_ident=$(diskinfo -s ${disk}.eli)
78 eli_descr=$(diskinfo -v ${disk}.eli | awk '/Disk descr/ {print $1}')
79 eli_rotrate=$(diskinfo -v ${disk}.eli | awk '/Rotation/ {print $1}')
80 eli_zonemode=$(diskinfo -v ${disk}.eli | awk '/Zone Mode/ {print $1}')
81 atf_check_equal "$disk_ident" "$eli_ident"
82 atf_check_equal "$disk_descr" "$eli_descr"
83 atf_check_equal "$disk_rotrate" "$eli_rotrate"
84 atf_check_equal "$disk_zonemode" "$eli_zonemode"
86 preserve_disk_props_cleanup()
92 atf_test_case physpath cleanup
95 atf_set "descr" "geli should append /eli to the underlying device's physical path"
96 atf_set "require.user" "root"
102 if ! error_message=$(geom_load_class_if_needed nop); then
103 atf_skip "$error_message"
107 # If the underlying device has no physical path, then geli should not
109 atf_check -o empty -e ignore diskinfo -p $md
110 atf_check -s exit:0 geli onetime $md
111 atf_check -o empty -e ignore diskinfo -p $md.eli
112 atf_check -s exit:0 geli kill $md
114 # If the underlying device does have a physical path, then geli should
116 physpath="some/physical/path"
117 atf_check gnop create -z $physpath ${md}
118 atf_check -s exit:0 geli onetime $md.nop
119 atf_check -o match:"^${physpath}/eli$" diskinfo -p $md.nop.eli
123 if [ -f "$TEST_MDS_FILE" ]; then
125 [ -c /dev/${md}.nop.eli ] && \
126 geli detach $md.nop.eli 2>/dev/null
127 [ -c /dev/${md}.nop ] && \
128 gnop destroy -f $md.nop 2>/dev/null
129 [ -c /dev/${md}.eli ] && \
130 geli detach $md.eli 2>/dev/null
131 mdconfig -d -u $md 2>/dev/null
132 done < $TEST_MDS_FILE
137 atf_init_test_cases()
139 atf_add_test_case physpath
140 atf_add_test_case preserve_props
141 atf_add_test_case preserve_disk_props
148 if [ -f "$MD_DEVS" ]; then
149 while read test_md; do
150 gnop destroy -f ${test_md}.nop 2>/dev/null
151 mdconfig -d -u $test_md 2>/dev/null
156 if [ -f "$PLAINFILES" ]; then
167 disks=`atf_config_get disks`
169 if [ -n "$disk" ]; then
170 geli kill ${disk} 2>/dev/null