Skip to content

Commit

Permalink
Disallow permission errors in device test
Browse files Browse the repository at this point in the history
Since the test is now not run by default it doesn't make sense to allow
permission errors.

Also reduces explanation in the `panic!` calls since that's already in
the ignore attribute.
  • Loading branch information
Thomasdezeeuw committed Jan 8, 2021
1 parent 6dc5d63 commit c3babcd
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions tests/socket.rs
Expand Up @@ -640,7 +640,7 @@ fn device() {
for interface in INTERFACES.iter() {
if let Err(err) = socket.bind_device(Some(interface.as_bytes())) {
// Network interface is not available try another.
if matches!(err.raw_os_error(), Some(libc::ENODEV) | Some(libc::EPERM)) {
if matches!(err.raw_os_error(), Some(libc::ENODEV)) {
eprintln!("error binding to device (`{}`): {}", interface, err);
continue;
} else {
Expand All @@ -658,11 +658,7 @@ fn device() {
return;
}

panic!(
"failing to bind to any device. \
Note that on Linux this requires the `CAP_NET_RAW` permission. \
This can be given using `sudo setcap cap_net_raw=ep $test_bin`."
);
panic!("failed to bind to any device.");
}

fn any_ipv4() -> SockAddr {
Expand Down

0 comments on commit c3babcd

Please sign in to comment.