On Fri, Jul 29, 2011 at 3:07 AM, Onkar N Mahajan
<[email protected]> wrote:
> Sorry, there was some problem with my email client. Please
> ignore all my previous FFSB patches and use this one.
>
> This patch adds to the Autotest framework capability
> to run the Flexible File System Benchmark.

Hi Onkar, in general, your test module looks really good, thanks for
contributing it! I've noticed few mistakes, most of them related to
slight issues, such as slight off indentation in some places, some
trailing whitespaces in some lines, spacing around assignments. Also,
as for every benchmark it's a good practice to record the results of
each iteration on a raw results file, see for example iozone and xfs
tests. Also, the class docstring is the one that should hold the
author name, along with a short description.

Although a laudable idea, your comments as docstrings are better off
being comments, with a single method docstring with a bit more
documentation about the intents of the methods and parameters it does
take. Of course, if you think the function is really really trivial
you might omit the docstrings, but I ask you to consider carefully :)

The tools I've used to make most of the corrections are
utils/reindent.py to fix any indentation and trailing whitespace in
lines, and pylint, to discover unused parameters, unused imports and
variables and assignment spacing issues. We in autotest try to follow
PEP 8 unless explicitly noted on the coding style document.

I've generated a fixup patch for your own reference and attached to
this message, so you keep in mind my recommendations in future
contributions.

I'm going to commit this shortly, thanks again!

