svn commit: r323442 - projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse
Alan Somers
asomers at FreeBSD.org
Mon Sep 11 15:38:52 UTC 2017
Author: asomers
Date: Mon Sep 11 15:38:51 2017
New Revision: 323442
URL: https://svnweb.freebsd.org/changeset/base/323442
Log:
Fix the inuse tests from the ZFS test suite.
Formerly there were 9 separate tests, all of which involved making sure that
ZFS, newfs, dumpadm, and svm wouldn't step on each others' toes. There was
also a lot of code dealing with Solaris's complicated partitioning scheme.
But in FreeBSD, this can all be much simpler. Everything goes through GEOM,
so we only need to test two assertions:
1) ZFS can't use a disk that's already in use, and
2) Something else can't use a disk that's in use by ZFS
tests/sys/cddl/zfs/tests/inuse/inuse_010_neg.ksh
Add a new testcase for assertion 1. The existing test cases were
all so complicated that it was easier to start from scratch.
tests/sys/cddl/zfs/tests/inuse/inuse_005_pos.ksh
Simplify this test case by eliminating partitions and only testing a
single pool topology.
tests/sys/cddl/zfs/tests/inuse/inuse_001_pos.ksh
tests/sys/cddl/zfs/tests/inuse/inuse_002_pos.ksh
tests/sys/cddl/zfs/tests/inuse/inuse_003_pos.ksh
tests/sys/cddl/zfs/tests/inuse/inuse_004_pos.ksh
tests/sys/cddl/zfs/tests/inuse/inuse_006_pos.ksh
tests/sys/cddl/zfs/tests/inuse/inuse_007_pos.ksh
tests/sys/cddl/zfs/tests/inuse/inuse_008_pos.ksh
tests/sys/cddl/zfs/tests/inuse/inuse_009_pos.ksh
Eliminate all other test cases
tests/sys/cddl/zfs/tests/inuse/inuse_test.sh
tests/sys/cddl/zfs/tests/inuse/Makefile Update boilerplate
Sponsored by: Spectra Logic Corp
Added:
projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_010_neg.ksh
Deleted:
projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_001_pos.ksh
projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_002_pos.ksh
projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_003_pos.ksh
projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_004_pos.ksh
projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_006_pos.ksh
projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_007_pos.ksh
projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_008_pos.ksh
projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_009_pos.ksh
Modified:
projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/Makefile
projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_005_pos.ksh
projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_test.sh
Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/Makefile
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/Makefile Mon Sep 11 15:33:40 2017 (r323441)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/Makefile Mon Sep 11 15:38:51 2017 (r323442)
@@ -8,16 +8,9 @@ FILESDIR=${TESTSDIR}
ATF_TESTS_KSH93+= inuse_test
-${PACKAGE}FILES+= inuse_002_pos.ksh
-${PACKAGE}FILES+= inuse_006_pos.ksh
-${PACKAGE}FILES+= inuse_003_pos.ksh
-${PACKAGE}FILES+= inuse_007_pos.ksh
-${PACKAGE}FILES+= inuse_009_pos.ksh
-${PACKAGE}FILES+= inuse_001_pos.ksh
-${PACKAGE}FILES+= inuse_005_pos.ksh
${PACKAGE}FILES+= inuse.cfg
+${PACKAGE}FILES+= inuse_005_pos.ksh
+${PACKAGE}FILES+= inuse_010_neg.ksh
${PACKAGE}FILES+= setup.ksh
-${PACKAGE}FILES+= inuse_004_pos.ksh
-${PACKAGE}FILES+= inuse_008_pos.ksh
.include <bsd.test.mk>
Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_005_pos.ksh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_005_pos.ksh Mon Sep 11 15:33:40 2017 (r323441)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_005_pos.ksh Mon Sep 11 15:38:51 2017 (r323442)
@@ -40,7 +40,7 @@
# by active pool.
#
# STRATEGY:
-# 1. Create a regular|mirror|raidz|raidz2 pool with the given disk
+# 1. Create a with the given disk
# 2. Try to newfs against the disk, verify it fails as expect.
#
# TESTABILITY: explicit
@@ -54,80 +54,19 @@
################################################################################
verify_runnable "global"
+set_disks
function cleanup
{
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
-
- #
- # Tidy up the disks we used.
- #
- cleanup_devices $vdisks $sdisks
}
-function verify_assertion #slices
-{
- typeset targets=$1
-
- for t in $targets; do
- log_mustnot eval "$ECHO y | $NEWFS $t"
- done
-
- return 0
-}
-
log_assert "Verify newfs over active pool fails."
log_onexit cleanup
-set -A vdevs "" "mirror" "raidz" "raidz1" "raidz2"
-
-typeset -i i=0
-
-while (( i < ${#vdevs[*]} )); do
-
- for num in 0 1 2 3 ; do
- eval typeset partition=\${FS_SIDE$num}
- disk=${partition%p*}
- partition=${partition##*p}
- if [[ $WRAPPER == *"smi"* && \
- $disk == ${saved_disk} ]]; then
- cyl=$(get_endslice $disk ${saved_slice})
- log_must set_partition $partition "$cyl" $FS_SIZE $disk
- else
- log_must set_partition $partition "" $FS_SIZE $disk
- fi
- saved_disk=$disk
- saved_slice=$partition
- done
-
- if [[ -n $SINGLE_DISK && -n ${vdevs[i]} ]]; then
- (( i = i + 1 ))
- continue
- fi
-
- create_pool $TESTPOOL1 ${vdevs[i]} $vslices spare $sslices
- $ZPOOL status $TESTPOOL1
- log_note "Running newfs on $rawtargets ..."
- verify_assertion "$rawtargets"
- destroy_pool $TESTPOOL1
- wipe_partition_table $vdisks $sdisks
-
- if [[ ( $FS_DISK0 == $FS_DISK2 ) && -n ${vdevs[i]} ]]; then
- (( i = i + 1 ))
- continue
- fi
-
- if [[ ( $FS_DISK0 == $FS_DISK3 ) && ( ${vdevs[i]} == "raidz2" ) ]]; then
- (( i = i + 1 ))
- continue
- fi
-
- create_pool $TESTPOOL1 ${vdevs[i]} $vdisks spare $sdisks
- verify_assertion "$rawtargets"
- destroy_pool $TESTPOOL1
-
- (( i = i + 1 ))
-done
+create_pool $TESTPOOL1 $DISK0
+log_mustnot $NEWFS -s 1024 "$DISK0"
+destroy_pool $TESTPOOL1
log_pass "Newfs over active pool fails."
Added: projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_010_neg.ksh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_010_neg.ksh Mon Sep 11 15:38:51 2017 (r323442)
@@ -0,0 +1,52 @@
+#!/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.
+#
+# $FreeBSD$
+
+. $STF_SUITE/include/libtest.kshlib
+set_disks
+
+FSSIZE=1024 #reduce filesystem size, just to speed up newfs
+MOUNTPOINT=$TMPDIR/inuse_010_neg_mp
+
+function cleanup
+{
+ poolexists $TESTPOOL && destroy_pool $TESTPOOL
+ $UMOUNT $MOUNTPOINT
+ cleanup_devices $DISK0
+ $RMDIR $MOUNTPOINT
+}
+
+log_onexit cleanup
+
+log_assert "ZFS shouldn't be able to use a disk with a mounted filesystem"
+
+log_must $NEWFS -s $FSSIZE $DISK0
+log_must $MKDIR $MOUNTPOINT
+log_must $MOUNT $DISK0 $MOUNTPOINT
+log_mustnot $ZPOOL create $TESTPOOL $DISK0
+
+log_pass "ZFS cannot use a disk with a mounted filesystem"
Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_test.sh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_test.sh Mon Sep 11 15:33:40 2017 (r323441)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/inuse/inuse_test.sh Mon Sep 11 15:38:51 2017 (r323442)
@@ -24,178 +24,41 @@
#
-atf_test_case inuse_001_pos
-inuse_001_pos_head()
-{
- atf_set "descr" "Ensure ZFS cannot use a device designated as a dump device"
- atf_set "require.progs" dumpadm zpool
- atf_set "timeout" 1200
-}
-inuse_001_pos_body()
-{
- . $(atf_get_srcdir)/../../include/default.cfg
- . $(atf_get_srcdir)/inuse.cfg
-
- ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
- ksh93 $(atf_get_srcdir)/inuse_001_pos.ksh || atf_fail "Testcase failed"
-}
-
-
-
-atf_test_case inuse_002_pos
-inuse_002_pos_head()
-{
- atf_set "descr" "Ensure ZFS does not interfere with devices in use by SVM"
- atf_set "require.progs" metainit metadb metastat zpool metaclear
- atf_set "timeout" 1200
-}
-inuse_002_pos_body()
-{
- . $(atf_get_srcdir)/../../include/default.cfg
- . $(atf_get_srcdir)/inuse.cfg
-
- ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
- ksh93 $(atf_get_srcdir)/inuse_002_pos.ksh || atf_fail "Testcase failed"
-}
-
-
-
-atf_test_case inuse_003_pos
-inuse_003_pos_head()
-{
- atf_set "descr" "Ensure ZFS does not interfere with devices that are in use byufsdump or ufsrestore"
- atf_set "require.progs" zpool ufsrestore ufsdump
- atf_set "timeout" 1200
-}
-inuse_003_pos_body()
-{
- . $(atf_get_srcdir)/../../include/default.cfg
- . $(atf_get_srcdir)/inuse.cfg
-
- ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
- ksh93 $(atf_get_srcdir)/inuse_003_pos.ksh || atf_fail "Testcase failed"
-}
-
-
-
-atf_test_case inuse_004_pos
-inuse_004_pos_head()
-{
- atf_set "descr" "format will disallow modification of a mounted zfs disk partition or a spare device"
- atf_set "require.progs" zfs zpool format
- atf_set "timeout" 1200
-}
-inuse_004_pos_body()
-{
- . $(atf_get_srcdir)/../../include/default.cfg
- . $(atf_get_srcdir)/inuse.cfg
-
- ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
- ksh93 $(atf_get_srcdir)/inuse_004_pos.ksh || atf_fail "Testcase failed"
-}
-
-
-
atf_test_case inuse_005_pos
inuse_005_pos_head()
{
atf_set "descr" "Verify newfs over active pool fails."
- atf_set "timeout" 1200
+ atf_set "require.progs" newfs zpool
+ atf_set "require.user" root
}
inuse_005_pos_body()
{
- atf_expect_fail "REQ25571 ZFS does not open geoms in exclusive mode"
. $(atf_get_srcdir)/../../include/default.cfg
. $(atf_get_srcdir)/inuse.cfg
- ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
+ verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/inuse_005_pos.ksh || atf_fail "Testcase failed"
}
-
-atf_test_case inuse_006_pos
-inuse_006_pos_head()
+atf_test_case inuse_010_neg
+inuse_010_neg_head()
{
- atf_set "descr" "Verify dumpadm over active pool fails."
- atf_set "require.progs" dumpadm
- atf_set "timeout" 1200
+ atf_set "descr" "ZFS shouldn't be able to use a disk with a mounted filesystem"
+ atf_set "require.progs" newfs zpool
+ atf_set "require.user" root
}
-inuse_006_pos_body()
+inuse_010_neg_body()
{
. $(atf_get_srcdir)/../../include/default.cfg
- . $(atf_get_srcdir)/inuse.cfg
- ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
- ksh93 $(atf_get_srcdir)/inuse_006_pos.ksh || atf_fail "Testcase failed"
+ verify_disk_count "$DISKS" 1
+ ksh93 $(atf_get_srcdir)/inuse_010_neg.ksh || atf_fail "Testcase failed"
}
-
-atf_test_case inuse_007_pos
-inuse_007_pos_head()
-{
- atf_set "descr" "Verify dumpadm over exported pool succeed."
- atf_set "require.progs" dumpadm zpool
- atf_set "timeout" 1200
-}
-inuse_007_pos_body()
-{
- . $(atf_get_srcdir)/../../include/default.cfg
- . $(atf_get_srcdir)/inuse.cfg
-
- ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
- ksh93 $(atf_get_srcdir)/inuse_007_pos.ksh || atf_fail "Testcase failed"
-}
-
-
-
-atf_test_case inuse_008_pos
-inuse_008_pos_head()
-{
- atf_set "descr" "Verify newfs over exported pool succeed."
- atf_set "require.progs" zpool
- atf_set "timeout" 1200
-}
-inuse_008_pos_body()
-{
- . $(atf_get_srcdir)/../../include/default.cfg
- . $(atf_get_srcdir)/inuse.cfg
-
- ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
- ksh93 $(atf_get_srcdir)/inuse_008_pos.ksh || atf_fail "Testcase failed"
-}
-
-
-
-atf_test_case inuse_009_pos
-inuse_009_pos_head()
-{
- atf_set "descr" "Verify format over exported pool succeed."
- atf_set "require.progs" zpool
- atf_set "timeout" 1200
-}
-inuse_009_pos_body()
-{
- . $(atf_get_srcdir)/../../include/default.cfg
- . $(atf_get_srcdir)/inuse.cfg
-
- ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
- ksh93 $(atf_get_srcdir)/inuse_009_pos.ksh || atf_fail "Testcase failed"
-}
-
-
-
atf_init_test_cases()
{
-
- atf_add_test_case inuse_001_pos
- atf_add_test_case inuse_002_pos
- atf_add_test_case inuse_003_pos
- atf_add_test_case inuse_004_pos
atf_add_test_case inuse_005_pos
- atf_add_test_case inuse_006_pos
- atf_add_test_case inuse_007_pos
- atf_add_test_case inuse_008_pos
- atf_add_test_case inuse_009_pos
+ atf_add_test_case inuse_010_neg
}
More information about the svn-src-projects
mailing list