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 / version_001_neg.ksh
blobcf5ef5116e904dd5f1f6855fa99bbf173eaa5241
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 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/include/libtest.shlib
33 . $STF_SUITE/tests/functional/cli_root/zfs_upgrade/zfs_upgrade.kshlib
36 # DESCRIPTION:
37 # Valid version values should be positive integers only.
39 # STRATEGY:
40 # 1) Form an array of invalid reservation values (negative and
41 # incorrectly formed)
42 # 2) Attempt to set each invalid version value in turn on a
43 # filesystem and volume.
44 # 3) Verify that attempt fails and the version value remains
45 # unchanged
48 verify_runnable "both"
50 log_assert "Verify invalid version values are rejected"
52 typeset values=('' '-1' '-1.0' '-1.8' '-9999999999999999' \
53 '0x1' '0b' '1b' '1.1b' '0' '0.000' '1.234')
56 # Function to loop through a series of bad reservation
57 # values, checking they are when we attempt to set them
58 # on a dataset.
60 function set_n_check # data-set
62 typeset obj=$1
63 typeset -i i=0
64 typeset -i j=0
66 orig_val=$(get_prop version $obj)
68 while (($i < ${#values[*]})); do
69 zfs set version=${values[$i]} $obj > /dev/null 2>&1
70 if [[ $? -eq 0 ]]; then
71 log_note "zfs set version=${values[$i]} $obj"
72 log_fail "The above version set returned 0!"
75 new_val=$(get_prop version $obj)
77 if [[ $new_val != $orig_val ]]; then
78 log_fail "$obj : version values changed " \
79 "($orig_val : $new_val)"
82 ((i = i + 1))
83 done
86 for dataset in $TESTPOOL/$TESTFS $TESTPOOL/$TESTCTR $TESTPOOL/$TESTVOL
88 set_n_check $dataset
89 done
91 log_pass "Invalid version values correctly rejected"