Skip to content

Commit

Permalink
selftests: forwarding: Only check tc version for tc tests
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
dsahern authored and davem330 committed Mar 2, 2018
1 parent 5f6f845 commit 198979b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: GPL-2.0

NUM_NETIFS=4
CHECK_TC="yes"
source lib.sh

h1_create()
Expand Down
29 changes: 18 additions & 11 deletions tools/testing/selftests/net/forwarding/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/net/forwarding/tc_actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/net/forwarding/tc_chains.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 2 additions & 0 deletions tools/testing/selftests/net/forwarding/tc_common.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

CHECK_TC="yes"

tc_check_packets()
{
local id=$1
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/net/forwarding/tc_flower.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/net/forwarding/tc_shblocks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 198979b

Please sign in to comment.