Skip to content

Commit ce331bf

Browse files
committed
Fixup to "Disable execveat and AF_ALG tests in seccomp mode"
1 parent 67ed663 commit ce331bf

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

test/test.rs

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,33 +73,35 @@ macro_rules! skip_if_not_root {
7373
};
7474
}
7575

76-
#[cfg(target_os = "linux")]
77-
macro_rules! skip_if_seccomp {
78-
($name:expr) => {
79-
if let Ok(s) = std::fs::read_to_string("/proc/self/status") {
80-
for l in s.lines() {
81-
let mut fields = l.split_whitespace();
82-
if fields.next() == Some("Seccomp:") &&
83-
fields.next() != Some("0")
84-
{
85-
use ::std::io::Write;
86-
let stderr = ::std::io::stderr();
87-
let mut handle = stderr.lock();
88-
writeln!(handle,
89-
"{} cannot be run in Seccomp mode. Skipping test.",
90-
stringify!($name)).unwrap();
91-
return;
76+
cfg_if! {
77+
if #[cfg(any(target_os = "android", target_os = "linux"))] {
78+
macro_rules! skip_if_seccomp {
79+
($name:expr) => {
80+
if let Ok(s) = std::fs::read_to_string("/proc/self/status") {
81+
for l in s.lines() {
82+
let mut fields = l.split_whitespace();
83+
if fields.next() == Some("Seccomp:") &&
84+
fields.next() != Some("0")
85+
{
86+
use ::std::io::Write;
87+
let stderr = ::std::io::stderr();
88+
let mut handle = stderr.lock();
89+
writeln!(handle,
90+
"{} cannot be run in Seccomp mode. Skipping test.",
91+
stringify!($name)).unwrap();
92+
return;
93+
}
94+
}
9295
}
9396
}
9497
}
98+
} else {
99+
macro_rules! skip_if_seccomp {
100+
($name:expr) => {}
101+
}
95102
}
96103
}
97104

98-
#[cfg(not(target_os = "linux"))]
99-
macro_rules! skip_if_seccomp {
100-
($name:expr) => {}
101-
}
102-
103105
mod sys;
104106
mod test_dir;
105107
mod test_fcntl;

0 commit comments

Comments
 (0)