napi_id.py 636 B

1234567891011121314151617181920212223
  1. #!/usr/bin/env python3
  2. # SPDX-License-Identifier: GPL-2.0
  3. from lib.py import ksft_run, ksft_exit
  4. from lib.py import ksft_eq, NetDrvEpEnv
  5. from lib.py import bkg, cmd, rand_port, NetNSEnter
  6. def test_napi_id(cfg) -> None:
  7. port = rand_port()
  8. listen_cmd = f"{cfg.test_dir}/napi_id_helper {cfg.addr} {port}"
  9. with bkg(listen_cmd, ksft_wait=3) as server:
  10. cmd(f"echo a | socat - TCP:{cfg.baddr}:{port}", host=cfg.remote, shell=True)
  11. ksft_eq(0, server.ret)
  12. def main() -> None:
  13. with NetDrvEpEnv(__file__) as cfg:
  14. ksft_run([test_napi_id], args=(cfg,))
  15. ksft_exit()
  16. if __name__ == "__main__":
  17. main()