Commit 0d8b4887 authored by Hangbin Liu's avatar Hangbin Liu Committed by Paolo Abeni

selftests/net: convert drop_monitor_tests.sh to run it in unique namespace

Here is the test result after conversion.

]# ./drop_monitor_tests.sh

Software drops test
    TEST: Capturing active software drops                               [ OK ]
    TEST: Capturing inactive software drops                             [ OK ]

Hardware drops test
    TEST: Capturing active hardware drops                               [ OK ]
    TEST: Capturing inactive hardware drops                             [ OK ]

Tests passed:   4
Tests failed:   0
Acked-by: default avatarDavid Ahern <dsahern@kernel.org>
Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 7c16d485
...@@ -2,10 +2,8 @@ ...@@ -2,10 +2,8 @@
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
# This test is for checking drop monitor functionality. # This test is for checking drop monitor functionality.
source lib.sh
ret=0 ret=0
# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4
# all tests in this script. Can be overridden with -t option # all tests in this script. Can be overridden with -t option
TESTS=" TESTS="
...@@ -13,10 +11,6 @@ TESTS=" ...@@ -13,10 +11,6 @@ TESTS="
hw_drops hw_drops
" "
IP="ip -netns ns1"
TC="tc -netns ns1"
DEVLINK="devlink -N ns1"
NS_EXEC="ip netns exec ns1"
NETDEVSIM_PATH=/sys/bus/netdevsim/ NETDEVSIM_PATH=/sys/bus/netdevsim/
DEV_ADDR=1337 DEV_ADDR=1337
DEV=netdevsim${DEV_ADDR} DEV=netdevsim${DEV_ADDR}
...@@ -43,7 +37,7 @@ setup() ...@@ -43,7 +37,7 @@ setup()
modprobe netdevsim &> /dev/null modprobe netdevsim &> /dev/null
set -e set -e
ip netns add ns1 setup_ns NS1
$IP link add dummy10 up type dummy $IP link add dummy10 up type dummy
$NS_EXEC echo "$DEV_ADDR 1" > ${NETDEVSIM_PATH}/new_device $NS_EXEC echo "$DEV_ADDR 1" > ${NETDEVSIM_PATH}/new_device
...@@ -57,7 +51,7 @@ setup() ...@@ -57,7 +51,7 @@ setup()
cleanup() cleanup()
{ {
$NS_EXEC echo "$DEV_ADDR" > ${NETDEVSIM_PATH}/del_device $NS_EXEC echo "$DEV_ADDR" > ${NETDEVSIM_PATH}/del_device
ip netns del ns1 cleanup_ns ${NS1}
} }
sw_drops_test() sw_drops_test()
...@@ -194,8 +188,15 @@ if [ $? -ne 0 ]; then ...@@ -194,8 +188,15 @@ if [ $? -ne 0 ]; then
exit $ksft_skip exit $ksft_skip
fi fi
# start clean # create netns first so we can get the namespace name
setup_ns NS1
cleanup &> /dev/null cleanup &> /dev/null
trap cleanup EXIT
IP="ip -netns ${NS1}"
TC="tc -netns ${NS1}"
DEVLINK="devlink -N ${NS1}"
NS_EXEC="ip netns exec ${NS1}"
for t in $TESTS for t in $TESTS
do do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment