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 2008 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26 27. $STF_SUITE/tests/cli_root/cli_common.kshlib 28 29################################################################################# 30# 31# __stc_assertion_start 32# 33# ID: zfs_send_004_neg 34# 35# DESCRIPTION: 36# Verify 'zfs send' fails with malformed parameters. 37# 38# STRATEGY: 39# 1. Define malformed parameters in array 40# 2. Feed the parameters to 'zfs send' 41# 3. Verify the result 42# 43# TESTABILITY: explicit 44# 45# TEST_AUTOMATION_LEVEL: automated 46# 47# CODING_STATUS: COMPLETED (2005-09-06) 48# 49# __stc_assertion_end 50# 51################################################################################ 52 53verify_runnable "both" 54 55function cleanup 56{ 57 typeset snap f 58 59 for snap in $snap1 $snap2 $snap3; do 60 snapexists $snap && \ 61 log_must $ZFS destroy -f $snap 62 done 63 64 for f in $tmpfile1 $tmpfile2; do 65 if [[ -e $f ]]; then 66 $RM -f $f 67 fi 68 done 69} 70 71fs=$TESTPOOL/$TESTFS 72snap1=$fs@snap1 73snap2=$fs@snap2 74snap3=$fs@snap3 75 76set -A badargs \ 77 "" "$TESTPOOL" "$TESTFS" "$fs" "$fs@nonexisten_snap" "?" \ 78 "$snap1/blah" "$snap1@blah" "-i" "-x" "-i $fs" \ 79 "-x $snap1 $snap2" "-i $snap1" \ 80 "-i $snap2 $snap1" "$snap1 $snap2" "-i $snap1 $snap2 $snap3" \ 81 "-ii $snap1 $snap2" "-iii $snap1 $snap2" " -i $snap2 $snap1/blah" \ 82 "-i $snap2/blah $snap1" \ 83 "-i $snap2/blah $snap1/blah" \ 84 "-i $snap1 blah@blah" \ 85 "-i blah@blah $snap1" \ 86 "-i $snap1 ${snap2##*@}" "-i $snap1 @${snap2##*@}" \ 87 "-i ${snap1##*@} ${snap2##*@}" "-i @${snap1##*@} @${snap2##*@}" \ 88 "-i ${snap1##*@} $snap2/blah" "-i @${snap1##*@} $snap2/blah" \ 89 "-i @@${snap1##*@} $snap2" "-i $snap1 -i $snap1 $snap2" \ 90 "-i snap1 snap2" "-i $snap1 snap2" \ 91 "-i $snap1 $snap2 -i $snap1 $snap2" \ 92 "-i snap1 $snap2 -i snap1 $snap2" 93 94log_assert "Verify that invalid parameters to 'zfs send' are caught." 95log_onexit cleanup 96 97log_must $ZFS snapshot $snap1 98tmpfile1=$TESTDIR/testfile1.${TESTCASE_ID} 99log_must $TOUCH $tmpfile1 100log_must $ZFS snapshot $snap2 101tmpfile2=$TESTDIR/testfile2.${TESTCASE_ID} 102log_must $TOUCH $tmpfile2 103log_must $ZFS snapshot $snap3 104 105typeset -i i=0 106while (( i < ${#badargs[*]} )) 107do 108 log_mustnot eval "$ZFS send ${badargs[i]} >/dev/null" 109 110 (( i = i + 1 )) 111done 112 113#Testing zfs send fails by send backup stream to terminal 114for arg in "$snap1" "-i $snap1 $snap2"; do 115 log_mustnot eval "$ZFS send $arg >/dev/console" 116done 117 118log_pass "Invalid parameters to 'zfs send' are caught as expected." 119