All of lore.kernel.org
 help / color / mirror / Atom feed
From: Allison Henderson <achender@kernel.org>
To: netdev@vger.kernel.org, pabeni@redhat.com, edumazet@google.com,
	kuba@kernel.org, horms@kernel.org, linux-rdma@vger.kernel.org,
	achender@kernel.org, linux-kselftest@vger.kernel.org,
	shuah@kernel.org
Subject: [PATCH net-next v2 5/9] selftests: rds: Add helper function verify_hashes() in test.py
Date: Wed, 13 May 2026 21:33:26 -0700	[thread overview]
Message-ID: <20260514043330.1718969-6-achender@kernel.org> (raw)
In-Reply-To: <20260514043330.1718969-1-achender@kernel.org>

Hoist the verify hashes logic in test.py into a helper function,
verify_hashes().  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>
---
 tools/testing/selftests/net/rds/test.py | 33 ++++++++++++-------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/tools/testing/selftests/net/rds/test.py b/tools/testing/selftests/net/rds/test.py
index ae74117b4174..a3def413d84a 100755
--- a/tools/testing/selftests/net/rds/test.py
+++ b/tools/testing/selftests/net/rds/test.py
@@ -152,6 +152,21 @@ def check_info(socks):
 
     ksft_pr(f"getsockopt(): {nr_success}/{nr_error}")
 
+def verify_hashes(snd_hashes, rcv_hashes):
+    """Compare send/recv hashes per (sender, receiver) pair."""
+    for key, snd_hash in snd_hashes.items():
+        rcv_hash = rcv_hashes.get(key)
+        if rcv_hash is None:
+            ksft_pr("FAIL: No data received")
+            return 1
+        if snd_hash.hexdigest() != rcv_hash.hexdigest():
+            ksft_pr("FAIL: Send/recv mismatch")
+            ksft_pr("hash expected:", snd_hash.hexdigest())
+            ksft_pr("hash received:", rcv_hash.hexdigest())
+            return 1
+        ksft_pr(f"{key[0]}/{key[1]}: ok")
+    return 0
+
 def stop_pcaps():
     """Stop tcpdump processes.
 
@@ -310,23 +325,7 @@ stop_pcaps()
 
 # We're done sending and receiving stuff, now let's check if what
 # we received is what we sent.
-ret = 0
-for (sender, receiver), send_hash in send_hashes.items():
-    recv_hash = recv_hashes.get((sender, receiver))
-
-    if recv_hash is None:
-        ksft_pr("FAIL: No data received")
-        ret = 1
-        break
-
-    if send_hash.hexdigest() != recv_hash.hexdigest():
-        ksft_pr("FAIL: Send/recv mismatch")
-        ksft_pr("hash expected:", send_hash.hexdigest())
-        ksft_pr("hash received:", recv_hash.hexdigest())
-        ret = 1
-        break
-
-    ksft_pr(f"{sender}/{receiver}: ok")
+ret = verify_hashes(send_hashes, recv_hashes)
 
 if ret == 0:
     ksft_pr("Success")
-- 
2.25.1


  parent reply	other threads:[~2026-05-14  4:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-14  4:33 [PATCH net-next v2 0/9] selftests: rds: Add ROCE support to rds selftests Allison Henderson
2026-05-14  4:33 ` [PATCH net-next v2 1/9] selftests: rds: Add helper function setup_tcp() in test.py Allison Henderson
2026-05-14  4:33 ` [PATCH net-next v2 2/9] selftests: rds: Add helper function check_info() " Allison Henderson
2026-05-14  4:33 ` [PATCH net-next v2 3/9] selftests: rds: Add helper function send_burst() " Allison Henderson
2026-05-14  4:33 ` [PATCH net-next v2 4/9] selftests: rds: Add helper function recv_burst() " Allison Henderson
2026-05-14  4:33 ` Allison Henderson [this message]
2026-05-14  4:33 ` [PATCH net-next v2 6/9] selftests: rds: Add helper function snd_rcv_packets() " Allison Henderson
2026-05-14  4:33 ` [PATCH net-next v2 7/9] selftests: rds: Register network teardown via atexit Allison Henderson
2026-05-14  4:33 ` [PATCH net-next v2 8/9] selftests: rds: Add ROCE support to test.py Allison Henderson
2026-05-14  4:33 ` [PATCH net-next v2 9/9] selftests: rds: Add ROCE support to run.sh Allison Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260514043330.1718969-6-achender@kernel.org \
    --to=achender@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.