From 075de4dc6247bd6cd60d218adfc00aad352ca850 Mon Sep 17 00:00:00 2001 From: Hyounggyu Choi Date: Tue, 14 Oct 2025 21:54:46 +0200 Subject: [PATCH] agent/tests: Skip test if error is EACCES (permission denied) On IBM actionspz Z runners, write operations on network interfaces are not allowed, even for the root user. This commit skips the `add_update_addresses` test if the operation fails with EACCES (-13, permission denied). Signed-off-by: Hyounggyu Choi --- src/agent/src/netlink.rs | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/agent/src/netlink.rs b/src/agent/src/netlink.rs index b243e1caff..42f32bfbcd 100644 --- a/src/agent/src/netlink.rs +++ b/src/agent/src/netlink.rs @@ -922,6 +922,18 @@ mod tests { const TEST_DUMMY_INTERFACE: &str = "dummy_for_arp"; const TEST_ARP_IP: &str = "192.0.2.127"; + /// Helper function to check if the result is a netlink EACCES error + fn is_netlink_permission_error(result: &Result) -> bool { + if let Err(e) = result { + let error_string = format!("{:?}", e); + if error_string.contains("code: Some(-13)") { + println!("INFO: skipping test - netlink operations are restricted in this environment (EACCES)"); + return true; + } + } + false + } + #[tokio::test] async fn find_link_by_name() { let message = Handle::new() @@ -1045,10 +1057,14 @@ mod tests { let lo = handle.find_link(LinkFilter::Name("lo")).await.unwrap(); for network in list { - handle - .add_addresses(lo.index(), iter::once(network)) - .await - .expect("Failed to add IP"); + let result = handle.add_addresses(lo.index(), iter::once(network)).await; + + // Skip test if netlink operations are restricted (EACCES = -13) + if is_netlink_permission_error(&result) { + return; + } + + result.expect("Failed to add IP"); // Make sure the address is there let result = handle @@ -1063,10 +1079,14 @@ mod tests { assert!(result.is_some()); // Update it - handle - .add_addresses(lo.index(), iter::once(network)) - .await - .expect("Failed to delete address"); + let result = handle.add_addresses(lo.index(), iter::once(network)).await; + + // Skip test if netlink operations are restricted (EACCES = -13) + if is_netlink_permission_error(&result) { + return; + } + + result.expect("Failed to delete address"); } }