@@ -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()
Also add a combined tx/rx test to send bulk data. Cc: Mina Almasry <almasrymina@google.com> Signed-off-by: Stanislav Fomichev <sdf@fomichev.me> --- tools/testing/selftests/drivers/net/devmem.py | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)