7290 ZFS test suite needs to control what utilities it can run
[unleashed.git] / usr / src / test / zfs-tests / tests / functional / cli_root / zfs_set / ro_props_001_pos.ksh
blob0c4124a8316748e772dd1fac2680f1ee4d6c4886
1 #!/bin/ksh -p
3 # CDDL HEADER START
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.
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.
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]
20 # CDDL HEADER END
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
27 # Copyright (c) 2016 by Delphix. All rights reserved.
30 . $STF_SUITE/include/libtest.shlib
31 . $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib
34 # DESCRIPTION:
35 # Verify that read-only properties are immutable.
36 # Note that we can only check properties that have no possibility of
37 # changing while we are running (which excludes e.g. "available").
39 # STRATEGY:
40 # 1. Create pool, fs, vol, fs@snap & vol@snap.
41 # 2. Get the original property value and set value to those properties.
42 # 3. Check return value.
43 # 4. Compare the current property value with the original one.
46 verify_runnable "both"
48 set -A values filesystem volume snapshot -3 0 1 50K 10G 80G \
49 2005/06/17 30K 20x yes no \
50 on off default pool/fs@snap $TESTDIR
51 set -A dataset $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \
52 $TESTPOOL/$TESTCTR/$TESTFS1 $TESTPOOL/$TESTFS@$TESTSNAP \
53 $TESTPOOL/$TESTVOL@$TESTSNAP
54 typeset ro_props="type used creation referenced refer compressratio \
55 mounted origin"
56 typeset snap_ro_props="volsize recordsize recsize quota reservation reserv mountpoint \
57 sharenfs checksum compression compress atime devices exec readonly rdonly \
58 setuid zoned"
60 zfs upgrade -v > /dev/null 2>&1
61 if [[ $? -eq 0 ]]; then
62 snap_ro_props="$snap_ro_props version"
65 function cleanup
67 datasetexists $TESTPOOL/$TESTVOL@$TESTSNAP && \
68 destroy_snapshot $TESTPOOL/$TESTVOL@$TESTSNAP
69 datasetexists $TESTPOOL/$TESTFS@$TESTSNAP && \
70 destroy_snapshot $TESTPOOL/$TESTFS@$TESTSNAP
73 log_assert "Verify that read-only properties are immutable."
74 log_onexit cleanup
76 # Create filesystem and volume's snapshot
77 create_snapshot $TESTPOOL/$TESTFS $TESTSNAP
78 create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP
80 typeset -i i=0
81 typeset -i j=0
82 typeset cur_value=""
83 typeset props=""
85 while (( i < ${#dataset[@]} )); do
86 props=$ro_props
88 dst_type=$(get_prop type ${dataset[i]})
89 if [[ $dst_type == 'snapshot' ]]; then
90 props="$ro_props $snap_ro_props"
93 for prop in $props; do
94 cur_value=$(get_prop $prop ${dataset[i]})
96 j=0
97 while (( j < ${#values[@]} )); do
99 # If the current property value is equal to values[j],
100 # just expect it failed. Otherwise, set it to dataset,
101 # expecting it failed and the property value is not
102 # equal to values[j].
104 if [[ $cur_value == ${values[j]} ]]; then
105 log_mustnot zfs set $prop=${values[j]} \
106 ${dataset[i]}
107 else
108 set_n_check_prop ${values[j]} $prop \
109 ${dataset[i]} false
111 (( j += 1 ))
112 done
113 done
114 (( i += 1 ))
115 done
117 log_pass "Setting uneditable properties should failed. It passed."