7290 ZFS test suite needs to control what utilities it can run
[unleashed.git] / usr / src / test / zfs-tests / tests / functional / cli_root / zfs_inherit / zfs_inherit_002_neg.ksh
blob584039f543c68af42f3e333048cff3249b83c1e7
1 #!/bin/ksh -p
3 # CDDL HEADER START
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]
20 # CDDL HEADER END
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
35 # DESCRIPTION:
36 # 'zfs inherit' should return an error with bad parameters in one command.
38 # STRATEGY:
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"
46 function cleanup
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" \
54 "one command."
55 log_onexit cleanup
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
65 typeset -i i=0
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 \
73 >/dev/null 2>&1"
74 done
75 done
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"
81 done
83 # zfs inherit should fail with too many arguments
84 (( i = 0 ))
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"
91 (( i = i + 2 ))
92 done
94 done
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"
100 done
102 log_pass "'zfs inherit' failed as expected when passing illegal arguments."