File: coverage_prefix_map.bash

package info (click to toggle)
ccache 4.13.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,420 kB
  • sloc: cpp: 50,251; asm: 28,570; sh: 9,632; ansic: 5,357; python: 834; perl: 68; makefile: 24
file content (154 lines) | stat: -rw-r--r-- 5,104 bytes parent folder | download
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
SUITE_coverage_prefix_map_PROBE() {
    touch test.c
    if ! $COMPILER -c -fcoverage-prefix-map=old=new test.c 2>/dev/null; then
        echo "-fcoverage-prefix-map not supported by compiler"
    fi

    if ! $RUN_WIN_XFAIL; then
        echo "coverage_prefix_map tests are broken on Windows."
        return
    fi
}

SUITE_coverage_prefix_map_SETUP() {
    unset CCACHE_NODIRECT

    mkdir -p dir1/src dir1/include
    cat <<EOF >dir1/src/test.c
#include <stdarg.h>
#include <test.h>
EOF
    cat <<EOF >dir1/include/test.h
int test;
EOF
    cp -r dir1 dir2
    backdate dir1/include/test.h dir2/include/test.h
}

SUITE_coverage_prefix_map() {
    # -------------------------------------------------------------------------
    TEST "Cache misses without a configured coverage prefix map"

    cd dir1
    CCACHE_BASEDIR=$(pwd) $CCACHE_COMPILE \
        -I$(pwd)/include \
        -g \
        -fprofile-instr-generate \
        -fdebug-compilation-dir=some_name_not_likely_to_exist_in_path \
        -c $(pwd)/src/test.c \
        -o $(pwd)/test.o
    expect_stat direct_cache_hit 0
    expect_stat preprocessed_cache_hit 0
    expect_stat cache_miss 1
    expect_stat files_in_cache 2

    cd ../dir2
    CCACHE_BASEDIR=$(pwd) $CCACHE_COMPILE \
        -I$(pwd)/include \
        -g \
        -fprofile-instr-generate \
        -fdebug-compilation-dir=some_name_not_likely_to_exist_in_path \
        -c $(pwd)/src/test.c \
        -o $(pwd)/test.o
    expect_stat direct_cache_hit 0
    expect_stat preprocessed_cache_hit 0
    expect_stat cache_miss 2
    expect_stat files_in_cache 4

    # -------------------------------------------------------------------------
    TEST "Cache hits with a configured coverage prefix map"

    cd dir1
    CCACHE_BASEDIR=$(pwd) $CCACHE_COMPILE \
        -I$(pwd)/include \
        -g \
        -fprofile-instr-generate \
        -fdebug-compilation-dir=some_name_not_likely_to_exist_in_path \
        -fcoverage-prefix-map=$(pwd)=some_other_name_not_likely_to_exist_in_path \
        -c $(pwd)/src/test.c \
        -o $(pwd)/test.o
    expect_stat direct_cache_hit 0
    expect_stat preprocessed_cache_hit 0
    expect_stat cache_miss 1
    expect_stat files_in_cache 2

    cd ../dir2
    CCACHE_BASEDIR=$(pwd) $CCACHE_COMPILE \
        -I$(pwd)/include \
        -g \
        -fprofile-instr-generate \
        -fdebug-compilation-dir=some_name_not_likely_to_exist_in_path \
        -fcoverage-prefix-map=$(pwd)=some_other_name_not_likely_to_exist_in_path \
        -c $(pwd)/src/test.c \
        -o $(pwd)/test.o
    expect_stat direct_cache_hit 1
    expect_stat preprocessed_cache_hit 0
    expect_stat cache_miss 1
    expect_stat files_in_cache 2

    # -------------------------------------------------------------------------
    TEST "Cache hits with multiple configured coverage prefix maps"

    cd dir1
    CCACHE_BASEDIR=$(pwd) $CCACHE_COMPILE \
        -I$(pwd)/include \
        -g \
        -fprofile-instr-generate \
        -fdebug-compilation-dir=some_name_not_likely_to_exist_in_path \
        -fcoverage-prefix-map=$(pwd)=some_other_name_not_likely_to_exist_in_path \
        -fcoverage-prefix-map=foo=bar \
        -c $(pwd)/src/test.c \
        -o $(pwd)/test.o
    expect_stat direct_cache_hit 0
    expect_stat preprocessed_cache_hit 0
    expect_stat cache_miss 1
    expect_stat files_in_cache 2

    cd ../dir2
    CCACHE_BASEDIR=$(pwd) $CCACHE_COMPILE \
        -I$(pwd)/include \
        -g \
        -fprofile-instr-generate \
        -fdebug-compilation-dir=some_name_not_likely_to_exist_in_path \
        -fcoverage-prefix-map=$(pwd)=some_other_name_not_likely_to_exist_in_path \
        -fcoverage-prefix-map=foo=bar \
        -c $(pwd)/src/test.c \
        -o $(pwd)/test.o
    expect_stat direct_cache_hit 1
    expect_stat preprocessed_cache_hit 0
    expect_stat cache_miss 1
    expect_stat files_in_cache 2

    # -------------------------------------------------------------------------
    TEST "Cache hits with multiple configured coverage prefix maps (different order)"

    cd dir1
    CCACHE_BASEDIR=$(pwd) $CCACHE_COMPILE \
        -I$(pwd)/include \
        -g \
        -fprofile-instr-generate \
        -fdebug-compilation-dir=some_name_not_likely_to_exist_in_path \
        -fcoverage-prefix-map=foo=bar \
        -fcoverage-prefix-map=$(pwd)=some_other_name_not_likely_to_exist_in_path \
        -c $(pwd)/src/test.c \
        -o $(pwd)/test.o
    expect_stat direct_cache_hit 0
    expect_stat preprocessed_cache_hit 0
    expect_stat cache_miss 1
    expect_stat files_in_cache 2

    cd ../dir2
    CCACHE_BASEDIR=$(pwd) $CCACHE_COMPILE \
        -I$(pwd)/include \
        -g \
        -fprofile-instr-generate \
        -fdebug-compilation-dir=some_name_not_likely_to_exist_in_path \
        -fcoverage-prefix-map=$(pwd)=some_other_name_not_likely_to_exist_in_path \
        -fcoverage-prefix-map=foo=bar \
        -c $(pwd)/src/test.c \
        -o $(pwd)/test.o
    expect_stat direct_cache_hit 1
    expect_stat preprocessed_cache_hit 0
    expect_stat cache_miss 1
    expect_stat files_in_cache 2
}