MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / test_reboot

Function test_reboot

tests/system/reboot.rs:3–17  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1#[test]
2#[cfg(feature = "thread")]
3fn test_reboot() {
4 use rustix::io::Errno;
5 use rustix::system::{self, RebootCommand};
6 use rustix::thread::{self, CapabilitySet};
7
8 let mut capabilities = thread::capabilities(None).expect("Failed to get capabilities");
9
10 capabilities.effective.set(CapabilitySet::SYS_BOOT, false);
11
12 thread::set_capabilities(None, capabilities).expect("Failed to set capabilities");
13
14 // The reboot syscall requires the `CapabilitySet::SYS_BOOT` permission
15 // to be called, otherwise [`Errno::PERM`] is returned
16 assert_eq!(system::reboot(RebootCommand::Restart), Err(Errno::PERM));
17}

Callers

nothing calls this directly

Calls 3

capabilitiesFunction · 0.85
set_capabilitiesFunction · 0.85
setMethod · 0.80

Tested by

no test coverage detected