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# $FreeBSD$ 24 25# 26# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)zfs_destroy_002_pos.ksh 1.2 07/01/09 SMI" 30# 31. $STF_SUITE/include/libtest.kshlib 32 33################################################################################ 34# 35# __stc_assertion_start 36# 37# ID: zfs_destroy_002_pos 38# 39# DESCRIPTION: 40# 'zfs destroy <filesystem|volume|snapshot>' can successfully destroy 41# the specified dataset which has no active dependents. 42# 43# STRATEGY: 44# 1. Create a filesystem,volume and snapshot in the storage pool 45# 2. Destroy the filesystem,volume and snapshot 46# 3. Verify the datasets are destroyed successfully 47# 48# TESTABILITY: explicit 49# 50# TEST_AUTOMATION_LEVEL: automated 51# 52# CODING_STATUS: COMPLETED (2006-06-07) 53# 54# __stc_assertion_end 55# 56################################################################################ 57 58verify_runnable "both" 59 60function cleanup 61{ 62 typeset -i i=0 63 while (( $i < ${#data_objs[*]} )); do 64 datasetexists "${data_objs[i]}" && \ 65 $ZFS destroy -rf ${data_objs[i]} 66 ((i = i + 1)) 67 done 68} 69 70log_assert "Verify 'zfs destroy' can destroy the specified datasets without active" \ 71 "dependents." 72log_onexit cleanup 73 74if is_global_zone ; then 75 set -A data_objs "$TESTPOOL/$TESTFS@$TESTSNAP" "$TESTPOOL/$TESTFS1" \ 76 "$TESTPOOL/$TESTVOL" "$TESTPOOL/$TESTVOL1" 77else 78 set -A data_objs "$TESTPOOL/$TESTFS@$TESTSNAP" "$TESTPOOL/$TESTFS1" 79fi 80 81log_must $ZFS create $TESTPOOL/$TESTFS1 82log_must $ZFS snapshot $TESTPOOL/$TESTFS@$TESTSNAP 83 84if is_global_zone ; then 85 log_must $ZFS create -V $VOLSIZE $TESTPOOL/$TESTVOL 86 87 # Max volume size is 1TB on 32-bit systems 88 [[ `$UNAME -p` == "i386" ]] && \ 89 BIGVOLSIZE=1Tb 90 [[ `$UNAME -p` == "arm" ]] && \ 91 BIGVOLSIZE=1Tb 92 [[ `$UNAME -p` == "mips" ]] && \ 93 BIGVOLSIZE=1Tb 94 [[ `$UNAME -p` == "powerpc" ]] && \ 95 BIGVOLSIZE=1Tb 96 log_must $ZFS create -sV $BIGVOLSIZE $TESTPOOL/$TESTVOL1 97fi 98 99typeset -i i=0 100while (( $i < ${#data_objs[*]} )); do 101 datasetexists ${data_objs[i]} || \ 102 log_fail "Create <filesystem>|<volume>|<snapshot> fail." 103 ((i = i + 1)) 104done 105 106i=0 107while (( $i < ${#data_objs[*]} )); do 108 log_must $ZFS destroy ${data_objs[i]} 109 datasetexists ${data_objs[i]} && \ 110 log_fail "'zfs destroy <filesystem>|<volume>|<snapshot>' fail." 111 ((i = i + 1)) 112done 113 114log_pass "'zfs destroy <filesystem>|<volume>|<snapshot>' works as expected." 115