Skip to content

Commit b251d34

Browse files
committed
🍒 Copy a selection of run-coverage test files into coverage-map
The output of these tests is too complicated to comfortably verify by hand, but we can still use them to observe changes to the underlying mappings produced by codegen/LLVM.
1 parent f07dcc0 commit b251d34

File tree

13 files changed

+1021
-0
lines changed

13 files changed

+1021
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The tests in this directory were copied from `tests/run-coverage` in order to
2+
capture the current behavior of the instrumentor on non-trivial programs.
3+
The actual mappings have not been closely inspected.
4+
5+
## Maintenance note
6+
7+
If a MIR optimization or LLVM upgrade causes these tests to fail,
8+
it should usually be OK to just `--bless` them,
9+
as long as the `run-coverage` test suite still works.
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
Function name: async2::async_func
2+
Raw bytes (9): 0x[01, 01, 00, 01, 01, 14, 01, 00, 17]
3+
Number of files: 1
4+
- file 0 => global file 1
5+
Number of expressions: 0
6+
Number of file 0 mappings: 1
7+
- Code(Counter(0)) at (prev + 20, 1) to (start + 0, 23)
8+
9+
Function name: async2::async_func::{closure#0}
10+
Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 14, 17, 03, 09, 05, 03, 0a, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02]
11+
Number of files: 1
12+
- file 0 => global file 1
13+
Number of expressions: 2
14+
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
15+
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
16+
Number of file 0 mappings: 4
17+
- Code(Counter(0)) at (prev + 20, 23) to (start + 3, 9)
18+
- Code(Counter(1)) at (prev + 3, 10) to (start + 2, 6)
19+
- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7)
20+
= (c0 - c1)
21+
- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
22+
= (c1 + (c0 - c1))
23+
24+
Function name: async2::async_func_just_println
25+
Raw bytes (9): 0x[01, 01, 00, 01, 01, 1f, 01, 00, 24]
26+
Number of files: 1
27+
- file 0 => global file 1
28+
Number of expressions: 0
29+
Number of file 0 mappings: 1
30+
- Code(Counter(0)) at (prev + 31, 1) to (start + 0, 36)
31+
32+
Function name: async2::async_func_just_println::{closure#0}
33+
Raw bytes (9): 0x[01, 01, 00, 01, 01, 1f, 24, 02, 02]
34+
Number of files: 1
35+
- file 0 => global file 1
36+
Number of expressions: 0
37+
Number of file 0 mappings: 1
38+
- Code(Counter(0)) at (prev + 31, 36) to (start + 2, 2)
39+
40+
Function name: async2::executor::block_on::<async2::async_func::{closure#0}>
41+
Raw bytes (44): 0x[01, 01, 05, 0b, 05, 01, 05, 01, 05, 02, 00, 02, 00, 06, 01, 33, 05, 0a, 36, 02, 0d, 20, 00, 23, 0b, 00, 27, 00, 49, 0f, 01, 17, 00, 1a, 05, 01, 0e, 00, 0f, 13, 02, 05, 00, 06]
42+
Number of files: 1
43+
- file 0 => global file 1
44+
Number of expressions: 5
45+
- expression 0 operands: lhs = Expression(2, Add), rhs = Counter(1)
46+
- expression 1 operands: lhs = Counter(0), rhs = Counter(1)
47+
- expression 2 operands: lhs = Counter(0), rhs = Counter(1)
48+
- expression 3 operands: lhs = Expression(0, Sub), rhs = Zero
49+
- expression 4 operands: lhs = Expression(0, Sub), rhs = Zero
50+
Number of file 0 mappings: 6
51+
- Code(Counter(0)) at (prev + 51, 5) to (start + 10, 54)
52+
- Code(Expression(0, Sub)) at (prev + 13, 32) to (start + 0, 35)
53+
= ((c0 + c1) - c1)
54+
- Code(Expression(2, Add)) at (prev + 0, 39) to (start + 0, 73)
55+
= (c0 + c1)
56+
- Code(Expression(3, Add)) at (prev + 1, 23) to (start + 0, 26)
57+
= (((c0 + c1) - c1) + Zero)
58+
- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 15)
59+
- Code(Expression(4, Add)) at (prev + 2, 5) to (start + 0, 6)
60+
= (((c0 + c1) - c1) + Zero)
61+
62+
Function name: async2::executor::block_on::<async2::async_func_just_println::{closure#0}>
63+
Raw bytes (44): 0x[01, 01, 05, 0b, 05, 01, 05, 01, 05, 02, 00, 02, 00, 06, 01, 33, 05, 0a, 36, 02, 0d, 20, 00, 23, 0b, 00, 27, 00, 49, 0f, 01, 17, 00, 1a, 05, 01, 0e, 00, 0f, 13, 02, 05, 00, 06]
64+
Number of files: 1
65+
- file 0 => global file 1
66+
Number of expressions: 5
67+
- expression 0 operands: lhs = Expression(2, Add), rhs = Counter(1)
68+
- expression 1 operands: lhs = Counter(0), rhs = Counter(1)
69+
- expression 2 operands: lhs = Counter(0), rhs = Counter(1)
70+
- expression 3 operands: lhs = Expression(0, Sub), rhs = Zero
71+
- expression 4 operands: lhs = Expression(0, Sub), rhs = Zero
72+
Number of file 0 mappings: 6
73+
- Code(Counter(0)) at (prev + 51, 5) to (start + 10, 54)
74+
- Code(Expression(0, Sub)) at (prev + 13, 32) to (start + 0, 35)
75+
= ((c0 + c1) - c1)
76+
- Code(Expression(2, Add)) at (prev + 0, 39) to (start + 0, 73)
77+
= (c0 + c1)
78+
- Code(Expression(3, Add)) at (prev + 1, 23) to (start + 0, 26)
79+
= (((c0 + c1) - c1) + Zero)
80+
- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 15)
81+
- Code(Expression(4, Add)) at (prev + 2, 5) to (start + 0, 6)
82+
= (((c0 + c1) - c1) + Zero)
83+
84+
Function name: async2::executor::block_on::VTABLE::{closure#0}
85+
Raw bytes (9): 0x[01, 01, 00, 01, 01, 37, 11, 00, 33]
86+
Number of files: 1
87+
- file 0 => global file 1
88+
Number of expressions: 0
89+
Number of file 0 mappings: 1
90+
- Code(Counter(0)) at (prev + 55, 17) to (start + 0, 51)
91+
92+
Function name: async2::executor::block_on::VTABLE::{closure#1}
93+
Raw bytes (9): 0x[01, 01, 00, 01, 01, 38, 11, 00, 33]
94+
Number of files: 1
95+
- file 0 => global file 1
96+
Number of expressions: 0
97+
Number of file 0 mappings: 1
98+
- Code(Counter(0)) at (prev + 56, 17) to (start + 0, 51)
99+
100+
Function name: async2::executor::block_on::VTABLE::{closure#2}
101+
Raw bytes (9): 0x[01, 01, 00, 01, 01, 39, 11, 00, 33]
102+
Number of files: 1
103+
- file 0 => global file 1
104+
Number of expressions: 0
105+
Number of file 0 mappings: 1
106+
- Code(Counter(0)) at (prev + 57, 17) to (start + 0, 51)
107+
108+
Function name: async2::executor::block_on::VTABLE::{closure#3}
109+
Raw bytes (9): 0x[01, 01, 00, 01, 01, 3a, 11, 00, 13]
110+
Number of files: 1
111+
- file 0 => global file 1
112+
Number of expressions: 0
113+
Number of file 0 mappings: 1
114+
- Code(Counter(0)) at (prev + 58, 17) to (start + 0, 19)
115+
116+
Function name: async2::main
117+
Raw bytes (9): 0x[01, 01, 00, 01, 01, 23, 01, 07, 02]
118+
Number of files: 1
119+
- file 0 => global file 1
120+
Number of expressions: 0
121+
Number of file 0 mappings: 1
122+
- Code(Counter(0)) at (prev + 35, 1) to (start + 7, 2)
123+
124+
Function name: async2::non_async_func
125+
Raw bytes (26): 0x[01, 01, 01, 05, 00, 04, 01, 09, 01, 03, 09, 05, 03, 0a, 02, 06, 00, 02, 06, 00, 07, 03, 01, 01, 00, 02]
126+
Number of files: 1
127+
- file 0 => global file 1
128+
Number of expressions: 1
129+
- expression 0 operands: lhs = Counter(1), rhs = Zero
130+
Number of file 0 mappings: 4
131+
- Code(Counter(0)) at (prev + 9, 1) to (start + 3, 9)
132+
- Code(Counter(1)) at (prev + 3, 10) to (start + 2, 6)
133+
- Code(Zero) at (prev + 2, 6) to (start + 0, 7)
134+
- Code(Expression(0, Add)) at (prev + 1, 1) to (start + 0, 2)
135+
= (c1 + Zero)
136+
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// compile-flags: --edition=2018
2+
3+
use core::{
4+
future::Future,
5+
marker::Send,
6+
pin::Pin,
7+
};
8+
9+
fn non_async_func() {
10+
println!("non_async_func was covered");
11+
let b = true;
12+
if b {
13+
println!("non_async_func println in block");
14+
}
15+
}
16+
17+
18+
19+
20+
async fn async_func() {
21+
println!("async_func was covered");
22+
let b = true;
23+
if b {
24+
println!("async_func println in block");
25+
}
26+
}
27+
28+
29+
30+
31+
async fn async_func_just_println() {
32+
println!("async_func_just_println was covered");
33+
}
34+
35+
fn main() {
36+
println!("codecovsample::main");
37+
38+
non_async_func();
39+
40+
executor::block_on(async_func());
41+
executor::block_on(async_func_just_println());
42+
}
43+
44+
mod executor {
45+
use core::{
46+
future::Future,
47+
pin::Pin,
48+
task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
49+
};
50+
51+
pub fn block_on<F: Future>(mut future: F) -> F::Output {
52+
let mut future = unsafe { Pin::new_unchecked(&mut future) };
53+
use std::hint::unreachable_unchecked;
54+
static VTABLE: RawWakerVTable = RawWakerVTable::new(
55+
|_| unsafe { unreachable_unchecked() }, // clone
56+
|_| unsafe { unreachable_unchecked() }, // wake
57+
|_| unsafe { unreachable_unchecked() }, // wake_by_ref
58+
|_| (),
59+
);
60+
let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
61+
let mut context = Context::from_waker(&waker);
62+
63+
loop {
64+
if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
65+
break val;
66+
}
67+
}
68+
}
69+
}

0 commit comments

Comments
 (0)