blob: 5fcd24f3dcc68253e17eb2d37ed386f64464d398 [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):
27 if not dir:
28 dir = self.tmpdir
mbligh548ace82006-10-19 14:36:45 +000029 os.chdir(dir)
30 if not args:
31 args = '-a'
mbligh9f5113d2007-06-25 23:41:10 +000032 profilers = self.job.profilers
33 if not profilers.only():
mbligh6303ed62007-07-19 16:19:16 +000034 for i in range(iterations):
35 system('%s/src/current/iozone %s' %
36 (self.srcdir, args))
mbligh548ace82006-10-19 14:36:45 +000037
38 # Do a profiling run if necessary
mbligh548ace82006-10-19 14:36:45 +000039 if profilers.present():
40 profilers.start(self)
41 system('%s/src/current/iozone %s' % (self.srcdir, args))
42 profilers.stop(self)
43 profilers.report(self)
mbligh6303ed62007-07-19 16:19:16 +000044
45 self.__format_results(open(self.debugdir + '/stdout').read())
46
47
48 def __format_results(self, results):
49 labels = ('write', 'rewrite', 'read', 'reread', 'randread',
50 'randwrite', 'bkwdread', 'recordrewrite',
51 'strideread', 'fwrite', 'frewrite',
52 'fread', 'freread')
53 out = open(self.resultsdir + '/keyval', 'w')
54 for line in results.split('\n'):
55 fields = line.split()
56 if len(fields) != 15:
57 continue
58 try:
59 fields = tuple([int(i) for i in fields])
60 except ValueError:
61 continue
62 for l, v in zip(labels, fields[2:]):
63 print >> out, "%d-%d-%s=%d" % (fields[0], fields[1], l, v)
64 print >> out
65 out.close()