Commit 6bdf4359 authored by Jan Kiene's avatar Jan Kiene
Browse files

add testcase name

parent cd1bf3ff
Loading
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -13,9 +13,10 @@ from pathlib import Path
class SanitizerError:
    SUMMARY_ID = ""

    def __init__(self, traceback: str, commandlines: dict) -> None:
    def __init__(self, traceback: str, commandlines: dict, testcase: str) -> None:
        self.traceback = traceback
        self.commandlines = commandlines
        self.testcase = testcase
        self.type, self.location = self.parse_type_and_location(traceback)

    def __hash__(self):
@@ -32,6 +33,7 @@ class SanitizerError:

    def to_dict(self) -> dict:
        return {
            "testcase": self.testcase,
            "location": self.location,
            "type": self.type,
            "traceback": self.traceback,
@@ -54,16 +56,10 @@ class SanitizerError:
class UsanError(SanitizerError):
    SUMMARY_ID = "UndefinedBehaviorSanitizer"

    def __init__(self, traceback: str, commandlines: dict):
        super().__init__(traceback, commandlines)


class MsanError(SanitizerError):
    SUMMARY_ID = "MemorySanitizer"

    def __init__(self, traceback: str, commandlines: dict) -> None:
        super().__init__(traceback, commandlines)


def parse_commandlines_from_sysout(sysout: str, cwd: Path) -> dict:
    commandlines = {
@@ -115,7 +111,9 @@ def postprocess_cmdline(cmdline: str, cwd: Path) -> str:
    return " ".join(cmdline_proc)


def parse_errors_from_sysout(sysout: str, cwd: Path) -> List[UsanError]:
def parse_errors_from_sysout(
    sysout: str, testcase_name: str, cwd: Path
) -> List[UsanError]:
    commandlines = parse_commandlines_from_sysout(sysout, cwd)
    errors = []

@@ -153,7 +151,7 @@ def parse_errors_from_sysout(sysout: str, cwd: Path) -> List[UsanError]:
        if line.startswith("SUMMARY:"):
            assert state == ParserState.IN

            errors.append(err_cls("\n".join(accu), commandlines))
            errors.append(err_cls("\n".join(accu), commandlines, testcase_name))
            state = ParserState.OUT

    return errors
@@ -165,8 +163,11 @@ def main(args):

    errors = []
    for tc in root[0].findall("testcase"):
        tc_name = tc.attrib["name"]
        for sysout in tc.findall("system-out"):
            errors.extend(parse_errors_from_sysout(sysout.text, args.inject_cwd))
            errors.extend(
                parse_errors_from_sysout(sysout.text, tc_name, args.inject_cwd)
            )

    unique_errors = list(sorted(set(errors)))
    print(f"Found {len(unique_errors)} unique errors")