blob: e3fb69df1fddeaee390edf7bbfb6e33d26ccc496 [file] [log] [blame]
mbligh34d01172008-06-05 16:26:31 +00001import signal, os
2from autotest_lib.client.bin import autotest_utils, test
3from autotest_lib.client.common_lib import utils
mblighe7a170f2006-12-05 07:48:18 +00004
5class bash_shared_mapping(test.test):
6 version = 3
7
8 # http://www.zip.com.au/~akpm/linux/patches/stuff/ext3-tools.tar.gz
9 def setup(self, tarball = 'ext3-tools.tar.gz'):
mbligh34d01172008-06-05 16:26:31 +000010 self.tarball = utils.unmap_url(self.bindir, tarball,
11 self.tmpdir)
12 autotest_utils.extract_tarball_to_dir(self.tarball, self.srcdir)
mblighe7a170f2006-12-05 07:48:18 +000013
14 os.chdir(self.srcdir)
mbligh34d01172008-06-05 16:26:31 +000015 utils.system('make bash-shared-mapping usemem')
mblighe7a170f2006-12-05 07:48:18 +000016
17
mbligh828fe762007-12-19 00:07:43 +000018 def execute(self, testdir = None, iterations = 10000):
mblighe7a170f2006-12-05 07:48:18 +000019 if not testdir:
20 testdir = self.tmpdir
21 os.chdir(testdir)
22 file = os.path.join(testdir, 'foo')
mblighdec07762006-12-07 19:21:52 +000023 # Want to use 3/4 of all memory for each of
24 # bash-shared-mapping and usemem
mbligh34d01172008-06-05 16:26:31 +000025 kilobytes = (3 * autotest_utils.memtotal()) / 4
mblighe7a170f2006-12-05 07:48:18 +000026
27 # Want two usemem -m megabytes in parallel in background.
mblighf07c5b02006-12-05 18:17:04 +000028 pid = [None, None]
mbligh2b3fe5d2006-12-25 01:29:20 +000029 usemem = os.path.join(self.srcdir, 'usemem')
30 args = ('usemem', '-N', '-m', '%d' % (kilobytes / 1024))
31 # print_to_tty ('2 x ' + ' '.join(args))
mblighf07c5b02006-12-05 18:17:04 +000032 for i in (0,1):
mblighf07c5b02006-12-05 18:17:04 +000033 pid[i] = os.spawnv(os.P_NOWAIT, usemem, args)
mblighe7a170f2006-12-05 07:48:18 +000034
mblighb4c9baf2007-12-18 23:14:34 +000035 cmd = "%s/bash-shared-mapping %s %d -t %d -n %d" % \
36 (self.srcdir, file, kilobytes,
37 count_cpus(), iterations)
mblighf07c5b02006-12-05 18:17:04 +000038 os.system(cmd)
mblighe7a170f2006-12-05 07:48:18 +000039
mblighf07c5b02006-12-05 18:17:04 +000040 for i in (0,1):
41 os.kill(pid[i], signal.SIGKILL)