[oe-commits] [openembedded-core] 13/55: oeqa/utils/logparser: Add in support for duration, exitcode and logs by section

git at git.openembedded.org git at git.openembedded.org
Mon Feb 25 22:29:09 UTC 2019


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch thud
in repository openembedded-core.

commit dc49021f75ed7e82713d1c9a04e045718bb9a548
Author: Richard Purdie <richard.purdie at linuxfoundation.org>
AuthorDate: Tue Jan 29 14:22:07 2019 +0000

    oeqa/utils/logparser: Add in support for duration, exitcode and logs by section
    
    Allow parsing of the ptest duration, exit code and timeout keywords
    from the logs, returning data on each section.
    
    Also include the logs broken out per section.
    
    (From OE-Core rev: a9a67dccaa5be0f06eedcab46dcff7cbf9202850)
    
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
    Signed-off-by: Armin Kuster <akuster808 at gmail.com>
---
 meta/lib/oeqa/runtime/cases/ptest.py |  4 +++-
 meta/lib/oeqa/utils/logparser.py     | 40 ++++++++++++++++++++++++++++++------
 2 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/meta/lib/oeqa/runtime/cases/ptest.py b/meta/lib/oeqa/runtime/cases/ptest.py
index ae54a01..3cfd7af 100644
--- a/meta/lib/oeqa/runtime/cases/ptest.py
+++ b/meta/lib/oeqa/runtime/cases/ptest.py
@@ -49,13 +49,15 @@ class PtestRunnerTest(OERuntimeTestCase):
         extras['ptestresult.rawlogs'] = {'log': output}
 
         # Parse and save results
-        parse_result = PtestParser().parse(ptest_runner_log)
+        parse_result, sections = PtestParser().parse(ptest_runner_log)
         parse_result.log_as_files(ptest_log_dir, test_status = ['pass','fail', 'skip'])
         if os.path.exists(ptest_log_dir_link):
             # Remove the old link to create a new one
             os.remove(ptest_log_dir_link)
         os.symlink(os.path.basename(ptest_log_dir), ptest_log_dir_link)
 
+        extras['ptestresult.sections'] = sections
+
         trans = str.maketrans("()", "__")
         resmap = {'pass': 'PASSED', 'skip': 'SKIPPED', 'fail': 'FAILED'}
         for section in parse_result.result_dict:
diff --git a/meta/lib/oeqa/utils/logparser.py b/meta/lib/oeqa/utils/logparser.py
index f8d1c03..dddea14 100644
--- a/meta/lib/oeqa/utils/logparser.py
+++ b/meta/lib/oeqa/utils/logparser.py
@@ -9,6 +9,7 @@ from . import ftools
 class PtestParser(object):
     def __init__(self):
         self.results = Result()
+        self.sections = {}
 
     def parse(self, logfile):
         test_regex = {}
@@ -19,28 +20,55 @@ class PtestParser(object):
         section_regex = {}
         section_regex['begin'] = re.compile(r"^BEGIN: .*/(.+)/ptest")
         section_regex['end'] = re.compile(r"^END: .*/(.+)/ptest")
+        section_regex['duration'] = re.compile(r"^DURATION: (.+)")
+        section_regex['exitcode'] = re.compile(r"^ERROR: Exit status is (.+)")
+        section_regex['timeout'] = re.compile(r"^TIMEOUT: .*/(.+)/ptest")
+
+        def newsection():
+            return { 'name': "No-section", 'log': "" }
+
+        current_section = newsection()
 
         with open(logfile, errors='replace') as f:
             for line in f:
                 result = section_regex['begin'].search(line)
                 if result:
-                    current_section = result.group(1)
+                    current_section['name'] = result.group(1)
                     continue
 
                 result = section_regex['end'].search(line)
                 if result:
-                    if current_section != result.group(1):
-                        bb.warn("Ptest log section mismatch %s vs. %s" % (current_section, result.group(1)))
-                    current_section = None
+                    if current_section['name'] != result.group(1):
+                        bb.warn("Ptest END log section mismatch %s vs. %s" % (current_section['name'], result.group(1)))
+                    if current_section['name'] in self.sections:
+                        bb.warn("Ptest duplicate section for %s" % (current_section['name']))
+                    self.sections[current_section['name']] = current_section
+                    del self.sections[current_section['name']]['name']
+                    current_section = newsection()
+                    continue
+
+                result = section_regex['timeout'].search(line)
+                if result:
+                    if current_section['name'] != result.group(1):
+                        bb.warn("Ptest TIMEOUT log section mismatch %s vs. %s" % (current_section['name'], result.group(1)))
+                    current_section['timeout'] = True
                     continue
 
+                for t in ['duration', 'exitcode']:
+                    result = section_regex[t].search(line)
+                    if result:
+                        current_section[t] = result.group(1)
+                        continue
+
+                current_section['log'] = current_section['log'] + line 
+
                 for t in test_regex:
                     result = test_regex[t].search(line)
                     if result:
-                        self.results.store(current_section, result.group(1), t)
+                        self.results.store(current_section['name'], result.group(1), t)
 
         self.results.sort_tests()
-        return self.results
+        return self.results, self.sections
 
 class Result(object):
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list