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) 2016 by Delphix. All rights reserved.
30#
31
32. $STF_SUITE/include/libtest.shlib
33. $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib
34
35#
36# DESCRIPTION:
37# 'zfs inherit' should return an error with bad parameters in one command.
38#
39# STRATEGY:
40# 1. Set an array of bad options and invlid properties to 'zfs inherit'
41# 2. Execute 'zfs inherit' with bad options and passing invlid properties
42# 3. Verify an error is returned.
43#
44
45verify_runnable "both"
46
47function cleanup
48{
49	for ds in $TESTPOOL $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL ; do
50		if snapexists $ds@$TESTSNAP; then
51			log_must zfs destroy $ds@$TESTSNAP
52		fi
53	done
54	cleanup_user_prop $TESTPOOL
55}
56
57log_assert "'zfs inherit' should inherit user property."
58log_onexit cleanup
59
60for ds in $TESTPOOL $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL ; do
61        typeset prop_name=$(valid_user_property 10)
62        typeset value=$(user_property_value 16)
63
64	log_must eval "zfs set $prop_name='$value' $ds"
65
66	log_must zfs snapshot $ds@$TESTSNAP
67
68	typeset snapvalue=$(get_prop $prop_name $ds@$TESTSNAP)
69
70	if [[ "$snapvalue" != "$value" ]] ; then
71		log_fail "The '$ds@$TESTSNAP '$prop_name' value '$snapvalue' " \
72			"not equal to the expected value '$value'."
73	fi
74
75	snapvalue=$(user_property_value 16)
76	log_must eval "zfs set $prop_name='$snapvalue' $ds@$TESTSNAP"
77
78	log_must zfs inherit $prop_name $ds@$TESTSNAP
79
80	snapvalue=$(get_prop $prop_name $ds@$TESTSNAP)
81
82	if [[ "$snapvalue" != "$value" ]] ; then
83		log_fail "The '$ds@$TESTSNAP '$prop_name' value '$snapvalue' " \
84			"not equal to the expected value '$value'."
85	fi
86
87
88done
89
90log_pass "'zfs inherit' inherit user property."
91