2 # Copyright 2015 EMC Corp.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 MAKEFS="makefs -t ffs"
33 . "$(dirname "$0")/makefs_tests_common.sh"
35 TEST_TUNEFS_OUTPUT=$TMPDIR/tunefs.output
39 if ! test_md_device=$(cat $TEST_MD_DEVICE_FILE); then
40 echo "$TEST_MD_DEVICE_FILE could not be opened; has an md(4) device been attached?"
44 umount -f /dev/$test_md_device || :
45 mdconfig -d -u $test_md_device || :
48 check_ffs_image_contents()
50 atf_check -e save:$TEST_TUNEFS_OUTPUT -o empty -s exit:0 \
51 tunefs -p /dev/$(cat $TEST_MD_DEVICE_FILE)
53 check_image_contents "$@"
56 # With no -M, -m, or -s options, makefs should autocalculate the image size
57 atf_test_case autocalculate_image_size cleanup
58 autocalculate_image_size_body()
60 atf_expect_fail "PR 229929 makefs(8) can underestimate image size"
63 atf_check -e empty -o save:$TEST_SPEC_FILE -s exit:0 \
64 mtree -c -k "$DEFAULT_MTREE_KEYWORDS" -p $TEST_INPUTS_DIR
67 atf_check -e empty -o not-empty -s exit:0 \
68 $MAKEFS $TEST_IMAGE $TEST_SPEC_FILE
72 check_ffs_image_contents
74 autocalculate_image_size_cleanup()
79 atf_test_case D_flag cleanup
82 atf_skip "makefs crashes with SIGBUS with dupe mtree entries; see FreeBSD bug # 192839"
86 atf_check -e empty -o save:$TEST_SPEC_FILE -s exit:0 \
87 mtree -cp $TEST_INPUTS_DIR
88 atf_check -e empty -o not-empty -s exit:0 \
89 $MAKEFS -F $TEST_SPEC_FILE -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
91 atf_check -e empty -o empty -s exit:0 \
92 cp $TEST_SPEC_FILE spec2.mtree
93 atf_check -e empty -o save:dupe_$TEST_SPEC_FILE -s exit:0 \
94 cat $TEST_SPEC_FILE spec2.mtree
96 atf_check -e empty -o not-empty -s not-exit:0 \
97 $MAKEFS -F dupe_$TEST_SPEC_FILE -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
98 atf_check -e empty -o not-empty -s exit:0 \
99 $MAKEFS -D -F dupe_$TEST_SPEC_FILE -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
106 atf_test_case F_flag cleanup
111 atf_check -e empty -o save:$TEST_SPEC_FILE -s exit:0 \
112 mtree -cp $TEST_INPUTS_DIR
114 atf_check -e empty -o not-empty -s exit:0 \
115 $MAKEFS -F $TEST_SPEC_FILE -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
118 check_ffs_image_contents
125 atf_test_case from_mtree_spec_file cleanup
126 from_mtree_spec_file_body()
130 atf_check -e empty -o save:$TEST_SPEC_FILE -s exit:0 \
131 mtree -c -k "$DEFAULT_MTREE_KEYWORDS" -p $TEST_INPUTS_DIR
134 atf_check -e empty -o not-empty -s exit:0 \
135 $MAKEFS -M 1m $TEST_IMAGE $TEST_SPEC_FILE
139 check_ffs_image_contents
141 from_mtree_spec_file_cleanup()
146 atf_test_case from_multiple_dirs cleanup
147 from_multiple_dirs_body()
149 test_inputs_dir2=$TMPDIR/inputs2
153 atf_check -e empty -o empty -s exit:0 mkdir -p $test_inputs_dir2
154 atf_check -e empty -o empty -s exit:0 \
155 touch $test_inputs_dir2/multiple_dirs_test_file
157 atf_check -e empty -o not-empty -s exit:0 \
158 $MAKEFS -M 1m $TEST_IMAGE $TEST_INPUTS_DIR $test_inputs_dir2
161 check_image_contents -d $test_inputs_dir2
163 from_multiple_dirs_cleanup()
168 atf_test_case from_single_dir cleanup
169 from_single_dir_body()
173 atf_check -e empty -o not-empty -s exit:0 \
174 $MAKEFS -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
177 check_ffs_image_contents
179 from_single_dir_cleanup()
184 atf_test_case o_flag_version_1 cleanup
185 o_flag_version_1_body()
192 ffs_label=UFS${ffs_version}
195 ffs_label=FFSv${ffs_version}
198 atf_skip "Unsupported platform"
204 atf_check -e empty -o not-empty -s exit:0 \
205 $MAKEFS -M 1m -o version=$ffs_version $TEST_IMAGE $TEST_INPUTS_DIR
208 atf_check -e ignore -o match:"$ffs_label" dumpfs $TEST_MOUNT_DIR
209 check_ffs_image_contents
211 o_flag_version_1_cleanup()
216 atf_test_case o_flag_version_2 cleanup
217 o_flag_version_2_body()
224 ffs_label=UFS${ffs_version}
227 ffs_label=FFSv${ffs_version}
230 atf_skip "Unsupported platform"
236 atf_check -e empty -o not-empty -s exit:0 \
237 $MAKEFS -M 1m -o version=$ffs_version $TEST_IMAGE $TEST_INPUTS_DIR
240 atf_check -e ignore -o match:"$ffs_label" dumpfs $TEST_MOUNT_DIR
241 check_ffs_image_contents
243 o_flag_version_2_cleanup()
248 atf_init_test_cases()
251 atf_add_test_case autocalculate_image_size
253 atf_add_test_case D_flag
254 atf_add_test_case F_flag
256 atf_add_test_case from_mtree_spec_file
257 atf_add_test_case from_multiple_dirs
258 atf_add_test_case from_single_dir
260 atf_add_test_case o_flag_version_1
261 atf_add_test_case o_flag_version_2