+ return throughput, status
+
+ def _get_ndrpdr_latency(self, msg):
+ """Get LATENCY from the test message.
+
+ :param msg: The test message to be parsed.
+ :type msg: str
+ :returns: Parsed data as a dict and the status (PASS/FAIL).
+ :rtype: tuple(dict, str)
+ """
+ latency_default = {
+ u"min": -1.0,
+ u"avg": -1.0,
+ u"max": -1.0,
+ u"hdrh": u""
+ }
+ latency = {
+ u"NDR": {
+ u"direction1": copy.copy(latency_default),
+ u"direction2": copy.copy(latency_default)
+ },
+ u"PDR": {
+ u"direction1": copy.copy(latency_default),
+ u"direction2": copy.copy(latency_default)
+ },
+ u"LAT0": {
+ u"direction1": copy.copy(latency_default),
+ u"direction2": copy.copy(latency_default)
+ },
+ u"PDR10": {
+ u"direction1": copy.copy(latency_default),
+ u"direction2": copy.copy(latency_default)
+ },
+ u"PDR50": {
+ u"direction1": copy.copy(latency_default),
+ u"direction2": copy.copy(latency_default)
+ },
+ u"PDR90": {
+ u"direction1": copy.copy(latency_default),
+ u"direction2": copy.copy(latency_default)
+ },
+ }
+
+ # TODO: Rewrite when long and base are not needed
+ groups = re.search(self.REGEX_NDRPDR_LAT_LONG, msg)
+ if groups is None:
+ groups = re.search(self.REGEX_NDRPDR_LAT, msg)
+ if groups is None:
+ groups = re.search(self.REGEX_NDRPDR_LAT_BASE, msg)
+ if groups is None:
+ return latency, u"FAIL"
+
+ def process_latency(in_str):
+ """Return object with parsed latency values.
+
+ TODO: Define class for the return type.
+
+ :param in_str: Input string, min/avg/max/hdrh format.
+ :type in_str: str
+ :returns: Dict with corresponding keys, except hdrh float values.
+ :rtype dict:
+ :throws IndexError: If in_str does not have enough substrings.
+ :throws ValueError: If a substring does not convert to float.
+ """
+ in_list = in_str.split('/', 3)
+
+ rval = {
+ u"min": float(in_list[0]),
+ u"avg": float(in_list[1]),
+ u"max": float(in_list[2]),
+ u"hdrh": u""
+ }
+
+ if len(in_list) == 4:
+ rval[u"hdrh"] = str(in_list[3])
+
+ return rval
+
+ try:
+ latency[u"NDR"][u"direction1"] = process_latency(groups.group(1))
+ latency[u"NDR"][u"direction2"] = process_latency(groups.group(2))
+ latency[u"PDR"][u"direction1"] = process_latency(groups.group(3))
+ latency[u"PDR"][u"direction2"] = process_latency(groups.group(4))
+ if groups.lastindex == 4:
+ return latency, u"PASS"
+ except (IndexError, ValueError):
+ pass
+
+ try:
+ latency[u"PDR90"][u"direction1"] = process_latency(groups.group(5))
+ latency[u"PDR90"][u"direction2"] = process_latency(groups.group(6))
+ latency[u"PDR50"][u"direction1"] = process_latency(groups.group(7))
+ latency[u"PDR50"][u"direction2"] = process_latency(groups.group(8))
+ latency[u"PDR10"][u"direction1"] = process_latency(groups.group(9))
+ latency[u"PDR10"][u"direction2"] = process_latency(groups.group(10))
+ latency[u"LAT0"][u"direction1"] = process_latency(groups.group(11))
+ latency[u"LAT0"][u"direction2"] = process_latency(groups.group(12))
+ if groups.lastindex == 12:
+ return latency, u"PASS"
+ except (IndexError, ValueError):
+ pass
+
+ # TODO: Remove when not needed
+ latency[u"NDR10"] = {
+ u"direction1": copy.copy(latency_default),
+ u"direction2": copy.copy(latency_default)
+ }
+ latency[u"NDR50"] = {
+ u"direction1": copy.copy(latency_default),
+ u"direction2": copy.copy(latency_default)
+ }
+ latency[u"NDR90"] = {
+ u"direction1": copy.copy(latency_default),
+ u"direction2": copy.copy(latency_default)
+ }
+ try:
+ latency[u"LAT0"][u"direction1"] = process_latency(groups.group(5))
+ latency[u"LAT0"][u"direction2"] = process_latency(groups.group(6))
+ latency[u"NDR10"][u"direction1"] = process_latency(groups.group(7))
+ latency[u"NDR10"][u"direction2"] = process_latency(groups.group(8))
+ latency[u"NDR50"][u"direction1"] = process_latency(groups.group(9))
+ latency[u"NDR50"][u"direction2"] = process_latency(groups.group(10))
+ latency[u"NDR90"][u"direction1"] = process_latency(groups.group(11))
+ latency[u"NDR90"][u"direction2"] = process_latency(groups.group(12))
+ latency[u"PDR10"][u"direction1"] = process_latency(groups.group(13))
+ latency[u"PDR10"][u"direction2"] = process_latency(groups.group(14))
+ latency[u"PDR50"][u"direction1"] = process_latency(groups.group(15))
+ latency[u"PDR50"][u"direction2"] = process_latency(groups.group(16))
+ latency[u"PDR90"][u"direction1"] = process_latency(groups.group(17))
+ latency[u"PDR90"][u"direction2"] = process_latency(groups.group(18))
+ return latency, u"PASS"
+ except (IndexError, ValueError):
+ pass
+
+ return latency, u"FAIL"