1#!/usr/local/bin/ksh93 -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26. $STF_SUITE/include/libtest.kshlib 27 28################################################################################ 29# 30# __stc_assertion_start 31# 32# ID: zfs_destroy_002_pos 33# 34# DESCRIPTION: 35# 'zfs destroy <filesystem|volume|snapshot>' can successfully destroy 36# the specified dataset which has no active dependents. 37# 38# STRATEGY: 39# 1. Create a filesystem,volume and snapshot in the storage pool 40# 2. Destroy the filesystem,volume and snapshot 41# 3. Verify the datasets are destroyed successfully 42# 43# TESTABILITY: explicit 44# 45# TEST_AUTOMATION_LEVEL: automated 46# 47# CODING_STATUS: COMPLETED (2006-06-07) 48# 49# __stc_assertion_end 50# 51################################################################################ 52 53verify_runnable "both" 54 55function cleanup 56{ 57 typeset -i i=0 58 while (( $i < ${#data_objs[*]} )); do 59 datasetexists "${data_objs[i]}" && \ 60 $ZFS destroy -rf ${data_objs[i]} 61 ((i = i + 1)) 62 done 63} 64 65log_assert "Verify 'zfs destroy' can destroy the specified datasets without active" \ 66 "dependents." 67log_onexit cleanup 68 69if is_global_zone ; then 70 set -A data_objs "$TESTPOOL/$TESTFS@$TESTSNAP" "$TESTPOOL/$TESTFS1" \ 71 "$TESTPOOL/$TESTVOL" "$TESTPOOL/$TESTVOL1" 72else 73 set -A data_objs "$TESTPOOL/$TESTFS@$TESTSNAP" "$TESTPOOL/$TESTFS1" 74fi 75 76log_must $ZFS create $TESTPOOL/$TESTFS1 77log_must $ZFS snapshot $TESTPOOL/$TESTFS@$TESTSNAP 78 79if is_global_zone ; then 80 log_must $ZFS create -V $VOLSIZE $TESTPOOL/$TESTVOL 81 82 # Max volume size is 1TB on 32-bit systems 83 [[ `$UNAME -p` == "i386" ]] && \ 84 BIGVOLSIZE=1Tb 85 [[ `$UNAME -p` == "arm" ]] && \ 86 BIGVOLSIZE=1Tb 87 [[ `$UNAME -p` == "mips" ]] && \ 88 BIGVOLSIZE=1Tb 89 [[ `$UNAME -p` == "powerpc" ]] && \ 90 BIGVOLSIZE=1Tb 91 log_must $ZFS create -sV $BIGVOLSIZE $TESTPOOL/$TESTVOL1 92fi 93 94typeset -i i=0 95while (( $i < ${#data_objs[*]} )); do 96 datasetexists ${data_objs[i]} || \ 97 log_fail "Create <filesystem>|<volume>|<snapshot> fail." 98 ((i = i + 1)) 99done 100 101i=0 102while (( $i < ${#data_objs[*]} )); do 103 log_must $ZFS destroy ${data_objs[i]} 104 datasetexists ${data_objs[i]} && \ 105 log_fail "'zfs destroy <filesystem>|<volume>|<snapshot>' fail." 106 ((i = i + 1)) 107done 108 109log_pass "'zfs destroy <filesystem>|<volume>|<snapshot>' works as expected." 110