Skip to content

Commit a64ab01

Browse files
author
zhuyunxing
committed
coverage. mcdc tests also generate branch coverage reports
1 parent a50e842 commit a64ab01

File tree

4 files changed

+53
-4
lines changed

4 files changed

+53
-4
lines changed

tests/coverage/mcdc/if.coverage

+27-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
LL| |//@ edition: 2021
33
LL| |//@ min-llvm-version: 18
44
LL| |//@ compile-flags: -Zcoverage-options=mcdc
5-
LL| |//@ llvm-cov-flags: --show-mcdc
5+
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
66
LL| |
77
LL| 2|fn mcdc_check_neither(a: bool, b: bool) {
88
LL| 2| if a && b {
99
^0
1010
------------------
11+
| Branch (LL:8): [True: 0, False: 2]
12+
| Branch (LL:13): [True: 0, False: 0]
13+
------------------
1114
|---> MC/DC Decision Region (LL:8) to (LL:14)
1215
|
1316
| Number of Conditions: 2
@@ -34,6 +37,9 @@
3437
LL| 2| if a && b {
3538
^1
3639
------------------
40+
| Branch (LL:8): [True: 1, False: 1]
41+
| Branch (LL:13): [True: 1, False: 0]
42+
------------------
3743
|---> MC/DC Decision Region (LL:8) to (LL:14)
3844
|
3945
| Number of Conditions: 2
@@ -60,6 +66,9 @@
6066
LL| 2|fn mcdc_check_b(a: bool, b: bool) {
6167
LL| 2| if a && b {
6268
------------------
69+
| Branch (LL:8): [True: 2, False: 0]
70+
| Branch (LL:13): [True: 1, False: 1]
71+
------------------
6372
|---> MC/DC Decision Region (LL:8) to (LL:14)
6473
|
6574
| Number of Conditions: 2
@@ -87,6 +96,9 @@
8796
LL| 3| if a && b {
8897
^2
8998
------------------
99+
| Branch (LL:8): [True: 2, False: 1]
100+
| Branch (LL:13): [True: 1, False: 1]
101+
------------------
90102
|---> MC/DC Decision Region (LL:8) to (LL:14)
91103
|
92104
| Number of Conditions: 2
@@ -117,6 +129,10 @@
117129
LL| 4| if a && (b || c) {
118130
^3 ^2
119131
------------------
132+
| Branch (LL:8): [True: 3, False: 1]
133+
| Branch (LL:14): [True: 1, False: 2]
134+
| Branch (LL:19): [True: 1, False: 1]
135+
------------------
120136
|---> MC/DC Decision Region (LL:8) to (LL:21)
121137
|
122138
| Number of Conditions: 3
@@ -150,6 +166,10 @@
150166
LL| 4| if (a || b) && c {
151167
^1
152168
------------------
169+
| Branch (LL:9): [True: 3, False: 1]
170+
| Branch (LL:14): [True: 1, False: 0]
171+
| Branch (LL:20): [True: 2, False: 2]
172+
------------------
153173
|---> MC/DC Decision Region (LL:8) to (LL:21)
154174
|
155175
| Number of Conditions: 3
@@ -180,6 +200,9 @@
180200
LL| 3| if a || b {
181201
^0
182202
------------------
203+
| Branch (LL:8): [True: 3, False: 0]
204+
| Branch (LL:13): [True: 0, False: 0]
205+
------------------
183206
|---> MC/DC Decision Region (LL:8) to (LL:14)
184207
|
185208
| Number of Conditions: 2
@@ -200,6 +223,9 @@
200223
LL| 3| if b && c {
201224
^2
202225
------------------
226+
| Branch (LL:12): [True: 2, False: 1]
227+
| Branch (LL:17): [True: 1, False: 1]
228+
------------------
203229
|---> MC/DC Decision Region (LL:12) to (LL:18)
204230
|
205231
| Number of Conditions: 2

tests/coverage/mcdc/if.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//@ edition: 2021
33
//@ min-llvm-version: 18
44
//@ compile-flags: -Zcoverage-options=mcdc
5-
//@ llvm-cov-flags: --show-mcdc
5+
//@ llvm-cov-flags: --show-branches=count --show-mcdc
66

77
fn mcdc_check_neither(a: bool, b: bool) {
88
if a && b {

tests/coverage/mcdc/nested_if.coverage

+24-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
LL| |//@ edition: 2021
33
LL| |//@ min-llvm-version: 18
44
LL| |//@ compile-flags: -Zcoverage-options=mcdc
5-
LL| |//@ llvm-cov-flags: --show-mcdc
5+
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
66
LL| |
77
LL| 4|fn nested_if_in_condition(a: bool, b: bool, c: bool) {
88
LL| 4| if a && if b || c { true } else { false } {
99
^3 ^2 ^2 ^1
1010
------------------
11+
| Branch (LL:8): [True: 3, False: 1]
12+
| Branch (LL:13): [True: 2, False: 1]
13+
| Branch (LL:16): [True: 1, False: 2]
14+
| Branch (LL:21): [True: 1, False: 1]
15+
------------------
1116
|---> MC/DC Decision Region (LL:8) to (LL:46)
1217
|
1318
| Number of Conditions: 2
@@ -53,6 +58,13 @@
5358
LL| 4| if a && if b || if c && d { true } else { false } { false } else { true } {
5459
^3 ^2 ^1 ^1 ^1 ^2 ^1
5560
------------------
61+
| Branch (LL:8): [True: 3, False: 1]
62+
| Branch (LL:13): [True: 1, False: 2]
63+
| Branch (LL:16): [True: 1, False: 2]
64+
| Branch (LL:21): [True: 1, False: 1]
65+
| Branch (LL:24): [True: 1, False: 1]
66+
| Branch (LL:29): [True: 1, False: 0]
67+
------------------
5668
|---> MC/DC Decision Region (LL:8) to (LL:78)
5769
|
5870
| Number of Conditions: 2
@@ -117,6 +129,10 @@
117129
LL| 3| if a && if b { false } else { true } {
118130
^2 ^1 ^1
119131
------------------
132+
| Branch (LL:8): [True: 2, False: 1]
133+
| Branch (LL:13): [True: 1, False: 1]
134+
| Branch (LL:16): [True: 1, False: 1]
135+
------------------
120136
|---> MC/DC Decision Region (LL:8) to (LL:41)
121137
|
122138
| Number of Conditions: 2
@@ -145,6 +161,13 @@
145161
LL| 7| if a && if b || c { if d && e { true } else { false } } else { false } {
146162
^6 ^5 ^5 ^2 ^1 ^4 ^1
147163
------------------
164+
| Branch (LL:8): [True: 6, False: 1]
165+
| Branch (LL:13): [True: 1, False: 5]
166+
| Branch (LL:16): [True: 1, False: 5]
167+
| Branch (LL:21): [True: 4, False: 1]
168+
| Branch (LL:28): [True: 2, False: 3]
169+
| Branch (LL:33): [True: 1, False: 1]
170+
------------------
148171
|---> MC/DC Decision Region (LL:8) to (LL:75)
149172
|
150173
| Number of Conditions: 2

tests/coverage/mcdc/nested_if.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//@ edition: 2021
33
//@ min-llvm-version: 18
44
//@ compile-flags: -Zcoverage-options=mcdc
5-
//@ llvm-cov-flags: --show-mcdc
5+
//@ llvm-cov-flags: --show-branches=count --show-mcdc
66

77
fn nested_if_in_condition(a: bool, b: bool, c: bool) {
88
if a && if b || c { true } else { false } {

0 commit comments

Comments
 (0)