selftests: drv-net: improve the use of ksft helpers in XSK queue test

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>
This commit is contained in:
Jakub Kicinski 2025-02-19 15:49:55 -08:00
parent 7147713799
commit 4fde839846
2 changed files with 10 additions and 4 deletions

View File

@ -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)

View 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)