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