]> git.baikalelectronics.ru Git - kernel.git/commit
selftests: net: devlink_port_split.py: skip test if no suitable device available
authorPo-Hsu Lin <po-hsu.lin@canonical.com>
Wed, 15 Mar 2023 16:53:53 +0000 (00:53 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Mar 2023 12:33:50 +0000 (13:33 +0100)
commit0f0ca01ff4cd750c2406ed2f09c6b9b16471be0b
tree48909c328b12979b8551a79d6606c76b1f2e7fab
parentbb50055ab49e5faf938fa7c6409ae26fd576ac57
selftests: net: devlink_port_split.py: skip test if no suitable device available

[ Upstream commit cad950d7e4ad284562c6d23f8b8ff1cb022b92d6 ]

The `devlink -j port show` command output may not contain the "flavour"
key, an example from Ubuntu 22.10 s390x LPAR(5.19.0-37-generic), with
mlx4 driver and iproute2-5.15.0:
  {"port":{"pci/0001:00:00.0/1":{"type":"eth","netdev":"ens301"},
           "pci/0001:00:00.0/2":{"type":"eth","netdev":"ens301d1"},
           "pci/0002:00:00.0/1":{"type":"eth","netdev":"ens317"},
           "pci/0002:00:00.0/2":{"type":"eth","netdev":"ens317d1"}}}

This will cause a KeyError exception.

Create a validate_devlink_output() to check for this "flavour" from
devlink command output to avoid this KeyError exception. Also let
it handle the check for `devlink -j dev show` output in main().

Apart from this, if the test was not started because the max lanes of
the designated device is 0. The script will still return 0 and thus
causing a false-negative test result.

Use a found_max_lanes flag to determine if these tests were skipped
due to this reason and return KSFT_SKIP to make it more clear.

Link: https://bugs.launchpad.net/bugs/1937133
Fixes: 9bc7757fba77 ("selftests: net: Add port split test")
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
Link: https://lore.kernel.org/r/20230315165353.229590-1-po-hsu.lin@canonical.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/net/devlink_port_split.py