]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests: drv-net: improve the use of ksft helpers in XSK queue test
authorJakub Kicinski <kuba@kernel.org>
Wed, 19 Feb 2025 23:49:55 +0000 (15:49 -0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 21 Feb 2025 01:58:25 +0000 (17:58 -0800)
Avoid exceptions when xsk attr is not present, and add a proper ksft
helper for "not in" condition.

Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Reviewed-by: Joe Damato <jdamato@fastly.com>
Tested-by: Kurt Kanzenbach <kurt@linutronix.de>
Tested-by: Joe Damato <jdamato@fastly.com>
Link: https://patch.msgid.link/20250219234956.520599-7-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/drivers/net/queues.py
tools/testing/selftests/net/lib/py/ksft.py

index 7af2adb61c25463cb83cab7b013e8c385eb22a79..a49f1a146e28ce0006b0c177f912a267186114c1 100755 (executable)
@@ -2,7 +2,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
 from lib.py import ksft_disruptive, ksft_exit, ksft_run
-from lib.py import ksft_eq, ksft_raises, KsftSkipEx, KsftFailEx
+from lib.py import ksft_eq, ksft_not_in, ksft_raises, KsftSkipEx, KsftFailEx
 from lib.py import EthtoolFamily, NetdevFamily, NlError
 from lib.py import NetDrvEnv
 from lib.py import bkg, cmd, defer, ip
@@ -47,10 +47,11 @@ def check_xdp(cfg, nl, xdp_queue_id=0) -> None:
                 if q['type'] == 'tx':
                     tx = True
 
-                ksft_eq(q['xsk'], {})
+                ksft_eq(q.get('xsk', None), {},
+                        comment="xsk attr on queue we configured")
             else:
-                if 'xsk' in q:
-                    _fail("Check failed: xsk attribute set.")
+                ksft_not_in('xsk', q,
+                            comment="xsk attr on queue we didn't configure")
 
         ksft_eq(rx, True)
         ksft_eq(tx, True)
index 3efe005436cd1e46e5d33a8403d1dfa72c40b168..fd23349fa8ca05f8680590e0c7f73c407b2ac31d 100644 (file)
@@ -71,6 +71,11 @@ def ksft_in(a, b, comment=""):
         _fail("Check failed", a, "not in", b, comment)
 
 
+def ksft_not_in(a, b, comment=""):
+    if a in b:
+        _fail("Check failed", a, "in", b, comment)
+
+
 def ksft_is(a, b, comment=""):
     if a is not b:
         _fail("Check failed", a, "is not", b, comment)