| 1 |
use nix::net::if_::*; |
| 2 |
|
| 3 |
#[cfg(linux_android)] |
| 4 |
const LOOPBACK: &[u8] = b"lo"; |
| 5 |
|
| 6 |
#[cfg(not(any(linux_android, target_os = "haiku")))] |
| 7 |
const LOOPBACK: &[u8] = b"lo0"; |
| 8 |
|
| 9 |
#[cfg(target_os = "haiku")] |
| 10 |
const LOOPBACK: &[u8] = b"loop"; |
| 11 |
|
| 12 |
#[test] |
| 13 |
#[cfg_attr(target_os = "cygwin", ignore)] |
| 14 |
fn test_if_nametoindex() { |
| 15 |
if_nametoindex(LOOPBACK).expect("assertion failed"); |
| 16 |
} |
| 17 |
|
| 18 |
#[test] |
| 19 |
#[cfg_attr(target_os = "cygwin", ignore)] |
| 20 |
fn test_if_indextoname() { |
| 21 |
let loopback_index = if_nametoindex(LOOPBACK).expect("assertion failed"); |
| 22 |
assert_eq!( |
| 23 |
if_indextoname(loopback_index) |
| 24 |
.expect("assertion failed") |
| 25 |
.as_bytes(), |
| 26 |
LOOPBACK |
| 27 |
); |
| 28 |
} |