comparison usr/src/test/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_001_neg.ksh @ 13899:0bcf78798346

3311 Want a test framework for arbitrary OS unit tests 3312 Add a testrunner package for OS unit tests 3313 Add a testrunner package to convert ZFS tests from STF Reviewed by: Matt Ahrens <matthew.ahrens@delphix.com> Reviewed by: Will Guyette <will.guyette@delphix.com> Reviewed by: Dan Kimmel <dan.kimmel@delphix.com> Reviewed by: Adam Leventhal <ahl@delphix.com> Reviewed by: Henrik Mattson <henrik.mattson@delphix.com> Reviewed by: Sonu Pillai <sonu.pillai@delphix.com> Reviewed by: Christopher Siden <chris.siden@delphix.com> Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Richard Lowe <richlowe@richlowe.net> Approved by: Richard Lowe <richlowe@richlowe.net>
author John Wren Kennedy <john.kennedy@delphix.com>
date Wed, 05 Dec 2012 22:04:50 -0500
parents
children
comparison
equal deleted inserted replaced
13898:7f822b09519b 13899:0bcf78798346
1 #!/bin/ksh -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 #
27
28 #
29 # Copyright (c) 2012 by Delphix. All rights reserved.
30 #
31
32 . $STF_SUITE/include/libtest.shlib
33
34 #
35 # DESCRIPTION:
36 # 'zfs clone' should fail with inapplicable scenarios, including:
37 # * Null arguments
38 # * non-existant 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 #
49 # STRATEGY:
50 # 1. Create an array of parameters
51 # 2. For each parameter in the array, execute the sub-command
52 # 3. Verify an error is returned.
53 #
54
55 verify_runnable "both"
56
57 typeset target1=$TESTPOOL/$TESTFS1
58 typeset target2=$TESTPOOL/$TESTCTR1/$TESTFS1
59 typeset targets="$target1 $target2 $NONEXISTPOOLNAME/$TESTFS"
60
61 set -A args "" \
62 "$TESTPOOL/$TESTFS@blah $target1" "$TESTPOOL/$TESTVOL@blah $target1" \
63 "$TESTPOOL/$TESTFS@blah* $target1" "$TESTPOOL/$TESTVOL@blah* $target1" \
64 "$SNAPFS $target1*" "$SNAPFS1 $target1*" \
65 "$SNAPFS /$target1" "$SNAPFS1 /$target1" \
66 "$SNAPFS $TESTPOOL//$TESTFS1" "$SNAPFS1 $TESTPOOL//$TESTFS1" \
67 "$SNAPFS $NONEXISTPOOLNAME/$TESTFS" "$SNAPFS1 $NONEXISTPOOLNAME/$TESTFS" \
68 "$SNAPFS" "$SNAPFS1" \
69 "$SNAPFS $target1 $target2" "$SNAPFS1 $target1 $target2"
70 typeset -i argsnum=${#args[*]}
71 typeset -i j=0
72 while (( j < argsnum )); do
73 args[((argsnum+j))]="-p ${args[j]}"
74 ((j = j + 1))
75 done
76
77 set -A moreargs "$SNAPFS $target2" "$SNAPFS1 $target2" \
78 "$SNAPFS $TESTPOOL" "$SNAPFS1 $TESTPOOL" \
79 "$SNAPFS $TESTPOOL/$TESTCTR" "$SNAPFS $TESTPOOL/$TESTFS" \
80 "$SNAPFS1 $TESTPOOL/$TESTCTR" "$SNAPFS1 $TESTPOOL/$TESTFS"
81
82 set -A args ${args[*]} ${moreargs[*]}
83
84 function setup_all
85 {
86 log_note "Create snapshots and mount them..."
87
88 for snap in $SNAPFS $SNAPFS1 ; do
89 if ! snapexists $snap ; then
90 log_must $ZFS snapshot $snap
91 fi
92 done
93
94 return 0
95 }
96
97 function cleanup_all
98 {
99 for fs in $targets; do
100 datasetexists $fs && log_must $ZFS destroy -f $fs
101 done
102
103 for snap in $SNAPFS $SNAPFS1 ; do
104 snapexists $snap && log_must $ZFS destroy -Rf $snap
105 done
106
107 return 0
108 }
109
110 log_assert "Badly-formed 'zfs clone' with inapplicable scenarios" \
111 "should return an error."
112 log_onexit cleanup_all
113
114 setup_all
115
116 typeset -i i=0
117 while (( i < ${#args[*]} )); do
118 log_mustnot $ZFS clone ${args[i]}
119 ((i = i + 1))
120 done
121
122 log_pass "Badly formed 'zfs clone' with inapplicable scenarios" \
123 "fail as expected."