Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] selftests: drv-net: Allow cross-compiling the hardware tests
@ 2026-09-01 16:41 Maxime Chevallier (Netdev Foundation)
  2026-09-01 16:41 ` [PATCH net-next 1/2] selftests: drv-net: ynl: Allow cross-compiling ynl and associated tools Maxime Chevallier (Netdev Foundation)
  2026-09-01 16:41 ` [PATCH net-next 2/2] selftests: drv-net: Use cross-compilation environment for the io_uring check Maxime Chevallier (Netdev Foundation)
  0 siblings, 2 replies; 7+ messages in thread
From: Maxime Chevallier (Netdev Foundation) @ 2026-09-01 16:41 UTC (permalink / raw)
  To: Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Donald Hunter, Simon Horman, Shuah Khan, matttbe,
	Stanislav Fomichev
  Cc: Maxime Chevallier (Netdev Foundation), netdev, linux-kernel,
	thomas.petazzoni, linux-kselftest

Hi everyone,

Here a small series to address some of the issues found while trying to run
the drivers/net/hw selftests on some variety of embedded devices. In
that case, tests are cross-compiled and installed to the rootfs with the
'install' target of the selftests.

Some tests require ynl, and ynl's build machinery hardcodes CC to gcc,
which doesn't work with cross-compiled setups. Let's use the
tools/scripts/Makefile.include instead.

This is duplicated across the ynl tools as it seems to be fairly common
to build alone.

Let's also deal with the io_uring zerocopy check that builds a tiny program
to verify that liburing is available and in the right version.

Maxime Chevallier (Netdev Foundation) (2):
  selftests: drv-net: ynl: Allow cross-compiling ynl and associated
    tools
  selftests: drv-net: Use cross-compilation environment for the io_uring
    check

 tools/net/ynl/Makefile                          | 1 +
 tools/net/ynl/generated/Makefile                | 3 ++-
 tools/net/ynl/lib/Makefile                      | 3 ++-
 tools/net/ynl/tests/Makefile                    | 2 +-
 tools/net/ynl/ynltool/Makefile                  | 4 ++--
 tools/testing/selftests/drivers/net/hw/Makefile | 3 +++
 6 files changed, 11 insertions(+), 5 deletions(-)

-- 
2.55.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net-next 1/2] selftests: drv-net: ynl: Allow cross-compiling ynl and associated tools
  2026-09-01 16:41 [PATCH net-next 0/2] selftests: drv-net: Allow cross-compiling the hardware tests Maxime Chevallier (Netdev Foundation)
