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 2009 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_clone_007_pos 33# 34# DESCRIPTION: 35# 'zfs clone -o version=' could upgrade version, but downgrade is denied. 36# 37# STRATEGY: 38# 1. Create clone with "-o version=" specified 39# 2. Verify it succeed while upgrade, but fails while the version downgraded. 40# 41# TESTABILITY: explicit 42# 43# TEST_AUTOMATION_LEVEL: automated 44# 45# CODING_STATUS: COMPLETED (2008-12-16) 46# 47# __stc_assertion_end 48# 49################################################################################ 50 51if ! $(check_opt_support "upgrade") ; then 52 log_unsupported "'zfs upgrade' unsupported." 53fi 54 55if ! $(check_opt_support "clone" "-o") ; then 56 log_unsupported "'zfs clone -o' unsupported." 57fi 58 59ZFS_VERSION=$($ZFS upgrade | $HEAD -1 | $AWK '{print $NF}' \ 60 | $SED -e 's/\.//g') 61 62verify_runnable "both" 63 64function cleanup 65{ 66 if snapexists $SNAPFS ; then 67 log_must $ZFS destroy -Rf $SNAPFS 68 fi 69} 70 71log_onexit cleanup 72 73log_assert "'zfs clone -o version=' could upgrade version," \ 74 "but downgrade is denied." 75 76log_must $ZFS snapshot $SNAPFS 77 78typeset -i ver 79 80if (( ZFS_TEST_VERSION == 0 )) ; then 81 (( ZFS_TEST_VERSION = ZFS_VERSION )) 82fi 83 84(( ver = ZFS_TEST_VERSION )) 85while (( ver <= ZFS_VERSION )); do 86 log_must $ZFS clone -o version=$ver $SNAPFS $TESTPOOL/$TESTCLONE 87 cleanup 88 (( ver = ver + 1 )) 89done 90 91(( ver = 0 )) 92while (( ver < ZFS_TEST_VERSION )); do 93 log_mustnot $ZFS clone -o version=$ver \ 94 $SNAPFS $TESTPOOL/$TESTCLONE 95 log_mustnot datasetexists $TESTPOOL/$TESTCLONE 96 cleanup 97 (( ver = ver + 1 )) 98done 99 100log_pass "'zfs clone -o version=' could upgrade version," \ 101 "but downgrade is denied." 102