linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: [PATCH] selftests: net: devlink_port_split.py: skip the test if no devlink device
@ 2021-05-20 15:00 Danielle Ratson
  0 siblings, 0 replies; 3+ messages in thread
From: Danielle Ratson @ 2021-05-20 15:00 UTC (permalink / raw)
  To: po-hsu.lin, linux-kernel, linux-kselftest, netdev
  Cc: shuah, kuba, davem, skhan



> -----Original Message-----
> From: Po-Hsu Lin <po-hsu.lin@canonical.com>
> Sent: Thursday, May 20, 2021 1:50 PM
> To: linux-kernel@vger.kernel.org; linux-kselftest@vger.kernel.org; netdev@vger.kernel.org
> Cc: po-hsu.lin@canonical.com; shuah@kernel.org; kuba@kernel.org; davem@davemloft.net; skhan@linuxfoundation.org
> Subject: [PATCH] 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>

Reviewed-by: Danielle Ratson <danieller@nvidia.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] selftests: net: devlink_port_split.py: skip the test if no devlink device
  2021-05-20 10:49 Po-Hsu Lin
@ 2021-05-20 22:50 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-05-20 22:50 UTC (permalink / raw)
  To: Po-Hsu Lin
  Cc: linux-kernel, linux-kselftest, netdev, shuah, kuba, davem, skhan

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Thu, 20 May 2021 18:49:54 +0800 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - selftests: net: devlink_port_split.py: skip the test if no devlink device
    https://git.kernel.org/netdev/net-next/c/25173dd4093a

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] selftests: net: devlink_port_split.py: skip the test if no devlink device
@ 2021-05-20 10:49 Po-Hsu Lin
  2021-05-20 22:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 3+ messages in thread
From: Po-Hsu Lin @ 2021-05-20 10:49 UTC (permalink / raw)
  To: linux-kernel, linux-kselftest, netdev
  Cc: po-hsu.lin, shuah, kuba, davem, skhan

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>
---
 tools/testing/selftests/net/devlink_port_split.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/devlink_port_split.py b/tools/testing/selftests/net/devlink_port_split.py
index 834066d..2b5d6ff 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)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-20 22:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-20 15:00 [PATCH] selftests: net: devlink_port_split.py: skip the test if no devlink device Danielle Ratson
  -- strict thread matches above, loose matches on Subject: below --
2021-05-20 10:49 Po-Hsu Lin
2021-05-20 22:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).