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
/// Whether this process is running on real Apple hardware, as opposed to a
/// virtualised Apple Silicon host such as a GitHub Actions `macos-14` runner.
///
/// Several readers in this module talk to physical sensors — the HID
/// temperature client, IOReport's "Energy Model" group, the `hw.perflevel*`
/// core-count sysctls. A VM is arm64 macOS and compiles everything fine, but
/// exposes none of them, so their tests cannot pass there. Rather than delete
/// those tests or let them fail every CI run, they skip when this returns
/// false — which keeps them strict on a real Mac, where the assertions are
/// the whole point.
///
/// Two independent signals, either of which is conclusive on its own:
///
/// - `kern.hv_vmm_present` is macOS's own hypervisor flag — 1 under a VM.
/// - `hw.nperflevels` is 2 on every Apple Silicon chip, which all have both
/// performance and efficiency cores. A virtualised host presents one uniform
/// core set and reports 1.
///
/// Both are checked because either alone could be wrong on a host neither of
/// us has seen. Note that `hw.optional.arm64` and `hw.perflevel0.physicalcpu`
/// are *not* usable here: both are present on a virtualised arm64 host too.
pub
/// Skip the rest of a test when there is no physical sensor hardware to read.
/// Prints why, so a skipped run in CI is visible rather than silently green.
pub use needs_real_hardware;