File: [Development] / xfs-cmds / xfstests / bench (download)
Revision 1.2, Wed Sep 18 08:03:37 2002 UTC (15 years, 1 month ago) by fsgqa
Branch: MAIN
Changes since 1.1: +22 -17
lines
trivial updates to get more bits to work together.
|
#!/bin/sh
#
# Wrapper for automating benchmarking runs.
# Usage: bench [passes] [user] [group] [script]
#
# ..where passes is the number of times to run each script; uid/gid
# gives credentials to use when running the script; and script is a
# simple wrapper around each actual benchmark tool (eg. see run.*),
# if this is ommited, all run.* scripts are used in turn.
#
# Each run.foo script should report a comma-separated-value list of
# benchmark results on stdout or fail with a non-zero exit code;
# unless the -i option is supplied in which case it should instead
# report a comma-separated-value list of column headers (for report
# generation purposes).
#
#-----------------------------------------------------------------------
# Copyright (c) 2002 Silicon Graphics, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Further, this software is distributed without any warranty that it is
# free of the rightful claim of any third person regarding infringement
# or the like. Any license provided herein, whether implied or
# otherwise, applies only to this software file. Patent licenses, if
# any, provided herein do not apply to combinations of this program with
# other software, or any other product whatsoever.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write the Free Software Foundation, Inc., 59
# Temple Place - Suite 330, Boston MA 02111-1307, USA.
#
# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
# Mountain View, CA 94043, or:
#
# http://www.sgi.com
#
# For further information regarding this notice, see:
#
# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
#-----------------------------------------------------------------------
#
# creator
owner=nathans@sgi.com
tmp=/tmp/$$
seq=bench
here=`pwd`
status=1 # failure is the default!
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
_cleanup()
{
echo " *** umount"
umount $SCRATCH_DEV >/dev/null 2>&1
}
trap "_cleanup; exit \$status" 0 1 2 3 15
ROOT="."
LOG="$ROOT/bench.log"
FULL="$ROOT/bench.full"
_log()
{
echo "$*" 1>&2
echo "$*" >>$LOG
echo "$*" >>$FULL
sync
}
_logp()
{
tee -a $FULL
}
_fail()
{
_log "$*"
status=1
exit 1
}
_run_benchmark()
{
pass=1
uid=`id -u $user`
gid=`id -g $group`
while [ $pass -le $passes -o $passes -lt 0 ]
do
_log " *** clean scratch device [$bench starting, pass $pass]"
mkfs_xfs -f $SCRATCH_DEV 2>&1 | _fix_malloc >>$FULL \
|| _fail " !!! failed to mkfs SCRATCH_DEV"
_log " *** mounting scratch device"
mount -t xfs $SCRATCH_DEV $SCRATCH_MNT \
|| _fail " !!! failed to mount"
_log " *** mkdir"
mkdir $SCRATCH_MNT/bench \
|| _fail " !!! couldn't mkdir benchdir"
chown -R $user.$group $SCRATCH_MNT/bench \
|| _fail " !!! couldn't chown benchdir"
cd $SCRATCH_MNT/bench
_log " *** bench [src/runas -u $uid -g $gid run.$bench]"
$here/src/runas -u $uid -g $gid $here/run.$bench | _logp
[ $? -eq 0 ] || _fail " !!! non-zero $bench status"
cd $here
_log " *** unmounting scratch device"
umount $SCRATCH_DEV 2>&1 | _logp \
|| _fail " !!! failed to umount"
_log " *** post-umount filesystem check"
_check_fs $SCRATCH_DEV
let "pass = pass + 1"
done
}
# real QA test starts here
_require_scratch
passes=-1
user=root
group=root
benches=`echo run.* | sed -e 's/run\.//g'`
[ $# -gt 0 ] && passes=$1
[ $# -gt 1 ] && user=$2
[ $# -gt 2 ] && group=$3
[ $# -gt 3 ] && benches=$4
[ -z "$benches" -o "$benches" = "*" ] && _fail "no benchmark scripts found"
for bench in $benches
do
echo "" >$FULL
echo "" >$LOG
_log "*** benchmark started (passes=$passes, benchmark=$bench)"
_log "*** (`date`)"
_log " *** unmounting scratch device"
umount $SCRATCH_DEV 2>&1 | _fix_malloc >>$FULL
_run_benchmark | _fix_malloc
_log "*** done $bench"
done
status=0