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