4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
28 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
32 # Simple function to get the source of the specified property.
33 # If unable to get the property then exits.
35 function get_prop_src # property dataset
41 prop_val=`zfs get -H -o source $prop $dataset`
43 if [[ $? -ne 0 ]]; then
44 log_fail "Unable to determine the source of $prop " \
45 "property for dataset $dataset"
52 # Function to check the 'source' of a property. The source can
53 # either be "default", "local", or "inherited from <parent dataset>".
55 # The 'expected src' argument must be either "default", "local", or
58 # Returns 0 on success, 1 on failure.
60 function verify_prop_src # child_dataset property expected_src
66 prop_src=`get_prop_src $prop $target`
69 # Rather than just checking if $prop_src == $expected
70 # we first determine what value $expected should have.
71 # This allows us to catch the case where a property
72 # has a source of "local" but we expected it to be
75 if [[ $expected == "default" ]]; then
76 if [[ $prop_src != $expected ]]; then
77 log_note "Property $prop of $target has source"\
78 " $prop_src rather than $expected"
81 elif [[ $expected == "local" ]]; then
82 if [[ $prop_src != $expected ]]; then
83 log_note "Property $prop of $target has source"\
84 " $prop_src rather than $expected"
87 elif [[ $prop_src != "inherited from $expected" ]]; then
88 log_note "Property $prop of $expected has source $prop_src"\
89 " rather than 'inherited from $expected'"
97 # Simple function to set a property to a
98 # specified value and verify it has changed
101 function set_n_verify_prop #property value dataset
107 zfs set $prop=$prop_val $dataset
108 check_val=`get_prop $prop $dataset`
110 if [[ $check_val != $prop_val ]]; then
111 log_fail "Property $prop of $dataset has value $check_val"\
112 " rather than $prop_val"