Skip to content

Commit

Permalink
Add ValgrindScanner methods
Browse files Browse the repository at this point in the history
Signed-off-by: Vallari Agrawal <[email protected]>
  • Loading branch information
VallariAg committed Jan 2, 2023
1 parent a3af9a4 commit d4efb4b
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions teuthology/util/xml_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ def scan_file(self, path):
(_, stdout, _) = self.client.exec_command(f'cat {path}', timeout=200)
if stdout:
xml_tree = etree.parse(stdout)
error_txt, error_data = self.get_error(xml_tree)
error_txt, error_data = self._get_error(xml_tree)
if error_data:
error_data["xml_file"] = path
self.yaml_data += [error_data]
return error_txt
log.debug(f'XML output not found at `{str(path)}`!')

def get_error(self):
def _get_error(self):
# defined in inherited classes
pass
return None, None

def write_logs(self):
yamlfile = self.yaml_path
Expand Down Expand Up @@ -84,7 +84,7 @@ def get_error_msg(self, xml_path):
log.exception(exc)
log.info("XML_DEBUG: get_error_msg: " + repr(exc))

def get_error(self, xml_tree):
def _get_error(self, xml_tree):
"""
Returns message of first error found.
And stores info of all errors in yaml_data.
Expand Down Expand Up @@ -118,11 +118,40 @@ def get_error(self, xml_tree):

return error_txt, { "failed_testsuites": dict(error_data), "num_of_failures": len(failed_testcases) }


class ValgrindScanner(XMLScanner):
def __init__(self, client=None) -> None:
super().__init__(client)
self.yaml_path = "/home/ubuntu/cephtest/archive/valgrind.yaml"

def get_error(self, xml_tree):
pass
def generate_yaml_summary(self):
try:
self.scan_all_files_in_dir('/var/log/ceph/valgrind/', '*')
except Exception as exc:
log.exception(exc)
log.info("XML_DEBUG: get_error_msg: " + repr(exc))


def _get_error(self, xml_tree):
if not xml_tree:
return None, None
error_tree = xml_tree.find('error')

error_data = {
"kind": "",
"traceback": "",
}

kind = error_tree.find('kind')
error_data["kind"] = kind.text

error_traceback = []
stack = error_tree.find('stack')
for frame in stack:
if len(error_traceback) >= 5:
break
fn = frame.find('fn')
error_traceback += [fn.text]
error_traceback_s = " \n".join(error_traceback)
error_data["traceback"] = error_traceback_s

return error_traceback_s, error_data

0 comments on commit d4efb4b

Please sign in to comment.