#!/bin/ksh
#
# Start parallell streaming read tests on multiple disks
# When used with the "-a" option, autodetect all disks on a specific
# controller, for example: disktest -a c0
#
# Author: Peter Eriksson <pen@lysator.liu.se>, 2003-12-02
#

# Modify the path below...
PCOPY=/usr/local/bin/pcopy

if [ "$1" = "-a" ]; then
    shift

    if [ "$1" = "" ]; then
	MATCH="c"
    else
	MATCH="$1"
    fi
    DISKS="`( echo 0 ; echo quit ) | (format 2>/dev/null) | fgrep \". ${MATCH}\" | awk '{printf \"%ss2 \", $2}'`"

elif [ "$1" != "" ]; then
    DISKS="$*"

else
    echo "Usage: disktest [-a] disks"
    exit 1
fi

n=0

onintr() {
	echo "\n*** INTERRUPT recevied - aborting...\c"
	pkill -P $$
	wait
	echo " Done."
	exit 1
}

trap onintr INT

echo "Starting concurrent test on: $DISKS"

while true; do
	(( n = n + 1 ))
	for D in $DISKS; do
		$PCOPY -s /dev/rdsk/$D /dev/null &
	done
	echo "Pass $n started at `date`"
	wait
done

exit 0

