mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00
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@linuxfoundation.org>
This commit is contained in:
parent
88f390bcb6
commit
3731033435
|
@ -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:
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user