1 // Test visualization of general MC/DC constructs.
3 // RUN: llvm-profdata merge %S/Inputs/mcdc-general.proftext -o %t.profdata
4 // RUN: llvm-cov show --show-mcdc %S/Inputs/mcdc-general.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs | FileCheck %s
5 // RUN: llvm-cov report --show-mcdc-summary %S/Inputs/mcdc-general.o -instr-profile %t.profdata -show-functions -path-equivalence=.,%S/Inputs %S/Inputs/mcdc-general.cpp | FileCheck %s -check-prefix=REPORT
9 // CHECK: ------------------
10 // CHECK-NEXT: |---> MC/DC Decision Region (12:7) to (12:27)
12 // CHECK-NEXT: | Number of Conditions: 4
13 // CHECK-NEXT: | Condition C1 --> (12:8)
14 // CHECK-NEXT: | Condition C2 --> (12:13)
15 // CHECK-NEXT: | Condition C3 --> (12:20)
16 // CHECK-NEXT: | Condition C4 --> (12:25)
18 // CHECK-NEXT: | Executed MC/DC Test Vectors:
20 // CHECK-NEXT: | C1, C2, C3, C4 Result
21 // CHECK-NEXT: | 1 { F, -, F, - = F }
22 // CHECK-NEXT: | 2 { F, -, T, F = F }
23 // CHECK-NEXT: | 3 { T, F, F, - = F }
24 // CHECK-NEXT: | 4 { T, F, T, F = F }
25 // CHECK-NEXT: | 5 { T, F, T, T = T }
26 // CHECK-NEXT: | 6 { T, T, -, - = T }
28 // CHECK-NEXT: | C1-Pair: covered: (1,6)
29 // CHECK-NEXT: | C2-Pair: covered: (3,6)
30 // CHECK-NEXT: | C3-Pair: covered: (3,5)
31 // CHECK-NEXT: | C4-Pair: covered: (4,5)
32 // CHECK-NEXT: | MC/DC Coverage for Decision: 100.00%
34 // CHECK-NEXT: ------------------
36 // CHECK: ------------------
37 // CHECK-NEXT: |---> MC/DC Decision Region (15:7) to (15:13)
39 // CHECK-NEXT: | Number of Conditions: 2
40 // CHECK-NEXT: | Condition C1 --> (15:7)
41 // CHECK-NEXT: | Condition C2 --> (15:12)
43 // CHECK-NEXT: | Executed MC/DC Test Vectors:
45 // CHECK-NEXT: | C1, C2 Result
46 // CHECK-NEXT: | 1 { F, - = F }
47 // CHECK-NEXT: | 2 { T, F = F }
48 // CHECK-NEXT: | 3 { T, T = T }
50 // CHECK-NEXT: | C1-Pair: covered: (1,3)
51 // CHECK-NEXT: | C2-Pair: covered: (2,3)
52 // CHECK-NEXT: | MC/DC Coverage for Decision: 100.00%
54 // CHECK-NEXT: |---> MC/DC Decision Region (15:19) to (15:25)
56 // CHECK-NEXT: | Number of Conditions: 2
57 // CHECK-NEXT: | Condition C1 --> (15:19)
58 // CHECK-NEXT: | Condition C2 --> (15:24)
60 // CHECK-NEXT: | Executed MC/DC Test Vectors:
62 // CHECK-NEXT: | C1, C2 Result
63 // CHECK-NEXT: | 1 { F, - = F }
64 // CHECK-NEXT: | 2 { T, T = T }
66 // CHECK-NEXT: | C1-Pair: covered: (1,2)
67 // CHECK-NEXT: | C2-Pair: not covered
68 // CHECK-NEXT: | MC/DC Coverage for Decision: 50.00%
70 // CHECK-NEXT: ------------------
72 // CHECK: ------------------
73 // CHECK-NEXT: |---> MC/DC Decision Region (18:7) to (19:15)
75 // CHECK-NEXT: | Number of Conditions: 4
76 // CHECK-NEXT: | Condition C1 --> (18:8)
77 // CHECK-NEXT: | Condition C2 --> (18:13)
78 // CHECK-NEXT: | Condition C3 --> (19:8)
79 // CHECK-NEXT: | Condition C4 --> (19:13)
81 // CHECK-NEXT: | Executed MC/DC Test Vectors:
83 // CHECK-NEXT: | C1, C2, C3, C4 Result
84 // CHECK-NEXT: | 1 { F, -, -, - = F }
85 // CHECK-NEXT: | 2 { T, F, -, - = F }
86 // CHECK-NEXT: | 3 { T, T, T, F = F }
87 // CHECK-NEXT: | 4 { T, T, T, T = T }
89 // CHECK-NEXT: | C1-Pair: covered: (1,4)
90 // CHECK-NEXT: | C2-Pair: covered: (2,4)
91 // CHECK-NEXT: | C3-Pair: not covered
92 // CHECK-NEXT: | C4-Pair: covered: (3,4)
93 // CHECK-NEXT: | MC/DC Coverage for Decision: 75.00%
95 // CHECK-NEXT: ------------------
97 // Turn off MC/DC visualization.
98 // RUN: llvm-cov show %S/Inputs/mcdc-general.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs | FileCheck %s -check-prefix=NOMCDC
99 // NOMCDC-NOT: MC/DC Decision Region
101 // REPORT: Name Regions Miss Cover Lines Miss Cover Branches Miss Cover MC/DC Conditions Miss Cover
102 // REPORT-NEXT: -------------------------------------------------------------------------------------------------------------------------------------------
103 // REPORT-NEXT: _Z4testbbbb 25 0 100.00% 9 0 100.00% 24 2 91.67% 12 2 83.33%
104 // REPORT-NEXT: main 1 0 100.00% 11 0 100.00% 0 0 0.00% 0 0 0.00%
106 // REPORT-NEXT: TOTAL 26 0 100.00% 20 0 100.00% 24 2 91.67% 12 2 83.33%
108 // Turn off MC/DC summary.
109 // RUN: llvm-cov report %S/Inputs/mcdc-general.o -instr-profile %t.profdata -show-functions -path-equivalence=.,%S/Inputs %S/Inputs/mcdc-general.cpp | FileCheck %s -check-prefix=REPORT_NOMCDC
110 // REPORT_NOMCDC-NOT: TOTAL{{.*}}12 2 83.33%
113 // Test file-level report.
114 // RUN: llvm-cov report --show-mcdc-summary %S/Inputs/mcdc-general.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs %S/Inputs/mcdc-general.cpp | FileCheck %s -check-prefix=FILEREPORT
115 // FILEREPORT: TOTAL{{.*}}12 2 83.33%
119 // RUN: rm -rf %t.html.dir
120 // RUN: llvm-cov show --show-mcdc-summary --show-mcdc %S/Inputs/mcdc-general.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs -format html -o %t.html.dir
121 // RUN: FileCheck -check-prefix=HTML -input-file=%t.html.dir/coverage/mcdc-general.cpp.html %s
122 // HTML-COUNT-4: MC/DC Decision Region (<span class='line-number'><a href='#L{{[0-9]+}}'><span>
124 // RUN: FileCheck -check-prefix HTML-INDEX -input-file %t.html.dir/index.html %s
125 // HTML-INDEX-LABEL: <table>
126 // HTML-INDEX: <td class='column-entry-bold'>Filename</td>
127 // HTML-INDEX: <td class='column-entry-bold'>Function Coverage</td>
128 // HTML-INDEX: <td class='column-entry-bold'>Line Coverage</td>
129 // HTML-INDEX: <td class='column-entry-bold'>Region Coverage</td>
130 // HTML-INDEX: <td class='column-entry-bold'>Branch Coverage</td>
131 // HTML-INDEX: <td class='column-entry-bold'>MC/DC</td>
132 // HTML-INDEX: <a href='coverage{{.*}}mcdc-general.cpp.html'{{.*}}mcdc-general.cpp</a>
133 // HTML-INDEX: <td class='column-entry-green'>
134 // HTML-INDEX: 100.00% (2/2)
135 // HTML-INDEX: 100.00% (20/20)
136 // HTML-INDEX: 100.00% (26/26)
137 // HTML-INDEX: 91.67% (22/24)
138 // HTML-INDEX: 83.33% (10/12)
139 // HTML-INDEX: Totals
141 Instructions for regenerating the test:
143 cd %S/Inputs # Or copy mcdc-general.cpp into the working directory
146 -fcoverage-compilation-dir=. -mllvm -enable-name-compression=false \
147 -fcoverage-mcdc -fprofile-instr-generate -fcoverage-mapping \
150 # Instructions for regenerating profdata
152 for x in mcdc-general; do
153 clang++ -fprofile-instr-generate $x.o -o $x
154 find -name '*.profraw' | xargs rm -f
156 llvm-profdata merge --sparse -o $x.profdata $(find -name '*.profraw')
157 llvm-profdata merge --text -o $x.proftext $x.profdata