diff options
author | Tibor Frank <tifrank@cisco.com> | 2018-08-20 14:23:46 +0200 |
---|---|---|
committer | Tibor Frank <tifrank@cisco.com> | 2018-08-22 13:12:38 +0000 |
commit | 4ac3464851ff9dd688ab25d0324573284b6bf274 (patch) | |
tree | be4b7456d9c5d30e4d81e107d79af8847d144d5c /resources/tools/presentation/input_data_parser.py | |
parent | 68c245727d68fc7ba84b7f494a1dbcb69910213e (diff) |
CSIT-944: PAL Extensions: Mapping table
Change-Id: I3bebf9ad849c056d2bbac476d22ef5e077af05b3
Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/tools/presentation/input_data_parser.py')
-rw-r--r-- | resources/tools/presentation/input_data_parser.py | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/resources/tools/presentation/input_data_parser.py b/resources/tools/presentation/input_data_parser.py index 4a72266f5f..0ecaf3fa5c 100644 --- a/resources/tools/presentation/input_data_parser.py +++ b/resources/tools/presentation/input_data_parser.py @@ -289,12 +289,17 @@ class ExecutionChecker(ResultVisitor): REGEX_TC_NUMBER = re.compile(r'tc[0-9]{2}-') - def __init__(self, metadata): + def __init__(self, metadata, mapping, ignore): """Initialisation. :param metadata: Key-value pairs to be included in "metadata" part of - JSON structure. + JSON structure. + :param mapping: Mapping of the old names of test cases to the new + (actual) one. + :param ignore: List of TCs to be ignored. :type metadata: dict + :type mapping: dict + :type ignore: list """ # Type of message to parse out from the test messages @@ -306,6 +311,12 @@ class ExecutionChecker(ResultVisitor): # Timestamp self._timestamp = None + # Mapping of TCs long names + self._mapping = mapping + + # Ignore list + self._ignore = ignore + # Number of VAT History messages found: # 0 - no message # 1 - VAT History of DUT1 @@ -626,12 +637,30 @@ class ExecutionChecker(ResultVisitor): :returns: Nothing. """ + longname_orig = test.longname.lower() + + # Check the ignore list + if longname_orig in self._ignore: + return + tags = [str(tag) for tag in test.tags] test_result = dict() - test_result["name"] = test.name.lower() + + # Change the TC long name and name if defined in the mapping table + longname = self._mapping.get(longname_orig, None) + if longname is not None: + name = longname.split('.')[-1] + logging.debug("{0}\n{1}\n{2}\n{3}".format( + self._data["metadata"], longname_orig, longname, name)) + else: + longname = longname_orig + name = test.name.lower() + + # Remove TC number from the TC long name (backward compatibility): + self._test_ID = re.sub(self.REGEX_TC_NUMBER, "", longname) # Remove TC number from the TC name (not needed): - test_result["name"] = re.sub(self.REGEX_TC_NUMBER, "", - test.name.lower()) + test_result["name"] = re.sub(self.REGEX_TC_NUMBER, "", name) + test_result["parent"] = test.parent.name.lower() test_result["tags"] = tags doc_str = test.doc.replace('"', "'").replace('\n', ' '). \ @@ -641,8 +670,6 @@ class ExecutionChecker(ResultVisitor): replace('\r', '').replace('"', "'") test_result["type"] = "FUNC" test_result["status"] = test.status - # Remove TC number from the TC long name (backward compatibility): - self._test_ID = re.sub(self.REGEX_TC_NUMBER, "", test.longname.lower()) if "PERFTEST" in tags: # Replace info about cores (e.g. -1c-) with the info about threads @@ -1021,8 +1048,7 @@ class InputData(object): return self.data[job][build]["tests"] - @staticmethod - def _parse_tests(job, build, log): + def _parse_tests(self, job, build, log): """Process data from robot output.xml file and return JSON structured data. @@ -1048,7 +1074,8 @@ class InputData(object): log.append(("ERROR", "Error occurred while parsing output.xml: " "{0}".format(err))) return None - checker = ExecutionChecker(metadata) + checker = ExecutionChecker(metadata, self._cfg.mapping, + self._cfg.ignore) result.visit(checker) return checker.data @@ -1099,7 +1126,7 @@ class InputData(object): if success: logs.append(("INFO", " Processing data from the build '{0}' ...". format(build["build"]))) - data = InputData._parse_tests(job, build, logs) + data = self._parse_tests(job, build, logs) if data is None: logs.append(("ERROR", "Input data file from the job '{job}', " "build '{build}' is damaged. Skipped.". |