Skip to contentSkip to conversation

tools: ynl: tests: adjust Makefile to mimic ksft

PATCH Applied Jakub Kicinski 5 participants 9 messages Mar 3 – Mar 5

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

cover tools: ynl: tests: adjust Makefile to mimic ksft

Make a few minor adjustments to tools/net/ynl/tests/Makefile to align its behavior more with how real kselftests behave. This series allows running the YNL tests in NIPA with little extra integration effort.

If anyone already integrated these tests into their CI minor adjustments to the integration may be needed (due to patch 2).

Jakub Kicinski (4):
tools: ynl: rename TESTS variable to TEST_PROGS
tools: ynl: don't install tests in /usr/bin/
tools: ynl: support INSTALL_PATH in the tests Makefile
tools: ynl: produce kselftest-list.txt from tests

 tools/net/ynl/tests/Makefile | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)
Signature · 1 line
2.53.0
author maintainer
#1 lore raw

PATCH 1/4 tools: ynl: rename TESTS variable to TEST_PROGS

Use the standard kselftest variable naming for tests in the Makefile. NIPA depends on being able to selectively target tests by setting those variables on the CLI.

---
 tools/net/ynl/tests/Makefile | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
tools/net/ynl/tests/Makefile +6 -6
index c1df2e001255..ee4362ca286d 100644
@@ -1,23 +1,23 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for YNL tests
 
-TESTS := \
+TEST_PROGS := \
 	test_ynl_cli.sh \
 	test_ynl_ethtool.sh \
-# end of TESTS
+# end of TEST_PROGS
 
-all: $(TESTS)
+all: $(TEST_PROGS)
 
 run_tests:
-	@for test in $(TESTS); do \
+	@for test in $(TEST_PROGS); do \
 		./$$test; \
 	done
 
-install: $(TESTS)
+install: $(TEST_PROGS)
 	@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 \
+	@for test in $(TEST_PROGS); do \
 		name=$$(basename $$test .sh); \
 		sed -e 's|^ynl=.*|ynl="ynl"|' \
 		    -e 's|^ynl_ethtool=.*|ynl_ethtool="ynl-ethtool"|' \
Signature · 1 line
2.53.0
author maintainer
#2 lore raw

PATCH 2/4 tools: ynl: don't install tests in /usr/bin/

In reply to Jakub Kicinski

Until commit 790792ebc960 ("tools: ynl: don't install tests") YNL selftests were installed with all the other YNL outputs. That's no longer the case, as tests are not really production artifacts. Let's not install them in /usr/bin at all, and mirror kselftest format more closely:

For: make -C tools/net/ynl/tests/ install DESTDIR=tmp

tmp/usr/share/kselftest

              ├── ktap_helpers.sh
              └── ynl
                  ├── test_ynl_cli.sh
                  └── test_ynl_ethtool.sh
---
 tools/net/ynl/tests/Makefile | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
tools/net/ynl/tests/Makefile +4 -5
index ee4362ca286d..5045341300e2 100644
@@ -14,16 +14,15 @@ all: $(TEST_PROGS)
 	done
 
 install: $(TEST_PROGS)
-	@mkdir -p $(DESTDIR)/usr/bin
-	@mkdir -p $(DESTDIR)/usr/share/kselftest
+	@mkdir -p $(DESTDIR)/usr/share/kselftest/ynl
 	@cp ../../../testing/selftests/kselftest/ktap_helpers.sh $(DESTDIR)/usr/share/kselftest/
 	@for test in $(TEST_PROGS); do \
-		name=$$(basename $$test .sh); \
+		name=$$(basename $$test); \
 		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; \
+		    $$test > $(DESTDIR)/usr/share/kselftest/ynl/$$name; \
+		chmod +x $(DESTDIR)/usr/share/kselftest/ynl/$$name; \
 	done
 
 clean distclean:
Signature · 1 line
2.53.0
author maintainer
#3 lore raw

PATCH 3/4 tools: ynl: support INSTALL_PATH in the tests Makefile

In reply to Jakub Kicinski

We have modelled the YNL tests after ksft to be able to reuse the NIPA wrappers. Make sure YNL honors INSTALL_PATH not just DESTDIR, ksft uses INSTALL_PATH.

---
 tools/net/ynl/tests/Makefile | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
tools/net/ynl/tests/Makefile +7 -5
index 5045341300e2..ee717db12dff 100644
@@ -6,6 +6,8 @@ TEST_PROGS := \
 	test_ynl_ethtool.sh \
 # end of TEST_PROGS
 
+INSTALL_PATH ?= $(DESTDIR)/usr/share/kselftest
+
 all: $(TEST_PROGS)
 
 run_tests:
@@ -14,15 +16,15 @@ all: $(TEST_PROGS)
 	done
 
 install: $(TEST_PROGS)
