Commit 5c605280 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'selftests-drv-net-replace-the-rpath-helper-with-path-objects'

Jakub Kicinski says:

====================
selftests: drv-net: replace the rpath helper with Path objects

Trying to change the env.rpath() helper during the development
cycle was causing a lot of conflicts between net and net-next.
Let's get it converted now that the trees are converged.

v2: https://lore.kernel.org/20250306171158.1836674-1-kuba@kernel.org
====================

Link: https://patch.msgid.link/20250327222315.1098596-1-kuba@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 7220e8f4 88dec030
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ def _get_hds_mode(cfg, netnl) -> str:


def _xdp_onoff(cfg):
    prog = cfg.rpath("../../net/lib/xdp_dummy.bpf.o")
    prog = cfg.net_lib_dir / "xdp_dummy.bpf.o"
    ip("link set dev %s xdp obj %s sec xdp" %
       (cfg.ifname, prog))
    ip("link set dev %s xdp off" % cfg.ifname)
+1 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ def main() -> None:
    with NetDrvEpEnv(__file__, nsim_test=False) as cfg:
        check_nic_features(cfg)

        cfg.bin_local = cfg.rpath("../../../net/lib/csum")
        cfg.bin_local = cfg.net_lib_dir / "csum"
        cfg.bin_remote = cfg.remote.deploy(cfg.bin_local)

        cases = []
+1 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ def check_reconfig_queues(cfg) -> None:
def check_reconfig_xdp(cfg) -> None:
    def reconfig(cfg) -> None:
        ip(f"link set dev %s xdp obj %s sec xdp" %
            (cfg.ifname, cfg.rpath("xdp_dummy.bpf.o")))
           (cfg.ifname, cfg.net_lib_dir / "xdp_dummy.bpf.o"))
        ip(f"link set dev %s xdp off" % cfg.ifname)

    _check_reconfig(cfg, reconfig)
+0 −13
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0

#define KBUILD_MODNAME "xdp_dummy"
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>

SEC("xdp")
int xdp_dummy_prog(struct xdp_md *ctx)
{
	return XDP_PASS;
}

char _license[] SEC("license") = "GPL";
+8 −13
Original line number Diff line number Diff line
@@ -13,22 +13,17 @@ from .remote import Remote
class NetDrvEnvBase:
    """
    Base class for a NIC / host envirnoments
    """
    def __init__(self, src_path):
        self.src_path = src_path
        self.env = self._load_env_file()

    def rpath(self, path):
    Attributes:
      test_dir: Path to the source directory of the test
      net_lib_dir: Path to the net/lib directory
    """
        Get an absolute path to a file based on a path relative to the directory
        containing the test which constructed env.
    def __init__(self, src_path):
        self.src_path = Path(src_path)
        self.test_dir = self.src_path.parent.resolve()
        self.net_lib_dir = (Path(__file__).parent / "../../../../net/lib").resolve()

        For example, if the test.py is in the same directory as
        a binary (built from helper.c), the test can use env.rpath("helper")
        to get the absolute path to the binary
        """
        src_dir = Path(self.src_path).parent.resolve()
        return (src_dir / path).as_posix()
        self.env = self._load_env_file()

    def _load_env_file(self):
        env = os.environ.copy()
Loading