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 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2011, 2016 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
36 # 'zfs inherit' should return an error with bad parameters in one command.
39 # 1. Set an array of bad options and invlid properties to 'zfs inherit'
40 # 2. Execute 'zfs inherit' with bad options and passing invlid properties
41 # 3. Verify an error is returned.
44 verify_runnable
"both"
48 if snapexists
$TESTPOOL/$TESTFS@
$TESTSNAP; then
49 log_must zfs destroy
$TESTPOOL/$TESTFS@
$TESTSNAP
53 log_assert
"'zfs inherit' should return an error with bad parameters in" \
57 set -A badopts
"r" "R" "-R" "-rR" "-a" "-" "-?" "-1" "-2" "-v" "-n"
58 set -A props
"recordsize" "mountpoint" "sharenfs" "checksum" "compression" \
59 "atime" "devices" "exec" "setuid" "readonly" "zoned" "snapdir" "aclmode" \
60 "aclinherit" "xattr" "copies"
61 set -A illprops
"recordsiz" "mountpont" "sharen" "compres" "atme" "blah"
63 log_must zfs snapshot
$TESTPOOL/$TESTFS@
$TESTSNAP
66 for ds
in $TESTPOOL $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \
67 $TESTPOOL/$TESTFS@
$TESTSNAP; do
69 # zfs inherit should fail with bad options
70 for opt
in ${badopts[@]}; do
71 for prop
in ${props[@]}; do
72 log_mustnot
eval "zfs inherit $opt $prop $ds \
77 # zfs inherit should fail with invalid properties
78 for prop
in "${illprops[@]}"; do
79 log_mustnot
eval "zfs inherit $prop $ds >/dev/null 2>&1"
80 log_mustnot
eval "zfs inherit -r $prop $ds >/dev/null 2>&1"
83 # zfs inherit should fail with too many arguments
85 while (( i
< ${#props[*]} -1 )); do
86 log_mustnot
eval "zfs inherit ${props[(( i ))]} \
87 ${props[(( i + 1 ))]} $ds >/dev/null 2>&1"
88 log_mustnot
eval "zfs inherit -r ${props[(( i ))]} \
89 ${props[(( i + 1 ))]} $ds >/dev/null 2>&1"
96 # zfs inherit should fail with missing datasets
97 for prop
in ${props[@]}; do
98 log_mustnot
eval "zfs inherit $prop >/dev/null 2>&1"
99 log_mustnot
eval "zfs inherit -r $prop >/dev/null 2>&1"
102 log_pass
"'zfs inherit' failed as expected when passing illegal arguments."