blob: 34c99cdaead5d630af793840e2e3d108d776cfd5 (
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
|
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::runtime::Runtime;
#[test]
fn basic_enter() {
let rt1 = rt();
let rt2 = rt();
let enter1 = rt1.enter();
let enter2 = rt2.enter();
drop(enter2);
drop(enter1);
}
#[test]
#[should_panic]
fn interleave_enter_different_rt() {
let rt1 = rt();
let rt2 = rt();
let enter1 = rt1.enter();
let enter2 = rt2.enter();
drop(enter1);
drop(enter2);
}
#[test]
#[should_panic]
fn interleave_enter_same_rt() {
let rt1 = rt();
let _enter1 = rt1.enter();
let enter2 = rt1.enter();
let enter3 = rt1.enter();
drop(enter2);
drop(enter3);
}
#[test]
#[cfg(not(tokio_wasi))]
fn interleave_then_enter() {
let _ = std::panic::catch_unwind(|| {
let rt1 = rt();
let rt2 = rt();
let enter1 = rt1.enter();
let enter2 = rt2.enter();
drop(enter1);
drop(enter2);
});
// Can still enter
let rt3 = rt();
let _enter = rt3.enter();
}
fn rt() -> Runtime {
tokio::runtime::Builder::new_current_thread()
.build()
.unwrap()
}
|