Hackbench test: Fix performance keyval generation

The hackbench test wasn't generating performance keyvals,
due to some incorrect assumptions at the postprocessing
code (the output for the test also has a debug line with
the number of tasks spawned, so the output generated will
not start with 'Time:', as the code assumes). Let's fix
that problem.

Also, in order for people to apply their custom
postprocessing to results (they might want to test out
some 3rd party postprocessing script, for example), is
allways good to keep record of the raw output generated
by the test, per iteration. I plan on doing the same
for the other benchmarks present on autotest.

Updates from v1:

 * Updated the test to postprocess keyvals per iteration

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@4410 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/tests/hackbench/hackbench.py b/client/tests/hackbench/hackbench.py
index 61323c2..b2375ac 100644
--- a/client/tests/hackbench/hackbench.py
+++ b/client/tests/hackbench/hackbench.py
@@ -3,6 +3,14 @@
 
 
 class hackbench(test.test):
+    """
+    This module will run the hackbench benchmark. Hackbench is a benchmark for
+    measuring the performance, overhead and scalability of the Linux scheduler.
+    The C program was pick from Ingo Molnar's page.
+
+    @author: Nikhil Rao (ncrao@google.com)
+    @see: http://people.redhat.com/~mingo/cfs-scheduler/tools/hackbench.c
+    """
     version = 1
     preserve_srcdir = True
 
@@ -14,17 +22,33 @@
 
     def initialize(self):
         self.job.require_gcc()
-        self.results = []
+        self.results = None
 
 
     def run_once(self, num_groups=90):
+        """
+        Run hackbench, store the output in raw output files per iteration and
+        also in the results list attribute.
+
+        @param num_groups: Number of children processes hackbench will spawn.
+        """
         hackbench_bin = os.path.join(self.srcdir, 'hackbench')
         cmd = '%s %s' % (hackbench_bin, num_groups)
-        self.results.append(utils.system_output(cmd, retain_output=True))
+        raw_output = utils.system_output(cmd, retain_output=True)
+        self.results = raw_output
+
+        path = os.path.join(self.resultsdir, 'raw_output_%s' % self.iteration)
+        raw_output_file = open(path, 'w')
+        raw_output_file.write(raw_output)
+        raw_output_file.close()
 
 
-    def postprocess(self):
-        for line in self.results:
+    def postprocess_iteration(self):
+        """
+        Pick up the results attribute and write it in the performance keyval.
+        """
+        lines = self.results.split('\n')
+        for line in lines:
             if line.startswith('Time:'):
                 time_val = line.split()[1]
                 self.write_perf_keyval({'time': time_val})