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