coverage: Add a test for -Zcoverage-options=condition
This commit is contained in:
parent
fa563c1384
commit
20174e6638
117
tests/coverage/condition/conditions.cov-map
Normal file
117
tests/coverage/condition/conditions.cov-map
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
Function name: conditions::assign_3_and_or
|
||||||
|
Raw bytes (60): 0x[01, 01, 06, 0d, 13, 09, 16, 01, 05, 01, 05, 09, 16, 01, 05, 08, 01, 1c, 01, 00, 2f, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 20, 05, 16, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 20, 0d, 09, 00, 12, 00, 13, 13, 00, 17, 00, 18, 03, 01, 05, 01, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 6
|
||||||
|
- expression 0 operands: lhs = Counter(3), rhs = Expression(4, Add)
|
||||||
|
- expression 1 operands: lhs = Counter(2), rhs = Expression(5, Sub)
|
||||||
|
- expression 2 operands: lhs = Counter(0), rhs = Counter(1)
|
||||||
|
- expression 3 operands: lhs = Counter(0), rhs = Counter(1)
|
||||||
|
- expression 4 operands: lhs = Counter(2), rhs = Expression(5, Sub)
|
||||||
|
- expression 5 operands: lhs = Counter(0), rhs = Counter(1)
|
||||||
|
Number of file 0 mappings: 8
|
||||||
|
- Code(Counter(0)) at (prev + 28, 1) to (start + 0, 47)
|
||||||
|
- Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10)
|
||||||
|
= (c3 + (c2 + (c0 - c1)))
|
||||||
|
- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14)
|
||||||
|
- Branch { true: Counter(1), false: Expression(5, Sub) } at (prev + 0, 13) to (start + 0, 14)
|
||||||
|
true = c1
|
||||||
|
false = (c0 - c1)
|
||||||
|
- Code(Counter(1)) at (prev + 0, 18) to (start + 0, 19)
|
||||||
|
- Branch { true: Counter(3), false: Counter(2) } at (prev + 0, 18) to (start + 0, 19)
|
||||||
|
true = c3
|
||||||
|
false = c2
|
||||||
|
- Code(Expression(4, Add)) at (prev + 0, 23) to (start + 0, 24)
|
||||||
|
= (c2 + (c0 - c1))
|
||||||
|
- Code(Expression(0, Add)) at (prev + 1, 5) to (start + 1, 2)
|
||||||
|
= (c3 + (c2 + (c0 - c1)))
|
||||||
|
|
||||||
|
Function name: conditions::assign_3_or_and
|
||||||
|
Raw bytes (56): 0x[01, 01, 04, 05, 07, 09, 0d, 01, 05, 01, 05, 08, 01, 17, 01, 00, 2f, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 20, 05, 0e, 00, 0d, 00, 0e, 0e, 00, 12, 00, 13, 20, 09, 0d, 00, 12, 00, 13, 09, 00, 17, 00, 18, 03, 01, 05, 01, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 4
|
||||||
|
- expression 0 operands: lhs = Counter(1), rhs = Expression(1, Add)
|
||||||
|
- expression 1 operands: lhs = Counter(2), rhs = Counter(3)
|
||||||
|
- expression 2 operands: lhs = Counter(0), rhs = Counter(1)
|
||||||
|
- expression 3 operands: lhs = Counter(0), rhs = Counter(1)
|
||||||
|
Number of file 0 mappings: 8
|
||||||
|
- Code(Counter(0)) at (prev + 23, 1) to (start + 0, 47)
|
||||||
|
- Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10)
|
||||||
|
= (c1 + (c2 + c3))
|
||||||
|
- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14)
|
||||||
|
- Branch { true: Counter(1), false: Expression(3, Sub) } at (prev + 0, 13) to (start + 0, 14)
|
||||||
|
true = c1
|
||||||
|
false = (c0 - c1)
|
||||||
|
- Code(Expression(3, Sub)) at (prev + 0, 18) to (start + 0, 19)
|
||||||
|
= (c0 - c1)
|
||||||
|
- Branch { true: Counter(2), false: Counter(3) } at (prev + 0, 18) to (start + 0, 19)
|
||||||
|
true = c2
|
||||||
|
false = c3
|
||||||
|
- Code(Counter(2)) at (prev + 0, 23) to (start + 0, 24)
|
||||||
|
- Code(Expression(0, Add)) at (prev + 1, 5) to (start + 1, 2)
|
||||||
|
= (c1 + (c2 + c3))
|
||||||
|
|
||||||
|
Function name: conditions::assign_and
|
||||||
|
Raw bytes (38): 0x[01, 01, 01, 01, 05, 06, 01, 0d, 01, 00, 21, 01, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 20, 05, 02, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 01, 01, 05, 01, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 1
|
||||||
|
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
|
||||||
|
Number of file 0 mappings: 6
|
||||||
|
- Code(Counter(0)) at (prev + 13, 1) to (start + 0, 33)
|
||||||
|
- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 10)
|
||||||
|
- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14)
|
||||||
|
- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 0, 13) to (start + 0, 14)
|
||||||
|
true = c1
|
||||||
|
false = (c0 - c1)
|
||||||
|
- Code(Counter(1)) at (prev + 0, 18) to (start + 0, 19)
|
||||||
|
- Code(Counter(0)) at (prev + 1, 5) to (start + 1, 2)
|
||||||
|
|
||||||
|
Function name: conditions::assign_or
|
||||||
|
Raw bytes (38): 0x[01, 01, 01, 01, 05, 06, 01, 12, 01, 00, 20, 01, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 20, 05, 02, 00, 0d, 00, 0e, 02, 00, 12, 00, 13, 01, 01, 05, 01, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 1
|
||||||
|
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
|
||||||
|
Number of file 0 mappings: 6
|
||||||
|
- Code(Counter(0)) at (prev + 18, 1) to (start + 0, 32)
|
||||||
|
- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 10)
|
||||||
|
- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14)
|
||||||
|
- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 0, 13) to (start + 0, 14)
|
||||||
|
true = c1
|
||||||
|
false = (c0 - c1)
|
||||||
|
- Code(Expression(0, Sub)) at (prev + 0, 18) to (start + 0, 19)
|
||||||
|
= (c0 - c1)
|
||||||
|
- Code(Counter(0)) at (prev + 1, 5) to (start + 1, 2)
|
||||||
|
|
||||||
|
Function name: conditions::foo
|
||||||
|
Raw bytes (9): 0x[01, 01, 00, 01, 01, 21, 01, 02, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 0
|
||||||
|
Number of file 0 mappings: 1
|
||||||
|
- Code(Counter(0)) at (prev + 33, 1) to (start + 2, 2)
|
||||||
|
|
||||||
|
Function name: conditions::func_call
|
||||||
|
Raw bytes (28): 0x[01, 01, 01, 01, 05, 04, 01, 25, 01, 01, 0a, 20, 05, 02, 01, 09, 00, 0a, 05, 00, 0e, 00, 0f, 01, 01, 01, 00, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 1
|
||||||
|
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
|
||||||
|
Number of file 0 mappings: 4
|
||||||
|
- Code(Counter(0)) at (prev + 37, 1) to (start + 1, 10)
|
||||||
|
- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 1, 9) to (start + 0, 10)
|
||||||
|
true = c1
|
||||||
|
false = (c0 - c1)
|
||||||
|
- Code(Counter(1)) at (prev + 0, 14) to (start + 0, 15)
|
||||||
|
- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2)
|
||||||
|
|
||||||
|
Function name: conditions::simple_assign
|
||||||
|
Raw bytes (9): 0x[01, 01, 00, 01, 01, 08, 01, 03, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 0
|
||||||
|
Number of file 0 mappings: 1
|
||||||
|
- Code(Counter(0)) at (prev + 8, 1) to (start + 3, 2)
|
||||||
|
|
90
tests/coverage/condition/conditions.coverage
Normal file
90
tests/coverage/condition/conditions.coverage
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
LL| |#![feature(coverage_attribute)]
|
||||||
|
LL| |//@ edition: 2021
|
||||||
|
LL| |//@ compile-flags: -Zcoverage-options=condition
|
||||||
|
LL| |//@ llvm-cov-flags: --show-branches=count
|
||||||
|
LL| |
|
||||||
|
LL| |use core::hint::black_box;
|
||||||
|
LL| |
|
||||||
|
LL| 2|fn simple_assign(a: bool) {
|
||||||
|
LL| 2| let x = a;
|
||||||
|
LL| 2| black_box(x);
|
||||||
|
LL| 2|}
|
||||||
|
LL| |
|
||||||
|
LL| 3|fn assign_and(a: bool, b: bool) {
|
||||||
|
LL| 3| let x = a && b;
|
||||||
|
^2
|
||||||
|
------------------
|
||||||
|
| Branch (LL:13): [True: 2, False: 1]
|
||||||
|
------------------
|
||||||
|
LL| 3| black_box(x);
|
||||||
|
LL| 3|}
|
||||||
|
LL| |
|
||||||
|
LL| 3|fn assign_or(a: bool, b: bool) {
|
||||||
|
LL| 3| let x = a || b;
|
||||||
|
^1
|
||||||
|
------------------
|
||||||
|
| Branch (LL:13): [True: 2, False: 1]
|
||||||
|
------------------
|
||||||
|
LL| 3| black_box(x);
|
||||||
|
LL| 3|}
|
||||||
|
LL| |
|
||||||
|
LL| 4|fn assign_3_or_and(a: bool, b: bool, c: bool) {
|
||||||
|
LL| 4| let x = a || b && c;
|
||||||
|
^2 ^1
|
||||||
|
------------------
|
||||||
|
| Branch (LL:13): [True: 2, False: 2]
|
||||||
|
| Branch (LL:18): [True: 1, False: 1]
|
||||||
|
------------------
|
||||||
|
LL| 4| black_box(x);
|
||||||
|
LL| 4|}
|
||||||
|
LL| |
|
||||||
|
LL| 4|fn assign_3_and_or(a: bool, b: bool, c: bool) {
|
||||||
|
LL| 4| let x = a && b || c;
|
||||||
|
^2 ^3
|
||||||
|
------------------
|
||||||
|
| Branch (LL:13): [True: 2, False: 2]
|
||||||
|
| Branch (LL:18): [True: 1, False: 1]
|
||||||
|
------------------
|
||||||
|
LL| 4| black_box(x);
|
||||||
|
LL| 4|}
|
||||||
|
LL| |
|
||||||
|
LL| 3|fn foo(a: bool) -> bool {
|
||||||
|
LL| 3| black_box(a)
|
||||||
|
LL| 3|}
|
||||||
|
LL| |
|
||||||
|
LL| 3|fn func_call(a: bool, b: bool) {
|
||||||
|
LL| 3| foo(a && b);
|
||||||
|
^2
|
||||||
|
------------------
|
||||||
|
| Branch (LL:9): [True: 2, False: 1]
|
||||||
|
------------------
|
||||||
|
LL| 3|}
|
||||||
|
LL| |
|
||||||
|
LL| |#[coverage(off)]
|
||||||
|
LL| |fn main() {
|
||||||
|
LL| | simple_assign(true);
|
||||||
|
LL| | simple_assign(false);
|
||||||
|
LL| |
|
||||||
|
LL| | assign_and(true, false);
|
||||||
|
LL| | assign_and(true, true);
|
||||||
|
LL| | assign_and(false, false);
|
||||||
|
LL| |
|
||||||
|
LL| | assign_or(true, false);
|
||||||
|
LL| | assign_or(true, true);
|
||||||
|
LL| | assign_or(false, false);
|
||||||
|
LL| |
|
||||||
|
LL| | assign_3_or_and(true, false, false);
|
||||||
|
LL| | assign_3_or_and(true, true, false);
|
||||||
|
LL| | assign_3_or_and(false, false, true);
|
||||||
|
LL| | assign_3_or_and(false, true, true);
|
||||||
|
LL| |
|
||||||
|
LL| | assign_3_and_or(true, false, false);
|
||||||
|
LL| | assign_3_and_or(true, true, false);
|
||||||
|
LL| | assign_3_and_or(false, false, true);
|
||||||
|
LL| | assign_3_and_or(false, true, true);
|
||||||
|
LL| |
|
||||||
|
LL| | func_call(true, false);
|
||||||
|
LL| | func_call(true, true);
|
||||||
|
LL| | func_call(false, false);
|
||||||
|
LL| |}
|
||||||
|
|
67
tests/coverage/condition/conditions.rs
Normal file
67
tests/coverage/condition/conditions.rs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
#![feature(coverage_attribute)]
|
||||||
|
//@ edition: 2021
|
||||||
|
//@ compile-flags: -Zcoverage-options=condition
|
||||||
|
//@ llvm-cov-flags: --show-branches=count
|
||||||
|
|
||||||
|
use core::hint::black_box;
|
||||||
|
|
||||||
|
fn simple_assign(a: bool) {
|
||||||
|
let x = a;
|
||||||
|
black_box(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn assign_and(a: bool, b: bool) {
|
||||||
|
let x = a && b;
|
||||||
|
black_box(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn assign_or(a: bool, b: bool) {
|
||||||
|
let x = a || b;
|
||||||
|
black_box(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn assign_3_or_and(a: bool, b: bool, c: bool) {
|
||||||
|
let x = a || b && c;
|
||||||
|
black_box(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn assign_3_and_or(a: bool, b: bool, c: bool) {
|
||||||
|
let x = a && b || c;
|
||||||
|
black_box(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo(a: bool) -> bool {
|
||||||
|
black_box(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn func_call(a: bool, b: bool) {
|
||||||
|
foo(a && b);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[coverage(off)]
|
||||||
|
fn main() {
|
||||||
|
simple_assign(true);
|
||||||
|
simple_assign(false);
|
||||||
|
|
||||||
|
assign_and(true, false);
|
||||||
|
assign_and(true, true);
|
||||||
|
assign_and(false, false);
|
||||||
|
|
||||||
|
assign_or(true, false);
|
||||||
|
assign_or(true, true);
|
||||||
|
assign_or(false, false);
|
||||||
|
|
||||||
|
assign_3_or_and(true, false, false);
|
||||||
|
assign_3_or_and(true, true, false);
|
||||||
|
assign_3_or_and(false, false, true);
|
||||||
|
assign_3_or_and(false, true, true);
|
||||||
|
|
||||||
|
assign_3_and_or(true, false, false);
|
||||||
|
assign_3_and_or(true, true, false);
|
||||||
|
assign_3_and_or(false, false, true);
|
||||||
|
assign_3_and_or(false, true, true);
|
||||||
|
|
||||||
|
func_call(true, false);
|
||||||
|
func_call(true, true);
|
||||||
|
func_call(false, false);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user