@ 2026-09-01 16:41 ` Maxime Chevallier (Netdev Foundation)
  2026-09-01 22:42   ` Jakub Kicinski
  2026-09-01 16:41 ` [PATCH net-next 2/2] selftests: drv-net: Use cross-compilation environment for the io_uring check Maxime Chevallier (Netdev Foundation)
  1 sibling, 1 reply; 7+ messages in thread
From: Maxime Chevallier (Netdev Foundation) @ 2026-09-01 16:41 UTC (permalink / raw)
  To: Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Donald Hunter, Simon Horman, Shuah Khan, matttbe,
	Stanislav Fomichev
  Cc: Maxime Chevallier (Netdev Foundation), netdev, linux-kernel,
	thomas.petazzoni, linux-kselftest

The ynl tool and libraries may be built standalone or through the
drivers/net/hw selftest machinery. This may target a different arch, so
we need to account for the cross-compiling options such as CROSS_COMPILE
or the LLVM-specific variables.

Let's include the tools/scripts/Makefile.include that deals with the
CC/AR resolution.

Fixup the ynltool CFLAGS handling to use +=, so that we don't override
the ones set in Makefile.include

Signed-off-by: Maxime Chevallier (Netdev Foundation) <maxime.chevallier@bootlin.com>
---
 tools/net/ynl/Makefile           | 1 +
 tools/net/ynl/generated/Makefile | 3 ++-
 tools/net/ynl/lib/Makefile       | 3 ++-
 tools/net/ynl/tests/Makefile     | 2 +-
 tools/net/ynl/ynltool/Makefile   | 4 ++--
 5 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/tools/net/ynl/Makefile b/tools/net/ynl/Makefile
index 3cefe4ed96cb..8bf72c063e86 100644
--- a/tools/net/ynl/Makefile
+++ b/tools/net/ynl/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
 include ../../scripts/Makefile.arch
+include ../../scripts/Makefile.include
 
 INSTALL	?= install
 prefix  ?= /usr
diff --git a/tools/net/ynl/generated/Makefile b/tools/net/ynl/generated/Makefile
index ea4128f612d6..5a186349b5a8 100644
--- a/tools/net/ynl/generated/Makefile
+++ b/tools/net/ynl/generated/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CC=gcc
+include ../../../scripts/Makefile.include
+
 CFLAGS += -std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \
 	-I../lib/ -idirafter $(UAPI_PATH)
 ifeq ("$(DEBUG)","1")
diff --git a/tools/net/ynl/lib/Makefile b/tools/net/ynl/lib/Makefile
index 9b98c0599600..7b3eae89982f 100644
--- a/tools/net/ynl/lib/Makefile
+++ b/tools/net/ynl/lib/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CC=gcc
+include ../../../scripts/Makefile.include
+
 CFLAGS += -std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow
 ifeq ("$(DEBUG)","1")
   CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan
diff --git a/tools/net/ynl/tests/Makefile b/tools/net/ynl/tests/Makefile
index 40827ca8e579..99ae7dcd6348 100644
--- a/tools/net/ynl/tests/Makefile
+++ b/tools/net/ynl/tests/Makefile
@@ -2,8 +2,8 @@
 # Makefile for YNL tests
 
 include ../Makefile.deps
+include ../../../scripts/Makefile.include
 
-CC=gcc
 CFLAGS += -std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \
 	-I../lib/ -I../generated/ -I../../../testing/selftests/ \
 	-idirafter $(UAPI_PATH)
diff --git a/tools/net/ynl/ynltool/Makefile b/tools/net/ynl/ynltool/Makefile
index 48b0f32050f0..85cc0840b403 100644
--- a/tools/net/ynl/ynltool/Makefile
+++ b/tools/net/ynl/ynltool/Makefile
@@ -1,12 +1,12 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
 include ../Makefile.deps
+include ../../../scripts/Makefile.include
 
 INSTALL	?= install
 prefix  ?= /usr
 
-CC := gcc
-CFLAGS := -Wall -Wextra -Werror -O2
+CFLAGS += -Wall -Wextra -Werror -O2
 ifeq ("$(DEBUG)","1")
   CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan
 endif
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next 2/2] selftests: drv-net: Use cross-compilation environment for the io_uring check
  2026-09-01 16:41 [PATCH net-next 0/2] selftests: drv-net: Allow cross-compiling the hardware tests Maxime Chevallier (Netdev Foundation)
  2026-09-01 16:41 ` [PATCH net-next 1/2] selftests: drv-net: ynl: Allow cross-compiling ynl and associated tools Maxime Chevallier (Netdev Foundation)
@ 2026-09-01 16:41 ` Maxime Chevallier (Netdev Foundation)
  2026-09-01 17:24   ` Matthieu Baerts
  1 sibling, 1 reply; 7+ messages in thread
From: Maxime Chevallier (Netdev Foundation) @ 2026-09-01 16:41 UTC (permalink / raw)
  To: Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Donald Hunter, Simon Horman, Shuah Khan, matttbe,
	Stanislav Fomichev
  Cc: Maxime Chevallier (Netdev Foundation), netdev, linux-kernel,
	thomas.petazzoni, linux-kselftest

To test for the presence of zerocopy support in the available liburing,
a small check program is compiled.

The CC value used for the io_uring library check defaults to the host
compiler, which will fail in cross-compiling environments.

Normally the CC for cross-compile is set in lib.mk, but this also
requires the test list to be set when we include it, and this check
needs to run first.

Note that this doesn't cover the LLVM cross-compiling case though.

Signed-off-by: Maxime Chevallier (Netdev Foundation) <maxime.chevallier@bootlin.com>
---
 tools/testing/selftests/drivers/net/hw/Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/testing/selftests/drivers/net/hw/Makefile b/tools/testing/selftests/drivers/net/hw/Makefile
index 78bb0169350b..0ebb4767cd57 100644
--- a/tools/testing/selftests/drivers/net/hw/Makefile
+++ b/tools/testing/selftests/drivers/net/hw/Makefile
@@ -1,5 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0+ OR MIT
 
