]>
git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_001_neg.ksh
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.
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.
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]
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
36 # 'zfs clone' should fail with inapplicable scenarios, including:
38 # * non-existent snapshots.
39 # * invalid characters in ZFS namesapec
40 # * Leading slash in the target clone name
41 # * The argument contains an empty component.
42 # * The pool specified in the target doesn't exist.
43 # * The parent dataset of the target doesn't exist.
44 # * The argument refer to a pool, not dataset.
45 # * The target clone already exists.
46 # * Null target clone argument.
47 # * Too many arguments.
48 # * Invalid record sizes.
51 # 1. Create an array of parameters
52 # 2. For each parameter in the array, execute the sub-command
53 # 3. Verify an error is returned.
56 verify_runnable
"both"
58 typeset target1
=$TESTPOOL/$TESTFS1
59 typeset target2
=$TESTPOOL/$TESTCTR1/$TESTFS1
60 typeset targets
="$target1 $target2 $NONEXISTPOOLNAME/$TESTFS"
63 "$TESTPOOL/$TESTFS@blah $target1" "$TESTPOOL/$TESTVOL@blah $target1" \
64 "$TESTPOOL/$TESTFS@blah* $target1" "$TESTPOOL/$TESTVOL@blah* $target1" \
65 "$SNAPFS $target1*" "$SNAPFS1 $target1*" \
66 "$SNAPFS /$target1" "$SNAPFS1 /$target1" \
67 "$SNAPFS $TESTPOOL//$TESTFS1" "$SNAPFS1 $TESTPOOL//$TESTFS1" \
68 "$SNAPFS $NONEXISTPOOLNAME/$TESTFS" "$SNAPFS1 $NONEXISTPOOLNAME/$TESTFS" \
69 "$SNAPFS" "$SNAPFS1" \
70 "$SNAPFS $target1 $target2" "$SNAPFS1 $target1 $target2" \
71 "-o recordsize=2M $SNAPFS1 $target1" \
72 "-o recordsize=128B $SNAPFS1 $target1"
73 typeset
-i argsnum
=${#args[*]}
75 while (( j
< argsnum
)); do
76 args
[((argsnum
+j
))]="-p ${args[j]}"
80 set -A moreargs
"$SNAPFS $target2" "$SNAPFS1 $target2" \
81 "$SNAPFS $TESTPOOL" "$SNAPFS1 $TESTPOOL" \
82 "$SNAPFS $TESTPOOL/$TESTCTR" "$SNAPFS $TESTPOOL/$TESTFS" \
83 "$SNAPFS1 $TESTPOOL/$TESTCTR" "$SNAPFS1 $TESTPOOL/$TESTFS"
85 set -A args
${args[*]} ${moreargs[*]}
89 log_note
"Create snapshots and mount them..."
91 for snap
in $SNAPFS $SNAPFS1 ; do
92 if ! snapexists
$snap ; then
93 log_must zfs snapshot
$snap
102 for fs
in $targets; do
103 datasetexists
$fs && log_must zfs destroy
-f $fs
106 for snap
in $SNAPFS $SNAPFS1 ; do
107 snapexists
$snap && log_must zfs destroy
-Rf $snap
113 log_assert
"Badly-formed 'zfs clone' with inapplicable scenarios" \
114 "should return an error."
115 log_onexit cleanup_all
120 while (( i
< ${#args[*]} )); do
121 log_mustnot zfs clone
${args[i]}
125 log_pass
"Badly formed 'zfs clone' with inapplicable scenarios" \