Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: forwarding: Only check tc version for tc tests

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>

authored by

David Ahern and committed by
David S. Miller
198979be 5f6f845b

+25 -15
+1
tools/testing/selftests/net/forwarding/bridge_vlan_aware.sh
··· 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 4 NUM_NETIFS=4 5 + CHECK_TC="yes" 5 6 source lib.sh 6 7 7 8 h1_create()
+18 -11
tools/testing/selftests/net/forwarding/lib.sh
··· 19 19 ############################################################################## 20 20 # Sanity checks 21 21 22 + check_tc_version() 23 + { 24 + tc -j &> /dev/null 25 + if [[ $? -ne 0 ]]; then 26 + echo "SKIP: iproute2 too old; tc is missing JSON support" 27 + exit 1 28 + fi 29 + 30 + tc filter help 2>&1 | grep block &> /dev/null 31 + if [[ $? -ne 0 ]]; then 32 + echo "SKIP: iproute2 too old; tc is missing shared block support" 33 + exit 1 34 + fi 35 + } 36 + 22 37 if [[ "$(id -u)" -ne 0 ]]; then 23 38 echo "SKIP: need root privileges" 24 39 exit 0 25 40 fi 26 41 27 - tc -j &> /dev/null 28 - if [[ $? -ne 0 ]]; then 29 - echo "SKIP: iproute2 too old, missing JSON support" 30 - exit 0 31 - fi 32 - 33 - tc filter help 2>&1 | grep block &> /dev/null 34 - if [[ $? -ne 0 ]]; then 35 - echo "SKIP: iproute2 too old, missing shared block support" 36 - exit 0 42 + if [[ "$CHECK_TC" = "yes" ]]; then 43 + check_tc_version 37 44 fi 38 45 39 46 if [[ ! -x "$(command -v jq)" ]]; then 40 47 echo "SKIP: jq not installed" 41 - exit 0 48 + exit 1 42 49 fi 43 50 44 51 if [[ ! -x "$(command -v $MZ)" ]]; then
+1 -1
tools/testing/selftests/net/forwarding/tc_actions.sh
··· 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 4 NUM_NETIFS=4 5 - source lib.sh 6 5 source tc_common.sh 6 + source lib.sh 7 7 8 8 tcflags="skip_hw" 9 9
+1 -1
tools/testing/selftests/net/forwarding/tc_chains.sh
··· 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 4 NUM_NETIFS=2 5 - source lib.sh 6 5 source tc_common.sh 6 + source lib.sh 7 7 8 8 tcflags="skip_hw" 9 9
+2
tools/testing/selftests/net/forwarding/tc_common.sh
··· 1 1 #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 + CHECK_TC="yes" 5 + 4 6 tc_check_packets() 5 7 { 6 8 local id=$1
+1 -1
tools/testing/selftests/net/forwarding/tc_flower.sh
··· 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 4 NUM_NETIFS=2 5 - source lib.sh 6 5 source tc_common.sh 6 + source lib.sh 7 7 8 8 tcflags="skip_hw" 9 9
+1 -1
tools/testing/selftests/net/forwarding/tc_shblocks.sh
··· 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 4 NUM_NETIFS=4 5 - source lib.sh 6 5 source tc_common.sh 6 + source lib.sh 7 7 8 8 tcflags="skip_hw" 9 9