xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_set/user_property_004_pos.ksh (revision b6805bf78d2bbbeeaea8909a05623587b42d58b3)
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. $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib
29
30#
31# DESCRIPTION:
32#	User property has no effect to snapshot until 'Snapshot properties' supported.
33#
34# STRATEGY:
35#	1. Verify user properties could be transformed by 'zfs snapshot'
36#	2. Verify user properties could be set upon snapshot.
37#
38
39verify_runnable "both"
40
41function cleanup
42{
43	for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL ; do
44		typeset fssnap=$fs@snap
45		if datasetexists $fssnap ; then
46			log_must $ZFS destroy -f $fssnap
47		fi
48	done
49	cleanup_user_prop $TESTPOOL
50}
51
52function nonexist_user_prop
53{
54	typeset user_prop=$1
55	typeset dtst=$2
56
57	typeset source=$(get_source $user_prop $dtst)
58	typeset value=$(get_prop $user_prop $dtst)
59	if [[ $source == '-' && $value == '-' ]]; then
60		return 0
61	else
62		return 1
63	fi
64}
65
66log_assert "User property has no effect to snapshot until 'Snapshot properties' supported."
67log_onexit cleanup
68
69typeset snap_property=
70
71$ZPOOL upgrade -v | $GREP "Snapshot properties" > /dev/null 2>&1
72if (( $? == 0 )) ; then
73	snap_property="true"
74fi
75
76for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL ; do
77	typeset fssnap=$fs@snap
78	prop_name=$(valid_user_property 10)
79	value=$(user_property_value 16)
80	log_must eval "$ZFS set $prop_name='$value' $fs"
81	log_must eval "check_user_prop $fs $prop_name '$value'"
82
83	log_must $ZFS snapshot $fssnap
84
85	if [[ -n $snap_property ]] ; then
86		log_mustnot nonexist_user_prop $prop_name $fssnap
87
88		log_must eval "$ZFS set $prop_name='$value' $fssnap"
89		log_mustnot nonexist_user_prop $prop_name $fssnap
90	else
91		log_must nonexist_user_prop $prop_name $fssnap
92		log_mustnot eval "$ZFS set $prop_name='$value' $fssnap"
93		log_must nonexist_user_prop $prop_name $fssnap
94	fi
95done
96
97log_pass "User properties has effect upon snapshot."
98