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