#![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(()) }