svn commit: r322069 - in projects/zfsd/head: etc/mtree tests/sys/cddl/zfs/tests/cli_root tests/sys/cddl/zfs/tests/cli_root/zfs_diff

Alan Somers asomers at FreeBSD.org
Fri Aug 4 23:01:16 UTC 2017


Author: asomers
Date: Fri Aug  4 23:01:13 2017
New Revision: 322069
URL: https://svnweb.freebsd.org/changeset/base/322069

Log:
  Add a regression test for PR 221234
  
  etc/mtree/BSD.tests.dist
  tests/sys/cddl/zfs/tests/cli_root/Makefile
  tests/sys/cddl/zfs/tests/cli_root/zfs_diff/...
  	Add an automated test that checks the typical output of "zfs diff".
  	The is the first and only automated test for "zfs diff".  It
  	currently fails for a file that gets moved to a new directory.
  
  PR:		221234
  Sponsored by:	Spectra Logic Corp

Added:
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/Makefile   (contents, props changed)
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/cleanup.ksh
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/setup.ksh
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/zfs_diff.cfg
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/zfs_diff_001_pos.golden
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/zfs_diff_001_pos.ksh
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/zfs_diff_test.sh   (contents, props changed)
Modified:
  projects/zfsd/head/etc/mtree/BSD.tests.dist
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/Makefile

Modified: projects/zfsd/head/etc/mtree/BSD.tests.dist
==============================================================================
--- projects/zfsd/head/etc/mtree/BSD.tests.dist	Fri Aug  4 22:40:26 2017	(r322068)
+++ projects/zfsd/head/etc/mtree/BSD.tests.dist	Fri Aug  4 23:01:13 2017	(r322069)
@@ -500,6 +500,8 @@
                         ..
                         zpool_detach
                         ..
+                        zfs_diff
+                        ..
                         zpool_scrub
                         ..
                         zfs_inherit

Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/Makefile
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/Makefile	Fri Aug  4 22:40:26 2017	(r322068)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/Makefile	Fri Aug  4 23:01:13 2017	(r322069)
@@ -18,6 +18,7 @@ TESTS_SUBDIRS+=	zfs_clone
 TESTS_SUBDIRS+=	zfs_copies
 TESTS_SUBDIRS+=	zfs_create
 TESTS_SUBDIRS+=	zfs_destroy
+TESTS_SUBDIRS+=	zfs_diff
 TESTS_SUBDIRS+=	zfs_get
 TESTS_SUBDIRS+=	zfs_inherit
 TESTS_SUBDIRS+=	zfs_mount

Added: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/Makefile	Fri Aug  4 23:01:13 2017	(r322069)
@@ -0,0 +1,18 @@
+# $FreeBSD$
+
+.include <src.opts.mk>
+
+PACKAGE=		tests
+
+TESTSDIR=${TESTSBASE}/sys/cddl/zfs/tests/cli_root/zfs_diff
+FILESDIR=${TESTSDIR}
+
+ATF_TESTS_KSH93+=	zfs_diff_test
+
+${PACKAGE}FILES+=	setup.ksh
+${PACKAGE}FILES+=	cleanup.ksh
+${PACKAGE}FILES+=	zfs_diff_001_pos.ksh
+${PACKAGE}FILES+=	zfs_diff.cfg
+${PACKAGE}FILES+=	zfs_diff_001_pos.golden
+
+.include <bsd.test.mk>

Added: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/cleanup.ksh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/cleanup.ksh	Fri Aug  4 23:01:13 2017	(r322069)
@@ -0,0 +1,31 @@
+#!/usr/local/bin/ksh93 -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2017 Spectra Logic Corp.  All rights reserved.
+# Use is subject to license terms.
+#
+#
+
+. $STF_SUITE/include/libtest.kshlib
+
+default_cleanup

Added: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/setup.ksh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/setup.ksh	Fri Aug  4 23:01:13 2017	(r322069)
@@ -0,0 +1,32 @@
+#!/usr/local/bin/ksh93 -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2017 Spectra Logic Corp.  All rights reserved.
+# Use is subject to license terms.
+#
+
+. $STF_SUITE/include/libtest.kshlib
+
+DISK=${DISKS%% *}
+
+default_setup $DISK

Added: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/zfs_diff.cfg
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/zfs_diff.cfg	Fri Aug  4 23:01:13 2017	(r322069)
@@ -0,0 +1,27 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2017 Spectra Logic.  All rights reserved.
+# Use is subject to license terms.
+#
+
+. $STF_SUITE/tests/cli_root/cli.cfg

