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

selftests: mlxsw: ethtool_lanes: Wait for lanes parameter dump explicitly

The ethtool dump includes the lanes parameter only when the port is up.
Therefore, the ethtool_lanes.sh test waits for ports to come before testing
the lanes parameter.

In some cases, the test considers the port as up, but the lanes parameter
is not yet dumped although assumed to be, resulting in ethtool_lanes.sh
test failure.

To avoid that, ensure that the lanes parameter is indeed dumped by waiting
for it explicitly, before preforming the test cases.

Signed-off-by: Danielle Ratson <danieller@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Danielle Ratson and committed by
Paolo Abeni
8d612ed4 bfc42940

+8 -6
+8 -6
tools/testing/selftests/drivers/net/mlxsw/ethtool_lanes.sh
··· 24 24 busywait "$TIMEOUT" wait_for_port_up ethtool $swp2 25 25 check_err $? "ports did not come up" 26 26 27 - local lanes_exist=$(ethtool $swp1 | grep 'Lanes:') 28 - if [[ -z $lanes_exist ]]; then 27 + busywait $TIMEOUT sh -c "ethtool $swp1 | grep -q Lanes:" 28 + if [[ $? -ne 0 ]]; then 29 29 log_test "SKIP: driver does not support lanes setting" 30 30 exit 1 31 31 fi ··· 122 122 ethtool_set $swp1 speed $max_speed lanes $lanes 123 123 ip link set dev $swp1 up 124 124 ip link set dev $swp2 up 125 - busywait "$TIMEOUT" wait_for_port_up ethtool $swp2 126 - check_err $? "ports did not come up" 125 + 126 + busywait $TIMEOUT sh -c "ethtool $swp1 | grep -q Lanes:" 127 + check_err $? "Lanes parameter is not presented on time" 127 128 128 129 check_lanes $swp1 $lanes $max_speed 129 130 log_test "$lanes lanes is autonegotiated" ··· 161 160 ethtool_set $swp2 speed $max_speed lanes $lanes autoneg off 162 161 ip link set dev $swp1 up 163 162 ip link set dev $swp2 up 164 - busywait "$TIMEOUT" wait_for_port_up ethtool $swp2 165 - check_err $? "ports did not come up" 163 + 164 + busywait $TIMEOUT sh -c "ethtool $swp1 | grep -q Lanes:" 165 + check_err $? "Lanes parameter is not presented on time" 166 166 167 167 check_lanes $swp1 $lanes $max_speed 168 168 log_test "Autoneg off, $lanes lanes detected during force mode"