Loading scripts/parse_sanitizer_errors_from_xml_report.py +39 −5 Original line number Diff line number Diff line #!/usr/env python3 import pandas as pd from xml.etree import ElementTree import argparse from enum import Enum from typing import List, Tuple import re import os from pathlib import Path class SanitizerError: Loading Loading @@ -61,7 +65,7 @@ class MsanError(SanitizerError): super().__init__(traceback, commandlines) def parse_commandlines_from_sysout(sysout: str) -> dict: def parse_commandlines_from_sysout(sysout: str, cwd: Path) -> dict: commandlines = { "IVAS_cod": "", "networkSimulator_g192": "", Loading @@ -81,14 +85,38 @@ def parse_commandlines_from_sysout(sysout: str) -> dict: and not line.strip().startswith(exe) ): assert commandlines[exe] == "" commandlines[exe] = line.strip() commandlines[exe] = postprocess_cmdline(line.strip(), cwd) break return commandlines def parse_errors_from_sysout(sysout: str) -> List[UsanError]: commandlines = parse_commandlines_from_sysout(sysout) def postprocess_cmdline(cmdline: str, cwd: Path) -> str: cmdline_split = cmdline.split() cmdline_proc = [] # change absolute paths into relative ones # remove the "quite" flag # for output and bitstream files only keep the filename for elem in cmdline_split: if elem == "-q": continue elif (elem_as_path := Path(elem)).is_absolute(): if elem_as_path.suffix == ".192" or ( elem_as_path.suffix == ".wav" and cmdline_split.index(elem) == len(cmdline_split) - 1 ): cmdline_proc.append(elem_as_path.name) else: cmdline_proc.append(str(elem_as_path.relative_to(cwd))) else: cmdline_proc.append(elem) return " ".join(cmdline_proc) def parse_errors_from_sysout(sysout: str, cwd: Path) -> List[UsanError]: commandlines = parse_commandlines_from_sysout(sysout, cwd) errors = [] class ParserState(Enum): Loading Loading @@ -138,7 +166,7 @@ def main(args): errors = [] for tc in root[0].findall("testcase"): for sysout in tc.findall("system-out"): errors.extend(parse_errors_from_sysout(sysout.text)) errors.extend(parse_errors_from_sysout(sysout.text, args.inject_cwd)) unique_errors = list(sorted(set(errors))) print(f"Found {len(unique_errors)} unique errors") Loading @@ -151,6 +179,12 @@ if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("xml_report") parser.add_argument("outfile") parser.add_argument( "--inject_cwd", help="Use this as cwd when pruning the long paths in the command lines. Debug option for testing.", default=Path(os.getcwd()).absolute(), type=Path, ) args = parser.parse_args() main(args) Loading
scripts/parse_sanitizer_errors_from_xml_report.py +39 −5 Original line number Diff line number Diff line #!/usr/env python3 import pandas as pd from xml.etree import ElementTree import argparse from enum import Enum from typing import List, Tuple import re import os from pathlib import Path class SanitizerError: Loading Loading @@ -61,7 +65,7 @@ class MsanError(SanitizerError): super().__init__(traceback, commandlines) def parse_commandlines_from_sysout(sysout: str) -> dict: def parse_commandlines_from_sysout(sysout: str, cwd: Path) -> dict: commandlines = { "IVAS_cod": "", "networkSimulator_g192": "", Loading @@ -81,14 +85,38 @@ def parse_commandlines_from_sysout(sysout: str) -> dict: and not line.strip().startswith(exe) ): assert commandlines[exe] == "" commandlines[exe] = line.strip() commandlines[exe] = postprocess_cmdline(line.strip(), cwd) break return commandlines def parse_errors_from_sysout(sysout: str) -> List[UsanError]: commandlines = parse_commandlines_from_sysout(sysout) def postprocess_cmdline(cmdline: str, cwd: Path) -> str: cmdline_split = cmdline.split() cmdline_proc = [] # change absolute paths into relative ones # remove the "quite" flag # for output and bitstream files only keep the filename for elem in cmdline_split: if elem == "-q": continue elif (elem_as_path := Path(elem)).is_absolute(): if elem_as_path.suffix == ".192" or ( elem_as_path.suffix == ".wav" and cmdline_split.index(elem) == len(cmdline_split) - 1 ): cmdline_proc.append(elem_as_path.name) else: cmdline_proc.append(str(elem_as_path.relative_to(cwd))) else: cmdline_proc.append(elem) return " ".join(cmdline_proc) def parse_errors_from_sysout(sysout: str, cwd: Path) -> List[UsanError]: commandlines = parse_commandlines_from_sysout(sysout, cwd) errors = [] class ParserState(Enum): Loading Loading @@ -138,7 +166,7 @@ def main(args): errors = [] for tc in root[0].findall("testcase"): for sysout in tc.findall("system-out"): errors.extend(parse_errors_from_sysout(sysout.text)) errors.extend(parse_errors_from_sysout(sysout.text, args.inject_cwd)) unique_errors = list(sorted(set(errors))) print(f"Found {len(unique_errors)} unique errors") Loading @@ -151,6 +179,12 @@ if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("xml_report") parser.add_argument("outfile") parser.add_argument( "--inject_cwd", help="Use this as cwd when pruning the long paths in the command lines. Debug option for testing.", default=Path(os.getcwd()).absolute(), type=Path, ) args = parser.parse_args() main(args)