• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# Runs the bonnie++ test on filesystems...
4
5# Copyright (C) 2003-2006 IBM
6#
7# This program is free software; you can redistribute it and/or
8# modify it under the terms of the GNU General Public License as
9# published by the Free Software Foundation; either version 2 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15# General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20# 02111-1307, USA.
21
22TEST_PID=$$
23
24# Try to find bonnie++ on the system
25BONNIE=`which bonnie++ 2> /dev/null`
26
27if [ -z "$BONNIE" ]; then
28	BONNIE=`ls $POUNDER_OPTDIR/bonnie++*/bonnie++`
29	if [ -z "$BONNIE" ]; then
30		echo "Cannot find bonnie++; did you run Install?"
31		exit -1
32	fi
33fi
34
35# Note old errors
36LOGFILE=/proc/$$/fd/1
37OLD_ERRORS=`egrep -ic "(err|fail|invalid|cannot|denied)" $LOGFILE`
38
39# Now figure out where we have mounted filesystems
40MOUNTS=`egrep "(ext|reiser)" /proc/mounts | awk -F " " '{print $2}'`
41
42rm -rf $POUNDER_TMPDIR/bonnie-script-$TEST_PID
43echo '#/bin/bash' > $POUNDER_TMPDIR/bonnie-script-$TEST_PID
44echo >> $POUNDER_TMPDIR/bonnie-script-$TEST_PID
45
46echo $MOUNTS | sed -e 's/ /\n/g' | while read f; do
47	# Clean out space for bonnie
48	rm -rf "$f/bonnie/"
49
50	# Set up for bonnie
51	mkdir -p "$f/bonnie/"
52
53	# Engage!
54	echo $BONNIE -u 0 -d \"$f/bonnie/\" \& >> $POUNDER_TMPDIR/bonnie-script-$TEST_PID
55done
56
57echo wait >> $POUNDER_TMPDIR/bonnie-script-$TEST_PID
58
59# Are we actually going to start any bonnie's?
60if [ `wc -l < $POUNDER_TMPDIR/bonnie-script-$TEST_PID` -lt 4 ]; then
61	echo "Not running bonnie at all.  Abort."
62	exit -1
63fi
64
65bash $POUNDER_TMPDIR/bonnie-script-$TEST_PID
66rm -rf $POUNDER_TMPDIR/bonnie-script-$TEST_PID
67
68# Clean ourselves up
69echo $MOUNTS | sed -e 's/ /\n/g' | while read f; do
70	# Clean out space for bonnie
71	rm -rf "$f/bonnie/"
72done
73
74# Did we find any new errors?
75NEW_ERRORS=`egrep -ic "(err|fail|invalid|cannot|denied)" $LOGFILE`
76ERRORS=$(( NEW_ERRORS - OLD_ERRORS ))
77if [ $ERRORS -eq 255 ]; then
78        ERRORS=254
79fi
80
81exit $ERRORS
82