From 62a3230be8f54e5d5b810016055705fb6993ede8 Mon Sep 17 00:00:00 2001 From: Rodrigo Campos Date: Thu, 18 Jun 2026 18:57:21 +0200 Subject: [PATCH] tests/integration: Simplify delete_netns() Signed-off-by: Rodrigo Campos (cherry picked from commit e6aea33b47dd410aab18123b1437f1fbb2013f01) --- tests/integration/checkpoint.bats | 6 ++++-- tests/integration/netdev.bats | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/integration/checkpoint.bats b/tests/integration/checkpoint.bats index 2e51ff7d6..0aee9ec38 100644 --- a/tests/integration/checkpoint.bats +++ b/tests/integration/checkpoint.bats @@ -24,12 +24,14 @@ function create_netns() { } function delete_netns() { + [ -v ns_name ] || return + # The interface shouldn't be on the host, but if we failed to move it to the container, it # might. Let's delete it if we created one (i.e. if ns_name is defined). - [ -v ns_name ] && ip link del dev dummy0 2>/dev/null + ip link del dev dummy0 2>/dev/null # Delete the namespace only if the ns_name variable is set. - [ -v ns_name ] && ip netns del "$ns_name" + ip netns del "$ns_name" unset ns_name unset ns_path diff --git a/tests/integration/netdev.bats b/tests/integration/netdev.bats index daf8c22df..a87dad8eb 100644 --- a/tests/integration/netdev.bats +++ b/tests/integration/netdev.bats @@ -18,8 +18,10 @@ function setup_netns() { } function delete_netns() { + [ -v ns_name ] || return + # Delete the namespace only if the ns_name variable is set. - [ -v ns_name ] && ip netns del "$ns_name" + ip netns del "$ns_name" unset ns_name unset ns_path