-	@mkdir -p $(DESTDIR)/usr/share/kselftest/ynl
-	@cp ../../../testing/selftests/kselftest/ktap_helpers.sh $(DESTDIR)/usr/share/kselftest/
+	@mkdir -p $(INSTALL_PATH)/ynl
+	@cp ../../../testing/selftests/kselftest/ktap_helpers.sh $(INSTALL_PATH)/
 	@for test in $(TEST_PROGS); do \
 		name=$$(basename $$test); \
 		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/share/kselftest/ynl/$$name; \
-		chmod +x $(DESTDIR)/usr/share/kselftest/ynl/$$name; \
+		    -e 's|KSELFTEST_KTAP_HELPERS=.*|KSELFTEST_KTAP_HELPERS="$(INSTALL_PATH)/ktap_helpers.sh"|' \
+		    $$test > $(INSTALL_PATH)/ynl/$$name; \
+		chmod +x $(INSTALL_PATH)/ynl/$$name; \
 	done
 
 clean distclean:
Signature · 1 line
2.53.0
author maintainer
#4 lore raw

PATCH 4/4 tools: ynl: produce kselftest-list.txt from tests

In reply to Jakub Kicinski

Executors will need kselftest-list.txt so create it when tests are installed.

---
 tools/net/ynl/tests/Makefile | 3 +++
 1 file changed, 3 insertions(+)
tools/net/ynl/tests/Makefile +3 -0
index ee717db12dff..eb166c9550db 100644
@@ -26,6 +26,9 @@ install: $(TEST_PROGS)
 		    $$test > $(INSTALL_PATH)/ynl/$$name; \
 		chmod +x $(INSTALL_PATH)/ynl/$$name; \
 	done
+	@for test in $(TEST_PROGS); do \
+		echo "ynl:$$test"; \
+	done > $(INSTALL_PATH)/kselftest-list.txt
 
 clean distclean:
 	@# Nothing to clean
Signature · 1 line
2.53.0
Acked-by on the v1 series
#5 lore raw
In reply to Jakub Kicinski

Hi Jakub,

Quoted 4 lines · Jakub Kicinski

Make a few minor adjustments to tools/net/ynl/tests/Makefile to align its behavior more with how real kselftests behave. This series allows running the YNL tests in NIPA with little extra integration effort.

Good idea! This looks good to me:

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
Reviewed-by on the v1 series
#6 lore raw
In reply to Jakub Kicinski
Quoted 8 lines · Jakub Kicinski

Make a few minor adjustments to tools/net/ynl/tests/Makefile to align its behavior more with how real kselftests behave. This series allows running the YNL tests in NIPA with little extra integration effort.

If anyone already integrated these tests into their CI minor adjustments to the integration may be needed (due to patch 2).

Quoted 12 lines

Jakub Kicinski (4):
tools: ynl: rename TESTS variable to TEST_PROGS
tools: ynl: don't install tests in /usr/bin/
tools: ynl: support INSTALL_PATH in the tests Makefile
tools: ynl: produce kselftest-list.txt from tests

 tools/net/ynl/tests/Makefile | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)
Signature · 1 line
2.53.0
maintainer Reviewed-by on the v1 series
#7 lore raw
In reply to Jakub Kicinski
Quoted 8 lines · Jakub Kicinski

Make a few minor adjustments to tools/net/ynl/tests/Makefile to align its behavior more with how real kselftests behave. This series allows running the YNL tests in NIPA with little extra integration effort.

If anyone already integrated these tests into their CI minor adjustments to the integration may be needed (due to patch 2).

Quoted 8 lines

Jakub Kicinski (4):
tools: ynl: rename TESTS variable to TEST_PROGS
tools: ynl: don't install tests in /usr/bin/
tools: ynl: support INSTALL_PATH in the tests Makefile
tools: ynl: produce kselftest-list.txt from tests

 tools/net/ynl/tests/Makefile | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)
#8 lore raw
In reply to Jakub Kicinski
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Tue, 3 Mar 2026 08:35:00 -0800 you wrote:

Make a few minor adjustments to tools/net/ynl/tests/Makefile to align its behavior more with how real kselftests behave. This series allows running the YNL tests in NIPA with little extra integration effort.

If anyone already integrated these tests into their CI minor adjustments to the integration may be needed (due to patch 2).

[...]

Here is the summary with links:
- [net-next,1/4] tools: ynl: rename TESTS variable to TEST_PROGS

    https://git.kernel.org/netdev/net-next/c/d86670b837fb
  - [net-next,2/4] tools: ynl: don't install tests in /usr/bin/
    https://git.kernel.org/netdev/net-next/c/3e90e00da96b
  - [net-next,3/4] tools: ynl: support INSTALL_PATH in the tests Makefile
    https://git.kernel.org/netdev/net-next/c/2bfc36f5ea16
  - [net-next,4/4] tools: ynl: produce kselftest-list.txt from tests
    https://git.kernel.org/netdev/net-next/c/32d6fd5832ad

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html