blob: c3d61f8305eb1eaf123643aa60c3c61f62f5ce1c [file] [log] [blame]
mbligh548ace82006-10-19 14:36:45 +00001#!/usr/bin/python
2
3import test
4from autotest_utils import *
5
6class iozone(test.test):
7 version = 1
8
mbligh920f4122007-07-09 21:43:39 +00009 # http://www.iozone.org/src/current/iozone3_283.tar
10 def setup(self, tarball = 'iozone3_283.tar'):
mbligh548ace82006-10-19 14:36:45 +000011 tarball = unmap_url(self.bindir, tarball, self.tmpdir)
12 extract_tarball_to_dir(tarball, self.srcdir)
13 os.chdir(os.path.join(self.srcdir, 'src/current'))
14
15 arch = get_current_kernel_arch()
16 if (arch == 'ppc'):
17 system('make linux-powerpc')
18 elif (arch == 'ppc64'):
19 system('make linux-powerpc64')
20 elif (arch == 'x86_64'):
21 system('make linux-AMD64')
22 else:
23 system('make linux')
24
mbligh1f337612007-09-30 01:19:47 +000025
26 def execute(self, dir = None, iterations=1, args = None):
mbligheea785f2008-01-25 16:39:11 +000027 self.keyval = open(os.path.join(self.resultsdir, 'keyval'),
28 'w')
mbligh1f337612007-09-30 01:19:47 +000029 if not dir:
30 dir = self.tmpdir
mbligh548ace82006-10-19 14:36:45 +000031 os.chdir(dir)
32 if not args:
33 args = '-a'
mbligh9f5113d2007-06-25 23:41:10 +000034 profilers = self.job.profilers
35 if not profilers.only():
mbligh6303ed62007-07-19 16:19:16 +000036 for i in range(iterations):
mbligheea785f2008-01-25 16:39:11 +000037 output = system_output('%s/src/current/iozone %s' %
38 (self.srcdir, args))
39 self.__format_results(output)
mbligh548ace82006-10-19 14:36:45 +000040
41 # Do a profiling run if necessary
mbligh548ace82006-10-19 14:36:45 +000042 if profilers.present():
43 profilers.start(self)
mbligheea785f2008-01-25 16:39:11 +000044 output = system_output('%s/src/current/iozone %s' %
45 (self.srcdir, args))
46 self.__format_results(output)
mbligh548ace82006-10-19 14:36:45 +000047 profilers.stop(self)
48 profilers.report(self)
mbligheea785f2008-01-25 16:39:11 +000049
50 self.keyval.close()
mbligh6303ed62007-07-19 16:19:16 +000051
52
53 def __format_results(self, results):
54 labels = ('write', 'rewrite', 'read', 'reread', 'randread',
55 'randwrite', 'bkwdread', 'recordrewrite',
56 'strideread', 'fwrite', 'frewrite',
57 'fread', 'freread')
mbligheea785f2008-01-25 16:39:11 +000058 for line in results.splitlines():
mbligh6303ed62007-07-19 16:19:16 +000059 fields = line.split()
60 if len(fields) != 15:
61 continue
62 try:
63 fields = tuple([int(i) for i in fields])
64 except ValueError:
65 continue
66 for l, v in zip(labels, fields[2:]):
mbligheea785f2008-01-25 16:39:11 +000067 print >> self.keyval, "%d-%d-%s=%d" % (fields[0], fields[1], l, v)
68 print >> self.keyval