Skip to content

Commit

Permalink
Fixup to "Disable execveat and AF_ALG tests in seccomp mode"
Browse files Browse the repository at this point in the history
  • Loading branch information
asomers committed Sep 19, 2019
1 parent 67ed663 commit ce331bf
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions test/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,33 +73,35 @@ macro_rules! skip_if_not_root {
};
}

#[cfg(target_os = "linux")]
macro_rules! skip_if_seccomp {
($name:expr) => {
if let Ok(s) = std::fs::read_to_string("/proc/self/status") {
for l in s.lines() {
let mut fields = l.split_whitespace();
if fields.next() == Some("Seccomp:") &&
fields.next() != Some("0")
{
use ::std::io::Write;
let stderr = ::std::io::stderr();
let mut handle = stderr.lock();
writeln!(handle,
"{} cannot be run in Seccomp mode. Skipping test.",
stringify!($name)).unwrap();
return;
cfg_if! {
if #[cfg(any(target_os = "android", target_os = "linux"))] {
macro_rules! skip_if_seccomp {
($name:expr) => {
if let Ok(s) = std::fs::read_to_string("/proc/self/status") {
for l in s.lines() {
let mut fields = l.split_whitespace();
if fields.next() == Some("Seccomp:") &&
fields.next() != Some("0")
{
use ::std::io::Write;
let stderr = ::std::io::stderr();
let mut handle = stderr.lock();
writeln!(handle,
"{} cannot be run in Seccomp mode. Skipping test.",
stringify!($name)).unwrap();
return;
}
}
}
}
}
} else {
macro_rules! skip_if_seccomp {
($name:expr) => {}
}
}
}

#[cfg(not(target_os = "linux"))]
macro_rules! skip_if_seccomp {
($name:expr) => {}
}

mod sys;
mod test_dir;
mod test_fcntl;
Expand Down

0 comments on commit ce331bf

Please sign in to comment.