Skip to content

Commit 5b68d43

Browse files
committed
selftests: drv-net: add a trivial ping test
JIRA: https://issues.redhat.com/browse/RHEL-57764 commit a48a87c Author: Jakub Kicinski <kuba@kernel.org> Date: Fri Apr 19 19:52:34 2024 -0700 selftests: drv-net: add a trivial ping test Add a very simple test for testing with a remote system. Both IPv4 and IPv6 connectivity is optional, later change will add checks to skip tests based on available addresses. Using netdevsim: $ ./run_kselftest.sh -t drivers/net:ping.py TAP version 13 1..1 # timeout set to 45 # selftests: drivers/net: ping.py # KTAP version 1 # 1..2 # ok 1 ping.test_v4 # ok 2 ping.test_v6 # # Totals: pass:2 fail:0 xfail:0 xpass:0 skip:0 error:0 ok 1 selftests: drivers/net: ping.py Command line SSH: $ NETIF=virbr0 REMOTE_TYPE=ssh REMOTE_ARGS=root@192.168.122.123 \ LOCAL_V4=192.168.122.1 REMOTE_V4=192.168.122.123 \ ./tools/testing/selftests/drivers/net/ping.py KTAP version 1 1..2 ok 1 ping.test_v4 ok 2 ping.test_v6 # SKIP Test requires IPv6 connectivity # Totals: pass:1 fail:0 xfail:1 xpass:0 skip:0 error:0 Existing devices placed in netns (and using net.config): $ cat drivers/net/net.config NETIF=veth0 REMOTE_TYPE=netns REMOTE_ARGS=red LOCAL_V4="192.168.1.1" REMOTE_V4="192.168.1.2" $ ./run_kselftest.sh -t drivers/net:ping.py TAP version 13 1..1 # timeout set to 45 # selftests: drivers/net: ping.py # KTAP version 1 # 1..2 # ok 1 ping.test_v4 # ok 2 ping.test_v6 # SKIP Test requires IPv6 connectivity # # Totals: pass:1 fail:0 xfail:1 xpass:0 skip:0 error:0 Reviewed-by: Willem de Bruijn <willemb@google.com> Link: https://lore.kernel.org/r/20240420025237.3309296-5-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Ivan Vecera <ivecera@redhat.com>
1 parent f2e9054 commit 5b68d43

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

tools/testing/selftests/drivers/net/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
TEST_INCLUDES := $(wildcard lib/py/*.py)
44

5-
TEST_PROGS := stats.py
5+
TEST_PROGS := \
6+
ping.py \
7+
stats.py \
8+
# end of TEST_PROGS
69

710
include ../../lib.mk
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python3
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
from lib.py import ksft_run, ksft_exit
5+
from lib.py import NetDrvEpEnv
6+
from lib.py import cmd
7+
8+
9+
def test_v4(cfg) -> None:
10+
cmd(f"ping -c 1 -W0.5 {cfg.remote_v4}")
11+
cmd(f"ping -c 1 -W0.5 {cfg.v4}", host=cfg.remote)
12+
13+
14+
def test_v6(cfg) -> None:
15+
cmd(f"ping -c 1 -W0.5 {cfg.remote_v6}")
16+
cmd(f"ping -c 1 -W0.5 {cfg.v6}", host=cfg.remote)
17+
18+
19+
def main() -> None:
20+
with NetDrvEpEnv(__file__) as cfg:
21+
ksft_run([test_v4, test_v6],
22+
args=(cfg, ))
23+
ksft_exit()
24+
25+
26+
if __name__ == "__main__":
27+
main()

0 commit comments

Comments
 (0)