selftests: rtnetlink: remove testns on test fail
authorPrashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Fri, 2 Mar 2018 02:22:20 +0000 (11:22 +0900)
committerDavid S. Miller <davem@davemloft.net>
Sun, 4 Mar 2018 23:36:15 +0000 (18:36 -0500)
This patch removes testns after test failure so that next test can
continue with clean ns

Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/rtnetlink.sh

index a622eeecc3a68d0cc81f3ee0614645e2c3ce27f8..e6f4852354353124df50e889f5c04ad220dc584e 100755 (executable)
@@ -517,6 +517,7 @@ kci_test_gretap()
        ip link help gretap 2>&1 | grep -q "^Usage:"
        if [ $? -ne 0 ];then
                echo "SKIP: gretap: iproute2 too old"
+               ip netns del "$testns"
                return 1
        fi
 
@@ -543,6 +544,7 @@ kci_test_gretap()
 
        if [ $ret -ne 0 ]; then
                echo "FAIL: gretap"
+               ip netns del "$testns"
                return 1
        fi
        echo "PASS: gretap"
@@ -565,6 +567,7 @@ kci_test_ip6gretap()
        ip link help ip6gretap 2>&1 | grep -q "^Usage:"
        if [ $? -ne 0 ];then
                echo "SKIP: ip6gretap: iproute2 too old"
+               ip netns del "$testns"
                return 1
        fi
 
@@ -591,6 +594,7 @@ kci_test_ip6gretap()
 
        if [ $ret -ne 0 ]; then
                echo "FAIL: ip6gretap"
+               ip netns del "$testns"
                return 1
        fi
        echo "PASS: ip6gretap"
@@ -655,6 +659,7 @@ kci_test_erspan()
 
        if [ $ret -ne 0 ]; then
                echo "FAIL: erspan"
+               ip netns del "$testns"
                return 1
        fi
        echo "PASS: erspan"
@@ -720,6 +725,7 @@ kci_test_ip6erspan()
 
        if [ $ret -ne 0 ]; then
                echo "FAIL: ip6erspan"
+               ip netns del "$testns"
                return 1
        fi
        echo "PASS: ip6erspan"