diff options
author | Po-Hsu Lin | 2021-05-20 18:49:54 +0800 |
---|---|---|
committer | David S. Miller | 2021-05-20 15:46:57 -0700 |
commit | 25173dd4093a24e977e2af9cd5654c205bf13547 (patch) | |
tree | e9ec7ca7de2ce37d4e609d70a3d5a11e1b6e93fb /tools/testing | |
parent | 07b5dc1d515a9a9b3973e0bdc716a78adf6db8f8 (diff) |
selftests: net: devlink_port_split.py: skip the test if no devlink device
When there is no devlink device, the following command will return:
$ devlink -j dev show
{dev:{}}
This will cause IndexError when trying to access the first element
in dev of this json dataset. Use the kselftest framework skip code
to skip this test in this case.
Example output with this change:
# selftests: net: devlink_port_split.py
# no devlink device was found, test skipped
ok 7 selftests: net: devlink_port_split.py # SKIP
Link: https://bugs.launchpad.net/bugs/1928889
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing')
-rwxr-xr-x | tools/testing/selftests/net/devlink_port_split.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/testing/selftests/net/devlink_port_split.py b/tools/testing/selftests/net/devlink_port_split.py index 834066d465fc..2b5d6ff87373 100755 --- a/tools/testing/selftests/net/devlink_port_split.py +++ b/tools/testing/selftests/net/devlink_port_split.py @@ -18,6 +18,8 @@ import sys # +# Kselftest framework requirement - SKIP code is 4 +KSFT_SKIP=4 Port = collections.namedtuple('Port', 'bus_info name') @@ -239,7 +241,11 @@ def main(cmdline=None): assert stderr == "" devs = json.loads(stdout)['dev'] - dev = list(devs.keys())[0] + if devs: + dev = list(devs.keys())[0] + else: + print("no devlink device was found, test skipped") + sys.exit(KSFT_SKIP) cmd = "devlink dev show %s" % dev stdout, stderr = run_command(cmd) |