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.
31 # - A copy of the ISO-9660 spec can be found here:
32 # http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-119.pdf
33 # - Any references to `rockridge` are referring to the `Rock Ridge` extensions
34 # of the ISO-9660 spec. A copy of the draft `IEEE-P1282` spec can be found
36 # http://www.ymi.com/ymi/sites/default/files/pdf/Rockridge.pdf
38 MAKEFS="makefs -t cd9660"
41 . "$(dirname "$0")/makefs_tests_common.sh"
45 if ! test_md_device=$(cat $TEST_MD_DEVICE_FILE); then
46 echo "$TEST_MD_DEVICE_FILE could not be opened; has an md(4) device been attached?"
50 umount -f /dev/$test_md_device || :
51 mdconfig -d -u $test_md_device || :
54 check_base_iso9660_image_contents()
56 # Symlinks are treated like files when rockridge support isn't
58 check_image_contents "$@" -X c
60 atf_check -e empty -o empty -s exit:0 test -L $TEST_INPUTS_DIR/c
61 atf_check -e empty -o empty -s exit:0 test -f $TEST_MOUNT_DIR/c
64 atf_test_case D_flag cleanup
67 atf_skip "makefs crashes with SIGBUS with dupe mtree entries; see FreeBSD bug # 192839"
71 atf_check -e empty -o save:$TEST_SPEC_FILE -s exit:0 \
72 mtree -cp $TEST_INPUTS_DIR
73 atf_check -e empty -o not-empty -s exit:0 \
74 $MAKEFS -F $TEST_SPEC_FILE -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
76 atf_check -e empty -o empty -s exit:0 \
77 cp $TEST_SPEC_FILE spec2.mtree
78 atf_check -e empty -o save:dupe_$TEST_SPEC_FILE -s exit:0 \
79 cat $TEST_SPEC_FILE spec2.mtree
81 atf_check -e empty -o not-empty -s not-exit:0 \
82 $MAKEFS -F dupe_$TEST_SPEC_FILE -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
83 atf_check -e empty -o not-empty -s exit:0 \
84 $MAKEFS -D -F dupe_$TEST_SPEC_FILE -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
91 atf_test_case F_flag cleanup
96 atf_check -e empty -o save:$TEST_SPEC_FILE -s exit:0 \
97 mtree -cp $TEST_INPUTS_DIR
99 atf_check -e empty -o empty -s exit:0 \
100 $MAKEFS -F $TEST_SPEC_FILE -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
103 check_base_iso9660_image_contents
110 atf_test_case from_mtree_spec_file cleanup
111 from_mtree_spec_file_body()
115 atf_check -e empty -o save:$TEST_SPEC_FILE -s exit:0 \
116 mtree -c -k "$DEFAULT_MTREE_KEYWORDS" -p $TEST_INPUTS_DIR
118 atf_check -e empty -o empty -s exit:0 \
119 $MAKEFS $TEST_IMAGE $TEST_SPEC_FILE
123 check_base_iso9660_image_contents
125 from_mtree_spec_file_cleanup()
130 atf_test_case from_multiple_dirs cleanup
131 from_multiple_dirs_body()
133 test_inputs_dir2=$TMPDIR/inputs2
137 atf_check -e empty -o empty -s exit:0 mkdir -p $test_inputs_dir2
138 atf_check -e empty -o empty -s exit:0 \
139 touch $test_inputs_dir2/multiple_dirs_test_file
141 atf_check -e empty -o empty -s exit:0 \
142 $MAKEFS $TEST_IMAGE $TEST_INPUTS_DIR $test_inputs_dir2
145 check_base_iso9660_image_contents -d $test_inputs_dir2
147 from_multiple_dirs_cleanup()
152 atf_test_case from_single_dir cleanup
153 from_single_dir_body()
157 atf_check -e empty -o empty -s exit:0 \
158 $MAKEFS $TEST_IMAGE $TEST_INPUTS_DIR
161 check_base_iso9660_image_contents
163 from_single_dir_cleanup()
168 atf_test_case o_flag_allow_deep_trees cleanup
169 o_flag_allow_deep_trees_body()
173 # Make sure the "more than 8 levels deep" requirement is met.
174 atf_check -e empty -o empty -s exit:0 \
175 mkdir -p $TEST_INPUTS_DIR/a/b/c/d/e/f/g/h/i/j
177 atf_check -e empty -o empty -s exit:0 \
178 $MAKEFS -o allow-deep-trees $TEST_IMAGE $TEST_INPUTS_DIR
181 check_base_iso9660_image_contents
183 o_flag_allow_deep_trees_cleanup()
188 atf_test_case o_flag_allow_max_name cleanup
189 o_flag_allow_max_name_body()
191 atf_expect_fail "-o allow-max-name doesn't appear to be implemented on FreeBSD's copy of makefs [yet]"
195 long_path=$TEST_INPUTS_DIR/$(jot -s '' -b 0 37)
197 # Make sure the "37 char name" limit requirement is met.
198 atf_check -e empty -o empty -s exit:0 touch $long_path
200 atf_check -e empty -o empty -s exit:0 \
201 $MAKEFS -o allow-max-name $TEST_IMAGE $TEST_INPUTS_DIR
204 check_base_iso9660_image_contents
206 o_flag_allow_max_name_cleanup()
211 atf_test_case o_flag_isolevel_1 cleanup
212 o_flag_isolevel_1_body()
214 atf_expect_fail "this testcase needs work; the filenames generated seem incorrect/corrupt"
218 atf_check -e empty -o empty -s exit:0 \
219 $MAKEFS -o isolevel=1 $TEST_IMAGE $TEST_INPUTS_DIR
222 check_base_iso9660_image_contents
224 o_flag_isolevel_1_cleanup()
229 atf_test_case o_flag_isolevel_2 cleanup
230 o_flag_isolevel_2_body()
234 atf_check -e empty -o empty -s exit:0 \
235 $MAKEFS -o isolevel=2 $TEST_IMAGE $TEST_INPUTS_DIR
238 check_base_iso9660_image_contents
240 o_flag_isolevel_2_cleanup()
245 atf_test_case o_flag_isolevel_3 cleanup
246 o_flag_isolevel_3_body()
250 # XXX: isolevel=3 isn't implemented yet. See FreeBSD bug # 203645
252 atf_check -e match:'makefs: ISO Level 3 is greater than 2\.' -o empty -s not-exit:0 \
253 $MAKEFS -o isolevel=3 $TEST_IMAGE $TEST_INPUTS_DIR
255 atf_check -e empty -o empty -s exit:0 \
256 $MAKEFS -o isolevel=3 $TEST_IMAGE $TEST_INPUTS_DIR
258 check_base_iso9660_image_contents
261 o_flag_isolevel_3_cleanup()
266 atf_test_case o_flag_preparer
267 o_flag_preparer_body()
271 preparer='My Very First ISO'
272 preparer_uppercase="$(echo $preparer | tr '[[:lower:]]' '[[:upper:]]')"
274 atf_check -e empty -o empty -s exit:0 touch $TEST_INPUTS_DIR/dummy_file
275 atf_check -e empty -o empty -s exit:0 \
276 $MAKEFS -o preparer="$preparer" $TEST_IMAGE $TEST_INPUTS_DIR
277 atf_check -e empty -o match:"$preparer_uppercase" -s exit:0 \
281 atf_test_case o_flag_publisher
282 o_flag_publisher_body()
286 publisher='My Super Awesome Publishing Company LTD'
287 publisher_uppercase="$(echo $publisher | tr '[[:lower:]]' '[[:upper:]]')"
289 atf_check -e empty -o empty -s exit:0 touch $TEST_INPUTS_DIR/dummy_file
290 atf_check -e empty -o empty -s exit:0 \
291 $MAKEFS -o publisher="$publisher" $TEST_IMAGE $TEST_INPUTS_DIR
292 atf_check -e empty -o match:"$publisher_uppercase" -s exit:0 \
296 atf_test_case o_flag_rockridge cleanup
297 o_flag_rockridge_body()
301 # Make sure the "more than 8 levels deep" requirement is met.
302 atf_check -e empty -o empty -s exit:0 \
303 mkdir -p $TEST_INPUTS_DIR/a/b/c/d/e/f/g/h/i/j
305 # Make sure the "pathname larger than 255 chars" requirement is met.
307 # $long_path's needs to be nested in a directory, as creating it
308 # outright as a 256 char filename via touch will fail with ENAMETOOLONG
309 long_path=$TEST_INPUTS_DIR/$(jot -s '/' -b "$(jot -s '' -b 0 64)" 4)
310 atf_check -e empty -o empty -s exit:0 mkdir -p "$(dirname $long_path)"
311 atf_check -e empty -o empty -s exit:0 touch "$long_path"
313 atf_check -e empty -o empty -s exit:0 \
314 $MAKEFS -o rockridge $TEST_IMAGE $TEST_INPUTS_DIR
317 check_image_contents -X .rr_moved
319 # .rr_moved is a special directory created when you have deep directory
320 # trees with rock ridge extensions on
321 atf_check -e empty -o empty -s exit:0 \
322 test -d $TEST_MOUNT_DIR/.rr_moved
324 o_flag_rockridge_cleanup()
329 atf_test_case o_flag_rockridge_dev_nodes cleanup
330 o_flag_rockridge_dev_nodes_head()
332 atf_set "descr" "Functional tests to ensure that dev nodes are handled properly with rockridge extensions (NetBSD kern/48852; FreeBSD bug 203648)"
334 o_flag_rockridge_dev_nodes_body()
338 (tar -cvf - -C /dev null && touch .tar_ok) | \
339 atf_check -e not-empty -o empty -s exit:0 tar -xvf - -C "$TEST_INPUTS_DIR"
341 atf_check -e empty -o empty -s exit:0 test -c $TEST_INPUTS_DIR/null
342 atf_check -e empty -o empty -s exit:0 test -f .tar_ok
344 atf_check -e empty -o empty -s exit:0 \
345 $MAKEFS -o rockridge $TEST_IMAGE $TEST_INPUTS_DIR
350 o_flag_rockridge_dev_nodes_cleanup()
355 atf_init_test_cases()
357 atf_add_test_case D_flag
358 atf_add_test_case F_flag
360 atf_add_test_case from_mtree_spec_file
361 atf_add_test_case from_multiple_dirs
362 atf_add_test_case from_single_dir
364 atf_add_test_case o_flag_allow_deep_trees
365 atf_add_test_case o_flag_allow_max_name
366 atf_add_test_case o_flag_isolevel_1
367 atf_add_test_case o_flag_isolevel_2
368 atf_add_test_case o_flag_isolevel_3
369 atf_add_test_case o_flag_preparer
370 atf_add_test_case o_flag_publisher
371 atf_add_test_case o_flag_rockridge
372 atf_add_test_case o_flag_rockridge_dev_nodes