1#!/usr/local/bin/ksh93 -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# $FreeBSD$ 24 25# 26# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)user_property_002_pos.ksh 1.3 07/02/06 SMI" 30# 31 32. $STF_SUITE/tests/cli_root/zfs_set/zfs_set_common.kshlib 33 34################################################################################# 35# 36# __stc_assertion_start 37# 38# ID: user_property_002_pos 39# 40# DESCRIPTION: 41# User defined property are always inherited from its parent dataset 42# directly. 43# 44# STRATEGY: 45# 1. Create pool, fs, volume, fsclone & volclone. 46# 2. Get random user property name and set to the pool 47# 3. Verify all dataset user property inherit from pool. 48# 4. Set intermediate dataset and verify its children will inherit user 49# property from it directly. 50# 51# TESTABILITY: explicit 52# 53# TEST_AUTOMATION_LEVEL: automated 54# 55# CODING_STATUS: COMPLETED (2006-09-04) 56# 57# __stc_assertion_end 58# 59################################################################################ 60 61verify_runnable "both" 62 63function cleanup 64{ 65 datasetexists $new_vol && log_must $ZFS rename $new_vol $vol 66 67 typeset dtst 68 for dtst in $new_fsclone $new_volclone $fsclone $volclone \ 69 $fssnap $volsnap; do 70 if datasetexists $dtst; then 71 log_must $ZFS destroy -f $dtst 72 fi 73 done 74 75 cleanup_user_prop $pool 76} 77 78# 79# Verify options datasets (3-n) inherit from the inherited dataset $2. 80# 81# $1 user property 82# $2 inherited dataset 83# $3-n datasets 84# 85function inherit_check 86{ 87 typeset prop=$1 88 typeset inherited_dtst=$2 89 shift 2 90 [[ -z $@ ]] && return 1 91 92 typeset inherited_value=$(get_prop $prop $inherited_dtst) 93 for dtst in $@; do 94 typeset value=$(get_prop $prop $dtst) 95 typeset source=$(get_source $prop $dtst) 96 if [[ "$value" != "$inherited_value" || \ 97 "$source" != "inherited from $inherited_dtst" ]] 98 then 99 return 1 100 fi 101 102 shift 103 done 104 105 return 0 106} 107 108log_assert "User defined property inherited from its parent." 109log_onexit cleanup 110 111pool=$TESTPOOL; fs=$pool/$TESTFS; vol=$pool/$TESTVOL 112fssnap=$fs@snap; volsnap=$vol@snap; 113log_must $ZFS snapshot $fssnap 114log_must $ZFS snapshot $volsnap 115fsclone=$pool/fsclone; volclone=$pool/volclone 116log_must $ZFS clone $fssnap $fsclone 117log_must $ZFS clone $volsnap $volclone 118 119prop_name=$(valid_user_property 10) 120value=$(user_property_value 16) 121log_must eval "$ZFS set $prop_name='$value' $pool" 122log_must eval "check_user_prop $pool $prop_name '$value'" 123log_must inherit_check $prop_name $pool $fs $vol $fsclone $volclone 124 125new_fsclone=$fs/fsclone; new_volclone=$fs/volclone 126log_must $ZFS rename $fsclone $new_fsclone 127log_must $ZFS rename $volclone $new_volclone 128log_must inherit_check $prop_name $pool $fs $new_fsclone $new_volclone 129 130log_note "Set intermediate dataset will change the inherited relationship." 131new_value=$(user_property_value 16) 132log_must eval "$ZFS set $prop_name='$new_value' $fs" 133log_must eval "check_user_prop $fs $prop_name '$new_value'" 134log_must inherit_check $prop_name $fs $new_fsclone $new_volclone 135 136log_pass "User defined property inherited from its parent passed." 137