zpool_iostat_002_pos.ksh revision f38cb554a534c6df738be3f4d23327e69888e634
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#!/bin/ksh -p
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# CDDL HEADER START
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# The contents of this file are subject to the terms of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Common Development and Distribution License (the "License").
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# You may not use this file except in compliance with the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# or http://www.opensolaris.org/os/licensing.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# See the License for the specific language governing permissions
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# and limitations under the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# When distributing Covered Code, include this CDDL HEADER in each
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# If applicable, add the following below this CDDL HEADER, with the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# fields enclosed by brackets "[]" replaced with your own identifying
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# information: Portions Copyright [yyyy] [name of copyright owner]
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# CDDL HEADER END
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Use is subject to license terms.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Copyright (c) 2013 by Delphix. All rights reserved.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# Verify that 'zpool iostat [interval [count]' can be executed as non-root.
#
# STRATEGY:
# 1. Set the interval to 1 and count to 4.
# 2. Sleep for 4 seconds.
# 3. Verify that the output has 4 records.
#
verify_runnable "both"
typeset tmpfile=/var/tmp/zfsiostat.out.$$
typeset -i stat_count=0
function cleanup
{
if [[ -f $tmpfile ]]; then
$RM -f $tmpfile
fi
}
log_onexit cleanup
log_assert "zpool iostat [pool_name ...] [interval] [count]"
if ! is_global_zone ; then
TESTPOOL=${TESTPOOL%%/*}
fi
$ZPOOL iostat $TESTPOOL 1 4 > $tmpfile 2>&1 &
sleep 4
stat_count=$($GREP $TESTPOOL $tmpfile | $WC -l)
if [[ $stat_count -ne 4 ]]; then
log_fail "zpool iostat [pool_name] [interval] [count] failed"
fi
log_pass "zpool iostat [pool_name ...] [interval] [count] passed"