Merge pull request #12535 from terfendail:testparser_update

pull/12512/head
Alexander Alekhin 6 years ago
commit 29c10b6792
  1. 36
      modules/ts/misc/testlog_parser.py

@ -33,6 +33,11 @@ class TestInfo(object):
self.status = "disabled" self.status = "disabled"
self.fixture = self.fixture.replace("DISABLED_", "") self.fixture = self.fixture.replace("DISABLED_", "")
self.name = self.name.replace("DISABLED_", "") self.name = self.name.replace("DISABLED_", "")
self.properties = {
prop.getAttribute("name") : prop.getAttribute("value")
for prop in xmlnode.getElementsByTagName("property")
if prop.hasAttribute("name") and prop.hasAttribute("value")
}
self.metrix = {} self.metrix = {}
self.parseLongMetric(xmlnode, "bytesIn"); self.parseLongMetric(xmlnode, "bytesIn");
self.parseLongMetric(xmlnode, "bytesOut"); self.parseLongMetric(xmlnode, "bytesOut");
@ -48,33 +53,34 @@ class TestInfo(object):
self.parseFloatMetric(xmlnode, "time"); self.parseFloatMetric(xmlnode, "time");
def parseLongMetric(self, xmlnode, name, default = 0): def parseLongMetric(self, xmlnode, name, default = 0):
if xmlnode.hasAttribute(name): if name in self.properties:
tmp = xmlnode.getAttribute(name) self.metrix[name] = long(self.properties[name])
val = long(tmp) elif xmlnode.hasAttribute(name):
self.metrix[name] = val self.metrix[name] = long(xmlnode.getAttribute(name))
else: else:
self.metrix[name] = default self.metrix[name] = default
def parseIntMetric(self, xmlnode, name, default = 0): def parseIntMetric(self, xmlnode, name, default = 0):
if xmlnode.hasAttribute(name): if name in self.properties:
tmp = xmlnode.getAttribute(name) self.metrix[name] = int(self.properties[name])
val = int(tmp) elif xmlnode.hasAttribute(name):
self.metrix[name] = val self.metrix[name] = int(xmlnode.getAttribute(name))
else: else:
self.metrix[name] = default self.metrix[name] = default
def parseFloatMetric(self, xmlnode, name, default = 0): def parseFloatMetric(self, xmlnode, name, default = 0):
if xmlnode.hasAttribute(name): if name in self.properties:
tmp = xmlnode.getAttribute(name) self.metrix[name] = float(self.properties[name])
val = float(tmp) elif xmlnode.hasAttribute(name):
self.metrix[name] = val self.metrix[name] = float(xmlnode.getAttribute(name))
else: else:
self.metrix[name] = default self.metrix[name] = default
def parseStringMetric(self, xmlnode, name, default = None): def parseStringMetric(self, xmlnode, name, default = None):
if xmlnode.hasAttribute(name): if name in self.properties:
tmp = xmlnode.getAttribute(name) self.metrix[name] = self.properties[name].strip()
self.metrix[name] = tmp.strip() elif xmlnode.hasAttribute(name):
self.metrix[name] = xmlnode.getAttribute(name).strip()
else: else:
self.metrix[name] = default self.metrix[name] = default

Loading…
Cancel
Save