Home | History | Annotate | Download | only in ddtest
      1 
      2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
      3 # Use of this source code is governed by a BSD-style license that can be
      4 # found in the LICENSE file.
      5 
      6 import os, shutil, re
      7 from autotest_lib.client.bin import utils, test
      8 
      9 class ddtest(test.test):
     10     version = 2
     11 
     12 
     13     def setup(self, tarball='ddtest.tar.gz'):
     14         tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
     15         utils.extract_tarball_to_dir(tarball, self.srcdir)
     16         os.chdir(self.srcdir)
     17         utils.system('make build')
     18 
     19 
     20     def initialize(self):
     21         self.job.require_gcc()
     22         self.results = []
     23         self.job.drop_caches_between_iterations = True
     24 
     25 
     26     def run_once(self, dir=None, blocksize=1024, blocknum=262144, threads=20):
     27         if not dir:
     28            dir = os.path.join(self.srcdir, 'rdir')
     29            shutil.rmtree(dir, True)
     30            os.mkdir(dir)
     31         args = '-D ' + dir
     32         args += ' -b %d' % blocksize
     33         args += ' -n %d' % blocknum
     34         args += ' -t %d' % threads
     35         self.results.append(utils.system_output(os.path.join(self.srcdir,
     36                             'ddtest') + ' ' + args))
     37 
     38 
     39     def postprocess(self):
     40         pattern = re.compile(r"throughput is (.*?) MB/sec")
     41         for throughput in pattern.findall("\n".join(self.results)):
     42             self.write_perf_keyval({'throughput':throughput})
     43