]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
logparser: Add decoding ltp logs
authorArmin Kuster <akuster808@gmail.com>
Mon, 22 Apr 2019 12:32:39 +0000 (06:32 -0600)
committerArmin Kuster <akuster808@gmail.com>
Fri, 14 Jun 2019 14:05:34 +0000 (07:05 -0700)
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
meta/lib/oeqa/utils/logparser.py

index 18285fb54485a7c6b3e3ad078f713d8b649ee14b..abff8c78ae1140174c9238ca84baaa9cceb20e1d 100644 (file)
@@ -89,3 +89,28 @@ class PtestParser(object):
                     status = self.results[section][test_name]
                     f.write(status + ": " + test_name + "\n")
 
+
+# ltp log parsing
+class LtpParser(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"SKIP")
+
+        with open(logfile, errors='replace') as f:
+            for line in f:
+                for t in test_regex:
+                    result = test_regex[t].search(line)
+                    if result:
+                        self.results[line.split()[0].strip()] = t
+
+        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