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_promote_006_neg 33# 34# DESCRIPTION: 35# 'zfs promote' will fail with invalid arguments: 36# (1) NULL arguments 37# (2) non-existent clone 38# (3) non-clone datasets: 39# pool, fs, snapshot,volume 40# (4) too many arguments. 41# (5) invalid options 42# 43# STRATEGY: 44# 1. Create an array of invalid arguments 45# 2. For each invalid argument in the array, 'zfs promote' should fail 46# 3. Verify the return code from zfs promote 47# 48# TESTABILITY: explicit 49# 50# TEST_AUTOMATION_LEVEL: automated 51# 52# CODING_STATUS: COMPLETED (2006-05-16) 53# 54# __stc_assertion_end 55# 56################################################################################ 57 58verify_runnable "both" 59 60snap=$TESTPOOL/$TESTFS@$TESTSNAP 61set -A args "" \ 62 "$TESTPOOL/blah" \ 63 "$TESTPOOL" "$TESTPOOL/$TESTFS" "$snap" \ 64 "$TESTPOOL/$TESTVOL" "$TESTPOL $TESTPOOL/$TESTFS" \ 65 "$clone $TESTPOOL/$TESTFS" "- $clone" "-? $clone" 66 67function cleanup 68{ 69 if datasetexists $clone; then 70 log_must $ZFS destroy $clone 71 fi 72 73 if snapexists $snap; then 74 destroy_snapshot $snap 75 fi 76} 77 78log_assert "'zfs promote' will fail with invalid arguments. " 79log_onexit cleanup 80 81snap=$TESTPOOL/$TESTFS@$TESTSNAP 82clone=$TESTPOOL/$TESTCLONE 83log_must $ZFS snapshot $snap 84log_must $ZFS clone $snap $clone 85 86typeset -i i=0 87while (( i < ${#args[*]} )); do 88 log_mustnot $ZFS promote ${args[i]} 89 90 (( i = i + 1 )) 91done 92 93log_pass "'zfs promote' fails with invalid argument as expected." 94