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 2007 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)reservation_001_neg.ksh 1.2 07/01/09 SMI" 30# 31 32. $STF_SUITE/include/libtest.kshlib 33. $STF_SUITE/tests/reservation/reservation.kshlib 34 35############################################################################### 36# 37# __stc_assertion_start 38# 39# ID: reservation_001_neg 40# 41# DESCRIPTION: 42# Valid reservation 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 reservation value in turn on a 48# filesystem and volume. 49# 3) Verify that attempt fails and the reservation value remains 50# unchanged 51# 52# TESTABILITY: explicit 53# 54# TEST_AUTOMATION_LEVEL: automated 55# 56# CODING_STATUS: COMPLETED (2005-07-04) 57# 58# __stc_assertion_end 59# 60################################################################################ 61 62verify_runnable "both" 63 64log_assert "Verify invalid reservation values are rejected" 65 66set -A suffix "b" "k" "m" "t" "p" "e" "K" "M" "G" "T" "P" "E" "kb" "Mb" "Gb" \ 67 "Tb" "Pb" "Eb" "KB" "MB" "GB" "TB" "PB" "EB" 68 69set -A values '' '-1' '-1.0' '-1.8' '-9999999999999999' '0x1' '0b' '1b' '1.1b' 70 71# 72# Function to loop through a series of bad reservation 73# values, checking they are when we attempt to set them 74# on a dataset. 75# 76function set_n_check # data-set 77{ 78 typeset obj=$1 79 typeset -i i=0 80 typeset -i j=0 81 82 orig_resv_val=$(get_prop reservation $obj) 83 84 while (( $i < ${#values[*]} )); do 85 j=0 86 while (( $j < ${#suffix[*]} )); do 87 88 $ZFS set \ 89 reservation=${values[$i]}${suffix[$j]} $obj \ 90 > /dev/null 2>&1 91 if [ $? -eq 0 ] 92 then 93 log_note "$ZFS set \ 94 reservation=${values[$i]}${suffix[$j]} $obj" 95 log_fail "The above reservation set returned 0!" 96 fi 97 98 new_resv_val=$(get_prop reservation $obj) 99 100 if [[ $new_resv_val != $orig_resv_val ]]; then 101 log_fail "$obj : reservation values changed " \ 102 "($orig_resv_val : $new_resv_val)" 103 fi 104 (( j = j + 1 )) 105 done 106 107 (( i = i + 1 )) 108 done 109} 110 111for dataset in $TESTPOOL/$TESTFS $TESTPOOL/$TESTCTR $TESTPOOL/$TESTVOL 112do 113 set_n_check $dataset 114done 115 116log_pass "Invalid reservation values correctly rejected" 117