Skip to content

Commit 5c60528

Browse files
committed
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/[email protected] ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 7220e8f + 88dec03 commit 5c60528

File tree

12 files changed

+22
-58
lines changed

12 files changed

+22
-58
lines changed

tools/testing/selftests/drivers/net/hds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def _get_hds_mode(cfg, netnl) -> str:
2020

2121

2222
def _xdp_onoff(cfg):
23-
prog = cfg.rpath("../../net/lib/xdp_dummy.bpf.o")
23+
prog = cfg.net_lib_dir / "xdp_dummy.bpf.o"
2424
ip("link set dev %s xdp obj %s sec xdp" %
2525
(cfg.ifname, prog))
2626
ip("link set dev %s xdp off" % cfg.ifname)

tools/testing/selftests/drivers/net/hw/csum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def main() -> None:
8888
with NetDrvEpEnv(__file__, nsim_test=False) as cfg:
8989
check_nic_features(cfg)
9090

91-
cfg.bin_local = cfg.rpath("../../../net/lib/csum")
91+
cfg.bin_local = cfg.net_lib_dir / "csum"
9292
cfg.bin_remote = cfg.remote.deploy(cfg.bin_local)
9393

9494
cases = []

tools/testing/selftests/drivers/net/hw/irq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def reconfig(cfg) -> None:
6969
def check_reconfig_xdp(cfg) -> None:
7070
def reconfig(cfg) -> None:
7171
ip(f"link set dev %s xdp obj %s sec xdp" %
72-
(cfg.ifname, cfg.rpath("xdp_dummy.bpf.o")))
72+
(cfg.ifname, cfg.net_lib_dir / "xdp_dummy.bpf.o"))
7373
ip(f"link set dev %s xdp off" % cfg.ifname)
7474

7575
_check_reconfig(cfg, reconfig)

tools/testing/selftests/drivers/net/hw/xdp_dummy.bpf.c

Lines changed: 0 additions & 13 deletions
This file was deleted.

