xfstests: Fix some file permission.
[xfstests-dev.git] / run.bonnie_ops
1 #!/bin/bash
2 #
3 # Copyright (c) 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it would be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write the Free Software Foundation,
16 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 #
18
19 # Do a bonnie++ create/read/delete run using 8192 files (unless
20 # BONNIE_KFILES environment variable is set -- note this number
21 # is multiplied by 1024 by bonnie++).  By default the files are
22 # created in the same directory, BONNIE_NDIRS specifies a count
23 # of subdirs to evenly spread files through.  Regular files are
24 # created by default (BONNIE_FILETYPE=regular), alternatively
25 # the values "symlinks" and "hardlinks" can be used.
26
27 # The script then massages the output into CSV format with the
28 # human-readable output preceding it as a "comment" (#-prefixed).
29
30 BONNIE_NDIRS=${BONNIE_NDIRS:=1}
31 BONNIE_KFILES=${BONNIE_KFILES:=8}
32 BONNIE_FILETYPE=${BONNIE_FILETYPE:=regular}
33
34 [ -z "$here" ] && here=`pwd`
35 . $here/common.bonnie
36
37
38 # Sample bonnie throughput output (stderr):
39 #Version 1.02c       ------Sequential Create------ --------Random Create--------
40 #                    -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
41 #              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
42 #                  4   525  27 +++++ +++   517  26   526  25 +++++ +++   230  12
43 # [ Note: the "files" can also be "^files:max" and possibly other things ]
44 filter_stderr()
45 {
46         sed -e 's/^..................../# /g' | awk '{print} END {print "#"}'
47 }
48
49
50 # Sample bonnie IOPs output (stdout):
51 # ",,,,,,,,,,,,,,4,525,27,+++++,+++,517,26,526,25,+++++,+++,230,12"
52 # [ nathans note: always get +++ due to 0:0 for min:max file sizes. ]
53 # [ I will need to fix the filter if I ever start using file sizes. ]
54
55 filter_stdout()
56 {
57         perl -ne '
58                 chomp;
59                 s/\+*//g; s/,+/,/g; s/^,//; s/,$//;
60                 @values = split /,/;
61                 printf "%9s", 1024 * shift @values;
62                 for ($i = 0; $i <= $#values; $i++) {
63                         if ($i % 2) { printf ",%4s%%", $values[$i] }
64                         else        { printf ",%10s", $values[$i] }
65                 }
66                 printf "\n";
67         '
68 }
69
70 if [ $# -gt 0 ]; then
71         printf "%9s,%10s,%5s,%10s,%5s,%10s,%5s,%10s,%5s\n" files \
72                 seqCR/s scCPU seqRM/s srCPU randCR/s rcCPU randRM/s rrCPU
73         exit 0
74 fi
75
76 case "$BONNIE_FILETYPE"
77 in
78         regular)  BONNIE_FILETYPE=0 ;;
79         symlink)  BONNIE_FILETYPE=-2 ;;
80         hardlink) BONNIE_FILETYPE=-1 ;;
81         *)  echo "BONNIE_FILETYPE has an unrecognised value" && exit 1 ;;
82 esac
83
84 run_bonnie -s 0 -n $BONNIE_KFILES:$BONNIE_FILETYPE:0:$BONNIE_NDIRS