zfs_destroy_common.kshlib revision 1d32ba663e202c24a5a1f2e5aef83fffb447cb7f
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# CDDL HEADER START
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# The contents of this file are subject to the terms of the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Common Development and Distribution License (the "License").
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# You may not use this file except in compliance with the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# or http://www.opensolaris.org/os/licensing.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# See the License for the specific language governing permissions
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# and limitations under the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner]
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# CDDL HEADER END
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Use is subject to license terms.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy. $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy.cfg
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Create or recover a set of test environment which include ctr, vol, fs,
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# snap & clone. It looks like the following.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $1 indicate which dependent dataset need be created. Such as 'snap', 'clone'.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # Volume test is only availible on globle zone
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if ! datasetexists $VOL && is_global_zone; then
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy echo "y" | newfs /dev/zvol/dsk/$VOL > /dev/null 2>&1
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_note "SUCCESS: newfs /dev/zvol/dsk/$VOL>/dev/null"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_fail "newfs /dev/zvol/dsk/$VOL > /dev/null"
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ ! -d $TESTDIR1 ]]; then
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must mount /dev/zvol/dsk/$VOL $TESTDIR1
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ $dtst == snap || $dtst == clone ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if ! datasetexists $VOLSNAP && is_global_zone; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ $dtst == clone ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if ! datasetexists $VOLCLONE && is_global_zone; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Clean up the testing environment
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if is_global_zone && ismounted "$TESTDIR1" "ufs" ; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ -d $TESTDIR1 ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Delete volume and related datasets from list, if the test cases was
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# runing in local zone. Then check them are existed or non-exists.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $1 function name
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $2-n datasets name
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # Volume and related stuff are unvailable in local zone
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ $dtst == $VOL || $dtst == $VOLSNAP || \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # Run each item in $newlist individually so on failure, the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # probelmatic dataset is listed in the logs.