mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
selftests: rds: Add helper function check_info() in test.py
Hoist the page info logic in test.py into a helper function, check_info(). This is a preparatory refactoring for the rds over ROCE series that helps modularize the send/recv logic. Breaking up the logic now will help avoid large function pylint errors later. No functional changes are introduced in this patch. Signed-off-by: Allison Henderson <achender@kernel.org> Link: https://patch.msgid.link/20260518012443.2629206-4-achender@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
853dee6aec
commit
78bcfe6f34
|
|
@ -79,6 +79,36 @@ def netns_socket(netns, *sock_args):
|
|||
u1.close()
|
||||
return socket.fromfd(fds[0], *sock_args)
|
||||
|
||||
def check_info(socks):
|
||||
"""
|
||||
Check all rds info pages for errors
|
||||
|
||||
:param socks: list of sockets to check
|
||||
"""
|
||||
|
||||
# the Python socket module doesn't know these
|
||||
rds_info_first = 10000
|
||||
rds_info_last = 10017
|
||||
|
||||
nr_success = 0
|
||||
nr_error = 0
|
||||
|
||||
for sock in socks:
|
||||
for optname in range(rds_info_first, rds_info_last + 1):
|
||||
# Sigh, the Python socket module doesn't allow us to pass
|
||||
# buffer lengths greater than 1024 for some reason. RDS
|
||||
# wants multiple pages.
|
||||
try:
|
||||
sock.getsockopt(socket.SOL_RDS, optname, 1024)
|
||||
nr_success = nr_success + 1
|
||||
except OSError as e:
|
||||
nr_error = nr_error + 1
|
||||
if e.errno == errno.ENOSPC:
|
||||
# ignore
|
||||
pass
|
||||
|
||||
ksft_pr(f"getsockopt(): {nr_success}/{nr_error}")
|
||||
|
||||
def stop_pcaps():
|
||||
"""Stop tcpdump processes.
|
||||
|
||||
|
|
@ -268,28 +298,7 @@ while nr_send < NUM_PACKETS:
|
|||
|
||||
ksft_pr("done", nr_send, nr_recv)
|
||||
|
||||
# the Python socket module doesn't know these
|
||||
RDS_INFO_FIRST = 10000
|
||||
RDS_INFO_LAST = 10017
|
||||
|
||||
nr_success = 0
|
||||
nr_error = 0
|
||||
|
||||
for s in sockets:
|
||||
for optname in range(RDS_INFO_FIRST, RDS_INFO_LAST + 1):
|
||||
# Sigh, the Python socket module doesn't allow us to pass
|
||||
# buffer lengths greater than 1024 for some reason. RDS
|
||||
# wants multiple pages.
|
||||
try:
|
||||
s.getsockopt(socket.SOL_RDS, optname, 1024)
|
||||
nr_success = nr_success + 1
|
||||
except OSError as e:
|
||||
nr_error = nr_error + 1
|
||||
if e.errno == errno.ENOSPC:
|
||||
# ignore
|
||||
pass
|
||||
|
||||
ksft_pr(f"getsockopt(): {nr_success}/{nr_error}")
|
||||
check_info(sockets)
|
||||
|
||||
# cancel timeout
|
||||
signal.alarm(0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user