-
-
Notifications
You must be signed in to change notification settings - Fork 94
/
smoke.rs
130 lines (105 loc) 路 2.93 KB
/
smoke.rs
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//#![feature(test)]
use heim_common::prelude::*;
use heim_common::units::frequency;
use heim_cpu as cpu;
use heim_runtime as rt;
#[heim_derive::skip_ci(target_os = "linux")]
#[heim_derive::test]
async fn smoke_frequency() {
let freq = cpu::frequency().await.unwrap();
assert!(freq.current().get::<frequency::hertz>() > 0);
let _ = freq.min();
let _ = freq.max();
}
#[heim_derive::test]
#[cfg(target_os = "linux")]
async fn smoke_frequencies() {
let frequencies = cpu::os::linux::frequencies();
rt::pin!(frequencies);
while let Some(freq) = frequencies.next().await {
let f = freq.unwrap();
let _ = f.current();
let _ = f.min();
let _ = f.max();
}
}
#[heim_derive::test]
async fn smoke_stats() {
let stats = cpu::stats().await.unwrap();
let _ = stats.ctx_switches();
let _ = stats.interrupts();
#[cfg(target_os = "linux")]
{
use heim_cpu::os::linux::CpuStatsExt;
let _ = stats.soft_interrupts();
}
#[cfg(target_os = "macos")]
{
use heim_cpu::os::macos::CpuStatsExt;
let _ = stats.soft_interrupts();
let _ = stats.syscalls();
}
#[cfg(target_os = "windows")]
{
use heim_cpu::os::windows::CpuStatsExt;
let _ = stats.dpc();
let _ = stats.syscalls();
}
}
#[heim_derive::test]
async fn smoke_time() {
let time = cpu::time().await;
let time = time.unwrap();
let _ = time.system();
let _ = time.user();
let _ = time.idle();
#[cfg(target_os = "linux")]
{
use heim_cpu::os::linux::CpuTimeExt;
let _ = time.nice();
let _ = time.io_wait();
let _ = time.irq();
let _ = time.soft_irq();
let _ = time.steal();
let _ = time.guest();
let _ = time.guest_nice();
}
}
#[heim_derive::test]
async fn smoke_times() {
let times = cpu::times();
rt::pin!(times);
while let Some(time) = times.next().await {
let time = time.unwrap();
let _ = time.system();
let _ = time.user();
let _ = time.idle();
#[cfg(target_os = "linux")]
{
use heim_cpu::os::linux::CpuTimeExt;
let _ = time.nice();
let _ = time.io_wait();
let _ = time.irq();
let _ = time.soft_irq();
let _ = time.steal();
let _ = time.guest();
let _ = time.guest_nice();
}
}
}
#[heim_derive::test]
async fn smoke_cpu_logical_count() {
let count = cpu::logical_count().await.unwrap();
assert!(count > 0);
}
// TODO: Crashes for some reasons in Azure VM, should be investigated
#[heim_derive::skip_ci(target_os = "windows")]
#[heim_derive::test]
async fn smoke_cpu_physical_count() {
let count = cpu::physical_count().await;
assert!(count.is_ok(), "cpu::physical_count failed: {:#?}", count);
let count = count.unwrap();
if let Some(cpus) = count {
assert!(cpus > 0);
}
}