tools/testing/selftests/drivers/net/lib/py/env.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,17 @@
1313
class NetDrvEnvBase:
1414
"""
1515
Base class for a NIC / host envirnoments
16+
17+
Attributes:
18+
test_dir: Path to the source directory of the test
19+
net_lib_dir: Path to the net/lib directory
1620
"""
1721
def __init__(self, src_path):
18-
self.src_path = src_path
19-
self.env = self._load_env_file()
20-
21-
def rpath(self, path):
22-
"""
23-
Get an absolute path to a file based on a path relative to the directory
24-
containing the test which constructed env.
22+
self.src_path = Path(src_path)
23+
self.test_dir = self.src_path.parent.resolve()
24+
self.net_lib_dir = (Path(__file__).parent / "../../../../net/lib").resolve()
2525

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

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

tools/testing/selftests/drivers/net/ping.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ def _set_offload_checksum(cfg, netnl, on) -> None:
5656
return
5757

5858
def _set_xdp_generic_sb_on(cfg) -> None:
59-
test_dir = os.path.dirname(os.path.realpath(__file__))
60-
prog = test_dir + "/../../net/lib/xdp_dummy.bpf.o"
59+
prog = cfg.net_lib_dir / "xdp_dummy.bpf.o"
6160
cmd(f"ip link set dev {remote_ifname} mtu 1500", shell=True, host=cfg.remote)
6261
cmd(f"ip link set dev {cfg.ifname} mtu 1500 xdpgeneric obj {prog} sec xdp", shell=True)
6362
defer(cmd, f"ip link set dev {cfg.ifname} xdpgeneric off")
@@ -66,8 +65,7 @@ def _set_xdp_generic_sb_on(cfg) -> None:
6665
time.sleep(10)
6766

6867
def _set_xdp_generic_mb_on(cfg) -> None:
69-
test_dir = os.path.dirname(os.path.realpath(__file__))
70-
prog = test_dir + "/../../net/lib/xdp_dummy.bpf.o"
68+
prog = cfg.net_lib_dir / "xdp_dummy.bpf.o"
7169
cmd(f"ip link set dev {remote_ifname} mtu 9000", shell=True, host=cfg.remote)
7270
defer(ip, f"link set dev {remote_ifname} mtu 1500", host=cfg.remote)
7371
ip("link set dev %s mtu 9000 xdpgeneric obj %s sec xdp.frags" % (cfg.ifname, prog))
@@ -77,8 +75,7 @@ def _set_xdp_generic_mb_on(cfg) -> None:
7775
time.sleep(10)
7876

7977
def _set_xdp_native_sb_on(cfg) -> None:
80-
test_dir = os.path.dirname(os.path.realpath(__file__))
81-
prog = test_dir + "/../../net/lib/xdp_dummy.bpf.o"
78+
prog = cfg.net_lib_dir / "xdp_dummy.bpf.o"
8279
cmd(f"ip link set dev {remote_ifname} mtu 1500", shell=True, host=cfg.remote)
8380
cmd(f"ip -j link set dev {cfg.ifname} mtu 1500 xdp obj {prog} sec xdp", shell=True)
8481
defer(ip, f"link set dev {cfg.ifname} mtu 1500 xdp off")
@@ -95,8 +92,7 @@ def _set_xdp_native_sb_on(cfg) -> None:
9592
time.sleep(10)
9693

9794
def _set_xdp_native_mb_on(cfg) -> None:
98-
test_dir = os.path.dirname(os.path.realpath(__file__))
99-
prog = test_dir + "/../../net/lib/xdp_dummy.bpf.o"
95+
prog = cfg.net_lib_dir / "xdp_dummy.bpf.o"
10096
cmd(f"ip link set dev {remote_ifname} mtu 9000", shell=True, host=cfg.remote)
10197
defer(ip, f"link set dev {remote_ifname} mtu 1500", host=cfg.remote)
10298
try:
@@ -109,8 +105,7 @@ def _set_xdp_native_mb_on(cfg) -> None:
109105
time.sleep(10)
110106

111107
def _set_xdp_offload_on(cfg) -> None:
112-
test_dir = os.path.dirname(os.path.realpath(__file__))
113-
prog = test_dir + "/../../net/lib/xdp_dummy.bpf.o"
108+
prog = cfg.net_lib_dir / "xdp_dummy.bpf.o"
114109
cmd(f"ip link set dev {cfg.ifname} mtu 1500", shell=True)
115110
try:
116111
cmd(f"ip link set dev {cfg.ifname} xdpoffload obj {prog} sec xdp", shell=True)

tools/testing/selftests/drivers/net/queues.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ def nl_get_queues(cfg, nl, qtype='rx'):
2626

2727
def check_xsk(cfg, nl, xdp_queue_id=0) -> None:
2828
# Probe for support
29-
xdp = cmd(cfg.rpath("xdp_helper") + ' - -', fail=False)
29+
xdp = cmd(f'{cfg.test_dir / "xdp_helper"} - -', fail=False)
3030
if xdp.ret == 255:
3131
raise KsftSkipEx('AF_XDP unsupported')
3232
elif xdp.ret > 0:
3333
raise KsftFailEx('unable to create AF_XDP socket')
3434

35-
with bkg(f'{cfg.rpath("xdp_helper")} {cfg.ifindex} {xdp_queue_id}',
35+
with bkg(f'{cfg.test_dir / "xdp_helper"} {cfg.ifindex} {xdp_queue_id}',
3636
ksft_wait=3):
3737

3838
rx = tx = False

tools/testing/selftests/net/udpgro_bench.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ source net_helper.sh
77

88
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
99

10-
BPF_FILE="xdp_dummy.bpf.o"
10+
BPF_FILE="lib/xdp_dummy.bpf.o"
1111

1212
cleanup() {
1313
local -r jobs="$(jobs -p)"

tools/testing/selftests/net/udpgro_frglist.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ source net_helper.sh
77

88
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
99

10-
BPF_FILE="xdp_dummy.bpf.o"
10+
BPF_FILE="lib/xdp_dummy.bpf.o"
1111

1212
cleanup() {
1313
local -r jobs="$(jobs -p)"

tools/testing/selftests/net/udpgro_fwd.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
source net_helper.sh
55

6-
BPF_FILE="xdp_dummy.bpf.o"
6+
BPF_FILE="lib/xdp_dummy.bpf.o"
77
readonly BASE="ns-$(mktemp -u XXXXXX)"
88
readonly SRC=2
99
readonly DST=1

0 commit comments

Comments
 (0)