From 29205751920972b872d14ec1e39c48e11211757e Mon Sep 17 00:00:00 2001 From: Arthur She Date: Mon, 2 Jun 2014 22:29:04 -0700 Subject: FWTS: fixed result parsing Add results.log parser for ubuntu/fwts.yaml to turn the test results into LAVA bundle stream. Change-Id: I5e2e0856526bbb1d3cc20b7c1c138aa20e0c060d --- ubuntu/scripts/fwts-parser.py | 63 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 ubuntu/scripts/fwts-parser.py (limited to 'ubuntu/scripts') diff --git a/ubuntu/scripts/fwts-parser.py b/ubuntu/scripts/fwts-parser.py new file mode 100755 index 0000000..bc20133 --- /dev/null +++ b/ubuntu/scripts/fwts-parser.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python + +import re +import sys + +RESULT_MAP = { 'PAS': 'pass', + 'FAL': 'fail', + 'SKP': 'skip', + 'ABT': 'fail', + 'WRN': 'fail', + 'ERR': 'fail' } +line = re.compile("(?P[a-z_]+)\\s*-(?P[A-Z]+):(?P.*)") +header = re.compile("(?P[a-z]+):\\s(?P[ ()a-zA-Z-_]+)") +result = re.compile("(?P.*):\\s(?PTest [0-9]),\\s(?P.*)") +summary = re.compile("(?P[0-9]+) passed, (?P[0-9]+) failed, (?P[0-9]+) warning, (?P[0-9]+) aborted, (?P[0-9]+) skipped, (?P[0-9]+) info only") + +grouplist = {} + +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + linere = line.search(l) + if linere: + owner = linere.group('owner') + field = linere.group('field') + content = linere.group('content') + if field == 'HED': + headerre = header.search(content) + if headerre: + group_name = headerre.group('group_name') + gt = {'name': group_name, 'subtests': [], 'result': ''} + grouplist[owner] = gt + elif field in RESULT_MAP: + resultre = result.search(content) + if resultre: + test = {'test_name': resultre.group('test_name'), + 'result': RESULT_MAP[field], + 'comment': resultre.group('comment')} + grouplist[owner]['subtests'].append(test) + else: + if 'comment' not in grouplist[owner]: + grouplist[owner]['comment'] = content + grouplist[owner]['result'] = RESULT_MAP[field] + elif field == 'SUM': + sumre = summary.search(content) + if sumre: + if re.match("^0000", ''.join(sumre.groups())): # 0 passed, 0 failed, 0 warning, 0 aborted + grouplist[owner]['result'] = 'skip' + +for gname, t in grouplist.iteritems(): + if len(t['subtests']) == 0: + t_result = 'skip' + t_comment = t['name'] + if t['result']: + t_result = t['result'] + if 'comment' in t: + t_comment = t['comment'] + print("%s (%s): %s" % (gname, t_comment, t_result)) + else: + for tt in t['subtests']: + if tt['comment']: + print("%s %s(%s): %s" % (gname, tt['test_name'], tt['comment'], tt['result'])) + else: + print("%s %s(%s): %s" % (gname, tt['test_name'], t['name'], tt['result'])) -- cgit v1.2.3