1eda14cbcSMatt Macy#! /bin/ksh -p
2eda14cbcSMatt Macy#
3eda14cbcSMatt Macy# CDDL HEADER START
4eda14cbcSMatt Macy#
5eda14cbcSMatt Macy# The contents of this file are subject to the terms of the
6eda14cbcSMatt Macy# Common Development and Distribution License (the "License").
7eda14cbcSMatt Macy# You may not use this file except in compliance with the License.
8eda14cbcSMatt Macy#
9eda14cbcSMatt Macy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10271171e0SMartin Matuska# or https://opensource.org/licenses/CDDL-1.0.
11eda14cbcSMatt Macy# See the License for the specific language governing permissions
12eda14cbcSMatt Macy# and limitations under the License.
13eda14cbcSMatt Macy#
14eda14cbcSMatt Macy# When distributing Covered Code, include this CDDL HEADER in each
15eda14cbcSMatt Macy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16eda14cbcSMatt Macy# If applicable, add the following below this CDDL HEADER, with the
17eda14cbcSMatt Macy# fields enclosed by brackets "[]" replaced with your own identifying
18eda14cbcSMatt Macy# information: Portions Copyright [yyyy] [name of copyright owner]
19eda14cbcSMatt Macy#
20eda14cbcSMatt Macy# CDDL HEADER END
21eda14cbcSMatt Macy#
22eda14cbcSMatt Macy
23eda14cbcSMatt Macy#
24eda14cbcSMatt Macy# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25eda14cbcSMatt Macy# Use is subject to license terms.
26eda14cbcSMatt Macy
27eda14cbcSMatt Macy#
28eda14cbcSMatt Macy# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
29*dbd5678dSMartin Matuska# Copyright (c) 2022 Hewlett Packard Enterprise Development LP.
30eda14cbcSMatt Macy#
31eda14cbcSMatt Macy
32eda14cbcSMatt Macy. $STF_SUITE/include/libtest.shlib
33eda14cbcSMatt Macy. $STF_SUITE/tests/functional/inheritance/inherit.kshlib
34eda14cbcSMatt Macy
35eda14cbcSMatt Macy#
36eda14cbcSMatt Macy# DESCRIPTION:
37eda14cbcSMatt Macy# Test that properties are correctly inherited using 'zfs set',
38eda14cbcSMatt Macy# 'zfs inherit' and 'zfs inherit -r'.
39eda14cbcSMatt Macy#
40eda14cbcSMatt Macy# STRATEGY:
41eda14cbcSMatt Macy# 1) Read a configX.cfg file and create the specified datasets
42eda14cbcSMatt Macy# 2) Read a stateX.cfg file and execute the commands within it
43eda14cbcSMatt Macy# and verify that the properties have the correct values
44eda14cbcSMatt Macy# 3) Repeat steps 1-2 for each configX and stateX files found.
45eda14cbcSMatt Macy#
46eda14cbcSMatt Macy
47eda14cbcSMatt Macyverify_runnable "global"
48eda14cbcSMatt Macy
49eda14cbcSMatt Macylog_assert "Test properties are inherited correctly"
50eda14cbcSMatt Macy
51eda14cbcSMatt Macy#
52eda14cbcSMatt Macy# Simple function to create specified datasets.
53eda14cbcSMatt Macy#
54eda14cbcSMatt Macyfunction create_dataset { #name type disks
55eda14cbcSMatt Macy	typeset dataset=$1
56eda14cbcSMatt Macy	typeset type=$2
57eda14cbcSMatt Macy	typeset disks=$3
58eda14cbcSMatt Macy
59eda14cbcSMatt Macy	if [[ $type == "POOL" ]]; then
60eda14cbcSMatt Macy		create_pool "$dataset" "$disks"
61eda14cbcSMatt Macy	elif [[ $type == "CTR" ]]; then
62eda14cbcSMatt Macy		log_must zfs create $dataset
63eda14cbcSMatt Macy		log_must zfs set canmount=off $dataset
64eda14cbcSMatt Macy	elif [[ $type == "FS" ]]; then
65eda14cbcSMatt Macy		log_must zfs create $dataset
66eda14cbcSMatt Macy	else
67eda14cbcSMatt Macy		log_fail "Unrecognised type $type"
68eda14cbcSMatt Macy	fi
69eda14cbcSMatt Macy
70eda14cbcSMatt Macy	list="$list $dataset"
71eda14cbcSMatt Macy}
72eda14cbcSMatt Macy
73eda14cbcSMatt Macy#
74eda14cbcSMatt Macy# Function to walk through all the properties in a
75eda14cbcSMatt Macy# dataset, setting them to a 'local' value if required.
76eda14cbcSMatt Macy#
77eda14cbcSMatt Macyfunction init_props { #dataset init_code
78eda14cbcSMatt Macy	typeset dataset=$1
79eda14cbcSMatt Macy	typeset init_code=$2
80eda14cbcSMatt Macy	typeset dir=$3
81eda14cbcSMatt Macy
82eda14cbcSMatt Macy	typeset -i i=0
83eda14cbcSMatt Macy
84eda14cbcSMatt Macy	#
85eda14cbcSMatt Macy	# Though the effect of '-' and 'default' is the same we
86eda14cbcSMatt Macy	# call them out via a log_note to aid in debugging the
87eda14cbcSMatt Macy	# config files
88eda14cbcSMatt Macy	#
89eda14cbcSMatt Macy	if [[ $init_code == "-" ]]; then
90eda14cbcSMatt Macy		log_note "Leaving properties for $dataset unchanged."
91eda14cbcSMatt Macy		[[ $def_recordsize == 0 ]] && \
92eda14cbcSMatt Macy		    update_recordsize $dataset $init_code
93eda14cbcSMatt Macy		return;
94eda14cbcSMatt Macy	elif [[ $init_code == "default" ]]; then
95eda14cbcSMatt Macy		log_note "Leaving properties for $dataset at default values."
96eda14cbcSMatt Macy		[[ $def_recordsize == 0 ]] && \
97eda14cbcSMatt Macy		    update_recordsize $dataset $init_code
98eda14cbcSMatt Macy		return;
99eda14cbcSMatt Macy	elif [[ $init_code == "local" ]]; then
100eda14cbcSMatt Macy		log_note "Setting properties for $dataset to local values."
101eda14cbcSMatt Macy		while (( i <  ${#prop[*]} )); do
102eda14cbcSMatt Macy			if [[ ${prop[i]} == "recordsize" ]]; then
103eda14cbcSMatt Macy				update_recordsize $dataset $init_code
104eda14cbcSMatt Macy			else
105eda14cbcSMatt Macy				if [[ ${prop[i]} == "mountpoint" ]]; then
106eda14cbcSMatt Macy					set_n_verify_prop ${prop[i]} \
107eda14cbcSMatt Macy					    ${local_val[((i/2))]}.$dir $dataset
108eda14cbcSMatt Macy				else
109eda14cbcSMatt Macy					set_n_verify_prop ${prop[i]} \
110eda14cbcSMatt Macy					    ${local_val[((i/2))]} $dataset
111eda14cbcSMatt Macy				fi
112eda14cbcSMatt Macy			fi
113eda14cbcSMatt Macy
114eda14cbcSMatt Macy			((i = i + 2))
115eda14cbcSMatt Macy		done
116eda14cbcSMatt Macy	else
117eda14cbcSMatt Macy		log_fail "Unrecognised init code $init_code"
118eda14cbcSMatt Macy	fi
119eda14cbcSMatt Macy}
120eda14cbcSMatt Macy
121eda14cbcSMatt Macy#
122eda14cbcSMatt Macy# We enter this function either to update the recordsize value
123eda14cbcSMatt Macy# in the default array, or to update the local value array.
124eda14cbcSMatt Macy#
125eda14cbcSMatt Macyfunction update_recordsize { #dataset init_code
126eda14cbcSMatt Macy	typeset dataset=$1
127eda14cbcSMatt Macy	typeset init_code=$2
128eda14cbcSMatt Macy	typeset idx=0
129eda14cbcSMatt Macy	typeset record_val
130eda14cbcSMatt Macy
131eda14cbcSMatt Macy	#
132eda14cbcSMatt Macy	# First need to find where the recordsize property is
133eda14cbcSMatt Macy	# located in the arrays
134eda14cbcSMatt Macy	#
135eda14cbcSMatt Macy	while (( idx <  ${#prop[*]} )); do
136eda14cbcSMatt Macy		[[ ${prop[idx]} == "recordsize" ]] && break
137eda14cbcSMatt Macy
138eda14cbcSMatt Macy		((idx = idx + 2))
139eda14cbcSMatt Macy	done
140eda14cbcSMatt Macy
141eda14cbcSMatt Macy	((idx = idx / 2))
142eda14cbcSMatt Macy	record_val=`get_prop recordsize $dataset`
143eda14cbcSMatt Macy	if [[ $init_code == "-" || $init_code == "default" ]]; then
144eda14cbcSMatt Macy		def_val[idx]=$record_val
145eda14cbcSMatt Macy		def_recordsize=1
146eda14cbcSMatt Macy	elif [[ $init_code == "local" ]]; then
147eda14cbcSMatt Macy		log_must zfs set recordsize=$record_val $dataset
148eda14cbcSMatt Macy		local_val[idx]=$record_val
149eda14cbcSMatt Macy	fi
150eda14cbcSMatt Macy}
151eda14cbcSMatt Macy
152eda14cbcSMatt Macy#
153eda14cbcSMatt Macy# The mountpoint property is slightly different from other properties and
154eda14cbcSMatt Macy# so is handled here. For all other properties if they are set to a specific
155eda14cbcSMatt Macy# value at a higher level in the data hierarchy (i.e. checksum=on) then that
156eda14cbcSMatt Macy# value propagates down the hierarchy unchanged, with the source field being
157eda14cbcSMatt Macy# set to 'inherited from <higher dataset>'.
158eda14cbcSMatt Macy#
159eda14cbcSMatt Macy# The mountpoint property is different in that while the value propagates
160eda14cbcSMatt Macy# down the hierarchy, the value at each level is determined by a combination
161eda14cbcSMatt Macy# of the top-level value and the current level in the hierarchy.
162eda14cbcSMatt Macy#
163eda14cbcSMatt Macy# For example consider the case where we have a pool (called pool1), containing
164eda14cbcSMatt Macy# a dataset (ctr) which in turn contains a filesystem (fs). If we set the
165eda14cbcSMatt Macy# mountpoint of the pool to '/mnt2' then the mountpoints for the dataset and
166eda14cbcSMatt Macy# filesystem are '/mnt2/ctr' and /mnt2/ctr/fs' respectively, with the 'source'
167eda14cbcSMatt Macy# field being set to 'inherited from pool1'.
168eda14cbcSMatt Macy#
169eda14cbcSMatt Macy# So at the filesystem level to calculate what our mountpoint property should
170eda14cbcSMatt Macy# be set to we walk back up the hierarchy sampling the mountpoint property at
171eda14cbcSMatt Macy# each level and forming up the expected mountpoint value piece by piece until
172eda14cbcSMatt Macy# we reach the level specified in the 'source' field, which in this example is
173eda14cbcSMatt Macy# the top-level pool.
174eda14cbcSMatt Macy#
175eda14cbcSMatt Macyfunction get_mntpt_val #dataset src index
176eda14cbcSMatt Macy{
177eda14cbcSMatt Macy	typeset dataset=$1
178eda14cbcSMatt Macy	typeset src=$2
179eda14cbcSMatt Macy	typeset idx=$3
180eda14cbcSMatt Macy	typeset new_path=""
181eda14cbcSMatt Macy	typeset dset
182eda14cbcSMatt Macy	typeset mntpt=""
183eda14cbcSMatt Macy
184eda14cbcSMatt Macy	if [[ $src == "local" ]]; then
185eda14cbcSMatt Macy		# Extract mount points specific to datasets
186eda14cbcSMatt Macy		if [[ $dataset == "TESTPOOL" ]]; then
187eda14cbcSMatt Macy			mntpt=${local_val[idx]}.1
188eda14cbcSMatt Macy		elif [[ $dataset == "TESTPOOL/TESTCTR" ]]; then
189eda14cbcSMatt Macy			mntpt=${local_val[idx]}.2
190eda14cbcSMatt Macy		else
191eda14cbcSMatt Macy			mntpt=${local_val[idx]}.3
192eda14cbcSMatt Macy		fi
193eda14cbcSMatt Macy	elif [[ $src == "default" ]]; then
194eda14cbcSMatt Macy		mntpt="/$dataset"
195eda14cbcSMatt Macy	else
196eda14cbcSMatt Macy		# Walk back up the hierarchy building up the
197eda14cbcSMatt Macy		# expected mountpoint property value.
198eda14cbcSMatt Macy		obj_name=${dataset##*/}
199eda14cbcSMatt Macy
200eda14cbcSMatt Macy		while [[ $src != $dataset ]]; do
201eda14cbcSMatt Macy			dset=${dataset%/*}
202eda14cbcSMatt Macy
203eda14cbcSMatt Macy			mnt_val=`get_prop mountpoint $dset`
204eda14cbcSMatt Macy
205eda14cbcSMatt Macy			mod_prop_val=${mnt_val##*/}
206eda14cbcSMatt Macy			new_path="/"$mod_prop_val$new_path
207eda14cbcSMatt Macy			dataset=$dset
208eda14cbcSMatt Macy		done
209eda14cbcSMatt Macy
210eda14cbcSMatt Macy		mntpt=$new_path"/"$obj_name
211eda14cbcSMatt Macy	fi
212eda14cbcSMatt Macy	echo $mntpt
213eda14cbcSMatt Macy}
214eda14cbcSMatt Macy
215eda14cbcSMatt Macy#
216eda14cbcSMatt Macy# Simple function to verify that a property has the
217eda14cbcSMatt Macy# expected value.
218eda14cbcSMatt Macy#
219eda14cbcSMatt Macyfunction verify_prop_val #property dataset src index
220eda14cbcSMatt Macy{
221eda14cbcSMatt Macy	typeset prop=$1
222eda14cbcSMatt Macy	typeset dataset=$2
223eda14cbcSMatt Macy	typeset src=$3
224eda14cbcSMatt Macy	typeset idx=$4
225eda14cbcSMatt Macy	typeset new_path=""
226eda14cbcSMatt Macy	typeset dset
227eda14cbcSMatt Macy	typeset exp_val
228eda14cbcSMatt Macy	typeset prop_val
229eda14cbcSMatt Macy
230eda14cbcSMatt Macy	prop_val=`get_prop $prop $dataset`
231eda14cbcSMatt Macy
232eda14cbcSMatt Macy	# mountpoint property is handled as a special case
233eda14cbcSMatt Macy	if [[ $prop == "mountpoint" ]]; then
234eda14cbcSMatt Macy		exp_val=`get_mntpt_val $dataset $src $idx`
235eda14cbcSMatt Macy	else
236eda14cbcSMatt Macy		if [[ $src == "local" ]]; then
237eda14cbcSMatt Macy			exp_val=${local_val[idx]}
238eda14cbcSMatt Macy		elif [[ $src == "default" ]]; then
239eda14cbcSMatt Macy			exp_val=${def_val[idx]}
240eda14cbcSMatt Macy		else
241eda14cbcSMatt Macy			#
242eda14cbcSMatt Macy			# We are inheriting the value from somewhere
243eda14cbcSMatt Macy			# up the hierarchy.
244eda14cbcSMatt Macy			#
245eda14cbcSMatt Macy			exp_val=`get_prop $prop $src`
246eda14cbcSMatt Macy		fi
247eda14cbcSMatt Macy	fi
248eda14cbcSMatt Macy
249eda14cbcSMatt Macy	if [[ $prop_val != $exp_val ]]; then
250eda14cbcSMatt Macy		# After putback PSARC/2008/231 Apr,09,2008,
251eda14cbcSMatt Macy		# the default value of aclinherit has changed to be
252eda14cbcSMatt Macy		# 'restricted' instead of 'secure',
253eda14cbcSMatt Macy		# but the old interface of 'secure' still exist
254eda14cbcSMatt Macy
255eda14cbcSMatt Macy		if [[ $prop != "aclinherit" || \
256eda14cbcSMatt Macy		    $exp_val != "secure" || \
257eda14cbcSMatt Macy		    $prop_val != "restricted" ]]; then
258eda14cbcSMatt Macy
259eda14cbcSMatt Macy			log_fail "$prop of $dataset is [$prop_val] rather "\
260eda14cbcSMatt Macy			    "than [$exp_val]"
261eda14cbcSMatt Macy		fi
262eda14cbcSMatt Macy	fi
263eda14cbcSMatt Macy}
264eda14cbcSMatt Macy
265eda14cbcSMatt Macy#
266eda14cbcSMatt Macy# Function to read the configX.cfg files and create the specified
267eda14cbcSMatt Macy# dataset hierarchy
268eda14cbcSMatt Macy#
269eda14cbcSMatt Macyfunction scan_config { #config-file
270eda14cbcSMatt Macy	typeset config_file=$1
271eda14cbcSMatt Macy
272eda14cbcSMatt Macy	DISK=${DISKS%% *}
273eda14cbcSMatt Macy
274eda14cbcSMatt Macy	list=""
275eda14cbcSMatt Macy	typeset -i mount_dir=1
276eda14cbcSMatt Macy
277eda14cbcSMatt Macy	grep "^[^#]" $config_file | {
278eda14cbcSMatt Macy		while read name type init ; do
279eda14cbcSMatt Macy			create_dataset $name $type $DISK
280eda14cbcSMatt Macy			init_props $name $init $mount_dir
281eda14cbcSMatt Macy			((mount_dir = mount_dir + 1))
282eda14cbcSMatt Macy		done
283eda14cbcSMatt Macy	}
284eda14cbcSMatt Macy}
285eda14cbcSMatt Macy
286eda14cbcSMatt Macy#
287eda14cbcSMatt Macy# Function to check an exit flag, calling log_fail if that exit flag
288eda14cbcSMatt Macy# is non-zero. Can be used from code that runs in a tight loop, which
289eda14cbcSMatt Macy# would otherwise result in a lot of journal output.
290eda14cbcSMatt Macy#
291eda14cbcSMatt Macyfunction check_failure { # int status, error message to use
292eda14cbcSMatt Macy
293eda14cbcSMatt Macy	typeset -i exit_flag=$1
294eda14cbcSMatt Macy	error_message=$2
295eda14cbcSMatt Macy
296eda14cbcSMatt Macy	if [[ $exit_flag -ne 0 ]]; then
297eda14cbcSMatt Macy		log_fail "$error_message"
298eda14cbcSMatt Macy	fi
299eda14cbcSMatt Macy}
300eda14cbcSMatt Macy
301eda14cbcSMatt Macy
302eda14cbcSMatt Macy#
303eda14cbcSMatt Macy# Main function. Executes the commands specified in the stateX.cfg
304eda14cbcSMatt Macy# files and then verifies that all the properties have the correct
305eda14cbcSMatt Macy# values and 'source' fields.
306eda14cbcSMatt Macy#
307eda14cbcSMatt Macyfunction scan_state { #state-file
308eda14cbcSMatt Macy	typeset state_file=$1
309eda14cbcSMatt Macy	typeset -i i=0
310eda14cbcSMatt Macy	typeset -i j=0
311eda14cbcSMatt Macy
312eda14cbcSMatt Macy	log_note "Reading state from $state_file"
313eda14cbcSMatt Macy
314eda14cbcSMatt Macy	while ((i <  ${#prop[*]})); do
315eda14cbcSMatt Macy		grep "^[^#]" $state_file | {
316eda14cbcSMatt Macy			while IFS=: read target op; do
317eda14cbcSMatt Macy				#
318eda14cbcSMatt Macy				# The user can if they wish specify that no
319eda14cbcSMatt Macy				# operation be performed (by specifying '-'
320eda14cbcSMatt Macy				# rather than a command). This is not as
321eda14cbcSMatt Macy				# useless as it sounds as it allows us to
322eda14cbcSMatt Macy				# verify that the dataset hierarchy has been
323eda14cbcSMatt Macy				# set up correctly as specified in the
324eda14cbcSMatt Macy				# configX.cfg file (which includes 'set'ting
325eda14cbcSMatt Macy				# properties at a higher level and checking
326eda14cbcSMatt Macy				# that they propagate down to the lower levels.
327eda14cbcSMatt Macy				#
328eda14cbcSMatt Macy				# Note in a few places here, we use
329eda14cbcSMatt Macy				# check_failure, rather than log_must - this
330eda14cbcSMatt Macy				# substantially reduces journal output.
331eda14cbcSMatt Macy				#
332eda14cbcSMatt Macy				if [[ $op == "-" ]]; then
333eda14cbcSMatt Macy					log_note "No operation specified"
334eda14cbcSMatt Macy				else
335eda14cbcSMatt Macy					export __ZFS_POOL_RESTRICT="TESTPOOL"
336271171e0SMartin Matuska					log_must_busy zfs unmount -a
337eda14cbcSMatt Macy					unset __ZFS_POOL_RESTRICT
338eda14cbcSMatt Macy
339eda14cbcSMatt Macy					for p in ${prop[i]} ${prop[((i+1))]}; do
340eda14cbcSMatt Macy						zfs $op $p $target
341716fd348SMartin Matuska						check_failure $? "zfs $op $p $target"
342eda14cbcSMatt Macy					done
343eda14cbcSMatt Macy				fi
344eda14cbcSMatt Macy				for check_obj in $list; do
345eda14cbcSMatt Macy					read init_src final_src
346eda14cbcSMatt Macy
347eda14cbcSMatt Macy					for p in ${prop[i]} ${prop[((i+1))]}; do
348eda14cbcSMatt Macy					# check_failure to keep journal small
349eda14cbcSMatt Macy						verify_prop_src $check_obj $p \
350eda14cbcSMatt Macy						    $final_src
351716fd348SMartin Matuska						check_failure $? "verify" \
352eda14cbcSMatt Macy						    "_prop_src $check_obj $p" \
353eda14cbcSMatt Macy						    "$final_src"
354eda14cbcSMatt Macy
355eda14cbcSMatt Macy					# Again, to keep journal size down.
356eda14cbcSMatt Macy						verify_prop_val $p $check_obj \
357eda14cbcSMatt Macy						    $final_src $j
358716fd348SMartin Matuska						check_failure $? "verify" \
359eda14cbcSMatt Macy						    "_prop_val $check_obj $p" \
360eda14cbcSMatt Macy						    "$final_src"
361eda14cbcSMatt Macy					done
362eda14cbcSMatt Macy				done
363eda14cbcSMatt Macy			done
364eda14cbcSMatt Macy		}
365eda14cbcSMatt Macy		((i = i + 2))
366eda14cbcSMatt Macy		((j = j + 1))
367eda14cbcSMatt Macy	done
368eda14cbcSMatt Macy}
369eda14cbcSMatt Macy
370eda14cbcSMatt Macy#
371eda14cbcSMatt Macy# Note that we keep this list relatively short so that this test doesn't
372eda14cbcSMatt Macy# time out (after taking more than 10 minutes).
373eda14cbcSMatt Macy#
374eda14cbcSMatt Macyset -A prop "checksum" "" \
375eda14cbcSMatt Macy	"compression" "" \
376eda14cbcSMatt Macy	"atime" "" \
377eda14cbcSMatt Macy	"sharenfs" "" \
378eda14cbcSMatt Macy	"recordsize" "recsize" \
379eda14cbcSMatt Macy	"snapdir" "" \
380*dbd5678dSMartin Matuska	"readonly" "" \
381*dbd5678dSMartin Matuska	"redundant_metadata" ""
382eda14cbcSMatt Macy
383eda14cbcSMatt Macy#
384eda14cbcSMatt Macy# Note except for the mountpoint default value (which is handled in
385eda14cbcSMatt Macy# the routine itself), each property specified in the 'prop' array
386eda14cbcSMatt Macy# above must have a corresponding entry in the two arrays below.
387eda14cbcSMatt Macy#
388eda14cbcSMatt Macy
389c03c5b1cSMartin Matuskaset -A def_val "on" "on" "on" \
390eda14cbcSMatt Macy	"off" "" \
391eda14cbcSMatt Macy	"hidden" \
392*dbd5678dSMartin Matuska	"off" \
393*dbd5678dSMartin Matuska	"all"
394eda14cbcSMatt Macy
395c03c5b1cSMartin Matuskaset -A local_val "off" "off" "off" \
396eda14cbcSMatt Macy	"on" "" \
397eda14cbcSMatt Macy	"visible" \
398*dbd5678dSMartin Matuska	"off" \
399*dbd5678dSMartin Matuska	"none"
400eda14cbcSMatt Macy
401eda14cbcSMatt Macy#
402eda14cbcSMatt Macy# Add system specific values
403eda14cbcSMatt Macy#
404eda14cbcSMatt Macyif is_linux; then
405eda14cbcSMatt Macy	prop+=("acltype" "")
406eda14cbcSMatt Macy	def_val+=("off")
407eda14cbcSMatt Macy	local_val+=("off")
408eda14cbcSMatt Macyelse
409eda14cbcSMatt Macy	prop+=("aclmode" "")
410eda14cbcSMatt Macy	def_val+=("discard")
411eda14cbcSMatt Macy	local_val+=("groupmask")
412eda14cbcSMatt Macyfi
413eda14cbcSMatt Macyif is_illumos; then
414eda14cbcSMatt Macy	prop+=("mountpoint" "")
415eda14cbcSMatt Macy	def_val+=("")
416eda14cbcSMatt Macy	local_val+=("$TESTDIR")
417eda14cbcSMatt Macyfi
418eda14cbcSMatt Macy
419eda14cbcSMatt Macy#
420eda14cbcSMatt Macy# Global flag indicating whether the default record size had been
421eda14cbcSMatt Macy# read.
422eda14cbcSMatt Macy#
423eda14cbcSMatt Macytypeset def_recordsize=0
424eda14cbcSMatt Macy
425eda14cbcSMatt Macyset -A config_files $(ls $STF_SUITE/tests/functional/inheritance/config*[1-9]*.cfg)
426eda14cbcSMatt Macyset -A state_files $(ls $STF_SUITE/tests/functional/inheritance/state*.cfg)
427eda14cbcSMatt Macy
428eda14cbcSMatt Macy#
429eda14cbcSMatt Macy# Global list of datasets created.
430eda14cbcSMatt Macy#
431eda14cbcSMatt Macylist=""
432eda14cbcSMatt Macy
433eda14cbcSMatt Macytypeset -i k=0
434eda14cbcSMatt Macy
435eda14cbcSMatt Macyif [[ ${#config_files[*]} != ${#state_files[*]} ]]; then
436eda14cbcSMatt Macy	log_fail "Must have the same number of config files " \
437eda14cbcSMatt Macy	    " (${#config_files[*]}) and state files ${#state_files[*]}"
438eda14cbcSMatt Macyfi
439eda14cbcSMatt Macy
440eda14cbcSMatt Macywhile ((k < ${#config_files[*]})); do
441eda14cbcSMatt Macy	default_cleanup_noexit
442eda14cbcSMatt Macy	def_recordsize=0
443eda14cbcSMatt Macy
444eda14cbcSMatt Macy	log_note "Testing configuration ${config_files[k]}"
445eda14cbcSMatt Macy
446eda14cbcSMatt Macy	scan_config ${config_files[k]}
447eda14cbcSMatt Macy	scan_state ${state_files[k]}
448eda14cbcSMatt Macy
449eda14cbcSMatt Macy	((k = k + 1))
450eda14cbcSMatt Macydone
451eda14cbcSMatt Macy
452eda14cbcSMatt Macylog_pass "Properties correctly inherited as expected"
453