> From db21a1144073fa5f56b7dd501c4e7438f45bdf60 Mon Sep 17 00:00:00 2001
> From: Onkar N Mahajan <[email protected]>
> Date: Tue, 26 Jul 2011 20:02:24 +0530
> Subject: [PATCH] Flexible File System Benchmark (FFSB) support in Autotest
>  Signed-off-by: Onkar N Mahajan <[email protected]>
>
> ---
>  client/tests/ffsb/README                       |   43 ++++++
>  client/tests/ffsb/control                      |   18 +++
>  client/tests/ffsb/ffsb.py                      |  177 
> ++++++++++++++++++++++++
>  client/tests/ffsb/profile.cfg.sample           |   25 ++++
>  client/tests/kvm/autotest_control/ffsb.control |   18 +++
>  client/tests/kvm/tests_base.cfg.sample         |    2 +
>  6 files changed, 283 insertions(+), 0 deletions(-)
>  create mode 100644 client/tests/ffsb/README
>  create mode 100644 client/tests/ffsb/control
>  create mode 100644 client/tests/ffsb/ffsb.py
>  create mode 100644 client/tests/ffsb/profile.cfg.sample
>  create mode 100644 client/tests/kvm/autotest_control/ffsb.control
>
> diff --git a/client/tests/ffsb/README b/client/tests/ffsb/README
> new file mode 100644
> index 0000000..d15c311
> --- /dev/null
> +++ b/client/tests/ffsb/README
> @@ -0,0 +1,43 @@
> +INTRODUCTION:
> +=============
> +This patch integrates the Flexible Filesystem Benchmark (FFSB) with
> +the autotest. This integration enables the high-performace I/O load testing 
> in the
> +KVM Virtual machine environment.
> +FFSB is a filesystem performance measurement tool.  It is a multi-threaded
> +application (using pthreads), written entirely in C with cross-platform
> +portability in mind.  It differs from other filesystem benchmarks in that
> +the user may supply a profile to create custom workloads, while most other
> +filesystem benchmarks use a fixed set of randomly generated workloads.
> +
> +More information about the FFSB can be got from reading the README in the
> +FFSB source directory which can be accessed from this link:
> +[http://sourceforge.net/projects/ffsb/]
> +
> +With this integration ,it is now possible to test variety of filesystems on
> +the KVM guest for :
> +
> +(1) directed I/O with sequential/random read/write.
> +(2) buffered I/O with sequential/random read/write.
> +(3) use varying block alignment boundries to measure filesystem behaviour.
> +(4) use multithreaded workloads to stress the filesystem.
> +(5) Exert weighted combination of I/O workloads to analyze the I/O performace
> +    for a specific scenario.
> +(6) Age filesystem according to a specified workload upto a specified limit.
> +
> +    Since the only interface used for the integration is a FFSB 
> configuration file;
> +Autotest will be able to run variety of I/O tests on guest as FFSB improves,
> +with no or minimal code change in Autotest itself.
> +
> +USE:
> +====
> +    To use the FFSB for Filesystem testing, two configuration files
> +need to be modified -
> +(1) Usual - tests.cfg file to activate the ffsb tests through KVM.
> +(2) profile.cfg - where the workloads are specified.
> +
> +TODO:
> +====
> +* Add validations for max. number of threads according to number of
> +  vcpus exported by QEMU-KVM
> +* Test Autotest/ffsb
> +* Test FFSB itself.
> diff --git a/client/tests/ffsb/control b/client/tests/ffsb/control
> new file mode 100644
> index 0000000..0164898
> --- /dev/null
> +++ b/client/tests/ffsb/control
> @@ -0,0 +1,18 @@
> +AUTHOR = "Onkar N Mahajan <[email protected]>"
> +NAME = "Flexible Filesystem Benchmark (FFSB)"
> +TEST_CATEGORY = "Filesystem Benchmark"
> +TEST_CLASS = "General"
> +TEST_TYPE = "client"
> +TIME = 'MEDIUM'
> +DOC = """\
> +
> +The Flexible Filesystem Benchmark (FFSB) is a cross-platform
> +filesystem performance measurement tool. It uses customizable
> +profiles to measure of different workloads, and it supports
> +multiple groups of threads across multiple filesystems.
> +
> +For more info, see http://sourceforge.net/projects/ffsb/
> +
> +"""
> +
> +job.run_test('ffsb')
> diff --git a/client/tests/ffsb/ffsb.py b/client/tests/ffsb/ffsb.py
> new file mode 100644
> index 0000000..c2f7aae
> --- /dev/null
> +++ b/client/tests/ffsb/ffsb.py
> @@ -0,0 +1,177 @@
> +import os, stat, string, logging, re, random, shutil
> +from autotest_lib.client.bin import test, os_dep, utils
> +from autotest_lib.client.common_lib import error
> +
> +class ffsb(test.test):
> +
> +    version=1
> +    params = {}
> +    tempdirs = []
> +    bytes = { 'K' : 1024 , 'k' : 1024 ,
> +              'M' : 1048576 , 'm' : 1048576 ,
> +              'G' : 1073741824 , 'g':1073741824,
> +              'T' : 1099511627776 , 't':1099511627776
> +            }
> +
> +
> +    def initialize(self):
> +        self.job.require_gcc()
> +        self.results = []
> +        self.nfail=0
> +
> +    def find_mnt_pt(self,path):
> +        pth = os.path.abspath(path)
> +        while not os.path.ismount(pth):
> +            pth = os.path.dirname(pth)
> +        return pth
> +
> +    def set_ffsb_params(self,usrfl) :
> +        """
> +        This function checks for the user supplied FFSB profile file
> +        and validates it against the availble resources on the
> +        guest - currently only disk space validation is supported
> +        but adjusting the number of threads according to the vcpus
> +        exported by the qemu-kvm also needs to be added.
> +
> +        @author Onkar N Mahajan ([email protected])
> +        """
> +        d = {}
> +        fr = open(usrfl,'r')
> +        for line in fr.read().split('\n'):
> +            p = re.compile(r'\s*\t*\[{1}filesystem(\d+)\]{1}')
> +            m = p.match(line)
> +            if m:
> +                fsno=int(line[m.start(1):m.end(1)])
> +                d[fsno] = []
> +            p = re.compile(r'(\s*\t*location)\=(.*)')
> +            m = p.match(line)
> +            if m:
> +                path = line[m.start(2):m.end(2)]
> +                mntpt=self.find_mnt_pt(path)
> +                f=os.statvfs(mntpt)
> +                avl_dsk_spc=f.f_bfree*f.f_bsize
> +                avl_dsk_spc*=0.95
> +                d[fsno].append(mntpt)
> +                d[fsno].append(int(avl_dsk_spc))
> +            p = re.compile(r'(\s*\t*num_files)\=(\d+)')
> +
> +            m = p.match(line)
> +            if m:
> +                usrnumfl = int(line[m.start(2):m.end(2)])
> +                d[fsno].append(usrnumfl)
> +            p = re.compile(r'(\s*\t*max_filesize)\=(\d+[kKMmGgTt]?)')
> +            m = p.match(line)
> +            if m:
> +                usrmaxflsz=line[m.start(2):m.end(2)]
> +                usrmaxflsz = int(usrmaxflsz[0:-1]) * 
> self.bytes[usrmaxflsz[-1]]
> +                d[fsno].append(usrmaxflsz)
> +        for k in d.keys():
> +            while d[k][2]*d[k][3] >= d[k][1]:
> +                d[k][2]-=1
> +            if d[k][2] == 0:
> +                d[k][2]=1
> +                d[k][3]=d[k][1]
> +            """
> +            If the ffsb mount point is on the same file system
> +            then use the available disk space after the previous
> +            tests
> +            """
> +            for k1 in d.keys():
> +                if d[k1][0] == d[k][0]:
> +                    d[k1][1] -= (d[k][2]*d[k][3])
> +        fr.close()
> +        return d
> +
> +    def dup_ffsb_profilefl(self) :
> +        """
> +        This generates a profile file which is a validated file
> +        that is actually used by the FFSB on the guest
> +        """
> +        self.usrfl = '%s/%s' % (os.path.split(self.srcdir)[0],'profile.cfg')
> +        self.sysfl = '%s/%s' % (self.srcdir,'profile.cfg')
> +
> +        """
> +        Validate the path from the FFSB configuration file, the
> +        disk space available for the test ,warn the user and
> +        change the file sizes and/or number of files to be used for
> +        generating the workload according to the available disk space
> +        on the guest.
> +        """
> +        params=self.set_ffsb_params(self.usrfl)
> +
> +        fsno=0
> +        fr = open(self.usrfl,'r')
> +        fw = open(self.sysfl,'w')
> +        for line in fr.read().split('\n'):
> +            p = re.compile(r'\s*\t*\[{1}filesystem(\d+)\]{1}')
> +            m = p.match(line)
> +            if m:
> +                fsno=int(line[m.start(1):m.end(1)])
> +            p = re.compile(r'(\s*\t*location)\=(.*)')
> +            m = p.match(line)
> +            if m:
> +                while True:
> +                    dirnm = ''.join(random.choice(string.letters) for i in 
> xrange(9))
> +                    if line[m.end(2)-1] == '/':
> +                        newline='%s%s' % (line[0:m.end(2)],dirnm)
> +                        ffsbdir='%s%s' % (line[m.start(2):m.end(2)],dirnm)
> +                    else:
> +                        newline='%s/%s' % (line[0:m.end(2)],dirnm)
> +                        ffsbdir='%s/%s' % (line[m.start(2):m.end(2)],dirnm)
> +                    self.tempdirs.append(ffsbdir)
> +                    if os.path.exists(ffsbdir):
> +                        continue
> +                    else:
> +                        os.makedirs(ffsbdir)
> +                        break
> +                fw.write(newline+'\n')
> +                continue
> +            p = re.compile(r'(\s*\t*num_files)\=(.*)')
> +            m = p.match(line)
> +            if m:
> +                newline = '%s=%s' % (line[0:m.end(1)],str(params[fsno][2]))
> +                fw.write(newline+'\n')
> +                continue
> +            p = re.compile(r'(\s*\t*max_filesize)\=(\d+[kKMmGgTt]?)')
> +            m = p.match(line)
> +            if m:
> +                newline = '%s%s' % (line[0:m.start(2)],str(params[fsno][3]))
> +                fw.write(newline+'\n')
> +                continue
> +            fw.write(line+'\n')
> +        fr.close()
> +        fw.close()
> +
> +
> +    def setup(self, tarball = 'ffsb-6.0-rc2.tar.bz2'):
> +        tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
> +        utils.extract_tarball_to_dir(tarball, self.srcdir)
> +        os.chdir(self.srcdir)
> +        os_dep.command('gcc')
> +        utils.configure()
> +        utils.make()
> +
> +
> +    def run_once(self, dir=None, extra_args='', user='root'):
> +        self.dup_ffsb_profilefl()
> +        # Run FFSB using abspath
> +        cmd = '%s/ffsb %s/profile.cfg' % (self.srcdir,self.srcdir)
> +        logging.info("Executing : %s",(cmd))
> +        try:
> +           self.results = utils.system_output(cmd, retain_output=True)
> +        except error.CmdError, e:
> +           self.nfail += 1
> +           logging.error('Failed to execute FFSB : %s', e)
> +
> +        logging.info(self.results)
> +
> +
> +    def postprocess(self):
> +        if self.nfail != 0:
> +            raise error.TestError('FFSB test failed.')
> +        else:
> +            logging.info('FFSB test passed')
> +            logging.info('Cleaning up test data...')
> +            for l in self.tempdirs:
> +                shutil.rmtree(l)
> +
> diff --git a/client/tests/ffsb/profile.cfg.sample 
> b/client/tests/ffsb/profile.cfg.sample
> new file mode 100644
> index 0000000..e68fead
> --- /dev/null
> +++ b/client/tests/ffsb/profile.cfg.sample
> @@ -0,0 +1,25 @@
> +# Large file random writes.
> +# 1024 files, 100MB per file.
> +
> +time=300  # 5 min
> +alignio=1
> +
> +[filesystem0]
> +#   For KVM Autotest , this will by-default
> +#   be / , unless and until the user is absolutely
> +#   sure what is is upto.
> +    location=/
> +    num_files=2
> +    min_filesize=1G
> +    max_filesize=2G
> +[end0]
> +
> +[threadgroup0]
> +    num_threads=4
> +
> +    read_random=1
> +    read_weight=1
> +
> +    read_size=5242880  # 5 MB
> +    read_blocksize=4096
> +[end0]
> diff --git a/client/tests/kvm/autotest_control/ffsb.control 
> b/client/tests/kvm/autotest_control/ffsb.control
> new file mode 100644
> index 0000000..0164898
> --- /dev/null
> +++ b/client/tests/kvm/autotest_control/ffsb.control
> @@ -0,0 +1,18 @@
> +AUTHOR = "Onkar N Mahajan <[email protected]>"
> +NAME = "Flexible Filesystem Benchmark (FFSB)"
> +TEST_CATEGORY = "Filesystem Benchmark"
> +TEST_CLASS = "General"
> +TEST_TYPE = "client"
> +TIME = 'MEDIUM'
> +DOC = """\
> +
> +The Flexible Filesystem Benchmark (FFSB) is a cross-platform
> +filesystem performance measurement tool. It uses customizable
> +profiles to measure of different workloads, and it supports
> +multiple groups of threads across multiple filesystems.
> +
> +For more info, see http://sourceforge.net/projects/ffsb/
> +
> +"""
> +
> +job.run_test('ffsb')
> diff --git a/client/tests/kvm/tests_base.cfg.sample 
> b/client/tests/kvm/tests_base.cfg.sample
> index b7342bd..346bfbf 100644
> --- a/client/tests/kvm/tests_base.cfg.sample
> +++ b/client/tests/kvm/tests_base.cfg.sample
> @@ -302,6 +302,8 @@ variants:
>                 test_control_file = bonnie.control
>             - ebizzy:
>                 test_control_file = ebizzy.control
> +            - ffsb:
> +                test_control_file = ffsb.control
>             - stress:
>                 test_control_file = stress.control
>             - disktest:
> --
> 1.7.3.1
>
>
> _______________________________________________
> Autotest mailing list
> [email protected]
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>
>



-- 
Lucas
From f5efad1d5a09e8304859d793dd3f0e9e15523c8c Mon Sep 17 00:00:00 2001
From: Lucas Meneghel Rodrigues <[email protected]>
Date: Tue, 2 Aug 2011 06:39:09 -0300
Subject: [PATCH] Fixup patch to ffsb

Signed-off-by: Lucas Meneghel Rodrigues <[email protected]>
---
 client/tests/ffsb/README  |    7 +-
 client/tests/ffsb/control |    4 +-
 client/tests/ffsb/ffsb.py |  166 +++++++++++++++++++++++++--------------------
 3 files changed, 98 insertions(+), 79 deletions(-)

diff --git a/client/tests/ffsb/README b/client/tests/ffsb/README
index d15c311..d2516ef 100644
--- a/client/tests/ffsb/README
+++ b/client/tests/ffsb/README
@@ -3,6 +3,7 @@ INTRODUCTION:
 This patch integrates the Flexible Filesystem Benchmark (FFSB) with
 the autotest. This integration enables the high-performace I/O load testing in the
 KVM Virtual machine environment.
+
 FFSB is a filesystem performance measurement tool.  It is a multi-threaded
 application (using pthreads), written entirely in C with cross-platform
 portability in mind.  It differs from other filesystem benchmarks in that
@@ -13,12 +14,12 @@ More information about the FFSB can be got from reading the README in the
 FFSB source directory which can be accessed from this link:
 [http://sourceforge.net/projects/ffsb/]
 
-With this integration ,it is now possible to test variety of filesystems on
+With this integration, it is now possible to test a variety of filesystems on
 the KVM guest for :
 
 (1) directed I/O with sequential/random read/write.
 (2) buffered I/O with sequential/random read/write.
-(3) use varying block alignment boundries to measure filesystem behaviour.
+(3) use varying block alignment boundaries to measure filesystem behaviour.
 (4) use multithreaded workloads to stress the filesystem.
 (5) Exert weighted combination of I/O workloads to analyze the I/O performace
     for a specific scenario.
@@ -30,7 +31,7 @@ with no or minimal code change in Autotest itself.
 
 USE:
 ====
-    To use the FFSB for Filesystem testing, two configuration files
+To use the FFSB for Filesystem testing, two configuration files
 need to be modified -
 (1) Usual - tests.cfg file to activate the ffsb tests through KVM.
 (2) profile.cfg - where the workloads are specified.
diff --git a/client/tests/ffsb/control b/client/tests/ffsb/control
index 0164898..c7e92eb 100644
--- a/client/tests/ffsb/control
+++ b/client/tests/ffsb/control
@@ -4,15 +4,13 @@ TEST_CATEGORY = "Filesystem Benchmark"
 TEST_CLASS = "General"
 TEST_TYPE = "client"
 TIME = 'MEDIUM'
-DOC = """\
-
+DOC = """
 The Flexible Filesystem Benchmark (FFSB) is a cross-platform
 filesystem performance measurement tool. It uses customizable
 profiles to measure of different workloads, and it supports
 multiple groups of threads across multiple filesystems.
 
 For more info, see http://sourceforge.net/projects/ffsb/
-
 """
 
 job.run_test('ffsb')
diff --git a/client/tests/ffsb/ffsb.py b/client/tests/ffsb/ffsb.py
index c2f7aae..90e35ec 100644
--- a/client/tests/ffsb/ffsb.py
+++ b/client/tests/ffsb/ffsb.py
@@ -1,56 +1,68 @@
-import os, stat, string, logging, re, random, shutil
+import os, string, logging, re, random, shutil
 from autotest_lib.client.bin import test, os_dep, utils
 from autotest_lib.client.common_lib import error
 
+
+def find_mnt_pt(path):
+    """
+    Find on which mount point a given path is mounted.
+
+    @param path: Path we want to figure its mount point.
+    """
+    pth = os.path.abspath(path)
+    while not os.path.ismount(pth):
+        pth = os.path.dirname(pth)
+    return pth
+
+
 class ffsb(test.test):
-    
-    version=1
+    """
+    This class wraps FFSB (Flexible File System Benchmark) execution
+    under autotest.
+
+    @author Onkar N Mahajan ([email protected])
+    """
+    version = 1
     params = {}
     tempdirs = []
-    bytes = { 'K' : 1024 , 'k' : 1024 , 
-              'M' : 1048576 , 'm' : 1048576 , 
-              'G' : 1073741824 , 'g':1073741824,
-              'T' : 1099511627776 , 't':1099511627776
-            }
+    bytes = {'K':1024 , 'k':1024,
+             'M':1048576, 'm':1048576,
+             'G':1073741824, 'g':1073741824,
+             'T':1099511627776 , 't':1099511627776}
 
 
     def initialize(self):
         self.job.require_gcc()
         self.results = []
-        self.nfail=0
+        self.nfail = 0
 
-    def find_mnt_pt(self,path):
-        pth = os.path.abspath(path)
-        while not os.path.ismount(pth):
-            pth = os.path.dirname(pth)
-        return pth
 
-    def set_ffsb_params(self,usrfl) :
+    def set_ffsb_params(self, usrfl):
         """
-        This function checks for the user supplied FFSB profile file 
-        and validates it against the availble resources on the 
-        guest - currently only disk space validation is supported 
+        This function checks for the user supplied FFSB profile file
+        and validates it against the availble resources on the
+        guest - currently only disk space validation is supported
         but adjusting the number of threads according to the vcpus
-        exported by the qemu-kvm also needs to be added. 
-          
-        @author Onkar N Mahajan ([email protected])
+        exported by the qemu-kvm also needs to be added.
+
+        @param usrfl: Path to the user profile file.
         """
-        d = {} 
+        d = {}
         fr = open(usrfl,'r')
         for line in fr.read().split('\n'):
             p = re.compile(r'\s*\t*\[{1}filesystem(\d+)\]{1}')
             m = p.match(line)
             if m:
-                fsno=int(line[m.start(1):m.end(1)])
-                d[fsno] = [] 
+                fsno = int(line[m.start(1):m.end(1)])
+                d[fsno] = []
             p = re.compile(r'(\s*\t*location)\=(.*)')
             m = p.match(line)
             if m:
                 path = line[m.start(2):m.end(2)]
-                mntpt=self.find_mnt_pt(path)
-                f=os.statvfs(mntpt)
-                avl_dsk_spc=f.f_bfree*f.f_bsize
-                avl_dsk_spc*=0.95
+                mntpt = find_mnt_pt(path)
+                f = os.statvfs(mntpt)
+                avl_dsk_spc = f.f_bfree * f.f_bsize
+                avl_dsk_spc *= 0.95
                 d[fsno].append(mntpt)
                 d[fsno].append(int(avl_dsk_spc))
             p = re.compile(r'(\s*\t*num_files)\=(\d+)')
@@ -62,62 +74,57 @@ class ffsb(test.test):
             p = re.compile(r'(\s*\t*max_filesize)\=(\d+[kKMmGgTt]?)')
             m = p.match(line)
             if m:
-                usrmaxflsz=line[m.start(2):m.end(2)]
+                usrmaxflsz = line[m.start(2):m.end(2)]
                 usrmaxflsz = int(usrmaxflsz[0:-1]) * self.bytes[usrmaxflsz[-1]]
                 d[fsno].append(usrmaxflsz)
-        for k in d.keys(): 
+        for k in d.keys():
             while d[k][2]*d[k][3] >= d[k][1]:
-                d[k][2]-=1
+                d[k][2] -= 1
             if d[k][2] == 0:
-                d[k][2]=1
-                d[k][3]=d[k][1]
-            """
-            If the ffsb mount point is on the same file system 
-            then use the available disk space after the previous 
-            tests
-            """
-            for k1 in d.keys(): 
+                d[k][2] = 1
+                d[k][3] = d[k][1]
+            # If the ffsb mount point is on the same file system
+            # then use the available disk space after the previous
+            # tests
+            for k1 in d.keys():
                 if d[k1][0] == d[k][0]:
                     d[k1][1] -= (d[k][2]*d[k][3])
         fr.close()
         return d
 
-    def dup_ffsb_profilefl(self) :
-        """ 
-        This generates a profile file which is a validated file 
-        that is actually used by the FFSB on the guest
-        """
-        self.usrfl = '%s/%s' % (os.path.split(self.srcdir)[0],'profile.cfg')
-        self.sysfl = '%s/%s' % (self.srcdir,'profile.cfg')
-        
+
+    def dup_ffsb_profilefl(self):
         """
-        Validate the path from the FFSB configuration file, the 
-        disk space available for the test ,warn the user and 
+        Validates the path from the FFSB configuration file, the
+        disk space available for the test, warn the user and
         change the file sizes and/or number of files to be used for
         generating the workload according to the available disk space
         on the guest.
         """
-        params=self.set_ffsb_params(self.usrfl)
-       
-        fsno=0
+        self.usrfl = '%s/%s' % (os.path.split(self.srcdir)[0],'profile.cfg')
+        self.sysfl = '%s/%s' % (self.srcdir,'profile.cfg')
+
+        params = self.set_ffsb_params(self.usrfl)
+
+        fsno = 0
         fr = open(self.usrfl,'r')
         fw = open(self.sysfl,'w')
         for line in fr.read().split('\n'):
             p = re.compile(r'\s*\t*\[{1}filesystem(\d+)\]{1}')
             m = p.match(line)
             if m:
-                fsno=int(line[m.start(1):m.end(1)])
+                fsno = int(line[m.start(1):m.end(1)])
             p = re.compile(r'(\s*\t*location)\=(.*)')
             m = p.match(line)
             if m:
                 while True:
                     dirnm = ''.join(random.choice(string.letters) for i in xrange(9))
-                    if line[m.end(2)-1] == '/':
-                        newline='%s%s' % (line[0:m.end(2)],dirnm)
-                        ffsbdir='%s%s' % (line[m.start(2):m.end(2)],dirnm)
+                    if line[m.end(2) - 1] == '/':
+                        newline = '%s%s' % (line[0:m.end(2)], dirnm)
+                        ffsbdir = '%s%s' % (line[m.start(2):m.end(2)], dirnm)
                     else:
-                        newline='%s/%s' % (line[0:m.end(2)],dirnm)
-                        ffsbdir='%s/%s' % (line[m.start(2):m.end(2)],dirnm)
+                        newline = '%s/%s' % (line[0:m.end(2)], dirnm)
+                        ffsbdir = '%s/%s' % (line[m.start(2):m.end(2)], dirnm)
                     self.tempdirs.append(ffsbdir)
                     if os.path.exists(ffsbdir):
                         continue
@@ -129,44 +136,58 @@ class ffsb(test.test):
             p = re.compile(r'(\s*\t*num_files)\=(.*)')
             m = p.match(line)
             if m:
-                newline = '%s=%s' % (line[0:m.end(1)],str(params[fsno][2]))
+                newline = '%s=%s' % (line[0:m.end(1)], str(params[fsno][2]))
                 fw.write(newline+'\n')
                 continue
             p = re.compile(r'(\s*\t*max_filesize)\=(\d+[kKMmGgTt]?)')
             m = p.match(line)
             if m:
-                newline = '%s%s' % (line[0:m.start(2)],str(params[fsno][3]))
+                newline = '%s%s' % (line[0:m.start(2)], str(params[fsno][3]))
                 fw.write(newline+'\n')
                 continue
-            fw.write(line+'\n')    
+            fw.write(line+'\n')
         fr.close()
         fw.close()
 
 
-    def setup(self, tarball = 'ffsb-6.0-rc2.tar.bz2'):	
+    def setup(self, tarball='ffsb-6.0-rc2.tar.bz2'):
+        """
+        Uncompress the FFSB tarball and compiles it.
+
+        @param tarball: FFSB tarball. Could be either a path relative to
+                self.srcdir or a URL.
+        """
         tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
         utils.extract_tarball_to_dir(tarball, self.srcdir)
         os.chdir(self.srcdir)
         os_dep.command('gcc')
         utils.configure()
         utils.make()
- 
 
-    def run_once(self, dir=None, extra_args='', user='root'):
+
+    def run_once(self):
+        """
+        Runs a single iteration of the FFSB.
+        """
         self.dup_ffsb_profilefl()
         # Run FFSB using abspath
-        cmd = '%s/ffsb %s/profile.cfg' % (self.srcdir,self.srcdir)
-        logging.info("Executing : %s",(cmd))
-        try: 
-           self.results = utils.system_output(cmd, retain_output=True)
+        cmd = '%s/ffsb %s/profile.cfg' % (self.srcdir, self.srcdir)
+        logging.info("FFSB command: %s", cmd)
+        self.results_path = os.path.join(self.resultsdir,
+                                         'raw_output_%s' % self.iteration)
+        try:
+            self.results = utils.system_output(cmd, retain_output=True)
+            logging.info(self.results)
+            utils.open_write_close(self.results_path, self.results)
         except error.CmdError, e:
-           self.nfail += 1
-           logging.error('Failed to execute FFSB : %s', e)
+            self.nfail += 1
+            logging.error('Failed to execute FFSB : %s', e)
 
-        logging.info(self.results)
-        
 
     def postprocess(self):
+        """
+        Do test postprocessing. Fail the test or clean up results.
+        """
         if self.nfail != 0:
             raise error.TestError('FFSB test failed.')
         else:
@@ -174,4 +195,3 @@ class ffsb(test.test):
             logging.info('Cleaning up test data...')
             for l in self.tempdirs:
                 shutil.rmtree(l)
-            
-- 
1.7.6

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to