Added: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/zfs_diff_001_pos.golden
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/zfs_diff_001_pos.golden	Fri Aug  4 23:01:13 2017	(r322069)
@@ -0,0 +1,13 @@
++	/testdir1526/dirs/create
++	/testdir1526/files/create
+-	/testdir1526/dirs/delete
+-	/testdir1526/files/delete
+M	/testdir1526/dirs
+M	/testdir1526/dirs/modify
+M	/testdir1526/files
+M	/testdir1526/files/dstdir
+M	/testdir1526/files/modify
+M	/testdir1526/files/srcdir
+R	/testdir1526/dirs/rename -> /testdir1526/dirs/rename.new
+R	/testdir1526/files/rename -> /testdir1526/files/rename.new
+R	/testdir1526/files/srcdir/move -> /testdir1526/files/dstdir/move

Added: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/zfs_diff_001_pos.ksh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/zfs_diff_001_pos.ksh	Fri Aug  4 23:01:13 2017	(r322069)
@@ -0,0 +1,77 @@
+#!/usr/local/bin/ksh93 -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2017 Spectra Logic Corp.  All rights reserved.
+# Use is subject to license terms.
+#
+
+. $STF_SUITE/include/libtest.kshlib
+. $STF_SUITE/tests/cli_root/zfs_set/zfs_set_common.kshlib
+
+verify_runnable "both"
+
+log_assert "'zfs diff' output for typical operations"
+
+# First create a bunch of files and directories
+
+#log_must ${CD} $TESTDIR
+log_must ${MKDIR} ${TESTDIR}/dirs
+log_must ${MKDIR} ${TESTDIR}/dirs/leavealone
+log_must ${MKDIR} ${TESTDIR}/dirs/modify
+log_must ${MKDIR} ${TESTDIR}/dirs/rename
+log_must ${MKDIR} ${TESTDIR}/dirs/delete
+log_must ${MKDIR} ${TESTDIR}/files
+log_must ${TOUCH} ${TESTDIR}/files/leavealone
+log_must ${TOUCH} ${TESTDIR}/files/modify
+log_must ${TOUCH} ${TESTDIR}/files/rename
+log_must ${TOUCH} ${TESTDIR}/files/delete
+log_must ${MKDIR} ${TESTDIR}/files/srcdir
+log_must ${MKDIR} ${TESTDIR}/files/dstdir
+log_must ${TOUCH} ${TESTDIR}/files/srcdir/move
+
+log_must $ZFS snapshot $TESTPOOL/$TESTFS at 1
+
+# Now modify them in different ways
+log_must ${TOUCH} ${TESTDIR}/dirs/modify
+log_must ${MV} ${TESTDIR}/dirs/rename ${TESTDIR}/dirs/rename.new
+log_must ${RMDIR} ${TESTDIR}/dirs/delete
+log_must ${MKDIR} ${TESTDIR}/dirs/create
+log_must ${DATE} >> ${TESTDIR}/files/modify
+log_must ${MV} ${TESTDIR}/files/rename ${TESTDIR}/files/rename.new
+log_must ${RM} ${TESTDIR}/files/delete
+log_must ${MV} ${TESTDIR}/files/srcdir/move ${TESTDIR}/files/dstdir/move
+log_must ${TOUCH} ${TESTDIR}/files/create
+
+log_must $ZFS snapshot $TESTPOOL/$TESTFS at 2
+
+# "zfs diff"'s output order is unspecified, so we must sort it.  The golden
+# file is already sorted.
+LC_ALL=C $ZFS diff $TESTPOOL/$TESTFS at 1 $TESTPOOL/$TESTFS at 2 | ${SORT} > $TESTDIR/zfs_diff_output.txt
+if [ $? -ne 0 ]; then
+	log_fail "zfs diff failed"
+fi
+
+# Finally, compare output to the golden output
+log_must diff $STF_SUITE/tests/cli_root/zfs_diff/zfs_diff_001_pos.golden $TESTDIR/zfs_diff_output.txt
+
+log_pass "'zfs diff' gave the expected output"

Added: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/zfs_diff_test.sh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_diff/zfs_diff_test.sh	Fri Aug  4 23:01:13 2017	(r322069)
@@ -0,0 +1,56 @@
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2017 Spectra Logic.  All rights reserved.
+# Use is subject to license terms.
+#
+
+
+atf_test_case zfs_diff_001_pos cleanup
+zfs_diff_001_pos_head()
+{
+	atf_set "descr" "zfs diff output for typical operations"
+	atf_set "require.progs"  zfs
+}
+zfs_diff_001_pos_body()
+{
+	export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ")
+	atf_expect_fail "PR221234 ZFS diff does not properly display files that have been moved to a new directory."
+	. $(atf_get_srcdir)/../../../include/default.cfg
+	. $(atf_get_srcdir)/zfs_diff.cfg
+
+	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
+	ksh93 $(atf_get_srcdir)/zfs_diff_001_pos.ksh || atf_fail "Testcase failed"
+}
+zfs_diff_001_pos_cleanup()
+{
+	export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ")
+	. $(atf_get_srcdir)/../../../include/default.cfg
+	. $(atf_get_srcdir)/zfs_diff.cfg
+
+	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
+}
+
+atf_init_test_cases()
+{
+
+	atf_add_test_case zfs_diff_001_pos
+}


More information about the svn-src-projects mailing list