From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
andrew+netdev@lunn.ch, horms@kernel.org, donald.hunter@gmail.com,
liuhangbin@gmail.com, matttbe@kernel.org,
Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next v2 01/10] tools: ynl: move samples to tests
Date: Fri, 6 Mar 2026 19:36:21 -0800 [thread overview]
Message-ID: <20260307033630.1396085-2-kuba@kernel.org> (raw)
In-Reply-To: <20260307033630.1396085-1-kuba@kernel.org>
The "samples" were always poor man's tests (used to manually
confirm that C YNL works).
Move all C sample programs from tools/net/ynl/samples/ to
tools/net/ynl/tests/, "merge" the Makefiles. The subsequent
changes will convert each sample into a proper KTAP selftests.
Since these are now tests rather than samples - default to
enabling asan. After all we're testing user space code here.
Sort the gitignore while at it, the page-pool entry was a leftover
so delete it.
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
tools/net/ynl/Makefile | 4 +-
tools/net/ynl/samples/Makefile | 36 --------------
tools/net/ynl/tests/Makefile | 47 +++++++++++++++++--
tools/net/ynl/{samples => tests}/devlink.c | 0
tools/net/ynl/{samples => tests}/ethtool.c | 0
tools/net/ynl/{samples => tests}/netdev.c | 0
tools/net/ynl/{samples => tests}/ovs.c | 0
tools/net/ynl/{samples => tests}/rt-addr.c | 0
tools/net/ynl/{samples => tests}/rt-link.c | 0
tools/net/ynl/{samples => tests}/rt-route.c | 0
.../ynl/{samples => tests}/tc-filter-add.c | 0
tools/net/ynl/{samples => tests}/tc.c | 0
tools/net/ynl/{samples => tests}/.gitignore | 3 +-
13 files changed, 45 insertions(+), 45 deletions(-)
delete mode 100644 tools/net/ynl/samples/Makefile
rename tools/net/ynl/{samples => tests}/devlink.c (100%)
rename tools/net/ynl/{samples => tests}/ethtool.c (100%)
rename tools/net/ynl/{samples => tests}/netdev.c (100%)
rename tools/net/ynl/{samples => tests}/ovs.c (100%)
rename tools/net/ynl/{samples => tests}/rt-addr.c (100%)
rename tools/net/ynl/{samples => tests}/rt-link.c (100%)
rename tools/net/ynl/{samples => tests}/rt-route.c (100%)
rename tools/net/ynl/{samples => tests}/tc-filter-add.c (100%)
rename tools/net/ynl/{samples => tests}/tc.c (100%)
rename tools/net/ynl/{samples => tests}/.gitignore (87%)
diff --git a/tools/net/ynl/Makefile b/tools/net/ynl/Makefile
index 9b692f368be7..d514a48dae27 100644
--- a/tools/net/ynl/Makefile
+++ b/tools/net/ynl/Makefile
@@ -14,12 +14,12 @@ includedir ?= $(prefix)/include
SPECDIR=../../../Documentation/netlink/specs
-SUBDIRS = lib generated samples ynltool tests
+SUBDIRS = lib generated ynltool tests
all: $(SUBDIRS) libynl.a
+tests: | lib generated libynl.a
ynltool: | lib generated libynl.a
-samples: | lib generated
libynl.a: | lib generated
@echo -e "\tAR $@"
@ar rcs $@ lib/ynl.o generated/*-user.o
diff --git a/tools/net/ynl/samples/Makefile b/tools/net/ynl/samples/Makefile
deleted file mode 100644
index d76cbd41cbb1..000000000000
--- a/tools/net/ynl/samples/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-
-include ../Makefile.deps
-
-CC=gcc
-CFLAGS += -std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \
- -I../lib/ -I../generated/ -idirafter $(UAPI_PATH)
-ifeq ("$(DEBUG)","1")
- CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan
-endif
-
-LDLIBS=../lib/ynl.a ../generated/protos.a
-
-SRCS=$(wildcard *.c)
-BINS=$(patsubst %.c,%,${SRCS})
-
-include $(wildcard *.d)
-
-all: $(BINS)
-
-CFLAGS_page-pool=$(CFLAGS_netdev)
-CFLAGS_tc-filter-add:=$(CFLAGS_tc)
-
-$(BINS): ../lib/ynl.a ../generated/protos.a $(SRCS)
- @echo -e '\tCC sample $@'
- @$(COMPILE.c) $(CFLAGS_$@) $@.c -o $@.o
- @$(LINK.c) $@.o -o $@ $(LDLIBS)
-
-clean:
- rm -f *.o *.d *~
-
-distclean: clean
- rm -f $(BINS)
-
-.PHONY: all clean distclean
-.DEFAULT_GOAL=all
diff --git a/tools/net/ynl/tests/Makefile b/tools/net/ynl/tests/Makefile
index eb166c9550db..5fa36c877235 100644
--- a/tools/net/ynl/tests/Makefile
+++ b/tools/net/ynl/tests/Makefile
@@ -1,21 +1,51 @@
# SPDX-License-Identifier: GPL-2.0
# Makefile for YNL tests
+include ../Makefile.deps
+
+CC=gcc
+CFLAGS += -std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \
+ -I../lib/ -I../generated/ -I../../../testing/selftests/ \
+ -idirafter $(UAPI_PATH)
+ifneq ("$(NDEBUG)","1")
+ CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan
+endif
+
+LDLIBS=../lib/ynl.a ../generated/protos.a
+
TEST_PROGS := \
test_ynl_cli.sh \
test_ynl_ethtool.sh \
# end of TEST_PROGS
+SRCS=$(wildcard *.c)
+BINS=$(patsubst %.c,%,${SRCS})
+
+CFLAGS_tc-filter-add:=$(CFLAGS_tc)
+
+include $(wildcard *.d)
+
INSTALL_PATH ?= $(DESTDIR)/usr/share/kselftest
-all: $(TEST_PROGS)
+all: $(BINS) $(TEST_PROGS)
+
+../lib/ynl.a:
+ @$(MAKE) -C ../lib
+
+ ../generated/protos.a:
+ @$(MAKE) -C ../generated
+
+$(BINS): ../lib/ynl.a ../generated/protos.a
+ @echo -e '\tCC test $@'
+ @$(COMPILE.c) $(CFLAGS_$@) $@.c -o $@.o
+ @$(LINK.c) $@.o -o $@ $(LDLIBS)
run_tests:
@for test in $(TEST_PROGS); do \
./$$test; \
done
-install: $(TEST_PROGS)
+install: $(TEST_PROGS) $(BINS)
@mkdir -p $(INSTALL_PATH)/ynl
@cp ../../../testing/selftests/kselftest/ktap_helpers.sh $(INSTALL_PATH)/
@for test in $(TEST_PROGS); do \
@@ -26,11 +56,18 @@ install: $(TEST_PROGS)
$$test > $(INSTALL_PATH)/ynl/$$name; \
chmod +x $(INSTALL_PATH)/ynl/$$name; \
done
+ @for bin in $(BINS); do \
+ cp $$bin $(INSTALL_PATH)/ynl/$$bin; \
+ done
@for test in $(TEST_PROGS); do \
echo "ynl:$$test"; \
done > $(INSTALL_PATH)/kselftest-list.txt
-clean distclean:
- @# Nothing to clean
+clean:
+ rm -f *.o *.d *~
-.PHONY: all install clean run_tests
+distclean: clean
+ rm -f $(BINS)
+
+.PHONY: all install clean distclean run_tests
+.DEFAULT_GOAL=all
diff --git a/tools/net/ynl/samples/devlink.c b/tools/net/ynl/tests/devlink.c
similarity index 100%
rename from tools/net/ynl/samples/devlink.c
rename to tools/net/ynl/tests/devlink.c
diff --git a/tools/net/ynl/samples/ethtool.c b/tools/net/ynl/tests/ethtool.c
similarity index 100%
rename from tools/net/ynl/samples/ethtool.c
rename to tools/net/ynl/tests/ethtool.c
diff --git a/tools/net/ynl/samples/netdev.c b/tools/net/ynl/tests/netdev.c
similarity index 100%
rename from tools/net/ynl/samples/netdev.c
rename to tools/net/ynl/tests/netdev.c
diff --git a/tools/net/ynl/samples/ovs.c b/tools/net/ynl/tests/ovs.c
similarity index 100%
rename from tools/net/ynl/samples/ovs.c
rename to tools/net/ynl/tests/ovs.c
diff --git a/tools/net/ynl/samples/rt-addr.c b/tools/net/ynl/tests/rt-addr.c
similarity index 100%
rename from tools/net/ynl/samples/rt-addr.c
rename to tools/net/ynl/tests/rt-addr.c
diff --git a/tools/net/ynl/samples/rt-link.c b/tools/net/ynl/tests/rt-link.c
similarity index 100%
rename from tools/net/ynl/samples/rt-link.c
rename to tools/net/ynl/tests/rt-link.c
diff --git a/tools/net/ynl/samples/rt-route.c b/tools/net/ynl/tests/rt-route.c
similarity index 100%
rename from tools/net/ynl/samples/rt-route.c
rename to tools/net/ynl/tests/rt-route.c
diff --git a/tools/net/ynl/samples/tc-filter-add.c b/tools/net/ynl/tests/tc-filter-add.c
similarity index 100%
rename from tools/net/ynl/samples/tc-filter-add.c
rename to tools/net/ynl/tests/tc-filter-add.c
diff --git a/tools/net/ynl/samples/tc.c b/tools/net/ynl/tests/tc.c
similarity index 100%
rename from tools/net/ynl/samples/tc.c
rename to tools/net/ynl/tests/tc.c
diff --git a/tools/net/ynl/samples/.gitignore b/tools/net/ynl/tests/.gitignore
similarity index 87%
rename from tools/net/ynl/samples/.gitignore
rename to tools/net/ynl/tests/.gitignore
index 05087ee323ba..045385df42a4 100644
--- a/tools/net/ynl/samples/.gitignore
+++ b/tools/net/ynl/tests/.gitignore
@@ -1,8 +1,7 @@
-ethtool
devlink
+ethtool
netdev
ovs
-page-pool
rt-addr
rt-link
rt-route
--
2.53.0
next prev parent reply other threads:[~2026-03-07 3:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-07 3:36 [PATCH net-next v2 00/10] tools: ynl: convert samples into selftests Jakub Kicinski
2026-03-07 3:36 ` Jakub Kicinski [this message]
2026-03-07 3:36 ` [PATCH net-next v2 02/10] tools: ynl: convert netdev sample to selftest Jakub Kicinski
2026-03-07 3:36 ` [PATCH net-next v2 03/10] tools: ynl: convert ovs " Jakub Kicinski
2026-03-07 3:36 ` [PATCH net-next v2 04/10] tools: ynl: convert rt-link " Jakub Kicinski
2026-03-07 3:36 ` [PATCH net-next v2 05/10] tools: ynl: convert tc and tc-filter-add samples " Jakub Kicinski
2026-03-07 3:36 ` [PATCH net-next v2 06/10] tools: ynl: add netdevsim wrapper library for YNL tests Jakub Kicinski
2026-03-07 3:36 ` [PATCH net-next v2 07/10] tools: ynl: convert devlink sample to selftest Jakub Kicinski
2026-03-07 3:36 ` [PATCH net-next v2 08/10] tools: ynl: convert ethtool " Jakub Kicinski
2026-03-07 3:36 ` [PATCH net-next v2 09/10] tools: ynl: convert rt-addr " Jakub Kicinski
2026-03-07 3:36 ` [PATCH net-next v2 10/10] tools: ynl: convert rt-route " Jakub Kicinski
2026-03-08 17:23 ` [PATCH net-next v2 00/10] tools: ynl: convert samples into selftests Donald Hunter
2026-03-10 0:10 ` 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=20260307033630.1396085-2-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=liuhangbin@gmail.com \
--cc=matttbe@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.