Home | History | Annotate | Download | only in bash_shared_mapping
      1 import signal, os
      2 from autotest_lib.client.bin import utils, test
      3 
      4 class bash_shared_mapping(test.test):
      5     version = 3
      6 
      7     # http://www.zip.com.au/~akpm/linux/patches/stuff/ext3-tools.tar.gz
      8     def setup(self, tarball = 'ext3-tools.tar.gz'):
      9         self.tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
     10         utils.extract_tarball_to_dir(self.tarball, self.srcdir)
     11 
     12         os.chdir(self.srcdir)
     13         utils.system('patch -p1 < ../makefile.patch')
     14         utils.make('bash-shared-mapping usemem')
     15 
     16 
     17     def initialize(self):
     18         self.job.require_gcc()
     19 
     20 
     21     def execute(self, testdir = None, iterations = 10000):
     22         if not testdir:
     23             testdir = self.tmpdir
     24         os.chdir(testdir)
     25         file = os.path.join(testdir, 'foo')
     26         # Want to use 3/4 of all memory for each of
     27         # bash-shared-mapping and usemem
     28         kilobytes = (3 * utils.memtotal()) / 4
     29 
     30         # Want two usemem -m megabytes in parallel in background.
     31         pid = [None, None]
     32         usemem = os.path.join(self.srcdir, 'usemem')
     33         args = ('usemem', '-N', '-m', '%d' % (kilobytes / 1024))
     34         # print_to_tty ('2 x ' + ' '.join(args))
     35         for i in (0,1):
     36             pid[i] = os.spawnv(os.P_NOWAIT, usemem, args)
     37 
     38         cmd = "%s/bash-shared-mapping %s %d -t %d -n %d" % \
     39                         (self.srcdir, file, kilobytes,
     40                          utils.count_cpus(), iterations)
     41         os.system(cmd)
     42 
     43         for i in (0, 1):
     44             os.kill(pid[i], signal.SIGKILL)
     45