zfs_clone_001_neg.ksh revision e9316f7696401f3e5e263a5939031cb8d5641a88
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# CDDL HEADER START
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# The contents of this file are subject to the terms of the
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# Common Development and Distribution License (the "License").
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# You may not use this file except in compliance with the License.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# See the License for the specific language governing permissions
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# and limitations under the License.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# When distributing Covered Code, include this CDDL HEADER in each
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk# If applicable, add the following below this CDDL HEADER, with the
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# fields enclosed by brackets "[]" replaced with your own identifying
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# information: Portions Copyright [yyyy] [name of copyright owner]
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# CDDL HEADER END
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# Use is subject to license terms.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# Copyright (c) 2012, 2015 by Delphix. All rights reserved.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# DESCRIPTION:
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# 'zfs clone' should fail with inapplicable scenarios, including:
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# * Null arguments
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# * non-existant snapshots.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# * invalid characters in ZFS namesapec
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# * Leading slash in the target clone name
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# * The argument contains an empty component.
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk# * The pool specified in the target doesn't exist.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# * The parent dataset of the target doesn't exist.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# * The argument refer to a pool, not dataset.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# * The target clone already exists.
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk# * Null target clone argument.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# * Too many arguments.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# * Invalid record sizes.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# 1. Create an array of parameters
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# 2. For each parameter in the array, execute the sub-command
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# 3. Verify an error is returned.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenktypeset targets="$target1 $target2 $NONEXISTPOOLNAME/$TESTFS"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk "$TESTPOOL/$TESTFS@blah $target1" "$TESTPOOL/$TESTVOL@blah $target1" \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk "$TESTPOOL/$TESTFS@blah* $target1" "$TESTPOOL/$TESTVOL@blah* $target1" \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk "$SNAPFS $TESTPOOL//$TESTFS1" "$SNAPFS1 $TESTPOOL//$TESTFS1" \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk "$SNAPFS $NONEXISTPOOLNAME/$TESTFS" "$SNAPFS1 $NONEXISTPOOLNAME/$TESTFS" \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk "$SNAPFS $target1 $target2" "$SNAPFS1 $target1 $target2" \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk "-o recordsize=2M $SNAPFS1 $target1" \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk "-o recordsize=128B $SNAPFS1 $target1"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenktypeset -i j=0
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkset -A moreargs "$SNAPFS $target2" "$SNAPFS1 $target2" \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk "$SNAPFS $TESTPOOL/$TESTCTR" "$SNAPFS $TESTPOOL/$TESTFS" \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk "$SNAPFS1 $TESTPOOL/$TESTCTR" "$SNAPFS1 $TESTPOOL/$TESTFS"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk datasetexists $fs && log_must $ZFS destroy -f $fs
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk snapexists $snap && log_must $ZFS destroy -Rf $snap
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenklog_assert "Badly-formed 'zfs clone' with inapplicable scenarios" \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk "should return an error."
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenktypeset -i i=0
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenklog_pass "Badly formed 'zfs clone' with inapplicable scenarios" \