From cc53c3d2d4b928221f2d51d3f1ace64f34029f1e Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Sun, 24 Apr 2016 15:54:07 +0300 Subject: stateful API: add get_ports_count based on result regression: be per core takes into account number of ports --- .../stf/trex_stf_lib/trex_client.py | 24 ++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'scripts/automation/trex_control_plane/stf') diff --git a/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py b/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py index 27428e69..f5887120 100755 --- a/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py +++ b/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py @@ -1094,7 +1094,7 @@ class CTRexResult(object): if not self.is_valid_hist(): return None else: - return CTRexResult.__get_value_by_path(self._history[len(self._history)-1], tree_path_to_key, regex) + return CTRexResult.__get_value_by_path(self._history[-1], tree_path_to_key, regex) def get_value_list (self, tree_path_to_key, regex = None, filter_none = True): """ @@ -1145,11 +1145,23 @@ class CTRexResult(object): + an empty dictionary if history is empty. """ - history_size = len(self._history) - if history_size != 0: - return self._history[len(self._history) - 1] - else: - return {} + if len(self._history): + return self._history[-1] + return {} + + def get_ports_count(self): + """ + Returns number of ports based on TRex result + + :return: + + number of ports in TRex result + + -1 if history is empty. + """ + + if not len(self._history): + return -1 + return len(self.__get_value_by_path(self._history[-1], 'trex-global.data', 'opackets-\d+')) + def update_result_data (self, latest_dump): """ -- cgit 1.2.3-korg