+# Set CC for the io_uring check
+CC := $(CROSS_COMPILE)gcc
+
 # Check if io_uring supports zero-copy receive
 HAS_IOURING_ZCRX := $(shell \
 	echo -e '#include <liburing.h>\n' \
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next 2/2] selftests: drv-net: Use cross-compilation environment for the io_uring check
  2026-09-01 16:41 ` [PATCH net-next 2/2] selftests: drv-net: Use cross-compilation environment for the io_uring check Maxime Chevallier (Netdev Foundation)
@ 2026-09-01 17:24   ` Matthieu Baerts
  2026-09-01 20:45     ` Maxime Chevallier
  0 siblings, 1 reply; 7+ messages in thread
From: Matthieu Baerts @ 2026-09-01 17:24 UTC (permalink / raw)
  To: Maxime Chevallier (Netdev Foundation)
  Cc: netdev, linux-kernel, thomas.petazzoni, linux-kselftest,
	Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Donald Hunter, Simon Horman, Shuah Khan, Stanislav Fomichev

Hi Maxime,

Thank you for looking at that.

On 01/09/2026 18:41, Maxime Chevallier (Netdev Foundation) wrote:
> To test for the presence of zerocopy support in the available liburing,
> a small check program is compiled.
> 
> The CC value used for the io_uring library check defaults to the host
> compiler, which will fail in cross-compiling environments.
> 
> Normally the CC for cross-compile is set in lib.mk, but this also
> requires the test list to be set when we include it, and this check
> needs to run first.
> 
> Note that this doesn't cover the LLVM cross-compiling case though.

Maybe it is enough to just check if LLVM is set?
> Signed-off-by: Maxime Chevallier (Netdev Foundation) <maxime.chevallier@bootlin.com>
> ---
>  tools/testing/selftests/drivers/net/hw/Makefile | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/testing/selftests/drivers/net/hw/Makefile b/tools/testing/selftests/drivers/net/hw/Makefile
> index 78bb0169350b..0ebb4767cd57 100644
> --- a/tools/testing/selftests/drivers/net/hw/Makefile
> +++ b/tools/testing/selftests/drivers/net/hw/Makefile
> @@ -1,5 +1,8 @@
>  # SPDX-License-Identifier: GPL-2.0+ OR MIT
>  
> +# Set CC for the io_uring check
> +CC := $(CROSS_COMPILE)gcc

Could we have something similar to
tools/testing/selftests/riscv/cfi/Makefile:

  # Set CC for the io_uring check done before including lib.mk
  ifeq ($(LLVM)$(CC),cc)
  CC := $(CROSS_COMPILE)gcc
  endif

WDYT?

But that's possibly not needed for this simple check? I guess if gcc can
find liburing.h, clang should look at the same places.

>  # Check if io_uring supports zero-copy receive
>  HAS_IOURING_ZCRX := $(shell \
>  	echo -e '#include <liburing.h>\n' \

Cheers,
Matt

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next 2/2] selftests: drv-net: Use cross-compilation environment for the io_uring check
  2026-09-01 17:24   ` Matthieu Baerts
@ 2026-09-01 20:45     ` Maxime Chevallier
  2026-09-01 22:46       ` Jakub Kicinski
  0 siblings, 1 reply; 7+ messages in thread
From: Maxime Chevallier @ 2026-09-01 20:45 UTC (permalink / raw)
  To: Matthieu Baerts
  Cc: netdev, linux-kernel, thomas.petazzoni, linux-kselftest,
	Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Donald Hunter, Simon Horman, Shuah Khan, Stanislav Fomichev

Hi Matthieu,

On 9/1/26 19:24, Matthieu Baerts wrote:
> Hi Maxime,
>> +# Set CC for the io_uring check
>> +CC := $(CROSS_COMPILE)gcc
> 
> Could we have something similar to
> tools/testing/selftests/riscv/cfi/Makefile:
> 
>   # Set CC for the io_uring check done before including lib.mk
>   ifeq ($(LLVM)$(CC),cc)
>   CC := $(CROSS_COMPILE)gcc
>   endif
> 
> WDYT?

Ah this is better indeed IMO, I'll use that in V2 then, thanks for
the tips.

Initially I considered doing a larger rework of extracting the logic
in lib.mk that sets CC to the right value base on CROSS_COMPILE, LLVM
and ARCH into a dedicated .mk file that we would include at the top,
but at that time it seemed to be too big of a rework for just the
io_uring check.

