Skip to content

Commit

Permalink
Fix partial net tests without support
Browse files Browse the repository at this point in the history
  • Loading branch information
cd-work committed Sep 14, 2023
1 parent 0ede36e commit ea956c7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
13 changes: 10 additions & 3 deletions tests/net_without_namespaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@ fn main() {
seccompiler::apply_filter(&program).unwrap();

let birdcage = Birdcage::new().unwrap();
birdcage.lock().unwrap();
let result = birdcage.lock();

let result = TcpStream::connect("8.8.8.8:443");
assert!(result.is_err());
match result {
// Seccomp is supported, so networking should still be blocked.
Ok(_) => {
let result = TcpStream::connect("8.8.8.8:443");
assert!(result.is_err());
},
// Seccomp isn't supported, so failure is desired.
Err(_) => (),
}
}

#[cfg(not(target_os = "linux"))]
Expand Down
13 changes: 10 additions & 3 deletions tests/net_without_seccomp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,17 @@ fn main() {
seccompiler::apply_filter(&program).unwrap();

let birdcage = Birdcage::new().unwrap();
birdcage.lock().unwrap();
let result = birdcage.lock();

let result = TcpStream::connect("8.8.8.8:443");
assert!(result.is_err());
match result {
// Namespaces are supported, so networking should still be blocked.
Ok(_) => {
let result = TcpStream::connect("8.8.8.8:443");
assert!(result.is_err());
},
// Namespaces aren't supported, so failure is desired.
Err(_) => (),
}
}

#[cfg(not(target_os = "linux"))]
Expand Down

0 comments on commit ea956c7

Please sign in to comment.