summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-01-29 16:52:18 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-01-31 23:23:26 +0000
commit7b17274c30c6e95d87bc6a08f1311f0200c3f609 (patch)
treeb8ef1660be23d5bdaf6d7ffcc59718d629bfd1b5 /meta/lib/oeqa/utils
parent54d4694f328a4ae07955aa68dcb6d3c183ed2edd (diff)
downloadpoky-7b17274c30c6e95d87bc6a08f1311f0200c3f609.tar.gz
oeqa/logparser: Various misc cleanups
Get rid of further unneeded code complications: * value mappings we could just direct use * ftools when we can write files easily ourself * test result status filtering we don't use * variable overwriting module imports (From OE-Core rev: d6065f136f6d353c3054cc3f440a4e259509f876) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r--meta/lib/oeqa/utils/logparser.py21
1 files changed, 8 insertions, 13 deletions
diff --git a/meta/lib/oeqa/utils/logparser.py b/meta/lib/oeqa/utils/logparser.py
index 8585c195c4..32fde14a7d 100644
--- a/meta/lib/oeqa/utils/logparser.py
+++ b/meta/lib/oeqa/utils/logparser.py
@@ -3,7 +3,6 @@
3import sys 3import sys
4import os 4import os
5import re 5import re
6from . import ftools
7 6
8# A parser that can be used to identify weather a line is a test result or a section statement. 7# A parser that can be used to identify weather a line is a test result or a section statement.
9class PtestParser(object): 8class PtestParser(object):
@@ -13,9 +12,9 @@ class PtestParser(object):
13 12
14 def parse(self, logfile): 13 def parse(self, logfile):
15 test_regex = {} 14 test_regex = {}
16 test_regex['pass'] = re.compile(r"^PASS:(.+)") 15 test_regex['PASSED'] = re.compile(r"^PASS:(.+)")
17 test_regex['fail'] = re.compile(r"^FAIL:(.+)") 16 test_regex['FAILED'] = re.compile(r"^FAIL:(.+)")
18 test_regex['skip'] = re.compile(r"^SKIP:(.+)") 17 test_regex['SKIPPED'] = re.compile(r"^SKIP:(.+)")
19 18
20 section_regex = {} 19 section_regex = {}
21 section_regex['begin'] = re.compile(r"^BEGIN: .*/(.+)/ptest") 20 section_regex['begin'] = re.compile(r"^BEGIN: .*/(.+)/ptest")
@@ -72,9 +71,7 @@ class PtestParser(object):
72 return self.results, self.sections 71 return self.results, self.sections
73 72
74 # Log the results as files. The file name is the section name and the contents are the tests in that section. 73 # Log the results as files. The file name is the section name and the contents are the tests in that section.
75 def results_as_files(self, target_dir, test_status): 74 def results_as_files(self, target_dir):
76 if not type(test_status) == type([]):
77 raise Exception("test_status should be a list. Got " + str(test_status) + " instead.")
78 if not os.path.exists(target_dir): 75 if not os.path.exists(target_dir):
79 raise Exception("Target directory does not exist: %s" % target_dir) 76 raise Exception("Target directory does not exist: %s" % target_dir)
80 77
@@ -84,10 +81,8 @@ class PtestParser(object):
84 prefix = section 81 prefix = section
85 section_file = os.path.join(target_dir, prefix) 82 section_file = os.path.join(target_dir, prefix)
86 # purge the file contents if it exists 83 # purge the file contents if it exists
87 open(section_file, 'w').close() 84 with open(section_file, 'w') as f:
88 for test_name in sorted(self.results[section]): 85 for test_name in sorted(self.results[section]):
89 status = self.results[section][test_name] 86 status = self.results[section][test_name]
90 # we log only the tests with status in the test_status list 87 f.write(status + ": " + test_name + "\n")
91 if status in test_status:
92 ftools.append_file(section_file, status + ": " + test_name)
93 88