• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Needs autoconf & automake & libtool to be installed. Ewwwwwwwwwwwwwwwwwwwwww
2import re, os
3from autotest_lib.client.bin import test, utils, os_dep
4
5
6class reaim(test.test):
7    version = 1
8
9    # http://prdownloads.sourceforge.net/re-aim-7/osdl-aim-7.0.1.13.tar.gz
10    def setup(self, tarball = 'osdl-aim-7.0.1.13.tar.gz'):
11        tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
12        utils.extract_tarball_to_dir(tarball, self.srcdir)
13
14        self.job.setup_dep(['libaio'])
15        libs = '-L' + self.autodir + '/deps/libaio/lib -laio'
16        cflags = '-I ' + self.autodir + '/deps/libaio/include'
17        var_libs = 'LIBS="' + libs + '"'
18        var_cflags  = 'CFLAGS="' + cflags + '"'
19        self.make_flags = var_libs + ' ' + var_cflags
20
21        os_dep.commands('autoconf', 'automake', 'libtoolize')
22        os.chdir(self.srcdir)
23        utils.system('./bootstrap')
24        utils.system('./configure')
25        # we can't use patch here, as the Makefile is autogenerated
26        # so we can't tell exactly what it looks like.
27        # Perform some foul in-place sed hackery instead.
28        for file in ('Makefile', 'src/Makefile'):
29            utils.system('sed -i "s/^CFLAGS =/CFLAGS +=/" ' + file)
30            utils.system('sed -i "s/^LIBS =/LIBS +=/" ' + file)
31        utils.system(self.make_flags + ' make')
32        os.rename('src/reaim', 'reaim')
33
34
35    def initialize(self):
36        self.job.require_gcc()
37        self.ldlib = 'LD_LIBRARY_PATH=%s/deps/libaio/lib'%(self.autodir)
38
39
40    def execute(self, iterations = 1, workfile = 'workfile.short',
41                    start = 1, end = 10, increment = 2,
42                    extra_args = '', tmpdir = None):
43        if not tmpdir:
44            tmpdir = self.tmpdir
45
46        # -f workfile
47        # -s <number of users to start with>
48        # -e <number of users to end with>
49        # -i <number of users to increment>
50        workfile = os.path.join('data', workfile)
51        args = "-f %s -s %d -e %d -i %d" % (workfile, start, end, increment)
52        config = os.path.join(self.srcdir, 'reaim.config')
53        utils.system('cp -f %s/reaim.config %s' % (self.bindir, config))
54        args += ' -c ./reaim.config'
55        open(config, 'a+').write("DISKDIR %s\n" % tmpdir)
56        os.chdir(self.srcdir)
57        cmd = self.ldlib + ' ./reaim ' + args + ' ' + extra_args
58
59        results = []
60
61        profilers = self.job.profilers
62        if not profilers.only():
63            for i in range(iterations):
64                results.append(utils.system_output(cmd, retain_output=True))
65
66        # Do a profiling run if necessary
67        if profilers.present():
68            profilers.start(self)
69            results.append(utils.system_output(cmd, retain_output=True))
70            profilers.stop(self)
71            profilers.report(self)
72
73        self.__format_results("\n".join(results))
74
75
76    def __format_results(self, results):
77        out = open(self.resultsdir + '/keyval', 'w')
78        for line in results.split('\n'):
79            m = re.match('Max Jobs per Minute (\d+)', line)
80            if m:
81                max_jobs_per_min = m.group(1)
82            if re.match(r"^[0-9\. ]+$", line):
83                fields = line.split()
84        out.write("""\
85max_jobs_per_min=%s
86num_forked=%s
87parent_time=%s
88child_systime=%s
89child_utime=%s
90jobs_min=%s
91jobs_min_child=%s
92std_dev_time=%s
93std_dev_pct=%s
94jti=%s
95""" % tuple([max_jobs_per_min] + fields))
96        out.close()
97