~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/drivers/net/ping.py

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/usr/bin/env python3
  2 # SPDX-License-Identifier: GPL-2.0
  3 
  4 from lib.py import ksft_run, ksft_exit
  5 from lib.py import ksft_eq
  6 from lib.py import NetDrvEpEnv
  7 from lib.py import bkg, cmd, wait_port_listen, rand_port
  8 
  9 
 10 def test_v4(cfg) -> None:
 11     cfg.require_v4()
 12 
 13     cmd(f"ping -c 1 -W0.5 {cfg.remote_v4}")
 14     cmd(f"ping -c 1 -W0.5 {cfg.v4}", host=cfg.remote)
 15 
 16 
 17 def test_v6(cfg) -> None:
 18     cfg.require_v6()
 19 
 20     cmd(f"ping -c 1 -W0.5 {cfg.remote_v6}")
 21     cmd(f"ping -c 1 -W0.5 {cfg.v6}", host=cfg.remote)
 22 
 23 
 24 def test_tcp(cfg) -> None:
 25     cfg.require_cmd("socat", remote=True)
 26 
 27     port = rand_port()
 28     listen_cmd = f"socat -{cfg.addr_ipver} -t 2 -u TCP-LISTEN:{port},reuseport STDOUT"
 29 
 30     with bkg(listen_cmd, exit_wait=True) as nc:
 31         wait_port_listen(port)
 32 
 33         cmd(f"echo ping | socat -t 2 -u STDIN TCP:{cfg.baddr}:{port}",
 34             shell=True, host=cfg.remote)
 35     ksft_eq(nc.stdout.strip(), "ping")
 36 
 37     with bkg(listen_cmd, host=cfg.remote, exit_wait=True) as nc:
 38         wait_port_listen(port, host=cfg.remote)
 39 
 40         cmd(f"echo ping | socat -t 2 -u STDIN TCP:{cfg.remote_baddr}:{port}", shell=True)
 41     ksft_eq(nc.stdout.strip(), "ping")
 42 
 43 
 44 def main() -> None:
 45     with NetDrvEpEnv(__file__) as cfg:
 46         ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg, ))
 47     ksft_exit()
 48 
 49 
 50 if __name__ == "__main__":
 51     main()

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php