Fix bug in parse_path where results from multi-machine synchronous jobs are ignored.

This patch fixes a bug in parse_path where results from multi-machine synchronous jobs are not parsed correctly and do not show up in the
database. Synchronous jobs keep result info in results/groupN/status.log.
The current parser algorithm parses results in results/groupN/<subdirs>.
This patch fixes that by adding parsing results/groupN in addition to the
subdirs.

Thanks to John Admanski for explaining the fix.

Signed-off-by: Nikhil Rao <ncrao@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@2865 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/tko/parse.py b/tko/parse.py
index 3d5a91f..9ae2954 100755
--- a/tko/parse.py
+++ b/tko/parse.py
@@ -152,22 +152,31 @@
     return None
 
 
+def parse_leaf_path(db, path, level, reparse, mail_on_failure):
+    job_elements = path.split("/")[-level:]
+    jobname = "/".join(job_elements)
+    try:
+        db.run_with_retry(parse_one, db, jobname, path, reparse,
+                          mail_on_failure)
+    except Exception:
+        traceback.print_exc()
+
+
 def parse_path(db, path, level, reparse, mail_on_failure):
     job_subdirs = _get_job_subdirs(path)
     if job_subdirs is not None:
+        # parse status.log in current directory, if it exists. multi-machine
+        # synchronous server side tests record output in this directory. without
+        # this check, we do not parse these results.
+        if os.path.exists(os.path.join(path, 'status.log')):
+            parse_leaf_path(db, path, level, reparse, mail_on_failure)
         # multi-machine job
         for subdir in job_subdirs:
             jobpath = os.path.join(path, subdir)
             parse_path(db, jobpath, level + 1, reparse, mail_on_failure)
     else:
         # single machine job
-        job_elements = path.split("/")[-level:]
-        jobname = "/".join(job_elements)
-        try:
-            db.run_with_retry(parse_one, db, jobname, path,
-                              reparse, mail_on_failure)
-        except Exception:
-            traceback.print_exc()
+        parse_leaf_path(db, path, level, reparse, mail_on_failure)
 
 
 def main():