selftest: fib_tests: Always cleanup before exit
authorRoxana Nicolescu <roxana.nicolescu@canonical.com>
Mon, 20 Feb 2023 11:04:00 +0000 (12:04 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 21 Feb 2023 09:45:08 +0000 (10:45 +0100)
Usage of `set -e` before executing a command causes immediate exit
on failure, without cleanup up the resources allocated at setup.
This can affect the next tests that use the same resources,
leading to a chain of failures.

A simple fix is to always call cleanup function when the script exists.
This approach is already used by other existing tests.

Fixes: 1056691b2680 ("selftests: fib_tests: Make test results more verbose")
Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
Link: https://lore.kernel.org/r/20230220110400.26737-2-roxana.nicolescu@canonical.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
tools/testing/selftests/net/fib_tests.sh

index 5637b5dadabdb252e23a700056768f3a1ad355fd..70ea8798b1f60be5100c97566e0a7ccba554c396 100755 (executable)
@@ -2065,6 +2065,8 @@ EOF
 ################################################################################
 # main
 
+trap cleanup EXIT
+
 while getopts :t:pPhv o
 do
        case $o in