blob: 608e309f4e3ceb5f2263121bb70b762b6ac571f5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#![cfg(feature = "linux-runtime")]
use futures_util::TryStreamExt;
use rtnetlink::packet_route::link::LinkAttribute;
// Run on the disposable ALT VM, including with no active roentgen0. A dump
// omits missing interfaces, whereas the production named lookup returns ENODEV.
#[tokio::test]
async fn tun_lookup_agrees_with_kernel_link_dump() -> anyhow::Result<()> {
let (connection, handle, _) = rtnetlink::new_connection()?;
tokio::spawn(connection);
let mut links = handle.link().get().execute();
let mut expected = None;
while let Some(link) = links.try_next().await? {
if link.attributes.iter().any(|attribute| {
matches!(attribute, LinkAttribute::IfName(name) if name == "roentgen0")
}) {
expected = Some(link.header.index);
}
}
assert_eq!(roentgen::linux::routes::tun_index().await?, expected);
Ok(())
}
|