aboutsummaryrefslogtreecommitdiffstats
path: root/build/plugins/suppressions.py
blob: db5037646dfc7879119ede9c157ca4f1b83e5080 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def onsuppressions(unit, *args):
    """
    SUPPRESSIONS() - allows to specify files with suppression notation which will be used by
    address, leak or thread sanitizer runtime by default.
    Use asan.supp filename for address sanitizer, lsan.supp for leak sanitizer
    and tsan.supp for thread sanitizer suppressions respectively.
    See https://clang.llvm.org/docs/AddressSanitizer.html#suppressing-memory-leaks
    for details.
    """
    import os

    valid = ("asan.supp", "tsan.supp", "lsan.supp")

    if unit.get("SANITIZER_TYPE") in ("leak", "address", "thread"):
        for x in args:
            if os.path.basename(x) not in valid:
                unit.message(
                    [
                        'error',
                        "Invalid suppression filename: {} (any of the following is expected: {})".format(x, valid),
                    ]
                )
                return
        unit.onsrcs(["GLOBAL"] + list(args))