Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Nov 2015 07:56:06 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r290586 - in stable/10: etc/mtree usr.sbin/makefs usr.sbin/makefs/tests
Message-ID:  <201511090756.tA97u6ic090298@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Mon Nov  9 07:56:06 2015
New Revision: 290586
URL: https://svnweb.freebsd.org/changeset/base/290586

Log:
  MFC r289739,r289743,r289897,r289901:
  
  r289739:
  
  Correctly reintroduce the rudimentary smoke tests I botched up
  in r289684
  
  Sponsored by: EMC / Isilon Storage Division
  
  r289743:
  
  Revise "create_test_inputs" to simplify the file structure as
  these testcases don't need to be nested as much as bin/ls/ls_tests.sh
  do when verifying ls -a, ls -A, etc. This allows the tests to make
  all paths relative to the top of the temporary directory instead of
  always tacking on $ATF_TMPDIR, thus complicating things unnecessarily
  
  Create non-empty files in create_test_inputs as well now, similar to
  create_test_inputs2 in bin/ls/ls_tests.sh
  
  Compare the input files to the output file contents using diff where
  possible:
  - Skip over the fifo comparison for now because it always fails
  - Skip over the symlink comparison on cd9660 because it always fails
    today
  
  Sponsored by: EMC / Isilon Storage Division
  
  r289897:
  
  Add more cd9660/FFS makefs testcases
  
  General changes:
  - Parameterize out the mount command.
  - Use mtree to verify the contents of an image (check_image_contents) instead
    of using diff (diff verifies content, but not file metadata).
  - Move common logic out to functions (common_cleanup, mount_image,
    check_image_contents)
  - Add stub testcases for makefs -D (crashes with SIGBUS, similar to bug # 192839)
  - Add a note about the ISO-9660 and rockridge specs
  - Add testcases that exercise:
  -- Creating disk images from an mtree and multiple directories.
  -- -F flag use (not really an extensive testcase right now)
  
  cd9660-specific test changes:
  
  - Remove an XXX comment about symlinks; I forgot that non-rockridge images turn
    symlinks into hardlinks.
  - Add testcases that exercise:
  -- -o allow-deep-trees
  -- -o allow-max-name stub testcase (doesn't seem to be implemented in makefs)
  -- -o preparer (existence in image; not conformance to spec)
  -- -o publisher (existence in image; not conformance to spec)
  -- -o rockridge (basic)
  
  Sponsored by: EMC / Isilon Storage Division
  
  r289901:
  
  Remove an ls -l I was using for debugging
  
  Sponsored by: EMC / Isilon Storage Division

Added:
  stable/10/usr.sbin/makefs/tests/
     - copied from r289739, head/usr.sbin/makefs/tests/
Modified:
  stable/10/etc/mtree/BSD.tests.dist
  stable/10/usr.sbin/makefs/Makefile
  stable/10/usr.sbin/makefs/tests/Makefile
  stable/10/usr.sbin/makefs/tests/makefs_cd9660_tests.sh
  stable/10/usr.sbin/makefs/tests/makefs_ffs_tests.sh
  stable/10/usr.sbin/makefs/tests/makefs_tests_common.sh
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/etc/mtree/BSD.tests.dist
==============================================================================
--- stable/10/etc/mtree/BSD.tests.dist	Mon Nov  9 07:49:39 2015	(r290585)
+++ stable/10/etc/mtree/BSD.tests.dist	Mon Nov  9 07:56:06 2015	(r290586)
@@ -402,6 +402,8 @@
         ..
         fstyp
         ..
+        makefs
+        ..
         newsyslog
         ..
         nmtree

Modified: stable/10/usr.sbin/makefs/Makefile
==============================================================================
--- stable/10/usr.sbin/makefs/Makefile	Mon Nov  9 07:49:39 2015	(r290585)
+++ stable/10/usr.sbin/makefs/Makefile	Mon Nov  9 07:56:06 2015	(r290586)
@@ -1,5 +1,7 @@
 #	$FreeBSD$
 
+.include <bsd.own.mk>
+
 PROG=	makefs
 
 CFLAGS+=-I${.CURDIR}
@@ -38,4 +40,8 @@ LDADD+=		${LIBNETBSD}
 DPADD+=  ${LIBSBUF} ${LIBUTIL}
 LDADD+=  -lsbuf -lutil
 
+.if ${MK_TESTS} != "no"
+SUBDIR+=	tests
+.endif
+
 .include <bsd.prog.mk>

Modified: stable/10/usr.sbin/makefs/tests/Makefile
==============================================================================
--- head/usr.sbin/makefs/tests/Makefile	Thu Oct 22 05:32:45 2015	(r289739)
+++ stable/10/usr.sbin/makefs/tests/Makefile	Mon Nov  9 07:56:06 2015	(r290586)
@@ -1,5 +1,7 @@
 # $FreeBSD$
 
+TESTSDIR=	${TESTSBASE}/usr.sbin/makefs
+
 ATF_TESTS_SH+=	makefs_cd9660_tests
 ATF_TESTS_SH+=	makefs_ffs_tests
 

Modified: stable/10/usr.sbin/makefs/tests/makefs_cd9660_tests.sh
==============================================================================
--- head/usr.sbin/makefs/tests/makefs_cd9660_tests.sh	Thu Oct 22 05:32:45 2015	(r289739)
+++ stable/10/usr.sbin/makefs/tests/makefs_cd9660_tests.sh	Mon Nov  9 07:56:06 2015	(r290586)
@@ -27,36 +27,262 @@
 # $FreeBSD$
 #
 
-. "$(dirname "$0")/makefs_tests_common.sh"
+# A note on specs:
+# - A copy of the ISO-9660 spec can be found here:
+#   http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-119.pdf
+# - Any references to `rockridge` are referring to the `Rock Ridge` extensions
+#   of the ISO-9660 spec. A copy of the draft `IEEE-P1282` spec can be found
+#   here:
+#   http://www.ymi.com/ymi/sites/default/files/pdf/Rockridge.pdf
 
 MAKEFS="makefs -t cd9660"
-TEST_IMAGE="test.iso"
+MOUNT="mount_cd9660"
+
+. "$(dirname "$0")/makefs_tests_common.sh"
+
+common_cleanup()
+{
+	if ! test_md_device=$(cat $TEST_MD_DEVICE_FILE); then
+		echo "$TEST_MD_DEVICE_FILE could not be opened; has an md(4) device been attached?"
+		return
+	fi
+
+	umount -f /dev/$test_md_device || :
+	mdconfig -d -u $test_md_device || :
+}
+
+check_base_iso9660_image_contents()
+{
+	# Symlinks are treated like files when rockridge support isn't
+	# specified
+	check_image_contents "$@" -X c
+
+	atf_check -e empty -o empty -s exit:0 test -L $TEST_INPUTS_DIR/c
+	atf_check -e empty -o empty -s exit:0 test -f $TEST_MOUNT_DIR/c
+}
+
+atf_test_case D_flag cleanup
+D_flag_body()
+{
+	atf_skip "makefs crashes with SIGBUS with dupe mtree entries; see FreeBSD bug # 192839"
+
+	create_test_inputs
+
+	atf_check -e empty -o save:$TEST_SPEC_FILE -s exit:0 \
+	    mtree -cp $TEST_INPUTS_DIR
+	atf_check -e empty -o not-empty -s exit:0 \
+	    $MAKEFS -F $TEST_SPEC_FILE -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
+
+	atf_check -e empty -o empty -s exit:0 \
+	    cp $TEST_SPEC_FILE spec2.mtree
+	atf_check -e empty -o save:dupe_$TEST_SPEC_FILE -s exit:0 \
+	    cat $TEST_SPEC_FILE spec2.mtree
+
+	atf_check -e empty -o not-empty -s not-exit:0 \
+	    $MAKEFS -F dupe_$TEST_SPEC_FILE -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
+	atf_check -e empty -o not-empty -s exit:0 \
+	    $MAKEFS -D -F dupe_$TEST_SPEC_FILE -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
+}
+D_flag_cleanup()
+{
+	common_cleanup
+}
+
+atf_test_case F_flag cleanup
+F_flag_body()
+{
+	create_test_inputs
+
+	atf_check -e empty -o save:$TEST_SPEC_FILE -s exit:0 \
+	    mtree -cp $TEST_INPUTS_DIR
+
+	atf_check -e empty -o empty -s exit:0 \
+	    $MAKEFS -F $TEST_SPEC_FILE -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
+
+	mount_image
+	check_base_iso9660_image_contents
+}
+F_flag_cleanup()
+{
+	common_cleanup
+}
+
+atf_test_case from_mtree_spec_file cleanup
+from_mtree_spec_file_body()
+{
+	create_test_inputs
+
+	atf_check -e empty -o save:$TEST_SPEC_FILE -s exit:0 \
+	    mtree -c -k type,link,size -p $TEST_INPUTS_DIR
+	cd $TEST_INPUTS_DIR
+	atf_check -e empty -o empty -s exit:0 \
+	    $MAKEFS $TEST_IMAGE $TEST_SPEC_FILE
+	cd -
+
+	mount_image
+	check_base_iso9660_image_contents
+}
+from_mtree_spec_file_cleanup()
+{
+	common_cleanup
+}
+
+atf_test_case from_multiple_dirs cleanup
+from_multiple_dirs_body()
+{
+	test_inputs_dir2=$TMPDIR/inputs2
+
+	create_test_inputs
+
+	atf_check -e empty -o empty -s exit:0 mkdir -p $test_inputs_dir2
+	atf_check -e empty -o empty -s exit:0 \
+	    touch $test_inputs_dir2/multiple_dirs_test_file
+
+	atf_check -e empty -o empty -s exit:0 \
+	    $MAKEFS $TEST_IMAGE $TEST_INPUTS_DIR $test_inputs_dir2
+
+	mount_image
+	check_base_iso9660_image_contents -d $test_inputs_dir2
+}
+from_multiple_dirs_cleanup()
+{
+	common_cleanup
+}
 
-atf_test_case basic_cd9660 cleanup
-basic_cd9660_body()
+atf_test_case from_single_dir cleanup
+from_single_dir_body()
 {
 	create_test_inputs
 
 	atf_check -e empty -o empty -s exit:0 \
 	    $MAKEFS $TEST_IMAGE $TEST_INPUTS_DIR
-	atf_check -e empty -o save:$TEST_MD_DEVICE_FILE -s exit:0 \
-	    mdconfig -a -f $TEST_IMAGE
+
+	mount_image
+	check_base_iso9660_image_contents
+}
+from_single_dir_cleanup()
+{
+	common_cleanup
+}
+
+atf_test_case o_flag_allow_deep_trees cleanup
+o_flag_allow_deep_trees_body()
+{
+	create_test_inputs
+
+	# Make sure the "more than 8 levels deep" requirement is met.
+	atf_check -e empty -o empty -s exit:0 \
+	    mkdir -p $TEST_INPUTS_DIR/a/b/c/d/e/f/g/h/i/j
+
+	atf_check -e empty -o empty -s exit:0 \
+	    $MAKEFS -o allow-deep-trees $TEST_IMAGE $TEST_INPUTS_DIR
+
+	mount_image
+	check_base_iso9660_image_contents
+}
+o_flag_allow_deep_trees_cleanup()
+{
+	common_cleanup
+}
+
+atf_test_case o_flag_allow_max_name cleanup
+o_flag_allow_max_name_body()
+{
+	atf_expect_fail "-o allow-max-name doesn't appear to be implemented on FreeBSD's copy of makefs [yet]"
+
+	create_test_inputs
+
+	long_path=$TEST_INPUTS_DIR/$(jot -s '' -b 0 37)
+
+	# Make sure the "37 char name" limit requirement is met.
+	atf_check -e empty -o empty -s exit:0 touch $long_path
+
 	atf_check -e empty -o empty -s exit:0 \
-	    mount_cd9660 /dev/$(cat $TEST_MD_DEVICE_FILE) $TEST_MOUNT_DIR
-	atf_check -e empty -o not-empty -s exit:0 ls $TEST_MOUNT_DIR
+	    $MAKEFS -o allow-max-name $TEST_IMAGE $TEST_INPUTS_DIR
+
+	mount_image
+	check_base_iso9660_image_contents
+}
+o_flag_allow_max_name_cleanup()
+{
+	common_cleanup
 }
-basic_cd9660_cleanup()
+
+atf_test_case o_flag_preparer
+o_flag_preparer_body()
 {
-	ls -a
+	create_test_dirs
 
-	test_md_device=$(cat $TEST_MD_DEVICE_FILE) || return
+	preparer='My Very First ISO'
+	preparer_uppercase="$(echo $preparer | tr '[[:lower:]]' '[[:upper:]]')"
 
-	umount -f /dev/$test_md_device
-	mdconfig -d -u $test_md_device
+	atf_check -e empty -o empty -s exit:0 touch $TEST_INPUTS_DIR/dummy_file
+	atf_check -e empty -o empty -s exit:0 \
+	    $MAKEFS -o preparer="$preparer" $TEST_IMAGE $TEST_INPUTS_DIR
+	atf_check -e empty -o match:"$preparer_uppercase" -s exit:0 \
+	    strings $TEST_IMAGE
+}
+
+atf_test_case o_flag_publisher
+o_flag_publisher_body()
+{
+	create_test_dirs
+
+	publisher='My Super Awesome Publishing Company LTD'
+	publisher_uppercase="$(echo $publisher | tr '[[:lower:]]' '[[:upper:]]')"
+
+	atf_check -e empty -o empty -s exit:0 touch $TEST_INPUTS_DIR/dummy_file
+	atf_check -e empty -o empty -s exit:0 \
+	    $MAKEFS -o publisher="$publisher" $TEST_IMAGE $TEST_INPUTS_DIR
+	atf_check -e empty -o match:"$publisher_uppercase" -s exit:0 \
+	    strings $TEST_IMAGE
+}
+
+atf_test_case o_flag_rockridge cleanup
+o_flag_rockridge_body()
+{
+	create_test_dirs
+
+	# Make sure the "more than 8 levels deep" requirement is met.
+	atf_check -e empty -o empty -s exit:0 \
+	    mkdir -p $TEST_INPUTS_DIR/a/b/c/d/e/f/g/h/i/j
+
+	# Make sure the "pathname larger than 255 chars" requirement is met.
+	#
+	# $long_path's needs to be nested in a directory, as creating it
+	# outright as a 256 char filename via touch will fail with ENAMETOOLONG
+	long_path=$TEST_INPUTS_DIR/$(jot -s '/' -b "$(jot -s '' -b 0 64)" 4)
+	atf_check -e empty -o empty -s exit:0 mkdir -p "$(dirname $long_path)"
+	atf_check -e empty -o empty -s exit:0 touch "$long_path"
+
+	atf_check -e empty -o empty -s exit:0 \
+	    $MAKEFS -o rockridge $TEST_IMAGE $TEST_INPUTS_DIR
+
+	mount_image
+	check_image_contents -X .rr_moved
+
+	# .rr_moved is a special directory created when you have deep directory
+	# trees with rock ridge extensions on
+	atf_check -e empty -o empty -s exit:0 \
+	    test -d $TEST_MOUNT_DIR/.rr_moved
+}
+o_flag_rockridge_cleanup()
+{
+	common_cleanup
 }
 
 atf_init_test_cases()
 {
+	atf_add_test_case D_flag
+	atf_add_test_case F_flag
+
+	atf_add_test_case from_mtree_spec_file
+	atf_add_test_case from_multiple_dirs
+	atf_add_test_case from_single_dir
 
-	atf_add_test_case basic_cd9660
+	atf_add_test_case o_flag_allow_deep_trees
+	atf_add_test_case o_flag_allow_max_name
+	atf_add_test_case o_flag_preparer
+	atf_add_test_case o_flag_publisher
+	atf_add_test_case o_flag_rockridge
 }

Modified: stable/10/usr.sbin/makefs/tests/makefs_ffs_tests.sh
==============================================================================
--- head/usr.sbin/makefs/tests/makefs_ffs_tests.sh	Thu Oct 22 05:32:45 2015	(r289739)
+++ stable/10/usr.sbin/makefs/tests/makefs_ffs_tests.sh	Mon Nov  9 07:56:06 2015	(r290586)
@@ -27,38 +27,146 @@
 # $FreeBSD$
 #
 
+MAKEFS="makefs -t ffs"
+MOUNT="mount"
+
 . "$(dirname "$0")/makefs_tests_common.sh"
 
-MAKEFS="makefs -t ffs"
-TEST_IMAGE="test.img"
+TEST_TUNEFS_OUTPUT=$TMPDIR/tunefs.output
+
+common_cleanup()
+{
+	if ! test_md_device=$(cat $TEST_MD_DEVICE_FILE); then
+		echo "$TEST_MD_DEVICE_FILE could not be opened; has an md(4) device been attached?"
+		return
+	fi
+
+	umount -f /dev/$test_md_device || :
+	mdconfig -d -u $test_md_device || :
+}
+
+check_ffs_image_contents()
+{
+	atf_check -e save:$TEST_TUNEFS_OUTPUT -o empty -s exit:0 \
+	    tunefs -p /dev/$(cat $TEST_MD_DEVICE_FILE)
+
+	check_image_contents "$@"
+}
 
-atf_test_case basic_ffs cleanup
-basic_ffs_body()
+atf_test_case D_flag cleanup
+D_flag_body()
 {
+	atf_skip "makefs crashes with SIGBUS with dupe mtree entries; see FreeBSD bug # 192839"
+
 	create_test_inputs
 
+	atf_check -e empty -o save:$TEST_SPEC_FILE -s exit:0 \
+	    mtree -cp $TEST_INPUTS_DIR
 	atf_check -e empty -o not-empty -s exit:0 \
-	    $MAKEFS -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
-	atf_check -e empty -o save:$TEST_MD_DEVICE_FILE -s exit:0 \
-	    mdconfig -a -f $TEST_IMAGE
-	atf_check -e save:$ATF_TMPDIR/tunefs.output -o empty -s exit:0 \
-	    tunefs -p /dev/$(cat $TEST_MD_DEVICE_FILE)
+	    $MAKEFS -F $TEST_SPEC_FILE -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
+
 	atf_check -e empty -o empty -s exit:0 \
-	    mount /dev/$(cat $TEST_MD_DEVICE_FILE) $TEST_MOUNT_DIR
-	atf_check -e empty -o not-empty -s exit:0 ls $TEST_MOUNT_DIR
+	    cp $TEST_SPEC_FILE spec2.mtree
+	atf_check -e empty -o save:dupe_$TEST_SPEC_FILE -s exit:0 \
+	    cat $TEST_SPEC_FILE spec2.mtree
+
+	atf_check -e empty -o not-empty -s not-exit:0 \
+	    $MAKEFS -F dupe_$TEST_SPEC_FILE -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
+	atf_check -e empty -o not-empty -s exit:0 \
+	    $MAKEFS -D -F dupe_$TEST_SPEC_FILE -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
+}
+D_flag_cleanup()
+{
+	common_cleanup
 }
-basic_ffs_cleanup()
+
+atf_test_case F_flag cleanup
+F_flag_body()
 {
-	ls -a
+	create_test_inputs
 
-	test_md_device=$(cat $TEST_MD_DEVICE_FILE) || return
+	atf_check -e empty -o save:$TEST_SPEC_FILE -s exit:0 \
+	    mtree -cp $TEST_INPUTS_DIR
+
+	atf_check -e empty -o not-empty -s exit:0 \
+	    $MAKEFS -F $TEST_SPEC_FILE -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
 
-	umount -f /dev/$test_md_device
-	mdconfig -d -u $test_md_device
+	mount_image
+	check_ffs_image_contents
+}
+F_flag_cleanup()
+{
+	common_cleanup
+}
+
+atf_test_case from_mtree_spec_file cleanup
+from_mtree_spec_file_body()
+{
+	create_test_inputs
+
+	atf_check -e empty -o save:$TEST_SPEC_FILE -s exit:0 \
+	    mtree -c -k type,link,size -p $TEST_INPUTS_DIR
+
+	cd $TEST_INPUTS_DIR
+	atf_check -e empty -o not-empty -s exit:0 \
+	    $MAKEFS $TEST_IMAGE $TEST_SPEC_FILE
+	cd -
+
+	mount_image
+	check_ffs_image_contents
+}
+from_mtree_spec_file_cleanup()
+{
+	common_cleanup
+}
+
+atf_test_case from_multiple_dirs cleanup
+from_multiple_dirs_body()
+{
+	test_inputs_dir2=$TMPDIR/inputs2
+
+	create_test_inputs
+
+	atf_check -e empty -o empty -s exit:0 mkdir -p $test_inputs_dir2
+	atf_check -e empty -o empty -s exit:0 \
+	    touch $test_inputs_dir2/multiple_dirs_test_file
+
+	atf_check -e empty -o not-empty -s exit:0 \
+	    $MAKEFS $TEST_IMAGE $TEST_INPUTS_DIR $test_inputs_dir2
+
+	mount_image
+	check_image_contents -d $test_inputs_dir2
+}
+from_multiple_dirs_cleanup()
+{
+	common_cleanup
+}
+
+atf_test_case from_single_dir cleanup
+from_single_dir_body()
+{
+	create_test_inputs
+
+	atf_check -e empty -o not-empty -s exit:0 \
+	    $MAKEFS -M 1m $TEST_IMAGE $TEST_INPUTS_DIR
+
+	mount_image
+	check_ffs_image_contents
+}
+from_single_dir_cleanup()
+{
+	common_cleanup
 }
 
 atf_init_test_cases()
 {
 
-	atf_add_test_case basic_ffs
+	atf_add_test_case D_flag
+	atf_add_test_case F_flag
+
+	atf_add_test_case from_mtree_spec_file
+	atf_add_test_case from_multiple_dirs
+	atf_add_test_case from_single_dir
+
+
 }

Modified: stable/10/usr.sbin/makefs/tests/makefs_tests_common.sh
==============================================================================
--- head/usr.sbin/makefs/tests/makefs_tests_common.sh	Thu Oct 22 05:32:45 2015	(r289739)
+++ stable/10/usr.sbin/makefs/tests/makefs_tests_common.sh	Mon Nov  9 07:56:06 2015	(r290586)
@@ -27,30 +27,73 @@
 # $FreeBSD$
 #
 
-TEST_MD_DEVICE_FILE="md.output"
-TEST_MOUNT_DIR="mnt"
+KB=1024
+: ${TMPDIR=/tmp}
+TEST_IMAGE="$TMPDIR/test.img"
+TEST_INPUTS_DIR="$TMPDIR/inputs"
+TEST_MD_DEVICE_FILE="$TMPDIR/md.output"
+TEST_MOUNT_DIR="$TMPDIR/mnt"
+TEST_SPEC_FILE="$TMPDIR/mtree.spec"
 
-create_test_dir()
+check_image_contents()
 {
-	[ -z "$ATF_TMPDIR" ] || return 0
-
-	export ATF_TMPDIR=$(pwd)
-
-	TEST_MD_DEVICE_FILE="${ATF_TMPDIR}/${TEST_MD_DEVICE_FILE}"
-	TEST_MOUNT_DIR="${ATF_TMPDIR}/${TEST_MOUNT_DIR}"
-
-	# XXX: need to nest this because of how kyua creates $TMPDIR; otherwise
-	# it will run into EPERM issues later
-	TEST_INPUTS_DIR="${ATF_TMPDIR}/test/inputs"
+	local directories=$TEST_INPUTS_DIR
+	local excludes mtree_excludes_arg mtree_file
+	local mtree_keywords="type,link,size"
+
+	while getopts "d:f:m:X:" flag; do
+		case "$flag" in
+		d)
+			directories="$directories $OPTARG"
+			;;
+		f)
+			mtree_file=$OPTARG
+			;;
+		m)
+			mtree_keywords=$OPTARG
+			;;
+		X)
+			excludes="$excludes $OPTARG"
+			;;
+		*)
+			echo "usage: check_image_contents [-d directory ...] [-f mtree-file] [-m mtree-keywords] [-X exclude]"
+			atf_fail "unhandled option: $flag"
+			;;
+		esac
+	done
+
+	if [ -n "$excludes" ]; then
+		echo "$excludes" | tr ' ' '\n' > excludes.txt
+		mtree_excludes_arg="-X excludes.txt"
+	fi
+
+	if [ -z "$mtree_file" ]; then
+		mtree_file=input_spec.mtree
+		for directory in $directories; do
+			mtree -c -k $mtree_keywords -p $directory $mtree_excludes_arg
+		done > $mtree_file
+	fi
+
+	echo "<---- Input spec BEGIN ---->"
+	cat $mtree_file
+	echo "<---- Input spec END ---->"
+	atf_check -e empty -o empty -s exit:0 \
+	    mtree -UW -f $mtree_file \
+		-p $TEST_MOUNT_DIR \
+		$mtree_excludes_arg
+}
 
