summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/drivers/net/hw/devmem.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing/selftests/drivers/net/hw/devmem.py')
-rwxr-xr-xtools/testing/selftests/drivers/net/hw/devmem.py46
1 files changed, 22 insertions, 24 deletions
diff --git a/tools/testing/selftests/drivers/net/hw/devmem.py b/tools/testing/selftests/drivers/net/hw/devmem.py
index 1223f0f5c10c..031cf9905f65 100755
--- a/tools/testing/selftests/drivers/net/hw/devmem.py
+++ b/tools/testing/selftests/drivers/net/hw/devmem.py
@@ -1,43 +1,41 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
-from lib.py import ksft_run, ksft_exit
-from lib.py import ksft_eq, KsftSkipEx
+from os import path
+from devmem_lib import setup_test, run_rx, run_tx, run_tx_chunks, run_rx_hds
+from lib.py import ksft_run, ksft_exit, ksft_disruptive
from lib.py import NetDrvEpEnv
-from lib.py import bkg, cmd, rand_port, wait_port_listen
-from lib.py import ksft_disruptive
-def require_devmem(cfg):
- if not hasattr(cfg, "_devmem_probed"):
- port = rand_port()
- probe_command = f"./ncdevmem -f {cfg.ifname}"
- cfg._devmem_supported = cmd(probe_command, fail=False, shell=True).ret == 0
- cfg._devmem_probed = True
-
- if not cfg._devmem_supported:
- raise KsftSkipEx("Test requires devmem support")
+@ksft_disruptive
+def check_rx(cfg) -> None:
+ """Run the devmem RX test."""
+ run_rx(cfg)
@ksft_disruptive
-def check_rx(cfg) -> None:
- cfg.require_v6()
- require_devmem(cfg)
+def check_tx(cfg) -> None:
+ """Run the devmem TX test."""
+ run_tx(cfg)
+
- port = rand_port()
- listen_cmd = f"./ncdevmem -l -f {cfg.ifname} -s {cfg.v6} -p {port}"
+@ksft_disruptive
+def check_tx_chunks(cfg) -> None:
+ """Run the devmem TX chunking test."""
+ run_tx_chunks(cfg)
- with bkg(listen_cmd) as socat:
- wait_port_listen(port)
- cmd(f"echo -e \"hello\\nworld\"| socat -u - TCP6:[{cfg.v6}]:{port}", host=cfg.remote, shell=True)
- ksft_eq(socat.stdout.strip(), "hello\nworld")
+def check_rx_hds(cfg) -> None:
+ """Run the HDS test."""
+ run_rx_hds(cfg)
def main() -> None:
+ """Run the devmem test cases."""
with NetDrvEpEnv(__file__) as cfg:
- ksft_run([check_rx],
- args=(cfg, ))
+ setup_test(cfg, path.abspath(path.dirname(__file__) + "/ncdevmem"))
+ ksft_run([check_rx, check_tx, check_tx_chunks, check_rx_hds],
+ args=(cfg,))
ksft_exit()