It lead to some headache about double-inclusions and relative paths lookups
that far exceeded my Makefile skills :(

Thanks for the review,

Maxime

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next 1/2] selftests: drv-net: ynl: Allow cross-compiling ynl and associated tools
  2026-09-01 16:41 ` [PATCH net-next 1/2] selftests: drv-net: ynl: Allow cross-compiling ynl and associated tools Maxime Chevallier (Netdev Foundation)
@ 2026-09-01 22:42   ` Jakub Kicinski
  0 siblings, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2026-09-01 22:42 UTC (permalink / raw)
  To: Maxime Chevallier (Netdev Foundation)
  Cc: Andrew Lunn, davem, Eric Dumazet, Paolo Abeni, Donald Hunter,
	Simon Horman, Shuah Khan, matttbe, Stanislav Fomichev, netdev,
	linux-kernel, thomas.petazzoni, linux-kselftest

On Tue,  1 Sep 2026 18:41:58 +0200 Maxime Chevallier (Netdev
Foundation) wrote:
> Subject: [PATCH net-next 1/2] selftests: drv-net: ynl: Allow cross-compiling ynl and associated tools

>  tools/net/ynl/Makefile           | 1 +
>  tools/net/ynl/generated/Makefile | 3 ++-
>  tools/net/ynl/lib/Makefile       | 3 ++-
>  tools/net/ynl/tests/Makefile     | 2 +-
>  tools/net/ynl/ynltool/Makefile   | 4 ++--

nit: wrong subject prefix, this is touching real ynl

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next 2/2] selftests: drv-net: Use cross-compilation environment for the io_uring check
  2026-09-01 20:45     ` Maxime Chevallier
@ 2026-09-01 22:46       ` Jakub Kicinski
  0 siblings, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2026-09-01 22:46 UTC (permalink / raw)
  To: Maxime Chevallier
  Cc: Matthieu Baerts, netdev, linux-kernel, thomas.petazzoni,
	linux-kselftest, Andrew Lunn, davem, Eric Dumazet, Paolo Abeni,
	Donald Hunter, Simon Horman, Shuah Khan, Stanislav Fomichev

On Tue, 1 Sep 2026 22:45:47 +0200 Maxime Chevallier wrote:
> Hi Matthieu,
> 
> On 9/1/26 19:24, Matthieu Baerts wrote:
> > Hi Maxime,  
> >> +# Set CC for the io_uring check
> >> +CC := $(CROSS_COMPILE)gcc  
> > 
> > Could we have something similar to
> > tools/testing/selftests/riscv/cfi/Makefile:
> > 
> >   # Set CC for the io_uring check done before including lib.mk
> >   ifeq ($(LLVM)$(CC),cc)
> >   CC := $(CROSS_COMPILE)gcc
> >   endif
> > 
> > WDYT?  
> 
> Ah this is better indeed IMO, I'll use that in V2 then, thanks for
> the tips.
> 
> Initially I considered doing a larger rework of extracting the logic
> in lib.mk that sets CC to the right value base on CROSS_COMPILE, LLVM
> and ARCH into a dedicated .mk file that we would include at the top,
> but at that time it seemed to be too big of a rework for just the
> io_uring check.
> 
> It lead to some headache about double-inclusions and relative paths lookups
> that far exceeded my Makefile skills :(
> 
> Thanks for the review,

I assume you don't actually have luring for your cross- env? Could we
keep it simple and just declare luring as unavailable when cross
compiling? Because the probing compilation rule is probably missing 
more flags to make cross compilation work.

Ignore if selftests using luring do actually work for you after this
patch..

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-09-01 22:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-01 16:41 [PATCH net-next 0/2] selftests: drv-net: Allow cross-compiling the hardware tests Maxime Chevallier (Netdev Foundation)
2026-09-01 16:41 ` [PATCH net-next 1/2] selftests: drv-net: ynl: Allow cross-compiling ynl and associated tools Maxime Chevallier (Netdev Foundation)
2026-09-01 22:42   ` Jakub Kicinski
2026-09-01 16:41 ` [PATCH net-next 2/2] selftests: drv-net: Use cross-compilation environment for the io_uring check Maxime Chevallier (Netdev Foundation)
2026-09-01 17:24   ` Matthieu Baerts
2026-09-01 20:45     ` Maxime Chevallier
2026-09-01 22:46       ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox