Commit ef22f78e authored by Jan Kiene's avatar Jan Kiene
Browse files

some fixes

- fix commandline extraction for multiple occurences of same exe
- when sorting issues put the ones with more found cmdlines first
- add logging
parent 9523179c
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -8,6 +8,10 @@ from typing import List, Tuple
import re
import os
from pathlib import Path
import logging


logging.basicConfig(level=logging.INFO)


class SanitizerError:
@@ -31,7 +35,14 @@ class SanitizerError:
        return f"<{self.__class__.__name__} at {self.location}>"

    def __lt__(self, other):
        # order by string comparison of location as first criterion
        # if location is the same in both instances, the smaller one is the one with more found command lines
        if self.location != other.location:
            return self.location < other.location
        else:
            num_cmdl_self = list(self.commandlines.values()).count("")
            num_cmdl_other = list(other.commandlines.values()).count("")
            return num_cmdl_self > num_cmdl_other

    def to_dict(self) -> dict:
        return {
@@ -86,8 +97,14 @@ def parse_commandlines_from_sysout(sysout: str, cwd: Path) -> dict:
                and " in _start " not in line
                and not line.strip().startswith(exe)
            ):
                assert commandlines[exe] == ""
                if commandlines[exe] != "":
                    logging.debug(
                        f"Commandline for {exe} already found, skip second one."
                    )
                else:
                    commandlines[exe] = postprocess_cmdline(line.strip(), cwd)

                # assumption: only one commandline per line
                break

    return commandlines
@@ -124,6 +141,7 @@ def postprocess_cmdline(cmdline: str, cwd: Path) -> str:
def parse_errors_from_sysout(
    sysout: str, testcase_name: str, cwd: Path
) -> List[UsanError]:
    logging.debug(testcase_name)
    commandlines = parse_commandlines_from_sysout(sysout, cwd)
    errors = []

@@ -179,7 +197,7 @@ def main(args):
                parse_errors_from_sysout(sysout.text, tc_name, args.inject_cwd)
            )

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

    df = pd.DataFrame([e.to_dict() for e in unique_errors])