On Mon, 6 Mar 2023 19:19:59 +0800 Po-Hsu Lin wrote:
The `devlink -j dev show` command output may not contain the "flavour" key, for example: $ devlink -j dev show {"dev":{"pci/0001:00:00.0":{},"pci/0002:00:00.0":{}}}
It's not dev that's supposed to have the flavor, it's port.
devlink -j port show
Are you running with old kernel or old user space? Flavor is not an optional attribute.
This will cause a KeyError exception. Fix this by checking the key existence first.
Also, if max lanes is 0 the port splitting won't be tested at all. but the script will end normally and thus causing a false-negative test result.
Use a test_ran flag to determine if these tests were skipped and return KSFT_SKIP accordingly.
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
Could you factor out the existing skipping logic from main() (the code under "if not dev:") and add the test for flavors to the same function? It'll be a bit more code but cleaner result IMHO.