+create_test_dirs()
+{
 	atf_check -e empty -s exit:0 mkdir -m 0777 -p $TEST_MOUNT_DIR
 	atf_check -e empty -s exit:0 mkdir -m 0777 -p $TEST_INPUTS_DIR
-	cd $TEST_INPUTS_DIR
 }
 
 create_test_inputs()
 {
-	create_test_dir
+	create_test_dirs
+
+	cd $TEST_INPUTS_DIR
 
 	atf_check -e empty -s exit:0 mkdir -m 0755 -p a/b/1
 	atf_check -e empty -s exit:0 ln -s a/b c
@@ -58,7 +101,9 @@ create_test_inputs()
 	atf_check -e empty -s exit:0 ln d e
 	atf_check -e empty -s exit:0 touch .f
 	atf_check -e empty -s exit:0 mkdir .g
-	atf_check -e empty -s exit:0 mkfifo h
+	# XXX: fifos on the filesystem don't match fifos created by makefs for
+	# some odd reason.
+	#atf_check -e empty -s exit:0 mkfifo h
 	atf_check -e ignore -s exit:0 dd if=/dev/zero of=i count=1000 bs=1
 	atf_check -e empty -s exit:0 touch klmn
 	atf_check -e empty -s exit:0 touch opqr
@@ -78,4 +123,23 @@ create_test_inputs()
 	atf_check -e empty -s exit:0 touch 0b00001100
 	atf_check -e empty -s exit:0 touch 0b00001101
 	atf_check -e empty -s exit:0 touch 0b00001110
+
+	for filesize in 1 512 $(( 2 * $KB )) $(( 10 * $KB )) $(( 512 * $KB )); \
+	do
+		atf_check -e ignore -o empty -s exit:0 \
+		    dd if=/dev/zero of=${filesize}.file bs=1 \
+		    count=1 oseek=${filesize} conv=sparse
+		files="${files} ${filesize}.file"
+	done
+
+	cd -
 }
+
+mount_image()
+{
+	atf_check -e empty -o save:$TEST_MD_DEVICE_FILE -s exit:0 \
+	    mdconfig -a -f $TEST_IMAGE
+	atf_check -e empty -o empty -s exit:0 \
+	    $MOUNT /dev/$(cat $TEST_MD_DEVICE_FILE) $TEST_MOUNT_DIR
+}
+



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511090756.tA97u6ic090298>