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 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/include/libtest.shlib
36 # "zfs snapshot -r" fails with invalid arguments or scenarios.
37 # The invalid scenarios may include:
38 # (1) The child filesystem already has snapshot with the same name
39 # (2) The child volume already has snapshot with the same name
42 # 1. Create an array of invalid arguments
43 # 2. Execute 'zfs snapshot -r' with each argument in the array,
44 # 3. Verify an error is returned.
47 verify_runnable "both"
53 for snap in $TESTPOOL/$TESTCTR/$TESTFS1@$TESTSNAP \
54 $TESTPOOL/$TESTCTR/$TESTVOL@$TESTSNAP;
57 log_must zfs destroy $snap
60 datasetexists $TESTPOOL/$TESTCTR/$TESTVOL && \
61 log_must zfs destroy -rf $TESTPOOL/$TESTCTR/$TESTVOL
65 log_assert "'zfs snapshot -r' fails with invalid arguments or scenarios. "
69 "$TESTPOOL/$TESTCTR@$TESTSNAP" "$TESTPOOL/$TESTCTR@blah?" \
70 "$TESTPOOL/$TESTCTR@blah*" "@$TESTSNAP" "$TESTPOOL/$TESTCTR@" \
71 "$TESTPOOL/$TESTFS/$TESTSNAP" "blah/blah@$TESTSNAP" \
72 "$TESTPOOL/$TESTCTR@$TESTSNAP@$TESTSNAP"
75 log_must zfs snapshot $TESTPOOL/$TESTCTR/$TESTFS1@$TESTSNAP
79 while (( i < ${#args[*]} )); do
80 log_mustnot zfs snapshot -r ${args[i]}
85 # Testing the invalid scenario: the child volume already has an
86 # identical name snapshot, zfs snapshot -r should fail when
87 # creating snapshot with -r for the parent
88 log_must zfs destroy $TESTPOOL/$TESTCTR/$TESTFS1@$TESTSNAP
89 if is_global_zone; then
90 log_must zfs create -V $VOLSIZE $TESTPOOL/$TESTCTR/$TESTVOL
92 log_must zfs create $TESTPOOL/$TESTCTR/$TESTVOL
94 log_must zfs snapshot $TESTPOOL/$TESTCTR/$TESTVOL@$TESTSNAP
96 log_mustnot zfs snapshot -r $TESTPOOL/$TESTCTR@$TESTSNAP
98 log_pass "'zfs snapshot -r' fails with invalid arguments or scenarios as expected."