Changeset View
Changeset View
Standalone View
Standalone View
tests/sys/devad2/devad2_test.sh
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | native \ No newline at end of property |
svn:executable | null | * \ No newline at end of property |
svn:keywords | null | FreeBSD=%H \ No newline at end of property |
svn:mime-type | null | text/plain \ No newline at end of property |
# | |||||
# Copyright (c) 2014 Spectra Logic Corporation | |||||
# All rights reserved. | |||||
# | |||||
# Redistribution and use in source and binary forms, with or without | |||||
# modification, are permitted provided that the following conditions | |||||
# are met: | |||||
# 1. Redistributions of source code must retain the above copyright | |||||
# notice, this list of conditions, and the following disclaimer, | |||||
# without modification. | |||||
# 2. Redistributions in binary form must reproduce at minimum a disclaimer | |||||
# substantially similar to the "NO WARRANTY" disclaimer below | |||||
# ("Disclaimer") and any redistribution must be conditioned upon | |||||
# including a substantially similar Disclaimer requirement for further | |||||
# binary redistribution. | |||||
# | |||||
# NO WARRANTY | |||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | |||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |||||
# HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |||||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |||||
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |||||
# POSSIBILITY OF SUCH DAMAGES. | |||||
# | |||||
# Authors: Ken Merry (Spectra Logic Corporation) | |||||
# | |||||
# $FreeBSD$ | |||||
# Default list of enclosure prcoessors on expanders. This is a space | |||||
# separated list of just the peripheral name and unit number. e.g.: | |||||
# "enc0 enc1 enc2" | |||||
export EXPANDER_LIST=${EXPANDER_LIST:-enc0} | |||||
# Default runtime. 5 minutes should be long enough to cause a panic if | |||||
# enough disks are available. | |||||
export PHY_CYCLE_RUNTIME=300 | |||||
# The test will take 10 seconds or so to exit after the runtime above | |||||
# expires. This is to insure that the ATF timeout is long enough to allow | |||||
# it to clean up. | |||||
export PHY_CYCLE_TIMEOUT=360 | |||||
# Lookup the geom mode of a disk. Will return something like r1w1e1 | |||||
# $1: geom name of disk. eg "da1" | |||||
get_disk_mode() | |||||
{ | |||||
geom disk list "$1" | awk '/Mode:/ {print $2}' | |||||
} | |||||
run_test() | |||||
{ | |||||
TEST_SECS=$1 | |||||
FREE_PHYDEVS="" | |||||
# Go through the list of expanders and find all of the disks that | |||||
# aren't opened exclusively. Record their expander and PHY number. | |||||
for EXP in ${EXPANDER_LIST} | |||||
do | |||||
PHYDEVS=`camcontrol smpphylist ${EXP} -q | awk ' | |||||
$NF ~ /[(,]da[0-9]+[),]/ { | |||||
match($NF, "da[0-9]+"); | |||||
print $1 "," substr($NF, RSTART, RLENGTH) | |||||
}'` | |||||
for pair in $PHYDEVS; do | |||||
# Exclude disks that are opened in exclusive mode | |||||
# from testing | |||||
# XXX Due to ZFS not opening disks in exclusive mode | |||||
# (BUG25571) this test won't detect disks being used | |||||
# by ZFS, only UFS or other filesystems. | |||||
phy=`echo $pair | cut -d , -f 1` | |||||
dev=`echo $pair | cut -d , -f 2` | |||||
if get_disk_mode $dev | grep -q 'e0'; then | |||||
ENC_PHY="${EXP},${phy}" | |||||
FREE_PHYDEVS="$FREE_PHYDEVS $ENC_PHY" | |||||
fi | |||||
done | |||||
done | |||||
num_freephys=`echo $FREE_PHYDEVS | wc -w` | |||||
if [ $num_freephys -le 0 ]; then | |||||
atf_skip "No PHYs detected on expander ${EXPANDER}, cannot run test" | |||||
fi | |||||
DEVAD_PHYS="" | |||||
for i in ${FREE_PHYDEVS} | |||||
do | |||||
DEVAD_PHYS="$DEVAD_PHYS -p $i" | |||||
done | |||||
SRC_DIR=$(atf_get_srcdir) | |||||
$SRC_DIR/devad2 -t $TEST_SECS $DEVAD_PHYS | |||||
if [ $? -eq 0 ]; then | |||||
atf_pass | |||||
else | |||||
atf_fail "devad2 test had non-zero exit status" | |||||
fi | |||||
} | |||||
atf_test_case phy_cycle_and_read | |||||
phy_cycle_and_read_head() | |||||
{ | |||||
EXP_REQ="" | |||||
for i in ${EXPANDER_LIST} | |||||
do | |||||
EXP_REQ="$EXP_REQ /dev/${i}" | |||||
done | |||||
atf_set "descr" "Test that cycles PHYs and reads for 5 minutes" | |||||
atf_set "require.files" "${EXP_REQ}" | |||||
atf_set "require.user" "root" | |||||
atf_set "require.config" "allow_devfs_side_effects" | |||||
atf_set "timeout" $PHY_CYCLE_TIMEOUT | |||||
} | |||||
phy_cycle_and_read_body() | |||||
{ | |||||
run_test $PHY_CYCLE_RUNTIME | |||||
} | |||||
# | |||||
# ATF Test Program Initialization | |||||
# | |||||
atf_init_test_cases() | |||||
{ | |||||
atf_add_test_case phy_cycle_and_read | |||||
} |