tools: ynl: add YNL test framework
Subsystems (3)
PATCH v7 1/1 tools: ynl: add YNL test framework
Add a test framework for YAML Netlink (YNL) tools, covering both CLI and ethtool functionality. The framework includes:
1) cli: family listing, netdev, ethtool, rt-* families, and nlctrl operations
2) ethtool: device info, statistics, ring/coalesce/pause parameters, and feature gettings
The current YNL syntax is a bit obscure, and end users may not always know how to use it. This test framework provides usage examples and also serves as a regression test to catch potential breakages caused by future changes.
---
v7: add distclean target (Simon Horman)
v6: rebase to latest net-next. update the shellcheck comment.
Link: https://lore.kernel.org/netdev/[email protected]
v5: add a comment about why disable shellcheck (Matthieu Baerts)
move ktap_set_plan after setup (Matthieu Baerts) Use TESTS_NO to track the test number (Matthieu Baerts)
v4: Use KTAP helper to report the test result (Matthieu Baerts)
iterate through $(TESTS) instead of being hard coded (Donald Hunter)
Link: https://lore.kernel.org/netdev/[email protected]v3: add make run_tests to run all the tests at a time (Jakub Kicinski)
use ipv4-or-v6 display hint for dual-stack fields (Jakub Kicinski) check sysfs in case of netdevsim buildin (Sabrina Dubroca)
v2: move test from selftest to ynl folder (Jakub Kicinski)
Link: https://lore.kernel.org/netdev/[email protected]
v1: Link: https://lore.kernel.org/netdev/[email protected]
--- tools/net/ynl/Makefile | 8 +- tools/net/ynl/tests/Makefile | 32 +++ tools/net/ynl/tests/config | 6 + tools/net/ynl/tests/test_ynl_cli.sh | 327 ++++++++++++++++++++++++ tools/net/ynl/tests/test_ynl_ethtool.sh | 222 ++++++++++++++++ 5 files changed, 593 insertions(+), 2 deletions(-) create mode 100644 tools/net/ynl/tests/Makefile create mode 100644 tools/net/ynl/tests/config create mode 100755 tools/net/ynl/tests/test_ynl_cli.sh create mode 100755 tools/net/ynl/tests/test_ynl_ethtool.sh
tools/net/ynl/Makefile +6 -2
@@ -12,7 +12,7 @@ endif libdir ?= $(prefix)/$(libdir_relative) includedir ?= $(prefix)/include -SUBDIRS = lib generated samples ynltool +SUBDIRS = lib generated samples ynltool tests all: $(SUBDIRS) libynl.a
@@ -49,5 +49,9 @@ install: libynl.a lib/*.h @echo -e "\tINSTALL pyynl" @pip install --prefix=$(DESTDIR)$(prefix) . @make -C generated install + @make -C tests install -.PHONY: all clean distclean install $(SUBDIRS) +run_tests: + @$(MAKE) -C tests run_tests + +.PHONY: all clean distclean install run_tests $(SUBDIRS)
tools/net/ynl/tests/Makefile new file +32 -0
@@ -0,0 +1,32 @@ +# SPDX-License-Identifier: GPL-2.0 +# Makefile for YNL tests + +TESTS := \ + test_ynl_cli.sh \ + test_ynl_ethtool.sh \ +# end of TESTS + +all: $(TESTS) + +run_tests: + @for test in $(TESTS); do \ + ./$$test; \ + done + +install: $(TESTS) + @mkdir -p $(DESTDIR)/usr/bin + @mkdir -p $(DESTDIR)/usr/share/kselftest + @cp ../../../testing/selftests/kselftest/ktap_helpers.sh $(DESTDIR)/usr/share/kselftest/ + @for test in $(TESTS); do \ + name=$$(basename $$test .sh); \ + sed -e 's|^ynl=.*|ynl="ynl"|' \ + -e 's|^ynl_ethtool=.*|ynl_ethtool="ynl-ethtool"|' \ + -e 's|KSELFTEST_KTAP_HELPERS=.*|KSELFTEST_KTAP_HELPERS="/usr/share/kselftest/ktap_helpers.sh"|' \ + $$test > $(DESTDIR)/usr/bin/$$name; \ + chmod +x $(DESTDIR)/usr/bin/$$name; \ + done + +clean distclean: + @# Nothing to clean + +.PHONY: all install clean run_tests
tools/net/ynl/tests/config new file +6 -0
@@ -0,0 +1,6 @@ +CONFIG_DUMMY=m +CONFIG_INET_DIAG=y +CONFIG_IPV6=y +CONFIG_NET_NS=y +CONFIG_NETDEVSIM=m +CONFIG_VETH=m
tools/net/ynl/tests/test_ynl_cli.sh new file +327 -0
327 lines not on this page · raw message
tools/net/ynl/tests/test_ynl_ethtool.sh new file +222 -0
222 lines not on this page · raw message
Signature · 1 line
2.50.1
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Mon, 24 Nov 2025 02:20:55 +0000 you wrote:
Add a test framework for YAML Netlink (YNL) tools, covering both CLI and ethtool functionality. The framework includes:
1) cli: family listing, netdev, ethtool, rt-* families, and nlctrl operations
2) ethtool: device info, statistics, ring/coalesce/pause parameters, and feature gettings[...]
Here is the summary with links:
- [PATCHv7,net-next] tools: ynl: add YNL test framework
https://git.kernel.org/netdev/net-next/c/308b7dee3e5c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html