// Test visualization of general MC/DC constructs.
// RUN: llvm-profdata merge %S/Inputs/mcdc-general.proftext -o %t.profdata
// RUN: llvm-cov show --show-mcdc %S/Inputs/mcdc-general.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs | FileCheck %s
// 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
// CHECK: test(bool
// CHECK: ------------------
// CHECK-NEXT: |---> MC/DC Decision Region (12:7) to (12:27)
// CHECK-NEXT: |
// CHECK-NEXT: | Number of Conditions: 4
// CHECK-NEXT: | Condition C1 --> (12:8)
// CHECK-NEXT: | Condition C2 --> (12:13)
// CHECK-NEXT: | Condition C3 --> (12:20)
// CHECK-NEXT: | Condition C4 --> (12:25)
// CHECK-NEXT: |
// CHECK-NEXT: | Executed MC/DC Test Vectors:
// CHECK-NEXT: |
// CHECK-NEXT: | C1, C2, C3, C4 Result
// CHECK-NEXT: | 1 { F, -, F, - = F }
// CHECK-NEXT: | 2 { F, -, T, F = F }
// CHECK-NEXT: | 3 { T, F, F, - = F }
// CHECK-NEXT: | 4 { T, F, T, F = F }
// CHECK-NEXT: | 5 { T, F, T, T = T }
// CHECK-NEXT: | 6 { T, T, -, - = T }
// CHECK-NEXT: |
// CHECK-NEXT: | C1-Pair: covered: (1,6)
// CHECK-NEXT: | C2-Pair: covered: (3,6)
// CHECK-NEXT: | C3-Pair: covered: (3,5)
// CHECK-NEXT: | C4-Pair: covered: (4,5)
// CHECK-NEXT: | MC/DC Coverage for Decision: 100.00%
// CHECK-NEXT: |
// CHECK-NEXT: ------------------
// CHECK: ------------------
// CHECK-NEXT: |---> MC/DC Decision Region (15:7) to (15:13)
// CHECK-NEXT: |
// CHECK-NEXT: | Number of Conditions: 2
// CHECK-NEXT: | Condition C1 --> (15:7)
// CHECK-NEXT: | Condition C2 --> (15:12)
// CHECK-NEXT: |
// CHECK-NEXT: | Executed MC/DC Test Vectors:
// CHECK-NEXT: |
// CHECK-NEXT: | C1, C2 Result
// CHECK-NEXT: | 1 { F, - = F }
// CHECK-NEXT: | 2 { T, F = F }
// CHECK-NEXT: | 3 { T, T = T }
// CHECK-NEXT: |
// CHECK-NEXT: | C1-Pair: covered: (1,3)
// CHECK-NEXT: | C2-Pair: covered: (2,3)
// CHECK-NEXT: | MC/DC Coverage for Decision: 100.00%
// CHECK-NEXT: |
// CHECK-NEXT: |---> MC/DC Decision Region (15:19) to (15:25)
// CHECK-NEXT: |
// CHECK-NEXT: | Number of Conditions: 2
// CHECK-NEXT: | Condition C1 --> (15:19)
// CHECK-NEXT: | Condition C2 --> (15:24)
// CHECK-NEXT: |
// CHECK-NEXT: | Executed MC/DC Test Vectors:
// CHECK-NEXT: |
// CHECK-NEXT: | C1, C2 Result
// CHECK-NEXT: | 1 { F, - = F }
// CHECK-NEXT: | 2 { T, T = T }
// CHECK-NEXT: |
// CHECK-NEXT: | C1-Pair: covered: (1,2)
// CHECK-NEXT: | C2-Pair: not covered
// CHECK-NEXT: | MC/DC Coverage for Decision: 50.00%
// CHECK-NEXT: |
// CHECK-NEXT: ------------------
// CHECK: ------------------
// CHECK-NEXT: |---> MC/DC Decision Region (18:7) to (19:15)
// CHECK-NEXT: |
// CHECK-NEXT: | Number of Conditions: 4
// CHECK-NEXT: | Condition C1 --> (18:8)
// CHECK-NEXT: | Condition C2 --> (18:13)
// CHECK-NEXT: | Condition C3 --> (19:8)
// CHECK-NEXT: | Condition C4 --> (19:13)
// CHECK-NEXT: |
// CHECK-NEXT: | Executed MC/DC Test Vectors:
// CHECK-NEXT: |
// CHECK-NEXT: | C1, C2, C3, C4 Result
// CHECK-NEXT: | 1 { F, -, -, - = F }
// CHECK-NEXT: | 2 { T, F, -, - = F }
// CHECK-NEXT: | 3 { T, T, T, F = F }
// CHECK-NEXT: | 4 { T, T, T, T = T }
// CHECK-NEXT: |
// CHECK-NEXT: | C1-Pair: covered: (1,4)
// CHECK-NEXT: | C2-Pair: covered: (2,4)
// CHECK-NEXT: | C3-Pair: not covered
// CHECK-NEXT: | C4-Pair: covered: (3,4)
// CHECK-NEXT: | MC/DC Coverage for Decision: 75.00%
// CHECK-NEXT: |
// CHECK-NEXT: ------------------
// Turn off MC/DC visualization.
// RUN: llvm-cov show %S/Inputs/mcdc-general.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs | FileCheck %s -check-prefix=NOMCDC
// NOMCDC-NOT: MC/DC Decision Region
// REPORT: Name Regions Miss Cover Lines Miss Cover Branches Miss Cover MC/DC Conditions Miss Cover
// REPORT-NEXT: -------------------------------------------------------------------------------------------------------------------------------------------
// REPORT-NEXT: _Z4testbbbb 25 0 100.00% 9 0 100.00% 24 2 91.67% 12 2 83.33%
// REPORT-NEXT: main 1 0 100.00% 11 0 100.00% 0 0 0.00% 0 0 0.00%
// REPORT-NEXT: ---
// REPORT-NEXT: TOTAL 26 0 100.00% 20 0 100.00% 24 2 91.67% 12 2 83.33%
// Turn off MC/DC summary.
// 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
// REPORT_NOMCDC-NOT: TOTAL{{.*}}12 2 83.33%
// Test file-level report.
// 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
// FILEREPORT: TOTAL{{.*}}12 2 83.33%
// Test html output.
// RUN: rm -rf %t.html.dir
// 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
// RUN: FileCheck -check-prefix=HTML -input-file=%t.html.dir/coverage/mcdc-general.cpp.html %s
// HTML-COUNT-4: MC/DC Decision Region (<span class='line-number'><a href='#L{{[0-9]+}}'><span>
// RUN: FileCheck -check-prefix HTML-INDEX -input-file %t.html.dir/index.html %s
// HTML-INDEX-LABEL: <table>
// HTML-INDEX: <td class='column-entry-bold'>Filename</td>
// HTML-INDEX: <td class='column-entry-bold'>Function Coverage</td>
// HTML-INDEX: <td class='column-entry-bold'>Line Coverage</td>
// HTML-INDEX: <td class='column-entry-bold'>Region Coverage</td>
// HTML-INDEX: <td class='column-entry-bold'>Branch Coverage</td>
// HTML-INDEX: <td class='column-entry-bold'>MC/DC</td>
// HTML-INDEX: <a href='coverage{{.*}}mcdc-general.cpp.html'{{.*}}mcdc-general.cpp</a>
// HTML-INDEX: <td class='column-entry-green'>
// HTML-INDEX: 100.00% (2/2)
// HTML-INDEX: 100.00% (20/20)
// HTML-INDEX: 100.00% (26/26)
// HTML-INDEX: 91.67% (22/24)
// HTML-INDEX: 83.33% (10/12)
// HTML-INDEX: Totals
Instructions for regenerating the test:
cd %S/Inputs # Or copy mcdc-general.cpp into the working directory
clang++ -c -Os \
-fcoverage-compilation-dir=. -mllvm -enable-name-compression=false \
-fcoverage-mcdc -fprofile-instr-generate -fcoverage-mapping \
mcdc-general.cpp
# Instructions for regenerating profdata
for x in mcdc-general; do
clang++ -fprofile-instr-generate $x.o -o $x
find -name '*.profraw' | xargs rm -f
./$x
llvm-profdata merge --sparse -o $x.profdata $(find -name '*.profraw')
llvm-profdata merge --text -o $x.proftext $x.profdata
done