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

selftests: forwarding: ethtool_extended_state: Convert to busywait

Currently, this script sets up the test scenario, which is supposed to end
in an inability of the system to negotiate a link. It then waits for a bit,
and verifies that the system can diagnose why the link was not established.

The wait time for the scenario where different link speeds are forced on
the two ends of a loopback cable, was set to 4 seconds, which exactly
covered it. As of a recent mlxsw firmware update, this time gets longer,
and this test starts failing.

The time that selftests currently wait for links to be established is
currently $WAIT_TIMEOUT, or 20 seconds. It seems reasonable that if this is
the time necessary to establish and bring up a link, it should also be
enough to determine that a link cannot be established and why.

Therefore in this patch, convert the sleeps to busywaits, so that if a
failure is established sooner (as is expected), the test runs quicker. And
use $WAIT_TIMEOUT as the time to wait.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Amit Cohen <amcohen@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Petr Machata and committed by
David S. Miller
04cfbc1d 9bacb93b

+28 -15
+28 -15
tools/testing/selftests/net/forwarding/ethtool_extended_state.sh
··· 11 11 source lib.sh 12 12 source ethtool_lib.sh 13 13 14 + TIMEOUT=$((WAIT_TIMEOUT * 1000)) # ms 15 + 14 16 setup_prepare() 15 17 { 16 18 swp1=${NETIFS[p1]} ··· 20 18 swp3=$NETIF_NO_CABLE 21 19 } 22 20 23 - ethtool_extended_state_check() 21 + ethtool_ext_state() 24 22 { 25 23 local dev=$1; shift 26 24 local expected_ext_state=$1; shift ··· 32 30 | sed -e 's/^[[:space:]]*//') 33 31 ext_state=$(echo $ext_state | cut -d "," -f1) 34 32 35 - [[ $ext_state == $expected_ext_state ]] 36 - check_err $? "Expected \"$expected_ext_state\", got \"$ext_state\"" 37 - 38 - [[ $ext_substate == $expected_ext_substate ]] 39 - check_err $? "Expected \"$expected_ext_substate\", got \"$ext_substate\"" 33 + if [[ $ext_state != $expected_ext_state ]]; then 34 + echo "Expected \"$expected_ext_state\", got \"$ext_state\"" 35 + return 1 36 + fi 37 + if [[ $ext_substate != $expected_ext_substate ]]; then 38 + echo "Expected \"$expected_ext_substate\", got \"$ext_substate\"" 39 + return 1 40 + fi 40 41 } 41 42 42 43 autoneg() 43 44 { 45 + local msg 46 + 44 47 RET=0 45 48 46 49 ip link set dev $swp1 up 47 50 48 - sleep 4 49 - ethtool_extended_state_check $swp1 "Autoneg" "No partner detected" 51 + msg=$(busywait $TIMEOUT ethtool_ext_state $swp1 \ 52 + "Autoneg" "No partner detected") 53 + check_err $? "$msg" 50 54 51 55 log_test "Autoneg, No partner detected" 52 56 ··· 61 53 62 54 autoneg_force_mode() 63 55 { 56 + local msg 57 + 64 58 RET=0 65 59 66 60 ip link set dev $swp1 up ··· 75 65 ethtool_set $swp1 speed $speed1 autoneg off 76 66 ethtool_set $swp2 speed $speed2 autoneg off 77 67 78 - sleep 4 79 - ethtool_extended_state_check $swp1 "Autoneg" \ 80 - "No partner detected during force mode" 68 + msg=$(busywait $TIMEOUT ethtool_ext_state $swp1 \ 69 + "Autoneg" "No partner detected during force mode") 70 + check_err $? "$msg" 81 71 82 - ethtool_extended_state_check $swp2 "Autoneg" \ 83 - "No partner detected during force mode" 72 + msg=$(busywait $TIMEOUT ethtool_ext_state $swp2 \ 73 + "Autoneg" "No partner detected during force mode") 74 + check_err $? "$msg" 84 75 85 76 log_test "Autoneg, No partner detected during force mode" 86 77 ··· 94 83 95 84 no_cable() 96 85 { 86 + local msg 87 + 97 88 RET=0 98 89 99 90 ip link set dev $swp3 up 100 91 101 - sleep 1 102 - ethtool_extended_state_check $swp3 "No cable" 92 + msg=$(busywait $TIMEOUT ethtool_ext_state $swp3 "No cable") 93 + check_err $? "$msg" 103 94 104 95 log_test "No cable" 105 96