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 "@(#)snapshot_010_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: snapshot_010_pos 38# 39# DESCRIPTION: 40# Verify 'destroy -r' can correctly destroy a snapshot tree at any point. 41# 42# STRATEGY: 43# 1. Use the snapshot -r to create snapshot for top level pool 44# 2. Select a middle point of the snapshot tree, use destroy -r to destroy all 45# snapshots beneath the point. 46# 3. Verify the destroy results. 47# 48# TESTABILITY: explicit 49# 50# TEST_AUTOMATION_LEVEL: automated 51# 52# CODING_STATUS: COMPLETED (2006-06-20) 53# 54# __stc_assertion_end 55# 56################################################################################ 57 58verify_runnable "both" 59 60function cleanup 61{ 62 typeset snap 63 64 datasetexists $ctrvol && \ 65 log_must $ZFS destroy -f $ctrvol 66 67 for snap in $ctrfs@$TESTSNAP1 \ 68 $snappool $snapvol $snapctr $snapctrvol \ 69 $snapctrclone $snapctrfs 70 do 71 snapexists $snap && \ 72 log_must $ZFS destroy -rf $snap 73 done 74 75} 76 77log_assert "Verify 'destroy -r' can correctly destroy a snapshot subtree at any point." 78log_onexit cleanup 79 80ctr=$TESTPOOL/$TESTCTR 81ctrfs=$ctr/$TESTFS1 82ctrvol=$ctr/$TESTVOL1 83snappool=$SNAPPOOL 84snapfs=$SNAPFS 85snapctr=$ctr@$TESTSNAP 86snapvol=$SNAPFS1 87snapctrvol=$ctr/$TESTVOL1@$TESTSNAP 88snapctrclone=$ctr/$TESTCLONE@$TESTSNAP 89snapctrfs=$SNAPCTR 90 91#preparation for testing 92log_must $ZFS snapshot $ctrfs@$TESTSNAP1 93if is_global_zone; then 94 log_must $ZFS create -V $VOLSIZE $ctrvol 95else 96 log_must $ZFS create $ctrvol 97fi 98 99log_must $ZFS snapshot -r $snappool 100 101#select the $TESTCTR as destroy point, $TESTCTR is a child of $TESTPOOL 102log_must $ZFS destroy -r $snapctr 103for snap in $snapctr $snapctrvol $snapctrclone $snapctrfs; do 104 snapexists $snap && \ 105 log_fail "The snapshot $snap is not destroyed correctly." 106done 107 108for snap in $snappool $snapfs $snapvol $ctrfs@$TESTSNAP1;do 109 ! snapexists $snap && \ 110 log_fail "The snapshot $snap should be not destroyed." 111done 112 113log_pass "'destroy -r' destroys snapshot subtree as expected." 114