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 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27. $STF_SUITE/include/libtest.shlib 28 29# 30# DESCRIPTION: 31# Executing 'zpool online' with valid parameters succeeds. 32# 33# STRATEGY: 34# 1. Create an array of correctly formed 'zpool online' options 35# 2. Execute each element of the array. 36# 3. Verify use of each option is successful. 37# 38 39verify_runnable "global" 40 41DISKLIST=$(get_disklist $TESTPOOL) 42 43set -A args "" 44 45function cleanup 46{ 47 # 48 # Ensure we don't leave disks in temporary online state (-t) 49 # 50 for disk in $DISKLIST; do 51 log_must $ZPOOL online $TESTPOOL $disk 52 check_state $TESTPOOL $disk "online" 53 if [[ $? != 0 ]]; then 54 log_fail "Unable to online $disk" 55 fi 56 57 done 58} 59 60log_assert "Executing 'zpool online' with correct options succeeds" 61 62log_onexit cleanup 63 64if [[ -z $DISKLIST ]]; then 65 log_fail "DISKLIST is empty." 66fi 67 68typeset -i i=0 69 70for disk in $DISKLIST; do 71 i=0 72 while [[ $i -lt ${#args[*]} ]]; do 73 log_must $ZPOOL offline $TESTPOOL $disk 74 check_state $TESTPOOL $disk "offline" 75 if [[ $? != 0 ]]; then 76 log_fail "$disk of $TESTPOOL did not match offline state" 77 fi 78 79 log_must $ZPOOL online ${args[$i]} $TESTPOOL $disk 80 check_state $TESTPOOL $disk "online" 81 if [[ $? != 0 ]]; then 82 log_fail "$disk of $TESTPOOL did not match online state" 83 fi 84 85 (( i = i + 1 )) 86 done 87done 88 89log_note "Issuing repeated 'zpool online' commands succeeds." 90 91typeset -i iters=20 92typeset -i index=0 93 94for disk in $DISKLIST; do 95 i=0 96 while [[ $i -lt $iters ]]; do 97 index=`expr $RANDOM % ${#args[*]}` 98 log_must $ZPOOL online ${args[$index]} $TESTPOOL $disk 99 check_state $TESTPOOL $disk "online" 100 if [[ $? != 0 ]]; then 101 log_fail "$disk of $TESTPOOL did not match online state" 102 fi 103 104 (( i = i + 1 )) 105 done 106done 107 108log_pass "'zpool online' with correct options succeeded" 109