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 2009 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)zfs_snapshot_007_neg.ksh 1.1 09/05/19 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: zfs_snapshot_007_pos 39# 40# DESCRIPTION: 41# 'zfs snapshot -o' cannot set properties other than user property 42# 43# STRATEGY: 44# 1. Create snapshot and give '-o property=value' with regular property. 45# 2. Verify the snapshot creation failed. 46# 47# TESTABILITY: explicit 48# 49# TEST_AUTOMATION_LEVEL: automated 50# 51# CODING_STATUS: COMPLETED (2009-04-27) 52# 53# __stc_assertion_end 54# 55################################################################################ 56 57verify_runnable "both" 58 59function cleanup 60{ 61 for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do 62 typeset fssnap=$fs@snap 63 if datasetexists $fssnap ; then 64 log_must $ZFS destroy -rf $fssnap 65 fi 66 done 67 cleanup_user_prop $TESTPOOL 68} 69 70function nonexist_user_prop 71{ 72 typeset user_prop=$1 73 typeset dtst=$2 74 75 typeset source=$(get_source $user_prop $dtst) 76 typeset value=$(get_prop $user_prop $dtst) 77 if [[ $source == '-' && $value == '-' ]]; then 78 return 0 79 else 80 return 1 81 fi 82} 83 84log_assert "'zfs snapshot -o' cannot set properties other than user property." 85log_onexit cleanup 86 87typeset ro_props="type used available avail creation referenced refer compressratio \ 88 mounted origin" 89typeset snap_ro_props="volsize recordsize recsize quota reservation reserv mountpoint \ 90 sharenfs checksum compression compress atime devices exec readonly rdonly \ 91 setuid zoned" 92 93$ZFS upgrade -v > /dev/null 2>&1 94if [[ $? -eq 0 ]]; then 95 snap_ro_props="$snap_ro_props version" 96fi 97 98 99for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do 100 typeset fssnap=$fs@snap 101 prop_name=$(valid_user_property 10) 102 value=$(user_property_value 16) 103 104 log_must eval "$ZFS snapshot -o $prop_name='$value' $fssnap" 105 log_must snapexists $fssnap 106 log_mustnot nonexist_user_prop $prop_name $fssnap 107 108 log_must $ZFS destroy -f $fssnap 109 110 prop_name2=$(valid_user_property 10) 111 value2=$(user_property_value 16) 112 113 log_must eval "$ZFS snapshot -o $prop_name='$value' -o $prop_name2='$value2' $fssnap" 114 log_must snapexists $fssnap 115 log_mustnot nonexist_user_prop $prop_name $fssnap 116 log_mustnot nonexist_user_prop $prop_name2 $fssnap 117 118 log_must $ZFS destroy -f $fssnap 119done 120 121cleanup 122 123prop_name=$(valid_user_property 10) 124value=$(user_property_value 16) 125 126log_must eval "$ZFS snapshot -r -o $prop_name='$value' $TESTPOOL@snap" 127for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do 128 typeset fssnap=$fs@snap 129 log_must snapexists $fssnap 130 log_mustnot nonexist_user_prop $prop_name $fssnap 131done 132 133cleanup 134 135prop_name2=$(valid_user_property 10) 136value2=$(user_property_value 16) 137 138log_must eval "$ZFS snapshot -r -o $prop_name='$value' -o $prop_name2='$value2' $TESTPOOL@snap" 139for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do 140 typeset fssnap=$fs@snap 141 log_must snapexists $fssnap 142 log_mustnot nonexist_user_prop $prop_name $fssnap 143 log_mustnot nonexist_user_prop $prop_name2 $fssnap 144done 145 146log_pass "'zfs snapshot -o' cannot set properties other than user property." 147