]> code.ossystems Code Review - openembedded-core.git/commitdiff
logparser: Add LTP compliance section
authorArmin Kuster <akuster808@gmail.com>
Mon, 22 Apr 2019 12:32:42 +0000 (06:32 -0600)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 29 Apr 2019 09:23:24 +0000 (10:23 +0100)
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oeqa/utils/logparser.py

index 76efac4d06ba0ad2f673c284a40f6b36e4acd132..584ad4f2639f61ccfb7f6baf4e39e3c0b0b4ccc9 100644 (file)
@@ -111,3 +111,40 @@ class LtpParser(object):
             self.section['log'] = self.section['log'] + ("%s: %s\n" % (result.strip()[:-2], test.strip()))
 
         return self.results, self.section
+
+
+# ltp Compliance log parsing
+class LtpComplianceParser(object):
+    def __init__(self):
+        self.results = {}
+        self.section = {'duration': "", 'log': ""}
+
+    def parse(self, logfile):
+        test_regex = {}
+        test_regex['PASSED'] = re.compile(r"^PASS")
+        test_regex['FAILED'] = re.compile(r"^FAIL")
+        test_regex['SKIPPED'] = re.compile(r"(?:UNTESTED)|(?:UNSUPPORTED)")
+
+        section_regex = {}
+        section_regex['test'] = re.compile(r"^Testing")
+
+        with open(logfile, errors='replace') as f:
+            for line in f:
+                result = section_regex['test'].search(line)
+                if result:
+                    self.name = ""
+                    self.name = line.split()[1].strip()
+                    self.results[self.name] = "PASSED"
+                    failed = 0
+
+                failed_result = test_regex['FAILED'].search(line)
+                if failed_result:
+                    failed = line.split()[1].strip()
+                    if int(failed) > 0:
+                        self.results[self.name] = "FAILED"
+
+        for test in self.results:
+            result = self.results[test]
+            self.section['log'] = self.section['log'] + ("%s: %s\n" % (result.strip()[:-2], test.strip()))
+
+        return self.results, self.section