blob: ee656e65923f3dcad2b864d7395431fa1b8c48f0 [file] [log] [blame]
mbligh548ace82006-10-19 14:36:45 +00001#!/usr/bin/python
mbligh9f857922008-06-05 16:19:07 +00002import os
3from autotest_lib.client.bin import test, autotest_utils
4from autotest_lib.client.common_lib import utils
mbligh548ace82006-10-19 14:36:45 +00005
mbligh548ace82006-10-19 14:36:45 +00006
7class iozone(test.test):
jadmanski0afbb632008-06-06 21:10:57 +00008 version = 1
mbligh548ace82006-10-19 14:36:45 +00009
mblighc5ddfd12008-08-04 17:15:00 +000010 def initialize(self):
11 self.job.require_gcc()
12
13
jadmanski0afbb632008-06-06 21:10:57 +000014 # http://www.iozone.org/src/current/iozone3_283.tar
15 def setup(self, tarball = 'iozone3_283.tar'):
mbligh8b352852008-06-07 01:07:08 +000016 tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
jadmanski0afbb632008-06-06 21:10:57 +000017 autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
18 os.chdir(os.path.join(self.srcdir, 'src/current'))
mbligh548ace82006-10-19 14:36:45 +000019
jadmanski0afbb632008-06-06 21:10:57 +000020 arch = autotest_utils.get_current_kernel_arch()
21 if (arch == 'ppc'):
22 utils.system('make linux-powerpc')
23 elif (arch == 'ppc64'):
24 utils.system('make linux-powerpc64')
25 elif (arch == 'x86_64'):
26 utils.system('make linux-AMD64')
27 else:
28 utils.system('make linux')
mbligh548ace82006-10-19 14:36:45 +000029
mbligh1f337612007-09-30 01:19:47 +000030
jadmanski0afbb632008-06-06 21:10:57 +000031 def execute(self, dir = None, iterations=1, args = None):
mbligh8b352852008-06-07 01:07:08 +000032 self.keyval = open(os.path.join(self.resultsdir, 'keyval'), 'w')
jadmanski0afbb632008-06-06 21:10:57 +000033 if not dir:
34 dir = self.tmpdir
35 os.chdir(dir)
36 if not args:
37 args = '-a'
38 profilers = self.job.profilers
39 if not profilers.only():
40 for i in range(iterations):
41 output = utils.system_output('%s/src/current/iozone %s' %
42 (self.srcdir, args))
43 self.__format_results(output)
mbligh548ace82006-10-19 14:36:45 +000044
jadmanski0afbb632008-06-06 21:10:57 +000045 # Do a profiling run if necessary
46 if profilers.present():
47 profilers.start(self)
48 output = utils.system_output('%s/src/current/iozone %s' %
49 (self.srcdir, args))
50 self.__format_results(output)
51 profilers.stop(self)
52 profilers.report(self)
mbligheea785f2008-01-25 16:39:11 +000053
jadmanski0afbb632008-06-06 21:10:57 +000054 self.keyval.close()
mbligh6303ed62007-07-19 16:19:16 +000055
56
jadmanski0afbb632008-06-06 21:10:57 +000057 def __format_results(self, results):
58 labels = ('write', 'rewrite', 'read', 'reread', 'randread',
59 'randwrite', 'bkwdread', 'recordrewrite',
mbligh8b352852008-06-07 01:07:08 +000060 'strideread', 'fwrite', 'frewrite', 'fread', 'freread')
jadmanski0afbb632008-06-06 21:10:57 +000061 for line in results.splitlines():
62 fields = line.split()
63 if len(fields) != 15:
64 continue
65 try:
66 fields = tuple([int(i) for i in fields])
67 except ValueError:
68 continue
69 for l, v in zip(labels, fields[2:]):
70 print >> self.keyval, "%d-%d-%s=%d" % (fields[0], fields[1], l, v)
71 print >> self.keyval