Skip to content

Commit c77788f

Browse files
author
zhuyunxing
committed
coverage. MCDC tests also report branches coverage
1 parent 4f61402 commit c77788f

File tree

6 files changed

+78
-6
lines changed

6 files changed

+78
-6
lines changed

Diff for: 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

Diff for: 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 {

Diff for: 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

Diff for: 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 } {

Diff for: tests/coverage/mcdc/non_control_flow.coverage

+24-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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| |// This test ensures that boolean expressions that are not inside control flow
88
LL| |// decisions are correctly instrumented.
@@ -13,6 +13,9 @@
1313
LL| 3| let x = a && b;
1414
^2
1515
------------------
16+
| Branch (LL:13): [True: 2, False: 1]
17+
| Branch (LL:18): [True: 1, False: 1]
18+
------------------
1619
|---> MC/DC Decision Region (LL:13) to (LL:19)
1720
|
1821
| Number of Conditions: 2
@@ -38,6 +41,9 @@
3841
LL| 3| let x = a || b;
3942
^1
4043
------------------
44+
| Branch (LL:13): [True: 2, False: 1]
45+
| Branch (LL:18): [True: 0, False: 1]
46+
------------------
4147
|---> MC/DC Decision Region (LL:13) to (LL:19)
4248
|
4349
| Number of Conditions: 2
@@ -62,6 +68,10 @@
6268
LL| 4| let x = a || b && c;
6369
^2 ^1
6470
------------------
71+
| Branch (LL:13): [True: 2, False: 2]
72+
| Branch (LL:18): [True: 1, False: 1]
73+
| Branch (LL:23): [True: 1, False: 0]
74+
------------------
6575
|---> MC/DC Decision Region (LL:13) to (LL:24)
6676
|
6777
| Number of Conditions: 3
@@ -89,6 +99,10 @@
8999
LL| 4| let x = a && b || c;
90100
^2 ^3
91101
------------------
102+
| Branch (LL:13): [True: 2, False: 2]
103+
| Branch (LL:18): [True: 1, False: 1]
104+
| Branch (LL:23): [True: 2, False: 1]
105+
------------------
92106
|---> MC/DC Decision Region (LL:13) to (LL:24)
93107
|
94108
| Number of Conditions: 3
@@ -116,6 +130,12 @@
116130
LL| 3| let x = a && (b && (c && (d && (e))));
117131
^2 ^1 ^1 ^1
118132
------------------
133+
| Branch (LL:13): [True: 2, False: 1]
134+
| Branch (LL:19): [True: 1, False: 1]
135+
| Branch (LL:25): [True: 1, False: 0]
136+
| Branch (LL:31): [True: 1, False: 0]
137+
| Branch (LL:36): [True: 1, False: 0]
138+
------------------
119139
|---> MC/DC Decision Region (LL:13) to (LL:42)
120140
|
121141
| Number of Conditions: 5
@@ -151,6 +171,9 @@
151171
LL| 3| foo(a && b);
152172
^2
153173
------------------
174+
| Branch (LL:9): [True: 2, False: 1]
175+
| Branch (LL:14): [True: 1, False: 1]
176+
------------------
154177
|---> MC/DC Decision Region (LL:9) to (LL:15)
155178
|
156179
| Number of Conditions: 2

Diff for: tests/coverage/mcdc/non_control_flow.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
// This test ensures that boolean expressions that are not inside control flow
88
// decisions are correctly instrumented.

0 commit comments

Comments
 (0)