From e670d760cabbe7f2f3e992d0df9881a7366cc8a3 Mon Sep 17 00:00:00 2001 From: shadow Date: Mon, 4 Aug 2008 06:36:02 +0000 Subject: [PATCH] simplify dbench test. more flexibility for find clients.txt b=15608 i=adilger i=grev --- lustre/tests/rundbench | 68 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a/lustre/tests/rundbench b/lustre/tests/rundbench index 40a8fde..ce51eaf 100755 --- a/lustre/tests/rundbench +++ b/lustre/tests/rundbench @@ -1,20 +1,66 @@ #!/bin/sh + +usage() { + echo "-C use chroot instead of cd" + echo "-D DIR - use 'DIR' as work directory" + echo + exit; +} + MOUNT=${MOUNT:-/mnt/lustre} DIR=${DIR:-$MOUNT/`hostname`} -#[ -e /proc/sys/lnet/debug ] && echo 0 > /proc/sys/lnet/debug + +PREFIX="on" +while getopts "CD:" opt $*; do + case $opt in + D) [ -d $OPTARG ] && DIR=$OPTARG ;; + C) CHROOT="yes" ;; + \?) usage ;; + esac +done + mkdir -p $DIR TGT=$DIR/client.txt -DBENCH_LIB=${DBENCH_LIB:-/usr/share/dbench} -SRC=${SRC:-$DBENCH_LIB/client.txt} -[ ! -s $TGT -a -s $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT -SRC=${SRC:-/usr/lib/dbench/client.txt} -[ ! -s $TGT -a -s $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT -SRC=/usr/lib/dbench/client_plain.txt -[ ! -s $TGT -a -s $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT -[ ! -s $TGT ] && echo "$0: $TGT doesn't exist (SRC=$SRC)" && exit 1 +CLIENT_PREFIX="${DBENCH_LIB} /usr/share/dbench /usr/local/share /usr/lib/dbench" +CLIENT_FILE="client.txt client_plain.txt dbench_client" +which dbench > /dev/null 2>&1 || { echo "dbench not installed, skip this test" && return 0; } +CLIENT="" + +for prefix in $CLIENT_PREFIX; do + for file in $CLIENT_FILE; do + if [ -s "${prefix}/${file}" ]; then + CLIENT="${prefix}/${file}"; + break; + fi + done + [ "x$CLIENT" != "x" ] && break; +done + +if [ -n "$SRC" -a -s "$SRC" ]; then + CLIENT=${SRC} +fi + +[ ! -s "$TGT" -a -n "$CLIENT" -a -s "$CLIENT" ] && echo "copying $CLIENT to $TGT" && cp $CLIENT $TGT +[ ! -s "$TGT" ] && echo "$0: $TGT doesn't exist (SRC=$CLIENT)" && exit 1 + +if [ "x$CHROOT" == "xyes" ]; then + echo "copying necessary libs to $DIR" + cp `which dbench` $DIR + LIBS71=$(ldd $DIR/dbench|sed -e 's/\t*//' -e 's/.*=> //' -e 's/ .*//' -e 's/^\///') + (cd / && tar chf - $LIBS71) | (cd $DIR && tar xvf -) + [ $? = 0 ] && ( echo "can't copy libs $LIBS71 to $DIR" && exit 1 ) + RUN="chroot $DIR" + PREFIX="in" + PATH=.:/:$PATH +fi + +shift $((OPTIND - 1)) + cd $DIR -echo "running 'dbench $@' on $PWD at `date`" -dbench -c client.txt $@ +echo "running 'dbench $@' $PREFIX $PWD at `date`" +$RUN dbench -c client.txt $@ RC=$? [ $RC -ne 0 ] && killall -9 dbench + +rm -rf dbench $LIBS71 client.txt exit $RC -- 1.8.3.1