diff options
author | Tibor Frank <tifrank@cisco.com> | 2019-08-15 13:12:57 +0200 |
---|---|---|
committer | Tibor Frank <tifrank@cisco.com> | 2019-08-15 12:30:12 +0000 |
commit | 3e58c2f916288c5ed22ce11f01fa56a4d19689d2 (patch) | |
tree | 547d1f04b0964ab76244c6ba0b3695948dd11f96 | |
parent | 660e18c08e0aef112d8bfa0dd6607ba307687c1e (diff) |
PAL: Process show runtime output
Change-Id: If7eac41cd33837eea7291f87129e2c176fbe6aea
Signed-off-by: Tibor Frank <tifrank@cisco.com>
-rw-r--r-- | resources/tools/presentation/input_data_parser.py | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/resources/tools/presentation/input_data_parser.py b/resources/tools/presentation/input_data_parser.py index 87989c5f91..b0d7245e0c 100644 --- a/resources/tools/presentation/input_data_parser.py +++ b/resources/tools/presentation/input_data_parser.py @@ -23,6 +23,7 @@ import re import resource import pandas as pd import logging +import prettytable from robot.api import ExecutionResult, ResultVisitor from robot import errors @@ -495,17 +496,53 @@ class ExecutionChecker(ResultVisitor): :type msg: Message :returns: Nothing. """ - if msg.message.count("Thread 0 vpp_main"): + if msg.message.count("Runtime:"): self._show_run_lookup_nr += 1 if self._lookup_kw_nr == 1 and self._show_run_lookup_nr == 1: self._data["tests"][self._test_ID]["show-run"] = str() if self._lookup_kw_nr > 1: self._msg_type = None if self._show_run_lookup_nr == 1: - text = msg.message.replace("vat# ", "").\ - replace("return STDOUT ", "").replace("\n\n", "\n").\ - replace('\n', ' |br| ').\ - replace('\r', '').replace('"', "'") + message = str(msg.message).replace(' ', '').replace('\n', '').\ + replace("'", '"').replace('b"', '"').replace('u"', '"')[8:] + runtime = loads(message) + try: + threads_nr = len(runtime[0]["clocks"]) + except (IndexError, KeyError): + return + tbl_hdr = ["Name", "Calls", "Vectors", "Suspends", "Clocks"] + table = [[tbl_hdr, ] for _ in range(threads_nr)] + for item in runtime: + for idx in range(threads_nr): + table[idx].append([ + item["name"], + item["calls"][idx], + item["vectors"][idx], + item["suspends"][idx], + item["clocks"][idx] + ]) + text = "" + for idx in range(threads_nr): + text += "Thread {idx} ".format(idx=idx) + text += "vpp_main\n" if idx == 0 else \ + "vpp_wk_{idx}\n".format(idx=idx-1) + txt_table = None + for row in table[idx]: + if txt_table is None: + txt_table = prettytable.PrettyTable(row) + else: + if any(row[1:]): + txt_table.add_row(row) + txt_table.align["Name"] = "l" + txt_table.align["Calls"] = "r" + txt_table.align["Vectors"] = "r" + txt_table.align["Suspends"] = "r" + txt_table.align["Clocks"] = "r" + + text += txt_table.get_string(sortby="Name") + '\n' + + text = text.replace('\n', ' |br| ').replace('\r', '').\ + replace('"', "'") try: self._data["tests"][self._test_ID]["show-run"] += " |br| " self._data["tests"][self._test_ID]["show-run"] += \ |