From: Hangbin Liu <[email protected]> Add a script for netdevsim speed test. Make sure the speed and duplex could be changed. And the speed can't be larger than the max speed.
Signed-off-by: Hangbin Liu <[email protected]> --- .../selftests/drivers/net/netdevsim/Makefile | 1 + .../drivers/net/netdevsim/ethtool-speed.sh | 33 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/tools/testing/selftests/drivers/net/netdevsim/Makefile b/tools/testing/selftests/drivers/net/netdevsim/Makefile index 9808c2fbae9e..bd3d0f5ee07a 100644 --- a/tools/testing/selftests/drivers/net/netdevsim/Makefile +++ b/tools/testing/selftests/drivers/net/netdevsim/Makefile @@ -8,6 +8,7 @@ TEST_PROGS := \ ethtool-features.sh \ ethtool-fec.sh \ ethtool-pause.sh \ + ethtool-speed.sh \ fib.sh \ fib_notifications.sh \ hw_stats_l3.sh \ diff --git a/tools/testing/selftests/drivers/net/netdevsim/ethtool-speed.sh b/tools/testing/selftests/drivers/net/netdevsim/ethtool-speed.sh new file mode 100755 index 000000000000..c8aefa9c8a1f --- /dev/null +++ b/tools/testing/selftests/drivers/net/netdevsim/ethtool-speed.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only + +source ethtool-common.sh + +NSIM_NETDEV=$(make_netdev) + +set -o pipefail + +s=$(ethtool --json "$NSIM_NETDEV" | jq '.[].speed') +check $? "$s" "5000" + +s=$(ethtool --json "$NSIM_NETDEV" | jq -r '.[].duplex') +check $? "$s" "Full" + +ethtool -s "$NSIM_NETDEV" speed 1000 duplex half + +s=$(ethtool --json "$NSIM_NETDEV" | jq '.[].speed') +check $? "$s" "1000" + +s=$(ethtool --json "$NSIM_NETDEV" | jq -r '.[].duplex') +check $? "$s" "Half" + +ethtool -s "$NSIM_NETDEV" speed 10000 2>/dev/null +check $? "" "" 1 + +if [ "$num_errors" -eq 0 ]; then + echo "PASSED all $((num_passes)) checks" + exit 0 +else + echo "FAILED $num_errors/$((num_errors+num_passes)) checks" + exit 1 +fi -- 2.55.0

