[Coverage][llvm-cov] Enable MC/DC Support in LLVM Source-based Code Coverage (2/3)
[llvm-project.git] / llvm / test / tools / llvm-cov / mcdc-const.test
blob86cc03437110b96de2cf3a26a95e3dcc18501a12
1 // Test visualization of MC/DC constructs for constant-folded condition masking.
3 // RUN: llvm-profdata merge %S/Inputs/mcdc-const.proftext -o %t.profdata
4 // RUN: llvm-cov show --show-branches=count --show-mcdc %S/Inputs/mcdc-const.o -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs %S/Inputs/mcdc-const.cpp | FileCheck %s -check-prefix=CHECKGENERALCASE
6 // CHECKGENERALCASE:  ------------------
7 // CHECKGENERALCASE-NEXT:  |  Branch (12:8): [True: 4, False: 1]
8 // CHECKGENERALCASE-NEXT:  |  Branch (12:13): [Folded - Ignored]
9 // CHECKGENERALCASE-NEXT:  |  Branch (12:20): [Folded - Ignored]
10 // CHECKGENERALCASE-NEXT:  |  Branch (12:25): [True: 0, False: 0]
11 // CHECKGENERALCASE-NEXT:  |  Branch (12:31): [Folded - Ignored]
12 // CHECKGENERALCASE-NEXT:  ------------------
13 // CHECKGENERALCASE-NEXT:  |---> MC/DC Decision Region (12:7) to (12:32)
14 // CHECKGENERALCASE-NEXT:  |
15 // CHECKGENERALCASE-NEXT:  |  Number of Conditions: 5
16 // CHECKGENERALCASE-NEXT:  |     Condition C1 --> (12:8)
17 // CHECKGENERALCASE-NEXT:  |     Condition C2 --> (12:13)
18 // CHECKGENERALCASE-NEXT:  |     Condition C3 --> (12:20)
19 // CHECKGENERALCASE-NEXT:  |     Condition C4 --> (12:25)
20 // CHECKGENERALCASE-NEXT:  |     Condition C5 --> (12:31)
21 // CHECKGENERALCASE-NEXT:  |
22 // CHECKGENERALCASE-NEXT:  |  Executed MC/DC Test Vectors:
23 // CHECKGENERALCASE-NEXT:  |
24 // CHECKGENERALCASE-NEXT:  |     C1, C2, C3, C4, C5    Result
25 // CHECKGENERALCASE-NEXT:  |  1 { F,  C,  C,  -,  C  = F      }
26 // CHECKGENERALCASE-NEXT:  |  2 { T,  C,  C,  -,  C  = T      }
27 // CHECKGENERALCASE-NEXT:  |
28 // CHECKGENERALCASE-NEXT:  |  C1-Pair: covered: (1,2)
29 // CHECKGENERALCASE-NEXT:  |  C2-Pair: constant folded
30 // CHECKGENERALCASE-NEXT:  |  C3-Pair: constant folded
31 // CHECKGENERALCASE-NEXT:  |  C4-Pair: not covered
32 // CHECKGENERALCASE-NEXT:  |  C5-Pair: constant folded
33 // CHECKGENERALCASE-NEXT:  |  MC/DC Coverage for Decision: 50.00%
34 // CHECKGENERALCASE-NEXT:  |
35 // CHECKGENERALCASE-NEXT:  ------------------
37 // RUN: llvm-profdata merge %S/Inputs/mcdc-const-folding.proftext -o %t.profdata
38 // RUN: llvm-cov show --show-mcdc %S/Inputs/mcdc-const-folding.o -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs %S/Inputs/mcdc-const-folding.cpp | FileCheck %s -check-prefix=CHECKFULLCASE
39 // RUN: llvm-cov report --show-mcdc-summary %S/Inputs/mcdc-const-folding.o -instr-profile %t.profdata -show-functions -path-equivalence=/tmp,%S/Inputs %S/Inputs/mcdc-const-folding.cpp | FileCheck %s -check-prefix=REPORT
41 // CHECKFULLCASE: |  1 { C,  -  = F      }
42 // CHECKFULLCASE: |  C1-Pair: constant folded
43 // CHECKFULLCASE: |  C2-Pair: not covered
44 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 0.00%
45 // CHECKFULLCASE: |  1 { F,  C  = F      }
46 // CHECKFULLCASE: |  2 { T,  C  = F      }
47 // CHECKFULLCASE: |  C1-Pair: not covered
48 // CHECKFULLCASE: |  C2-Pair: constant folded
49 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 0.00%
50 // CHECKFULLCASE: |  1 { C,  F  = F      }
51 // CHECKFULLCASE: |  2 { C,  T  = T      }
52 // CHECKFULLCASE: |  C1-Pair: constant folded
53 // CHECKFULLCASE: |  C2-Pair: covered: (1,2)
54 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 100.00%
55 // CHECKFULLCASE: |  1 { F,  C  = F      }
56 // CHECKFULLCASE: |  2 { T,  C  = T      }
57 // CHECKFULLCASE: |  C1-Pair: covered: (1,2)
58 // CHECKFULLCASE: |  C2-Pair: constant folded
59 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 100.00%
60 // CHECKFULLCASE: |  1 { C,  -  = T      }
61 // CHECKFULLCASE: |  C1-Pair: constant folded
62 // CHECKFULLCASE: |  C2-Pair: not covered
63 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 0.00%
64 // CHECKFULLCASE: |  1 { T,  C  = T      }
65 // CHECKFULLCASE: |  2 { F,  C  = T      }
66 // CHECKFULLCASE: |  C1-Pair: not covered
67 // CHECKFULLCASE: |  C2-Pair: constant folded
68 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 0.00%
69 // CHECKFULLCASE: |  1 { C,  F  = F      }
70 // CHECKFULLCASE: |  2 { C,  T  = T      }
71 // CHECKFULLCASE: |  C1-Pair: constant folded
72 // CHECKFULLCASE: |  C2-Pair: covered: (1,2)
73 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 100.00%
74 // CHECKFULLCASE: |  1 { F,  C  = F      }
75 // CHECKFULLCASE: |  2 { T,  C  = T      }
76 // CHECKFULLCASE: |  C1-Pair: covered: (1,2)
77 // CHECKFULLCASE: |  C2-Pair: constant folded
78 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 100.00%
79 // CHECKFULLCASE: |  1 { C,  -,  -  = F      }
80 // CHECKFULLCASE: |  C1-Pair: constant folded
81 // CHECKFULLCASE: |  C2-Pair: not covered
82 // CHECKFULLCASE: |  C3-Pair: not covered
83 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 0.00%
84 // CHECKFULLCASE: |  1 { F,  C,  -  = F      }
85 // CHECKFULLCASE: |  2 { T,  C,  -  = F      }
86 // CHECKFULLCASE: |  C1-Pair: not covered
87 // CHECKFULLCASE: |  C2-Pair: constant folded
88 // CHECKFULLCASE: |  C3-Pair: not covered
89 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 0.00%
90 // CHECKFULLCASE: |  1 { C,  F,  -  = F      }
91 // CHECKFULLCASE: |  2 { C,  T,  F  = F      }
92 // CHECKFULLCASE: |  3 { C,  T,  T  = T      }
93 // CHECKFULLCASE: |  C1-Pair: constant folded
94 // CHECKFULLCASE: |  C2-Pair: covered: (1,3)
95 // CHECKFULLCASE: |  C3-Pair: covered: (2,3)
96 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 100.00%
97 // CHECKFULLCASE: |  1 { F,  C,  -  = F      }
98 // CHECKFULLCASE: |  2 { T,  C,  F  = F      }
99 // CHECKFULLCASE: |  3 { T,  C,  T  = T      }
100 // CHECKFULLCASE: |  C1-Pair: covered: (1,3)
101 // CHECKFULLCASE: |  C2-Pair: constant folded
102 // CHECKFULLCASE: |  C3-Pair: covered: (2,3)
103 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 100.00%
104 // CHECKFULLCASE: |  1 { C,  -,  -  = T      }
105 // CHECKFULLCASE: |  C1-Pair: constant folded
106 // CHECKFULLCASE: |  C2-Pair: not covered
107 // CHECKFULLCASE: |  C3-Pair: not covered
108 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 0.00%
109 // CHECKFULLCASE: |  1 { T,  C,  -  = T      }
110 // CHECKFULLCASE: |  2 { F,  C,  -  = T      }
111 // CHECKFULLCASE: |  C1-Pair: not covered
112 // CHECKFULLCASE: |  C2-Pair: constant folded
113 // CHECKFULLCASE: |  C3-Pair: not covered
114 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 0.00%
115 // CHECKFULLCASE: |  1 { C,  F,  T  = T      }
116 // CHECKFULLCASE: |  2 { C,  T,  -  = T      }
117 // CHECKFULLCASE: |  C1-Pair: constant folded
118 // CHECKFULLCASE: |  C2-Pair: not covered
119 // CHECKFULLCASE: |  C3-Pair: not covered
120 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 0.00%
121 // CHECKFULLCASE: |  1 { T,  C,  -  = T      }
122 // CHECKFULLCASE: |  2 { F,  C,  T  = T      }
123 // CHECKFULLCASE: |  C1-Pair: not covered
124 // CHECKFULLCASE: |  C2-Pair: constant folded
125 // CHECKFULLCASE: |  C3-Pair: not covered
126 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 0.00%
127 // CHECKFULLCASE: |  1 { F,  -,  C  = F      }
128 // CHECKFULLCASE: |  2 { T,  F,  C  = F      }
129 // CHECKFULLCASE: |  3 { T,  T,  C  = F      }
130 // CHECKFULLCASE: |  C1-Pair: not covered
131 // CHECKFULLCASE: |  C2-Pair: not covered
132 // CHECKFULLCASE: |  C3-Pair: constant folded
133 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 0.00%
134 // CHECKFULLCASE: |  1 { F,  C,  -  = F      }
135 // CHECKFULLCASE: |  2 { T,  C,  -  = F      }
136 // CHECKFULLCASE: |  C1-Pair: not covered
137 // CHECKFULLCASE: |  C2-Pair: constant folded
138 // CHECKFULLCASE: |  C3-Pair: not covered
139 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 0.00%
140 // CHECKFULLCASE: |  1 { F,  -,  C  = F      }
141 // CHECKFULLCASE: |  2 { T,  F,  C  = F      }
142 // CHECKFULLCASE: |  3 { T,  T,  C  = T      }
143 // CHECKFULLCASE: |  C1-Pair: covered: (1,3)
144 // CHECKFULLCASE: |  C2-Pair: covered: (2,3)
145 // CHECKFULLCASE: |  C3-Pair: constant folded
146 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 100.00%
147 // CHECKFULLCASE: |  1 { F,  C,  -  = F      }
148 // CHECKFULLCASE: |  2 { T,  C,  F  = F      }
149 // CHECKFULLCASE: |  3 { T,  C,  T  = T      }
150 // CHECKFULLCASE: |  C1-Pair: covered: (1,3)
151 // CHECKFULLCASE: |  C2-Pair: constant folded
152 // CHECKFULLCASE: |  C3-Pair: covered: (2,3)
153 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 100.00%
154 // CHECKFULLCASE: |  1 { T,  -,  C  = T      }
155 // CHECKFULLCASE: |  2 { F,  T,  C  = T      }
156 // CHECKFULLCASE: |  C1-Pair: not covered
157 // CHECKFULLCASE: |  C2-Pair: not covered
158 // CHECKFULLCASE: |  C3-Pair: constant folded
159 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 0.00%
160 // CHECKFULLCASE: |  1 { T,  C,  -  = T      }
161 // CHECKFULLCASE: |  2 { F,  C,  -  = T      }
162 // CHECKFULLCASE: |  C1-Pair: not covered
163 // CHECKFULLCASE: |  C2-Pair: constant folded
164 // CHECKFULLCASE: |  C3-Pair: not covered
165 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 0.00%
166 // CHECKFULLCASE: |  1 { T,  -,  C  = T      }
167 // CHECKFULLCASE: |  2 { F,  T,  C  = T      }
168 // CHECKFULLCASE: |  C1-Pair: not covered
169 // CHECKFULLCASE: |  C2-Pair: not covered
170 // CHECKFULLCASE: |  C3-Pair: constant folded
171 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 0.00%
172 // CHECKFULLCASE: |  1 { T,  C,  -  = T      }
173 // CHECKFULLCASE: |  2 { F,  C,  T  = T      }
174 // CHECKFULLCASE: |  C1-Pair: not covered
175 // CHECKFULLCASE: |  C2-Pair: constant folded
176 // CHECKFULLCASE: |  C3-Pair: not covered
177 // CHECKFULLCASE: |  MC/DC Coverage for Decision: 0.00%
179 // REPORT: _Z5case0b {{.*}} 1       1   0.00%
180 // REPORT: _Z5case1b {{.*}} 1       1   0.00%
181 // REPORT: _Z5case2b {{.*}} 1       0 100.00%
182 // REPORT: _Z5case3b {{.*}} 1       0 100.00%
183 // REPORT: _Z5case4b {{.*}} 1       1   0.00%
184 // REPORT: _Z5case5b {{.*}} 1       1   0.00%
185 // REPORT: _Z5case6b {{.*}} 1       0 100.00%
186 // REPORT: _Z5case7b {{.*}} 1       0 100.00%
187 // REPORT: _Z5case8bb {{.*}} 2       2   0.00%
188 // REPORT: _Z5case9bb {{.*}} 2       2   0.00%
189 // REPORT: _Z5caseabb {{.*}} 2       0 100.00%
190 // REPORT: _Z5casebbb {{.*}} 2       0 100.00%
191 // REPORT: _Z5casecbb {{.*}} 2       2   0.00%
192 // REPORT: _Z5casedbb {{.*}} 2       2   0.00%
193 // REPORT: _Z5caseebb {{.*}} 2       2   0.00%
194 // REPORT: _Z5casefbb {{.*}} 2       2   0.00%
195 // REPORT: _Z5casegbb {{.*}} 2       2   0.00%
196 // REPORT: _Z5casehbb {{.*}} 2       2   0.00%
197 // REPORT: _Z5caseibb {{.*}} 2       0 100.00%
198 // REPORT: _Z5casejbb {{.*}} 2       0 100.00%
199 // REPORT: _Z5casekbb {{.*}} 2       2   0.00%
200 // REPORT: _Z5caselbb {{.*}} 2       2   0.00%
201 // REPORT: _Z5casembb {{.*}} 2       2   0.00%
202 // REPORT: _Z5casenbb {{.*}} 2       2   0.00%
203 // REPORT: TOTAL {{.*}} 40      28  30.00%
205 Instructions for regenerating the test:
207 # cd %S/Inputs
208 cp mcdc-const.cpp /tmp
209 cp mcdc-const-folding.cpp /tmp
211 clang -fcoverage-mcdc -fprofile-instr-generate \
212     -fcoverage-mapping /tmp/mcdc-const.cpp -o /tmp/mcdc-const.o
214 clang -fcoverage-mcdc -fprofile-instr-generate \
215     -fcoverage-mapping /tmp/mcdc-const-folding.cpp -o /tmp/mcdc-const-folding.o
217 mv /tmp/mcdc-const.o %S/Inputs
218 mv /tmp/mcdc-const-folding.o %S/Inputs