]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tools: ynl: move samples to tests
authorJakub Kicinski <kuba@kernel.org>
Sat, 7 Mar 2026 03:36:21 +0000 (19:36 -0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 10 Mar 2026 00:02:25 +0000 (17:02 -0700)
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>
Tested-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://patch.msgid.link/20260307033630.1396085-2-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
13 files changed:
tools/net/ynl/Makefile
tools/net/ynl/samples/Makefile [deleted file]
tools/net/ynl/tests/.gitignore [moved from tools/net/ynl/samples/.gitignore with 87% similarity]
tools/net/ynl/tests/Makefile
tools/net/ynl/tests/devlink.c [moved from tools/net/ynl/samples/devlink.c with 100% similarity]
tools/net/ynl/tests/ethtool.c [moved from tools/net/ynl/samples/ethtool.c with 100% similarity]
tools/net/ynl/tests/netdev.c [moved from tools/net/ynl/samples/netdev.c with 100% similarity]
tools/net/ynl/tests/ovs.c [moved from tools/net/ynl/samples/ovs.c with 100% similarity]
tools/net/ynl/tests/rt-addr.c [moved from tools/net/ynl/samples/rt-addr.c with 100% similarity]
tools/net/ynl/tests/rt-link.c [moved from tools/net/ynl/samples/rt-link.c with 100% similarity]
tools/net/ynl/tests/rt-route.c [moved from tools/net/ynl/samples/rt-route.c with 100% similarity]
tools/net/ynl/tests/tc-filter-add.c [moved from tools/net/ynl/samples/tc-filter-add.c with 100% similarity]
tools/net/ynl/tests/tc.c [moved from tools/net/ynl/samples/tc.c with 100% similarity]

index 9b692f368be7ec42fb0bc012bb4e3cce76c0bff0..d514a48dae270d284e15aebd95a113241008afd3 100644 (file)
@@ -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 (file)
index d76cbd4..0000000
+++ /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
similarity index 87%
rename from tools/net/ynl/samples/.gitignore
rename to tools/net/ynl/tests/.gitignore
index 05087ee323ba236a4f5fb6d713767847f0bde124..045385df42a4541be2c785353162e8f4594d3c39 100644 (file)
@@ -1,8 +1,7 @@
-ethtool
 devlink
+ethtool
 netdev
 ovs
-page-pool
 rt-addr
 rt-link
 rt-route
index eb166c9550db0fd45951a8ef1e84c338771edbd0..5fa36c877235dbe120b6f2e1bb133411a1e30007 100644 (file)
@@ -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 *~
+
+distclean: clean
+       rm -f $(BINS)
 
-.PHONY: all install clean run_tests
+.PHONY: all install clean distclean run_tests
+.DEFAULT_GOAL=all