From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
shuah@kernel.org, sdf@google.com, donald.hunter@gmail.com,
linux-kselftest@vger.kernel.org, petrm@nvidia.com,
Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next v2 4/7] selftests: nl_netdev: add a trivial Netlink netdev test
Date: Tue, 2 Apr 2024 19:34:23 -0700 [thread overview]
Message-ID: <20240403023426.1762996-5-kuba@kernel.org> (raw)
In-Reply-To: <20240403023426.1762996-1-kuba@kernel.org>
Add a trivial test using YNL.
$ ./tools/testing/selftests/net/nl_netdev.py
KTAP version 1
1..2
ok 1 nl_netdev.empty_check
ok 2 nl_netdev.lo_check
Instantiate the family once, it takes longer than the test itself.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
v2:
- pass family as argument
CC: shuah@kernel.org
CC: linux-kselftest@vger.kernel.org
---
tools/testing/selftests/net/Makefile | 1 +
tools/testing/selftests/net/nl_netdev.py | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+)
create mode 100755 tools/testing/selftests/net/nl_netdev.py
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index cb418a2346bc..5e34c93aa51b 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -34,6 +34,7 @@ TEST_PROGS += gre_gso.sh
TEST_PROGS += cmsg_so_mark.sh
TEST_PROGS += cmsg_time.sh cmsg_ipv6.sh
TEST_PROGS += netns-name.sh
+TEST_PROGS += nl_netdev.py
TEST_PROGS += srv6_end_dt46_l3vpn_test.sh
TEST_PROGS += srv6_end_dt4_l3vpn_test.sh
TEST_PROGS += srv6_end_dt6_l3vpn_test.sh
diff --git a/tools/testing/selftests/net/nl_netdev.py b/tools/testing/selftests/net/nl_netdev.py
new file mode 100755
index 000000000000..2b8b488fb419
--- /dev/null
+++ b/tools/testing/selftests/net/nl_netdev.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0
+
+from lib.py import ksft_run, ksft_pr, ksft_eq, ksft_ge, NetdevFamily
+
+
+def empty_check(nf) -> None:
+ devs = nf.dev_get({}, dump=True)
+ ksft_ge(len(devs), 1)
+
+
+def lo_check(nf) -> None:
+ lo_info = nf.dev_get({"ifindex": 1})
+ ksft_eq(len(lo_info['xdp-features']), 0)
+ ksft_eq(len(lo_info['xdp-rx-metadata-features']), 0)
+
+
+def main() -> None:
+ nf = NetdevFamily()
+ ksft_run([empty_check, lo_check], args=(nf, ))
+
+
+if __name__ == "__main__":
+ main()
--
2.44.0
next prev parent reply other threads:[~2024-04-03 2:34 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 2:34 [PATCH net-next v2 0/7] selftests: net: groundwork for YNL-based tests Jakub Kicinski
2024-04-03 2:34 ` [PATCH net-next v2 1/7] netlink: specs: define ethtool header flags Jakub Kicinski
2024-04-04 10:38 ` Petr Machata
2024-04-03 2:34 ` [PATCH net-next v2 2/7] tools: ynl: copy netlink error to NlError Jakub Kicinski
2024-04-04 10:39 ` Petr Machata
2024-04-03 2:34 ` [PATCH net-next v2 3/7] selftests: net: add scaffolding for Netlink tests in Python Jakub Kicinski
2024-04-04 9:11 ` Petr Machata
2024-04-03 2:34 ` Jakub Kicinski [this message]
2024-04-04 10:39 ` [PATCH net-next v2 4/7] selftests: nl_netdev: add a trivial Netlink netdev test Petr Machata
2024-04-03 2:34 ` [PATCH net-next v2 5/7] netdevsim: report stats by default, like a real device Jakub Kicinski
2024-04-04 10:40 ` Petr Machata
2024-04-04 13:52 ` Jakub Kicinski
2024-04-04 13:40 ` Paolo Abeni
2024-04-04 13:53 ` Jakub Kicinski
2024-04-03 2:34 ` [PATCH net-next v2 6/7] selftests: drivers: add scaffolding for Netlink tests in Python Jakub Kicinski
2024-04-04 10:42 ` Petr Machata
2024-04-05 1:58 ` Jakub Kicinski
2024-04-03 2:34 ` [PATCH net-next v2 7/7] testing: net-drv: add a driver test for stats reporting Jakub Kicinski
2024-04-04 17:40 ` [PATCH net-next v2 0/7] selftests: net: groundwork for YNL-based tests patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240403023426.1762996-5-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@google.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.com \
--cc=sdf@google.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).