Thread (7 messages) 7 messages, 3 authors, 2024-09-27
STALE663d

[RFC PATCH net-next v1 4/4] selftests: ncdevmem: Add TX side to the test

From: Stanislav Fomichev <sdf@fomichev.me>
Date: 2024-09-13 15:09:22
Subsystem: kernel selftest framework, networking drivers, the rest · Maintainers: Shuah Khan, Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

Also add a combined tx/rx test to send bulk data.

Cc: Mina Almasry <redacted>
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
---
 tools/testing/selftests/drivers/net/devmem.py | 37 ++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/drivers/net/devmem.py b/tools/testing/selftests/drivers/net/devmem.py
index bbd32e0b0fe2..2e8903334d51 100755
--- a/tools/testing/selftests/drivers/net/devmem.py
+++ b/tools/testing/selftests/drivers/net/devmem.py
@@ -35,9 +35,44 @@ from lib.py import ksft_disruptive
     ksft_eq(nc.stdout.strip(), "hello\nworld")
 
 
+@ksft_disruptive
+def check_tx(cfg) -> None:
+    cfg.require_v6()
+    require_devmem(cfg)
+
+    port = rand_port()
+    listen_cmd = f"nc -l {cfg.v6} {port}"
+
+    pwd = cmd(f"pwd").stdout.strip()
+    with bkg(listen_cmd) as nc:
+        wait_port_listen(port)
+        cmd(f"echo -e \"hello\\nworld\"| {pwd}/ncdevmem -f {cfg.ifname} -s {cfg.v6} -p {port}", host=cfg.remote, shell=True)
+
+    ksft_eq(nc.stdout.strip(), "hello\nworld")
+
+
+@ksft_disruptive
+def check_txrx(cfg) -> None:
+    cfg.require_v6()
+    require_devmem(cfg)
+
+    cmd(f"cat /dev/urandom | tr -dc '[:print:]' | head -c 1M > random_file.txt", host=cfg.remote, shell=True)
+    want_sha = cmd(f"sha256sum random_file.txt", host=cfg.remote, shell=True).stdout.strip()
+
+    port = rand_port()
+    listen_cmd = f"./ncdevmem -l -f {cfg.ifname} -s {cfg.v6} -p {port} | tee random_file.txt | sha256sum -"
+
+    pwd = cmd(f"pwd").stdout.strip()
+    with bkg(listen_cmd, exit_wait=True) as nc:
+        wait_port_listen(port)
+        cmd(f"cat random_file.txt | {pwd}/ncdevmem -f {cfg.ifname} -s {cfg.v6} -p {port}", host=cfg.remote, shell=True)
+
+    ksft_eq(nc.stdout.strip().split(" ")[0], want_sha.split(" ")[0])
+
+
 def main() -> None:
     with NetDrvEpEnv(__file__) as cfg:
-        ksft_run([check_rx],
+        ksft_run([check_tx, check_rx, check_txrx],
                  args=(cfg, ))
     ksft_exit()
 
-- 
2.46.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help