()
| 79 | )] |
| 80 | #[test] |
| 81 | fn 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] |
nothing calls this directly
no test coverage detected