| # SPDX-License-Identifier: GPL-2.0 | |
| """ | |
| Driver test environment. | |
| NetDrvEnv and NetDrvEpEnv are the main environment classes. | |
| NetDrvContEnv extends NetDrvEpEnv with netkit container support. | |
| Former is for local host only tests, latter creates / connects | |
| to a remote endpoint. See NIPA wiki for more information about | |
| running and writing driver tests. | |
| """ | |
| import sys | |
| from pathlib import Path | |
| KSFT_DIR = (Path(__file__).parent / "../../../..").resolve() | |
| try: | |
| sys.path.append(KSFT_DIR.as_posix()) | |
| # Import one by one to avoid pylint false positives | |
| from net.lib.py import NetNS, NetNSEnter, NetdevSimDev, UserNetNS | |
| from net.lib.py import EthtoolFamily, NetdevFamily, NetshaperFamily, \ | |
| NlError, RtnlFamily, DevlinkFamily, PSPFamily, Netlink | |
| from net.lib.py import CmdExitFailure | |
| from net.lib.py import bkg, cmd, bpftool, bpftrace, defer, ethtool, \ | |
| fd_read_timeout, ip, rand_port, rand_ports, tc, wait_port_listen, \ | |
| wait_file | |
| from net.lib.py import bpf_map_set, bpf_map_dump, bpf_prog_map_ids | |
| from net.lib.py import KsftSkipEx, KsftFailEx, KsftXfailEx | |
| from net.lib.py import ksft_disruptive, ksft_exit, ksft_pr, ksft_run, \ | |
| ksft_setup, ksft_variants, KsftNamedVariant | |
| from net.lib.py import ksft_eq, ksft_ge, ksft_in, ksft_is, ksft_lt, \ | |
| ksft_ne, ksft_not_in, ksft_raises, ksft_true, ksft_gt, ksft_not_none | |
| __all__ = ["NetNS", "NetNSEnter", "NetdevSimDev", "UserNetNS", | |
| "EthtoolFamily", "NetdevFamily", "NetshaperFamily", | |
| "NlError", "RtnlFamily", "DevlinkFamily", "PSPFamily", "Netlink", | |
| "CmdExitFailure", | |
| "bkg", "cmd", "bpftool", "bpftrace", "defer", "ethtool", | |
| "fd_read_timeout", "ip", "rand_port", "rand_ports", "tc", | |
| "wait_port_listen", "wait_file", | |
| "bpf_map_set", "bpf_map_dump", "bpf_prog_map_ids", | |
| "KsftSkipEx", "KsftFailEx", "KsftXfailEx", | |
| "ksft_disruptive", "ksft_exit", "ksft_pr", "ksft_run", | |
| "ksft_setup", "ksft_variants", "KsftNamedVariant", | |
| "ksft_eq", "ksft_ge", "ksft_in", "ksft_is", "ksft_lt", | |
| "ksft_ne", "ksft_not_in", "ksft_raises", "ksft_true", "ksft_gt", | |
| "ksft_not_none", "ksft_not_none"] | |
| from .env import NetDrvEnv, NetDrvEpEnv, NetDrvContEnv | |
| from .load import GenerateTraffic, Iperf3Runner | |
| from .remote import Remote | |
| __all__ += ["NetDrvEnv", "NetDrvEpEnv", "NetDrvContEnv", "GenerateTraffic", | |
| "Remote", "Iperf3Runner"] | |
| except ModuleNotFoundError as e: | |
| print("Failed importing `net` library from kernel sources") | |
| print(str(e)) | |
| sys.exit(4) |