selftests: forwarding: Only check tc version for tc tests
authorDavid Ahern <dsahern@gmail.com>
Thu, 1 Mar 2018 21:49:30 +0000 (13:49 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 2 Mar 2018 02:19:02 +0000 (21:19 -0500)
Capabilities of tc command are irrelevant for router tests:
    $ ./router.sh
    SKIP: iproute2 too old, missing shared block support

Add a CHECK_TC flag and only check tc capabilities if set. Add flag to
tc_common.sh and have it sourced before lib.sh

Also, if the command lacks some feature the test should exit non-0.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/forwarding/bridge_vlan_aware.sh
tools/testing/selftests/net/forwarding/lib.sh
tools/testing/selftests/net/forwarding/tc_actions.sh
tools/testing/selftests/net/forwarding/tc_chains.sh
tools/testing/selftests/net/forwarding/tc_common.sh
tools/testing/selftests/net/forwarding/tc_flower.sh
tools/testing/selftests/net/forwarding/tc_shblocks.sh

index 23866a6..d0af521 100644 (file)
@@ -19,26 +19,33 @@ fi
 ##############################################################################
 # Sanity checks
 
+check_tc_version()
+{
+       tc -j &> /dev/null
+       if [[ $? -ne 0 ]]; then
+               echo "SKIP: iproute2 too old; tc is missing JSON support"
+               exit 1
+       fi
+
+       tc filter help 2>&1 | grep block &> /dev/null
+       if [[ $? -ne 0 ]]; then
+               echo "SKIP: iproute2 too old; tc is missing shared block support"
+               exit 1
+       fi
+}
+
 if [[ "$(id -u)" -ne 0 ]]; then
        echo "SKIP: need root privileges"
        exit 0
 fi
 
-tc -j &> /dev/null
-if [[ $? -ne 0 ]]; then
-       echo "SKIP: iproute2 too old, missing JSON support"
-       exit 0
-fi
-
-tc filter help 2>&1 | grep block &> /dev/null
-if [[ $? -ne 0 ]]; then
-       echo "SKIP: iproute2 too old, missing shared block support"
-       exit 0
+if [[ "$CHECK_TC" = "yes" ]]; then
+       check_tc_version
 fi
 
 if [[ ! -x "$(command -v jq)" ]]; then
        echo "SKIP: jq not installed"
-       exit 0
+       exit 1
 fi
 
 if [[ ! -x "$(command -v $MZ)" ]]; then
index 8423431..8ab5cf0 100755 (executable)
@@ -2,8 +2,8 @@
 # SPDX-License-Identifier: GPL-2.0
 
 NUM_NETIFS=4
-source lib.sh
 source tc_common.sh
+source lib.sh
 
 tcflags="skip_hw"
 
index 94c114a..2fd1522 100755 (executable)
@@ -2,8 +2,8 @@
 # SPDX-License-Identifier: GPL-2.0
 
 NUM_NETIFS=2
-source lib.sh
 source tc_common.sh
+source lib.sh
 
 tcflags="skip_hw"
 
index acd0b52..9d3b64a 100644 (file)
@@ -1,6 +1,8 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
+CHECK_TC="yes"
+
 tc_check_packets()
 {
        local id=$1
index 026a4ea..032b882 100755 (executable)
@@ -2,8 +2,8 @@
 # SPDX-License-Identifier: GPL-2.0
 
 NUM_NETIFS=2
-source lib.sh
 source tc_common.sh
+source lib.sh
 
 tcflags="skip_hw"
 
index cfc8a2a..077b980 100755 (executable)
@@ -2,8 +2,8 @@
 # SPDX-License-Identifier: GPL-2.0
 
 NUM_NETIFS=4
-source lib.sh
 source tc_common.sh
+source lib.sh
 
 tcflags="skip_hw"