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

Function test_secure_computing_mode

tests/thread/prctl.rs:81–102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

79)]
80#[test]
81fn test_secure_computing_mode() {
82 if !linux_kernel_config_item_is_enabled("CONFIG_SECCOMP").unwrap_or(false) {
83 eprintln!(
84 "test_secure_computing_mode: Test skipped due to missing kernel
85 feature: CONFIG_SECCOMP."
86 );
87 return;
88 }
89
90 // If seccomp is enabled, calling `secure_computing_mode` could evoke a
91 // `Signal::KILL`, so only call it if seccomp is disabled.
92 for line in std::io::BufReader::new(std::fs::File::open("/proc/self/status").unwrap()).lines() {
93 if let Some(seccomp) = line.unwrap().strip_prefix("Seccomp:") {
94 let seccomp = seccomp.trim();
95 let seccomp: i32 = seccomp.parse().unwrap();
96 let seccomp: rustix::thread::SecureComputingMode = seccomp.try_into().unwrap();
97 if seccomp == rustix::thread::SecureComputingMode::Disabled {
98 assert_eq!(seccomp, secure_computing_mode().unwrap());
99 }
100 }
101 }
102}
103
104#[cfg(feature = "system")]
105#[test]

Callers

nothing calls this directly

Calls 3

parseMethod · 0.80
openFunction · 0.50

Tested by

no test coverage detected