coverage. MCDC tests also report branches coverage

This commit is contained in:
zhuyunxing 2024-07-02 14:24:43 +08:00
parent 4f6140258f
commit c77788f011
6 changed files with 78 additions and 6 deletions

View File

@ -2,12 +2,15 @@
LL| |//@ edition: 2021
LL| |//@ min-llvm-version: 18
LL| |//@ compile-flags: -Zcoverage-options=mcdc
LL| |//@ llvm-cov-flags: --show-mcdc
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
LL| |
LL| 2|fn mcdc_check_neither(a: bool, b: bool) {
LL| 2| if a && b {
^0
------------------
| Branch (LL:8): [True: 0, False: 2]
| Branch (LL:13): [True: 0, False: 0]
------------------
|---> MC/DC Decision Region (LL:8) to (LL:14)
|
| Number of Conditions: 2
@ -34,6 +37,9 @@
LL| 2| if a && b {
^1
------------------
| Branch (LL:8): [True: 1, False: 1]
| Branch (LL:13): [True: 1, False: 0]
------------------
|---> MC/DC Decision Region (LL:8) to (LL:14)
|
| Number of Conditions: 2
@ -60,6 +66,9 @@
LL| 2|fn mcdc_check_b(a: bool, b: bool) {
LL| 2| if a && b {
------------------
| Branch (LL:8): [True: 2, False: 0]
| Branch (LL:13): [True: 1, False: 1]
------------------
|---> MC/DC Decision Region (LL:8) to (LL:14)
|
| Number of Conditions: 2
@ -87,6 +96,9 @@
LL| 3| if a && b {
^2
------------------
| Branch (LL:8): [True: 2, False: 1]
| Branch (LL:13): [True: 1, False: 1]
------------------
|---> MC/DC Decision Region (LL:8) to (LL:14)
|
| Number of Conditions: 2
@ -117,6 +129,10 @@
LL| 4| if a && (b || c) {
^3 ^2
------------------
| Branch (LL:8): [True: 3, False: 1]
| Branch (LL:14): [True: 1, False: 2]
| Branch (LL:19): [True: 1, False: 1]
------------------
|---> MC/DC Decision Region (LL:8) to (LL:21)
|
| Number of Conditions: 3
@ -150,6 +166,10 @@
LL| 4| if (a || b) && c {
^1
------------------
| Branch (LL:9): [True: 3, False: 1]
| Branch (LL:14): [True: 1, False: 0]
| Branch (LL:20): [True: 2, False: 2]
------------------
|---> MC/DC Decision Region (LL:8) to (LL:21)
|
| Number of Conditions: 3
@ -180,6 +200,9 @@
LL| 3| if a || b {
^0
------------------
| Branch (LL:8): [True: 3, False: 0]
| Branch (LL:13): [True: 0, False: 0]
------------------
|---> MC/DC Decision Region (LL:8) to (LL:14)
|
| Number of Conditions: 2
@ -200,6 +223,9 @@
LL| 3| if b && c {
^2
------------------
| Branch (LL:12): [True: 2, False: 1]
| Branch (LL:17): [True: 1, False: 1]
------------------
|---> MC/DC Decision Region (LL:12) to (LL:18)
|
| Number of Conditions: 2

View File

@ -2,7 +2,7 @@
//@ edition: 2021
//@ min-llvm-version: 18
//@ compile-flags: -Zcoverage-options=mcdc
//@ llvm-cov-flags: --show-mcdc
//@ llvm-cov-flags: --show-branches=count --show-mcdc
fn mcdc_check_neither(a: bool, b: bool) {
if a && b {

View File

@ -2,12 +2,17 @@
LL| |//@ edition: 2021
LL| |//@ min-llvm-version: 18
LL| |//@ compile-flags: -Zcoverage-options=mcdc
LL| |//@ llvm-cov-flags: --show-mcdc
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
LL| |
LL| 4|fn nested_if_in_condition(a: bool, b: bool, c: bool) {
LL| 4| if a && if b || c { true } else { false } {
^3 ^2 ^2 ^1
------------------
| Branch (LL:8): [True: 3, False: 1]
| Branch (LL:13): [True: 2, False: 1]
| Branch (LL:16): [True: 1, False: 2]
| Branch (LL:21): [True: 1, False: 1]
------------------
|---> MC/DC Decision Region (LL:8) to (LL:46)
|
| Number of Conditions: 2
@ -53,6 +58,13 @@
LL| 4| if a && if b || if c && d { true } else { false } { false } else { true } {
^3 ^2 ^1 ^1 ^1 ^2 ^1
------------------
| Branch (LL:8): [True: 3, False: 1]
| Branch (LL:13): [True: 1, False: 2]
| Branch (LL:16): [True: 1, False: 2]
| Branch (LL:21): [True: 1, False: 1]
| Branch (LL:24): [True: 1, False: 1]
| Branch (LL:29): [True: 1, False: 0]
------------------
|---> MC/DC Decision Region (LL:8) to (LL:78)
|
| Number of Conditions: 2
@ -117,6 +129,10 @@
LL| 3| if a && if b { false } else { true } {
^2 ^1 ^1
------------------
| Branch (LL:8): [True: 2, False: 1]
| Branch (LL:13): [True: 1, False: 1]
| Branch (LL:16): [True: 1, False: 1]
------------------
|---> MC/DC Decision Region (LL:8) to (LL:41)
|
| Number of Conditions: 2
@ -145,6 +161,13 @@
LL| 7| if a && if b || c { if d && e { true } else { false } } else { false } {
^6 ^5 ^5 ^2 ^1 ^4 ^1
------------------
| Branch (LL:8): [True: 6, False: 1]
| Branch (LL:13): [True: 1, False: 5]
| Branch (LL:16): [True: 1, False: 5]
| Branch (LL:21): [True: 4, False: 1]
| Branch (LL:28): [True: 2, False: 3]
| Branch (LL:33): [True: 1, False: 1]
------------------
|---> MC/DC Decision Region (LL:8) to (LL:75)
|
| Number of Conditions: 2

View File

@ -2,7 +2,7 @@
//@ edition: 2021
//@ min-llvm-version: 18
//@ compile-flags: -Zcoverage-options=mcdc
//@ llvm-cov-flags: --show-mcdc
//@ llvm-cov-flags: --show-branches=count --show-mcdc
fn nested_if_in_condition(a: bool, b: bool, c: bool) {
if a && if b || c { true } else { false } {

View File

@ -2,7 +2,7 @@
LL| |//@ edition: 2021
LL| |//@ min-llvm-version: 18
LL| |//@ compile-flags: -Zcoverage-options=mcdc
LL| |//@ llvm-cov-flags: --show-mcdc
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
LL| |
LL| |// This test ensures that boolean expressions that are not inside control flow
LL| |// decisions are correctly instrumented.
@ -13,6 +13,9 @@
LL| 3| let x = a && b;
^2
------------------
| Branch (LL:13): [True: 2, False: 1]
| Branch (LL:18): [True: 1, False: 1]
------------------
|---> MC/DC Decision Region (LL:13) to (LL:19)
|
| Number of Conditions: 2
@ -38,6 +41,9 @@
LL| 3| let x = a || b;
^1
------------------
| Branch (LL:13): [True: 2, False: 1]
| Branch (LL:18): [True: 0, False: 1]
------------------
|---> MC/DC Decision Region (LL:13) to (LL:19)
|
| Number of Conditions: 2
@ -62,6 +68,10 @@
LL| 4| let x = a || b && c;
^2 ^1
------------------
| Branch (LL:13): [True: 2, False: 2]
| Branch (LL:18): [True: 1, False: 1]
| Branch (LL:23): [True: 1, False: 0]
------------------
|---> MC/DC Decision Region (LL:13) to (LL:24)
|
| Number of Conditions: 3
@ -89,6 +99,10 @@
LL| 4| let x = a && b || c;
^2 ^3
------------------
| Branch (LL:13): [True: 2, False: 2]
| Branch (LL:18): [True: 1, False: 1]
| Branch (LL:23): [True: 2, False: 1]
------------------
|---> MC/DC Decision Region (LL:13) to (LL:24)
|
| Number of Conditions: 3
@ -116,6 +130,12 @@
LL| 3| let x = a && (b && (c && (d && (e))));
^2 ^1 ^1 ^1
------------------
| Branch (LL:13): [True: 2, False: 1]
| Branch (LL:19): [True: 1, False: 1]
| Branch (LL:25): [True: 1, False: 0]
| Branch (LL:31): [True: 1, False: 0]
| Branch (LL:36): [True: 1, False: 0]
------------------
|---> MC/DC Decision Region (LL:13) to (LL:42)
|
| Number of Conditions: 5
@ -151,6 +171,9 @@
LL| 3| foo(a && b);
^2
------------------
| Branch (LL:9): [True: 2, False: 1]
| Branch (LL:14): [True: 1, False: 1]
------------------
|---> MC/DC Decision Region (LL:9) to (LL:15)
|
| Number of Conditions: 2

View File

@ -2,7 +2,7 @@
//@ edition: 2021
//@ min-llvm-version: 18
//@ compile-flags: -Zcoverage-options=mcdc
//@ llvm-cov-flags: --show-mcdc
//@ llvm-cov-flags: --show-branches=count --show-mcdc
// This test ensures that boolean expressions that are not inside control flow
// decisions are correctly instrumented.