blob: af52560fcd84615423152ab3065c2216e98bfd94 [file] [log] [blame]
mblighb4904792007-01-01 02:15:01 +00001import test
2from autotest_utils import *
mbligheb131362007-01-09 22:24:38 +00003import os, sys
4from subprocess import *
mblighb4904792007-01-01 02:15:01 +00005
6class disktest(test.test):
7 version = 1
8
9 def setup(self):
10 os.mkdir(self.srcdir)
11 os.chdir(self.bindir)
12 system('cp disktest.c src/')
13 os.chdir(self.srcdir)
mbligheb131362007-01-09 22:24:38 +000014 cflags = '-D_FILE_OFFSET_BITS=64 -D _GNU_SOURCE -static -Wall'
mbligh98e3e012007-01-03 00:10:38 +000015 system('cc disktest.c ' + cflags + ' -o disktest')
mblighb4904792007-01-01 02:15:01 +000016
17
mbligheb131362007-01-09 22:24:38 +000018 def test_one_disk_chunk(self, disk, chunk):
19 print "testing %d MB files on %s in %d MB memory" % \
20 (self.chunk_mb, disk, self.memory_mb)
21 cmd = "~/disktest -m %d -f %s/testfile.%d -i -S" % \
22 (self.chunk_mb, disk, chunk)
23 p = Popen(cmd, shell=True)
24 return(p.pid)
25
26
27 def execute(self, disks, gigabytes = 100, chunk_mb = 1024):
28 os.chdir(self.srcdir + '/disktest')
29
30 self.chunk_mb = chunk_mb
31 self.memory_mb = memtotal()/1024
32 if self.memory_mb > chunk_mb/2:
33 raise "Too much RAM (%dMB) for this test to work" % \
34 self.memory_mb
35
36 chunks = (1024 * gigabytes) / chunk_mb
37
38 for i in range(chunks):
39 pids = []
40 for disk in disks:
41 pid = test_one_disk_chunk(chunk_mb, disk, chunk)
42 pids.append(pid)
43 errors = []
44 for pid in pids:
45 (junk, retval) = os.waitpid(pid, 0)
46 if (retval != 0):
47 errors.append(retval)
48 if errors:
49 raise "Errors from children: %s" % errors
50