diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-01-29 13:00:41 +0000 | 
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-02-25 22:27:39 +0000 | 
| commit | a18ab724da3b93e0ebca6972cdfcb1145cffad5f (patch) | |
| tree | d99ed8b37fc75df892692106f8c23c421f9c5720 | |
| parent | f89486cda1508dcf5e4704eec4e44e45c0d1a66e (diff) | |
| download | poky-a18ab724da3b93e0ebca6972cdfcb1145cffad5f.tar.gz | |
oeqa/logparser: Further simplification/clarification
Rename the paster to be ptest specific and apply some further cleanups
to the code to simplify and clarify what its doing.
(From OE-Core rev: 45a5886f1ec458d4c306b8d68fd31d568bc36b47)
(From OE-Core rev: a4187e32f2cf90c0c7a155bef29fe558cea1edd9)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/lib/oeqa/runtime/cases/ptest.py | 6 | ||||
| -rw-r--r-- | meta/lib/oeqa/utils/logparser.py | 36 | 
2 files changed, 19 insertions, 23 deletions
| diff --git a/meta/lib/oeqa/runtime/cases/ptest.py b/meta/lib/oeqa/runtime/cases/ptest.py index ebef3f9eac..1ce22a09e7 100644 --- a/meta/lib/oeqa/runtime/cases/ptest.py +++ b/meta/lib/oeqa/runtime/cases/ptest.py | |||
| @@ -6,13 +6,13 @@ from oeqa.core.decorator.depends import OETestDepends | |||
| 6 | from oeqa.core.decorator.oeid import OETestID | 6 | from oeqa.core.decorator.oeid import OETestID | 
| 7 | from oeqa.core.decorator.data import skipIfNotFeature | 7 | from oeqa.core.decorator.data import skipIfNotFeature | 
| 8 | from oeqa.runtime.decorator.package import OEHasPackage | 8 | from oeqa.runtime.decorator.package import OEHasPackage | 
| 9 | from oeqa.utils.logparser import Lparser, Result | 9 | from oeqa.utils.logparser import PtestParser, Result | 
| 10 | 10 | ||
| 11 | class PtestRunnerTest(OERuntimeTestCase): | 11 | class PtestRunnerTest(OERuntimeTestCase): | 
| 12 | 12 | ||
| 13 | # a ptest log parser | 13 | # a ptest log parser | 
| 14 | def parse_ptest(self, logfile): | 14 | def parse_ptest(self, logfile): | 
| 15 | parser = Lparser() | 15 | parser = PtestParser() | 
| 16 | result = Result() | 16 | result = Result() | 
| 17 | 17 | ||
| 18 | with open(logfile, errors='replace') as f: | 18 | with open(logfile, errors='replace') as f: | 
| @@ -20,7 +20,7 @@ class PtestRunnerTest(OERuntimeTestCase): | |||
| 20 | result_tuple = parser.parse_line(line) | 20 | result_tuple = parser.parse_line(line) | 
| 21 | if not result_tuple: | 21 | if not result_tuple: | 
| 22 | continue | 22 | continue | 
| 23 | result_tuple = line_type, category, status, name = parser.parse_line(line) | 23 | line_type, category, status, name = result_tuple | 
| 24 | 24 | ||
| 25 | if line_type == 'section' and status == 'begin': | 25 | if line_type == 'section' and status == 'begin': | 
| 26 | current_section = name | 26 | current_section = name | 
| diff --git a/meta/lib/oeqa/utils/logparser.py b/meta/lib/oeqa/utils/logparser.py index 328baeefaf..0807093fda 100644 --- a/meta/lib/oeqa/utils/logparser.py +++ b/meta/lib/oeqa/utils/logparser.py | |||
| @@ -6,35 +6,31 @@ import re | |||
| 6 | from . import ftools | 6 | from . import ftools | 
| 7 | 7 | ||
| 8 | # A parser that can be used to identify weather a line is a test result or a section statement. | 8 | # A parser that can be used to identify weather a line is a test result or a section statement. | 
| 9 | class Lparser(object): | 9 | class PtestParser(object): | 
| 10 | 10 | ||
| 11 | def __init__(self, **kwargs): | 11 | def __init__(self): | 
| 12 | 12 | ||
| 13 | self.test_regex = {} | 13 | self.test_regex = {} | 
| 14 | self.test_regex[0] = {} | 14 | self.test_regex['pass'] = re.compile(r"^PASS:(.+)") | 
| 15 | self.test_regex[0]['pass'] = re.compile(r"^PASS:(.+)") | 15 | self.test_regex['fail'] = re.compile(r"^FAIL:(.+)") | 
| 16 | self.test_regex[0]['fail'] = re.compile(r"^FAIL:(.+)") | 16 | self.test_regex['skip'] = re.compile(r"^SKIP:(.+)") | 
| 17 | self.test_regex[0]['skip'] = re.compile(r"^SKIP:(.+)") | ||
| 18 | 17 | ||
| 19 | self.section_regex = {} | 18 | self.section_regex = {} | 
| 20 | self.section_regex[0] = {} | 19 | self.section_regex['begin'] = re.compile(r"^BEGIN: .*/(.+)/ptest") | 
| 21 | self.section_regex[0]['begin'] = re.compile(r"^BEGIN: .*/(.+)/ptest") | 20 | self.section_regex['end'] = re.compile(r"^END: .*/(.+)/ptest") | 
| 22 | self.section_regex[0]['end'] = re.compile(r"^END: .*/(.+)/ptest") | ||
| 23 | 21 | ||
| 24 | # Parse a line and return a tuple containing the type of result (test/section) and its category, status and name | 22 | # Parse a line and return a tuple containing the type of result (test/section) and its category, status and name | 
| 25 | def parse_line(self, line): | 23 | def parse_line(self, line): | 
| 26 | 24 | ||
| 27 | for test_category, test_status_list in self.test_regex.items(): | 25 | for test_status, status_regex in test_status_list.items(): | 
| 28 | for test_status, status_regex in test_status_list.items(): | 26 | test_name = status_regex.search(line) | 
| 29 | test_name = status_regex.search(line) | 27 | if test_name: | 
| 30 | if test_name: | 28 | return ['test', test_category, test_status, test_name.group(1)] | 
| 31 | return ['test', test_category, test_status, test_name.group(1)] | 29 | |
| 32 | 30 | for section_status, status_regex in section_status_list.items(): | |
| 33 | for section_category, section_status_list in self.section_regex.items(): | 31 | section_name = status_regex.search(line) | 
| 34 | for section_status, status_regex in section_status_list.items(): | 32 | if section_name: | 
| 35 | section_name = status_regex.search(line) | 33 | return ['section', section_category, section_status, section_name.group(1)] | 
| 36 | if section_name: | ||
| 37 | return ['section', section_category, section_status, section_name.group(1)] | ||
| 38 | return None | 34 | return None | 
| 39 | 35 | ||
| 40 | 36 | ||
