1#!/usr/local/bin/ksh93 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_promote_008_pos 33# 34# DESCRIPTION: 35# 'zfs promote' can successfully promote a volume clone. 36# 37# STRATEGY: 38# 1. Create a volume clone 39# 2. Promote the volume clone 40# 3. Verify the dependency changed. 41# 42# TESTABILITY: explicit 43# 44# TEST_AUTOMATION_LEVEL: automated 45# 46# CODING_STATUS: COMPLETED (2007-02-05) 47# 48# __stc_assertion_end 49# 50################################################################################ 51 52verify_runnable "global" 53 54function cleanup 55{ 56 if snapexists $csnap; then 57 log_must $ZFS promote $vol 58 fi 59 60 log_must $ZFS destroy -rR $snap 61} 62 63log_assert "'zfs promote' can promote a volume clone." 64log_onexit cleanup 65 66vol=$TESTPOOL/$TESTVOL 67snap=$vol@$TESTSNAP 68clone=$TESTPOOL/volclone 69csnap=$clone@$TESTSNAP 70 71if ! snapexists $snap ; then 72 log_must $ZFS snapshot $snap 73 log_must $ZFS clone $snap $clone 74fi 75 76log_must $ZFS promote $clone 77 78# verify the 'promote' operation 79! snapexists $csnap && \ 80 log_fail "Snapshot $csnap doesn't exist after zfs promote." 81snapexists $snap && \ 82 log_fail "Snapshot $snap is still there after zfs promote." 83 84origin_prop=$(get_prop origin $vol) 85[[ "$origin_prop" != "$csnap" ]] && \ 86 log_fail "The dependency of $vol is not correct." 87origin_prop=$(get_prop origin $clone) 88[[ "$origin_prop" != "-" ]] && \ 89 log_fail "The dependency of $clone is not correct." 90 91log_pass "'zfs promote' can promote volume clone as expected." 92 93