mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00

Looks like more and more tests want to iterate over IP version, run the same test over ipv4 and ipv6. The current naming of members in the env class makes it a bit awkward, we have separate members for ipv4 and ipv6 parameters. Store the parameters inside dicts, so that tests can easily index them with ip version. Reviewed-by: Willem de Bruijn <willemb@google.com> Link: https://patch.msgid.link/20250218225426.77726-4-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
46 lines
1.2 KiB
Python
Executable File
46 lines
1.2 KiB
Python
Executable File
#!/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 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:
|
|
cfg.require_ipver("6")
|
|
require_devmem(cfg)
|
|
|
|
port = rand_port()
|
|
listen_cmd = f"./ncdevmem -l -f {cfg.ifname} -s {cfg.addr_v['6']} -p {port}"
|
|
|
|
with bkg(listen_cmd) as socat:
|
|
wait_port_listen(port)
|
|
cmd(f"echo -e \"hello\\nworld\"| socat -u - TCP6:[{cfg.addr_v['6']}]:{port}", host=cfg.remote, shell=True)
|
|
|
|
ksft_eq(socat.stdout.strip(), "hello\nworld")
|
|
|
|
|
|
def main() -> None:
|
|
with NetDrvEpEnv(__file__) as cfg:
|
|
ksft_run([check_rx],
|
|
args=(cfg, ))
|
|
ksft_exit()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|