mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-07-14 22:06:46 +00:00
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 <Hyounggyu.Choi@ibm.com>
This commit is contained in:
committed by
Steve Horsman
parent
3f84b623a3
commit
075de4dc62
@@ -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<T>(result: &Result<T>) -> 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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user