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# 24# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26 27. $STF_SUITE/include/libtest.kshlib 28. $STF_SUITE/tests/cli_root/zfs_upgrade/zfs_upgrade.kshlib 29 30############################################################################### 31# 32# __stc_assertion_start 33# 34# ID: version_001_neg 35# 36# DESCRIPTION: 37# Valid version values should be positive integers only. 38# 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 46# 47# TESTABILITY: explicit 48# 49# TEST_AUTOMATION_LEVEL: automated 50# 51# CODING_STATUS: COMPLETED (2007-06-27) 52# 53# __stc_assertion_end 54# 55################################################################################ 56 57verify_runnable "both" 58 59if ! fs_prop_exist "version" ; then 60 log_unsupported "version is not supported by this release." 61fi 62 63log_assert "Verify invalid version values are rejected" 64 65set -A values '' '-1' '-1.0' '-1.8' '-9999999999999999' \ 66 '0x1' '0b' '1b' '1.1b' '0' '0.000' '1.234' 67 68# 69# Function to loop through a series of bad reservation 70# values, checking they are when we attempt to set them 71# on a dataset. 72# 73function set_n_check # data-set 74{ 75 typeset obj=$1 76 typeset -i i=0 77 typeset -i j=0 78 79 orig_val=$(get_prop version $obj) 80 81 while (( $i < ${#values[*]} )); do 82 $ZFS set version=${values[$i]} $obj > /dev/null 2>&1 83 if [[ $? -eq 0 ]]; then 84 log_note "$ZFS set version=${values[$i]} $obj" 85 log_fail "The above version set returned 0!" 86 fi 87 88 new_val=$(get_prop version $obj) 89 90 if [[ $new_val != $orig_val ]]; then 91 log_fail "$obj : version values changed " \ 92 "($orig_val : $new_val)" 93 fi 94 95 (( i = i + 1 )) 96 done 97} 98 99for dataset in $TESTPOOL/$TESTFS $TESTPOOL/$TESTCTR $TESTPOOL/$TESTVOL 100do 101 set_n_check $dataset 102done 103 104log_pass "Invalid version values correctly rejected" 105