diff options
author | David Ahern <dsahern@gmail.com> | 2018-03-01 16:49:30 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-03-01 21:19:02 -0500 |
commit | 198979be6c16aa62025d5a47680f2c7849b7e64c (patch) | |
tree | ac773524647c2cbd5c5c8fbb0b1d827308c35063 | |
parent | 5f6f845b608a3fa13e5da0584eea5803710cf708 (diff) |
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>
7 files changed, 25 insertions, 15 deletions
diff --git a/tools/testing/selftests/net/forwarding/bridge_vlan_aware.sh b/tools/testing/selftests/net/forwarding/bridge_vlan_aware.sh index 651998e70557..75d922438bc9 100755 --- a/tools/testing/selftests/net/forwarding/bridge_vlan_aware.sh +++ b/tools/testing/selftests/net/forwarding/bridge_vlan_aware.sh | |||
@@ -2,6 +2,7 @@ | |||
2 | # SPDX-License-Identifier: GPL-2.0 | 2 | # SPDX-License-Identifier: GPL-2.0 |
3 | 3 | ||
4 | NUM_NETIFS=4 | 4 | NUM_NETIFS=4 |
5 | CHECK_TC="yes" | ||
5 | source lib.sh | 6 | source lib.sh |
6 | 7 | ||
7 | h1_create() | 8 | h1_create() |
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 23866a685f77..d0af52109360 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh | |||
@@ -19,26 +19,33 @@ fi | |||
19 | ############################################################################## | 19 | ############################################################################## |
20 | # Sanity checks | 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 | if [[ "$(id -u)" -ne 0 ]]; then | 37 | if [[ "$(id -u)" -ne 0 ]]; then |
23 | echo "SKIP: need root privileges" | 38 | echo "SKIP: need root privileges" |
24 | exit 0 | 39 | exit 0 |
25 | fi | 40 | fi |
26 | 41 | ||
27 | tc -j &> /dev/null | 42 | if [[ "$CHECK_TC" = "yes" ]]; then |
28 | if [[ $? -ne 0 ]]; then | 43 | check_tc_version |
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 | ||
37 | fi | 44 | fi |
38 | 45 | ||
39 | if [[ ! -x "$(command -v jq)" ]]; then | 46 | if [[ ! -x "$(command -v jq)" ]]; then |
40 | echo "SKIP: jq not installed" | 47 | echo "SKIP: jq not installed" |
41 | exit 0 | 48 | exit 1 |
42 | fi | 49 | fi |
43 | 50 | ||
44 | if [[ ! -x "$(command -v $MZ)" ]]; then | 51 | if [[ ! -x "$(command -v $MZ)" ]]; then |
diff --git a/tools/testing/selftests/net/forwarding/tc_actions.sh b/tools/testing/selftests/net/forwarding/tc_actions.sh index 84234317a25d..8ab5cf0a960b 100755 --- a/tools/testing/selftests/net/forwarding/tc_actions.sh +++ b/tools/testing/selftests/net/forwarding/tc_actions.sh | |||
@@ -2,8 +2,8 @@ | |||
2 | # SPDX-License-Identifier: GPL-2.0 | 2 | # SPDX-License-Identifier: GPL-2.0 |
3 | 3 | ||
4 | NUM_NETIFS=4 | 4 | NUM_NETIFS=4 |
5 | source lib.sh | ||
6 | source tc_common.sh | 5 | source tc_common.sh |
6 | source lib.sh | ||
7 | 7 | ||
8 | tcflags="skip_hw" | 8 | tcflags="skip_hw" |
9 | 9 | ||
diff --git a/tools/testing/selftests/net/forwarding/tc_chains.sh b/tools/testing/selftests/net/forwarding/tc_chains.sh index 94c114ad8b44..2fd15226974b 100755 --- a/tools/testing/selftests/net/forwarding/tc_chains.sh +++ b/tools/testing/selftests/net/forwarding/tc_chains.sh | |||
@@ -2,8 +2,8 @@ | |||
2 | # SPDX-License-Identifier: GPL-2.0 | 2 | # SPDX-License-Identifier: GPL-2.0 |
3 | 3 | ||
4 | NUM_NETIFS=2 | 4 | NUM_NETIFS=2 |
5 | source lib.sh | ||
6 | source tc_common.sh | 5 | source tc_common.sh |
6 | source lib.sh | ||
7 | 7 | ||
8 | tcflags="skip_hw" | 8 | tcflags="skip_hw" |
9 | 9 | ||
diff --git a/tools/testing/selftests/net/forwarding/tc_common.sh b/tools/testing/selftests/net/forwarding/tc_common.sh index acd0b520241c..9d3b64a2a264 100644 --- a/tools/testing/selftests/net/forwarding/tc_common.sh +++ b/tools/testing/selftests/net/forwarding/tc_common.sh | |||
@@ -1,6 +1,8 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | # SPDX-License-Identifier: GPL-2.0 | 2 | # SPDX-License-Identifier: GPL-2.0 |
3 | 3 | ||
4 | CHECK_TC="yes" | ||
5 | |||
4 | tc_check_packets() | 6 | tc_check_packets() |
5 | { | 7 | { |
6 | local id=$1 | 8 | local id=$1 |
diff --git a/tools/testing/selftests/net/forwarding/tc_flower.sh b/tools/testing/selftests/net/forwarding/tc_flower.sh index 026a4ea4b2fb..032b882adfc0 100755 --- a/tools/testing/selftests/net/forwarding/tc_flower.sh +++ b/tools/testing/selftests/net/forwarding/tc_flower.sh | |||
@@ -2,8 +2,8 @@ | |||
2 | # SPDX-License-Identifier: GPL-2.0 | 2 | # SPDX-License-Identifier: GPL-2.0 |
3 | 3 | ||
4 | NUM_NETIFS=2 | 4 | NUM_NETIFS=2 |
5 | source lib.sh | ||
6 | source tc_common.sh | 5 | source tc_common.sh |
6 | source lib.sh | ||
7 | 7 | ||
8 | tcflags="skip_hw" | 8 | tcflags="skip_hw" |
9 | 9 | ||
diff --git a/tools/testing/selftests/net/forwarding/tc_shblocks.sh b/tools/testing/selftests/net/forwarding/tc_shblocks.sh index cfc8a2ace388..077b98048ef4 100755 --- a/tools/testing/selftests/net/forwarding/tc_shblocks.sh +++ b/tools/testing/selftests/net/forwarding/tc_shblocks.sh | |||
@@ -2,8 +2,8 @@ | |||
2 | # SPDX-License-Identifier: GPL-2.0 | 2 | # SPDX-License-Identifier: GPL-2.0 |
3 | 3 | ||
4 | NUM_NETIFS=4 | 4 | NUM_NETIFS=4 |
5 | source lib.sh | ||
6 | source tc_common.sh | 5 | source tc_common.sh |
6 | source lib.sh | ||
7 | 7 | ||
8 | tcflags="skip_hw" | 8 | tcflags="skip_hw" |
9 | 9 | ||