Commit 04cfbc1d authored by Petr Machata's avatar Petr Machata Committed by David S. Miller

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: default avatarPetr Machata <petrm@nvidia.com>
Reviewed-by: default avatarAmit Cohen <amcohen@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9bacb93b
...@@ -11,6 +11,8 @@ NUM_NETIFS=2 ...@@ -11,6 +11,8 @@ NUM_NETIFS=2
source lib.sh source lib.sh
source ethtool_lib.sh source ethtool_lib.sh
TIMEOUT=$((WAIT_TIMEOUT * 1000)) # ms
setup_prepare() setup_prepare()
{ {
swp1=${NETIFS[p1]} swp1=${NETIFS[p1]}
...@@ -18,7 +20,7 @@ setup_prepare() ...@@ -18,7 +20,7 @@ setup_prepare()
swp3=$NETIF_NO_CABLE swp3=$NETIF_NO_CABLE
} }
ethtool_extended_state_check() ethtool_ext_state()
{ {
local dev=$1; shift local dev=$1; shift
local expected_ext_state=$1; shift local expected_ext_state=$1; shift
...@@ -30,21 +32,27 @@ ethtool_extended_state_check() ...@@ -30,21 +32,27 @@ ethtool_extended_state_check()
| sed -e 's/^[[:space:]]*//') | sed -e 's/^[[:space:]]*//')
ext_state=$(echo $ext_state | cut -d "," -f1) ext_state=$(echo $ext_state | cut -d "," -f1)
[[ $ext_state == $expected_ext_state ]] if [[ $ext_state != $expected_ext_state ]]; then
check_err $? "Expected \"$expected_ext_state\", got \"$ext_state\"" echo "Expected \"$expected_ext_state\", got \"$ext_state\""
return 1
[[ $ext_substate == $expected_ext_substate ]] fi
check_err $? "Expected \"$expected_ext_substate\", got \"$ext_substate\"" if [[ $ext_substate != $expected_ext_substate ]]; then
echo "Expected \"$expected_ext_substate\", got \"$ext_substate\""
return 1
fi
} }
autoneg() autoneg()
{ {
local msg
RET=0 RET=0
ip link set dev $swp1 up ip link set dev $swp1 up
sleep 4 msg=$(busywait $TIMEOUT ethtool_ext_state $swp1 \
ethtool_extended_state_check $swp1 "Autoneg" "No partner detected" "Autoneg" "No partner detected")
check_err $? "$msg"
log_test "Autoneg, No partner detected" log_test "Autoneg, No partner detected"
...@@ -53,6 +61,8 @@ autoneg() ...@@ -53,6 +61,8 @@ autoneg()
autoneg_force_mode() autoneg_force_mode()
{ {
local msg
RET=0 RET=0
ip link set dev $swp1 up ip link set dev $swp1 up
...@@ -65,12 +75,13 @@ autoneg_force_mode() ...@@ -65,12 +75,13 @@ autoneg_force_mode()
ethtool_set $swp1 speed $speed1 autoneg off ethtool_set $swp1 speed $speed1 autoneg off
ethtool_set $swp2 speed $speed2 autoneg off ethtool_set $swp2 speed $speed2 autoneg off
sleep 4 msg=$(busywait $TIMEOUT ethtool_ext_state $swp1 \
ethtool_extended_state_check $swp1 "Autoneg" \ "Autoneg" "No partner detected during force mode")
"No partner detected during force mode" check_err $? "$msg"
ethtool_extended_state_check $swp2 "Autoneg" \ msg=$(busywait $TIMEOUT ethtool_ext_state $swp2 \
"No partner detected during force mode" "Autoneg" "No partner detected during force mode")
check_err $? "$msg"
log_test "Autoneg, No partner detected during force mode" log_test "Autoneg, No partner detected during force mode"
...@@ -83,12 +94,14 @@ autoneg_force_mode() ...@@ -83,12 +94,14 @@ autoneg_force_mode()
no_cable() no_cable()
{ {
local msg
RET=0 RET=0
ip link set dev $swp3 up ip link set dev $swp3 up
sleep 1 msg=$(busywait $TIMEOUT ethtool_ext_state $swp3 "No cable")
ethtool_extended_state_check $swp3 "No cable" check_err $? "$msg"
log_test "No cable" log_test "No cable"
......
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