OSDN Git Service

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)
committerJakub Kicinski <kuba@kernel.org>
Fri, 17 Mar 2023 00:38:05 +0000 (17:38 -0700)
commit24994513ad13ff2c47ba91d2b5df82c3d496c370
tree38c2a2cfb5a56f835b74471f1fe66097aec45f5a
parentf38373345c65529639a01fba3675eb8cb4c579c3
selftests: net: devlink_port_split.py: skip test if no suitable device available

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: f3348a82e727 ("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>
tools/testing/selftests/net/devlink_port_split.py