]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1574] shell scripts: remove_if_exists
authorAndrei Pavel <andrei@isc.org>
Fri, 11 Dec 2020 14:49:18 +0000 (16:49 +0200)
committerAndrei Pavel <andrei@isc.org>
Mon, 14 Dec 2020 10:08:11 +0000 (12:08 +0200)
src/lib/testutils/dhcp_test_lib.sh.in

index 161bfa4d8aacec910da0d3db30ce14aa2438ed58..6cdb484afd2c0282f113aee119b4e575360476a9 100644 (file)
@@ -539,6 +539,15 @@ cleanup() {
     kill_processes_by_name "kea-lfc"
 
     # Remove temporary files.
+    remove_if_exists \
+        "${CA_CFG_FILE-}" \
+        "${CFG_FILE-}" \
+        "${D2_CFG_FILE-}" \
+        "${DHCP4_CFG_FILE-}" \
+        "${DHCP6_CFG_FILE-}" \
+        "${KEACTRL_CFG_FILE-}" \
+        "${NC_CFG_FILE-}"
+
     # Use ${var+x} to test if ${var} is defined.
     if test -n "${LOG_FILE+x}" && test -n "${LOG_FILE}"; then
         rm -rf "${LOG_FILE}"
@@ -550,27 +559,6 @@ cleanup() {
     if test -n "${LEASE_FILE+x}" && test -n "${LEASE_FILE}"; then
         rm -rf "${LEASE_FILE}"*
     fi
-    if test -n "${CFG_FILE+x}" && test -n "${CFG_FILE}"; then
-        rm -rf "${CFG_FILE}"
-    fi
-    if test -n "${DHCP4_CFG_FILE+x}" && test -n "${DHCP4_CFG_FILE}"; then
-        rm -rf "${DHCP4_CFG_FILE}"
-    fi
-    if test -n "${DHCP6_CFG_FILE+x}" && test -n "${DHCP6_CFG_FILE}"; then
-        rm -rf "${DHCP6_CFG_FILE}"
-    fi
-    if test -n "${D2_CFG_FILE+x}" && test -n "${D2_CFG_FILE}"; then
-        rm -rf "${D2_CFG_FILE}"
-    fi
-    if test -n "${CA_CFG_FILE+x}" && test -n "${CA_CFG_FILE}"; then
-        rm -rf "${CA_CFG_FILE}"
-    fi
-    if test -n "${NC_CFG_FILE+x}" && test -n "${NC_CFG_FILE}"; then
-        rm -rf "${NC_CFG_FILE}"
-    fi
-    if test -n "${KEACTRL_CFG_FILE+x}" && test -n "${KEACTRL_CFG_FILE}"; then
-        rm -rf "${KEACTRL_CFG_FILE}"
-    fi
 }
 
 # Exists the test in the clean way.