summaryrefslogtreecommitdiff
path: root/test/suites/sanitize_blacklist.bash
blob: a2411e9bcbd67b332b000f675b2d21247855d4fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
SUITE_sanitize_blacklist_PROBE() {
    touch test.c blacklist.txt
    if ! $REAL_COMPILER -c -fsanitize-blacklist=blacklist.txt \
         test.c 2>/dev/null; then
        echo "-fsanitize-blacklist not supported by compiler"
    fi
}

SUITE_sanitize_blacklist_SETUP() {
    generate_code 1 test1.c
    echo "fun:foo" >blacklist.txt

    unset CCACHE_NODIRECT
}

SUITE_sanitize_blacklist() {
    # -------------------------------------------------------------------------
    TEST "Compile OK"

    $REAL_COMPILER -c -fsanitize-blacklist=blacklist.txt test1.c

    $CCACHE_COMPILE -c -fsanitize-blacklist=blacklist.txt test1.c
    expect_stat 'cache hit (direct)' 0
    expect_stat 'cache miss' 1
    expect_stat 'files in cache' 2

    $CCACHE_COMPILE -c -fsanitize-blacklist=blacklist.txt test1.c
    expect_stat 'cache hit (direct)' 1
    expect_stat 'cache miss' 1
    expect_stat 'files in cache' 2

    echo "fun:bar" >blacklist.txt

    $CCACHE_COMPILE -c -fsanitize-blacklist=blacklist.txt test1.c
    expect_stat 'cache hit (direct)' 1
    expect_stat 'cache miss' 2
    expect_stat 'files in cache' 4

    $CCACHE_COMPILE -c -fsanitize-blacklist=blacklist.txt test1.c
    expect_stat 'cache hit (direct)' 2
    expect_stat 'cache miss' 2
    expect_stat 'files in cache' 4

    # -------------------------------------------------------------------------
    TEST "Compile failed"

    if $REAL_COMPILER -c -fsanitize-blacklist=nosuchfile.txt test1.c 2>expected.stderr; then
        test_failed "Expected an error compiling test1.c"
    fi

    rm blacklist.txt

    if $CCACHE_COMPILE -c -fsanitize-blacklist=blacklist.txt test1.c 2>expected.stderr; then
        test_failed "Expected an error compiling test1.c"
    fi

    expect_stat 'error hashing extra file' 1
}