lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230306111959.429680-1-po-hsu.lin@canonical.com>
Date:   Mon,  6 Mar 2023 19:19:59 +0800
From:   Po-Hsu Lin <po-hsu.lin@...onical.com>
To:     linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
        netdev@...r.kernel.org
Cc:     idosch@...lanox.com, danieller@...lanox.com, petrm@...lanox.com,
        shuah@...nel.org, pabeni@...hat.com, kuba@...nel.org,
        edumazet@...gle.com, davem@...emloft.net, po-hsu.lin@...onical.com
Subject: [PATCH] selftests: net: devlink_port_split.py: skip test if no suitable device available

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":{}}}

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@...onical.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 2b5d6ff..462f3df 100755
--- a/tools/testing/selftests/net/devlink_port_split.py
+++ b/tools/testing/selftests/net/devlink_port_split.py
@@ -61,7 +61,7 @@ class devlink_ports(object):
 
         for port in ports:
             if dev in port:
-                if ports[port]['flavour'] == 'physical':
+                if 'flavour' in ports[port] and ports[port]['flavour'] == 'physical':
                     arr.append(Port(bus_info=port, name=ports[port]['netdev']))
 
         return arr
@@ -231,6 +231,7 @@ def make_parser():
 
 
 def main(cmdline=None):
+    test_ran = False
     parser = make_parser()
     args = parser.parse_args(cmdline)
 
@@ -277,6 +278,11 @@ def main(cmdline=None):
                 split_splittable_port(port, lane, max_lanes, dev)
 
                 lane //= 2
+        test_ran = True
+
+    if not test_ran:
+        print("No suitable device for the test, test skipped")
+        sys.exit(KSFT_SKIP)
 
 
 if __name__ == "__main__":
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