about summary refs log tree commit diff
path: root/tests/coverage/mcdc/condition-limit.coverage
blob: 4eb87432fab48532c8f76f63772b2d8c722e3734 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
   LL|       |#![feature(coverage_attribute)]
   LL|       |//@ edition: 2021
   LL|       |//@ min-llvm-version: 18
   LL|       |//@ compile-flags: -Zcoverage-options=mcdc
   LL|       |//@ llvm-cov-flags: --show-branches=count --show-mcdc
   LL|       |
   LL|       |// Check that MC/DC instrumentation can gracefully handle conditions that
   LL|       |// exceed LLVM's limit of 6 conditions per decision.
   LL|       |//
   LL|       |// (The limit is enforced in `compiler/rustc_mir_build/src/build/coverageinfo/mcdc.rs`.)
   LL|       |
   LL|      1|fn good() {
   LL|      1|    // With only 6 conditions, perform full MC/DC instrumentation.
   LL|      1|    let [a, b, c, d, e, f] = <[bool; 6]>::default();
   LL|      1|    if a && b && c && d && e && f {
                          ^0   ^0   ^0   ^0   ^0
  ------------------
  |  Branch (LL:8): [True: 0, False: 1]
  |  Branch (LL:13): [True: 0, False: 0]
  |  Branch (LL:18): [True: 0, False: 0]
  |  Branch (LL:23): [True: 0, False: 0]
  |  Branch (LL:28): [True: 0, False: 0]
  |  Branch (LL:33): [True: 0, False: 0]
  ------------------
  |---> MC/DC Decision Region (LL:8) to (LL:34)
  |
  |  Number of Conditions: 6
  |     Condition C1 --> (LL:8)
  |     Condition C2 --> (LL:13)
  |     Condition C3 --> (LL:18)
  |     Condition C4 --> (LL:23)
  |     Condition C5 --> (LL:28)
  |     Condition C6 --> (LL:33)
  |
  |  Executed MC/DC Test Vectors:
  |
  |     C1, C2, C3, C4, C5, C6    Result
  |  1 { F,  -,  -,  -,  -,  -  = F      }
  |
  |  C1-Pair: not covered
  |  C2-Pair: not covered
  |  C3-Pair: not covered
  |  C4-Pair: not covered
  |  C5-Pair: not covered
  |  C6-Pair: not covered
  |  MC/DC Coverage for Decision: 0.00%
  |
  ------------------
   LL|      0|        core::hint::black_box("hello");
   LL|      1|    }
   LL|      1|}
   LL|       |
   LL|      1|fn bad() {
   LL|      1|    // With 7 conditions, fall back to branch instrumentation only.
   LL|      1|    let [a, b, c, d, e, f, g] = <[bool; 7]>::default();
   LL|      1|    if a && b && c && d && e && f && g {
                          ^0   ^0   ^0   ^0   ^0   ^0
  ------------------
  |  Branch (LL:8): [True: 0, False: 1]
  |  Branch (LL:13): [True: 0, False: 0]
  |  Branch (LL:18): [True: 0, False: 0]
  |  Branch (LL:23): [True: 0, False: 0]
  |  Branch (LL:28): [True: 0, False: 0]
  |  Branch (LL:33): [True: 0, False: 0]
  |  Branch (LL:38): [True: 0, False: 0]
  ------------------
   LL|      0|        core::hint::black_box("hello");
   LL|      1|    }
   LL|      1|}
   LL|       |
   LL|       |#[coverage(off)]
   LL|       |fn main() {
   LL|       |    good();
   LL|       |    bad();
   LL|       |}