Skip to contentSkip to conversation

manage net/null dependency for tests

PATCH Superseded Bruce Richardson 4 participants 24 messages Jan 22 – Mar 3 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover manage net/null dependency for tests

A number of unit tests take advantage of net_null driver to use as a dummy packet source. When this driver is disabled we then get tests failures in fast-tests. Fix these by recording the dependency appropriately or by skipping test sections if the dependency isn't present. The final patch is an optional extra - it marks the null driver down to always be built.

Bruce Richardson (3):
test/bpf: skip some testing if null net driver not present
test: fix missing dependency on null networking driver
drivers: always enable the null net driver [RFC]

 app/test/meson.build | 4 ++--
 app/test/test_bpf.c  | 9 +++++++++
 drivers/meson.build  | 2 ++
 3 files changed, 13 insertions(+), 2 deletions(-)

--
2.51.0

#1 lore raw

PATCH 1/3 test/bpf: skip some testing if null net driver not present

Some of the BPF tests require the net/null driver to be present, so skip those tests if it's not found. If the early part of the tests fail, return that failure - on if they succeed do we return skipped on the missing dependency.

---
 app/test/test_bpf.c | 9 +++++++++
 1 file changed, 9 insertions(+)
app/test/test_bpf.c +9 -0
index a7d56f8d86..ae588acb16 100644
@@ -3725,6 +3725,11 @@ test_bpf_elf_rx_load(void)
 	return ret == 0 ? TEST_SUCCESS : TEST_FAILED;
 }
 
+#ifdef RTE_NET_NULL
+static const bool have_net_null = true;
+#else
+static const bool have_net_null;  /* statics default to false */
+#endif
 
 static int
 test_bpf_elf(void)
@@ -3732,6 +3737,10 @@ test_bpf_elf(void)
 	int ret;
 
 	ret = test_bpf_elf_load();
+	if (ret == TEST_SUCCESS && !have_net_null) {
+		printf("net_null driver not available, skipping remainder of BPF tests\n");
+		return TEST_SKIPPED;
+	}
 	if (ret == TEST_SUCCESS)
 		ret = test_bpf_elf_tx_load();
 	if (ret == TEST_SUCCESS)
Signature · 1 line
2.51.0
#2 lore raw

Re: [PATCH 1/3] test/bpf: skip some testing if null net driver not present

Quoted 27 lines · On Thu, 22 Jan 2026 12:23:51 +0000 Bruce Richardson…

Some of the BPF tests require the net/null driver to be present, so skip those tests if it's not found. If the early part of the tests fail, return that failure - on if they succeed do we return skipped on the missing dependency.

---
 app/test/test_bpf.c | 9 +++++++++
 1 file changed, 9 insertions(+)
app/test/test_bpf.c +5 -0
index a7d56f8d86..ae588acb16 100644
@@ -3725,6 +3725,11 @@ test_bpf_elf_rx_load(void)
 	return ret == 0 ? TEST_SUCCESS : TEST_FAILED;
 }
 
+#ifdef RTE_NET_NULL
+static const bool have_net_null = true;
+#else
+static const bool have_net_null;  /* statics default to false */
+#endif
 
 static int
 test_bpf_elf(void)

app/test/test_bpf.c test_bpf_elf(void) · line 3746

Quoted 10 lines
app/test/test_bpf.c +4 -0
@@ -3732,6 +3737,10 @@ test_bpf_elf(void)
 	int ret;
 
 	ret = test_bpf_elf_load();
+	if (ret == TEST_SUCCESS && !have_net_null) {
+		printf("net_null driver not available, skipping remainder of BPF tests\n");
+		return TEST_SKIPPED;
+	}
 	if (ret == TEST_SUCCESS)
 		ret = test_bpf_elf_tx_load();
 	if (ret == TEST_SUCCESS)

Only the tests doing ELF load need a device.
I think that part can be handled at compile time with the #ifdef
or by splitting the ELF load tests to another file and doing it with meson.build

#3 lore raw

Re: [PATCH 1/3] test/bpf: skip some testing if null net driver not present

Quoted 32 lines · Stephen Hemminger
Quoted 29 lines · On Thu, 22 Jan 2026 12:23:51 +0000 Bruce Richardson…

Some of the BPF tests require the net/null driver to be present, so skip those tests if it's not found. If the early part of the tests fail, return that failure - on if they succeed do we return skipped on the missing dependency.

---
 app/test/test_bpf.c | 9 +++++++++
 1 file changed, 9 insertions(+)
app/test/test_bpf.c +5 -0
index a7d56f8d86..ae588acb16 100644
@@ -3725,6 +3725,11 @@ test_bpf_elf_rx_load(void)
 	return ret == 0 ? TEST_SUCCESS : TEST_FAILED;
 }
 
+#ifdef RTE_NET_NULL
+static const bool have_net_null = true;
+#else
+static const bool have_net_null;  /* statics default to false */
+#endif
 
 static int
 test_bpf_elf(void)
@@ -3732,6 +3737,10 @@ test_bpf_elf(void)
 	int ret;
 
Quoted 12 lines

app/test/test_bpf.c test_bpf_elf(void) · line 3746

Quoted 8 lines
app/test/test_bpf.c +4 -0
 	ret = test_bpf_elf_load();
+	if (ret == TEST_SUCCESS && !have_net_null) {
+		printf("net_null driver not available, skipping remainder of BPF tests\n");
+		return TEST_SKIPPED;
+	}
 	if (ret == TEST_SUCCESS)
 		ret = test_bpf_elf_tx_load();
 	if (ret == TEST_SUCCESS)

Only the tests doing ELF load need a device.
I think that part can be handled at compile time with the #ifdef
or by splitting the ELF load tests to another file and doing it with meson.build

We could do that using ifdefs, but it means adding ifdefs around lots of code blocks as the compiler will complain about unused functions if we just ifdef out the calls to them. That's why I took this approach, to have the minimal possible ifdef. If we don't want to mark the test as skipped we can just change it to return success immedately if we don't have the null driver.

/Bruce

#4 lore raw

PATCH 1/1 test/bpf: skip the BPF ELF load tests if net null missing

In reply to Bruce Richardson

The BPF filtering tests need NULL PMD vdev to work.

---
 app/test/test_bpf.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
app/test/test_bpf.c +11 -3
index 0e969f9f13..78998c6194 100644
@@ -3280,7 +3280,15 @@ test_bpf(void)
 
 REGISTER_FAST_TEST(bpf_autotest, NOHUGE_OK, ASAN_OK, test_bpf);
 
-#ifdef TEST_BPF_ELF_LOAD
+/*
+ * The BPF elf load tests needs the BPF programs to be successfully
+ * compiled into generated file bpf_test.h. This means having
+ * clang with BPF target and xxd command to encode object.
+ *
+ * Test also needs the NULL PMD to be able to have something
+ * to insert filter onto.
+ */
+#if defined(RTE_NET_NULL) && defined(TEST_BPF_ELF_LOAD)
 
 /*
  * Helper function to write BPF object data to temporary file.
@@ -3746,11 +3754,11 @@ test_bpf_elf(void)
 static int
 test_bpf_elf(void)
 {
-	printf("BPF compile not supported, skipping test\n");
+	printf("BPF compile or NULL PMD not supported, skipping test\n");
 	return TEST_SKIPPED;
 }
 
-#endif /* !TEST_BPF_ELF_LOAD */
+#endif /* !(TEST_BPF_ELF_LOAD && RTE_NULL) */
 
 REGISTER_FAST_TEST(bpf_elf_autotest, NOHUGE_OK, ASAN_OK, test_bpf_elf);
 
Signature · 1 line
2.51.0
Acked-by on v1 1/1
#5 lore raw

RE: [PATCH] test/bpf: skip the BPF ELF load tests if net null missing

Quoted 6 lines

From: Stephen Hemminger [mailto:[email protected]]
Sent: Thursday, 22 January 2026 23.17

The BPF filtering tests need NULL PMD vdev to work.

With or without suggested change,

Quoted 12 lines
---
 app/test/test_bpf.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
app/test/test_bpf.c +0 -0
index 0e969f9f13..78998c6194 100644
@@ -3280,7 +3280,15 @@ test_bpf(void)
 
 REGISTER_FAST_TEST(bpf_autotest, NOHUGE_OK, ASAN_OK, test_bpf);
 

app/test/test_bpf.c test_bpf(void) · line 3291

Quoted 10 lines
app/test/test_bpf.c +9 -1
-#ifdef TEST_BPF_ELF_LOAD
+/*
+ * The BPF elf load tests needs the BPF programs to be successfully
+ * compiled into generated file bpf_test.h. This means having
+ * clang with BPF target and xxd command to encode object.
+ *
+ * Test also needs the NULL PMD to be able to have something
+ * to insert filter onto.
+ */
+#if defined(RTE_NET_NULL) && defined(TEST_BPF_ELF_LOAD)

nit:
Consider swapping the order:
#if defined(TEST_BPF_ELF_LOAD) && defined(RTE_NET_NULL)

Quoted 20 lines
app/test/test_bpf.c +2 -3
 /*
  * Helper function to write BPF object data to temporary file.
@@ -3746,11 +3754,11 @@ test_bpf_elf(void)
 static int
 test_bpf_elf(void)
 {
-	printf("BPF compile not supported, skipping test\n");
+	printf("BPF compile or NULL PMD not supported, skipping test\n");
 	return TEST_SKIPPED;
 }
 
-#endif /* !TEST_BPF_ELF_LOAD */
+#endif /* !(TEST_BPF_ELF_LOAD && RTE_NULL) */
 
 REGISTER_FAST_TEST(bpf_elf_autotest, NOHUGE_OK, ASAN_OK,
 test_bpf_elf);
 
--

2.51.0

#7 lore raw

PATCH 2/3 test: fix missing dependency on null networking driver

In reply to Bruce Richardson

The pcapng and vdev autotests depend upon the null networking driver in order to run, so record that dependency in the meson file, so they are skipped if it's not present.

Fixes 50823f30f0c8 ("test: build using per-file dependencies")
---
 app/test/meson.build | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
app/test/meson.build +2 -2
index f4d04a6e42..0195a31c95 100644
@@ -135,7 +135,7 @@ source_file_deps = {
     'test_mp_secondary.c': ['hash'],
     'test_net_ether.c': ['net'],
     'test_net_ip6.c': ['net'],
-    'test_pcapng.c': ['ethdev', 'net', 'pcapng', 'bus_vdev'],
+    'test_pcapng.c': ['ethdev', 'net', 'pcapng', 'bus_vdev', 'net_null'],
     'test_pdcp.c': ['eventdev', 'pdcp', 'net', 'timer', 'security'],
     'test_pdump.c': ['pdump'] + sample_packet_forward_deps,
     'test_per_lcore.c': [],
@@ -209,7 +209,7 @@ source_file_deps = {
     'test_trace.c': [],
     'test_trace_perf.c': [],
     'test_trace_register.c': [],
-    'test_vdev.c': ['kvargs', 'bus_vdev'],
+    'test_vdev.c': ['kvargs', 'bus_vdev', 'net_null'],
     'test_version.c': [],
 }
 
Signature · 1 line
2.51.0
#8 lore raw

PATCH 3/3 drivers: always enable the null net driver [RFC]

In reply to Bruce Richardson

Having the net_null driver always available can be convenient and allows use by unit tests, so add this trivial driver to the always-enable list.

---
I'm not sure if we want this to be always enabled or not, so sending this as an RFC. I can see definite advantages to doing so, but I also dislike having too many components on the always-enable list.

Since I'm ambivilent myself, including this patch so the community can decide.

---
 drivers/meson.build | 2 ++
 1 file changed, 2 insertions(+)
drivers/meson.build +2 -0
index 3fe3be48fb..9ed0dba786 100644
@@ -80,6 +80,8 @@ endif
 always_enable = ['bus/pci', 'bus/vdev']
 # we always need a mempool driver, and ring is default, so make it mandatory
 always_enable += ['mempool/ring']
+# unit tests take advantage of net/null driver, so always enable it
+always_enable += ['net/null']
 enable_drivers += always_enable
 
 default_cflags = machine_args
Signature · 1 line
2.51.0
#9 lore raw

RE: [PATCH 3/3] drivers: always enable the null net driver [RFC]

Quoted 10 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Thursday, 22 January 2026 13.24

Having the net_null driver always available can be convenient and allows
use by unit tests, so add this trivial driver to the always-enable list.

Quoted 7 lines

---
I'm not sure if we want this to be always enabled or not, so sending this as an RFC. I can see definite advantages to doing so, but I also dislike having too many components on the always-enable list.

Since I'm ambivilent myself, including this patch so the community can decide.

I don't think real applications use this.
If they do, they can include it manually.

My main objection is:
We are setting the wrong precedence if we make stuff like this mandatory for convenience.

But I agree with the reason you are suggesting it.

Is there some other way it can be enabled for unit tests? Maybe the null driver can depend on the unit tests being built?

I don't mind that the driver is being built.
I just don't want it included by default when statically linking a monolithic application.

I'm flexible on this RFC, so it's a very soft NAK from me.
If it can be disabled at build time, I'm OK with it. (But still concerned about setting the wrong precedence.)

Quoted 20 lines
---
 drivers/meson.build | 2 ++
 1 file changed, 2 insertions(+)
drivers/meson.build +0 -0
index 3fe3be48fb..9ed0dba786 100644
@@ -80,6 +80,8 @@ endif
 always_enable = ['bus/pci', 'bus/vdev']
 # we always need a mempool driver, and ring is default, so make it

mandatory
always_enable += ['mempool/ring']

drivers/meson.build +2 -1
+# unit tests take advantage of net/null driver, so always enable it
+always_enable += ['net/null']
 enable_drivers += always_enable
 
 default_cflags = machine_args
--

2.51.0

#10 lore raw

Re: [PATCH 3/3] drivers: always enable the null net driver [RFC]

Quoted 26 lines · Morten Brørup
Quoted 10 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Thursday, 22 January 2026 13.24

Having the net_null driver always available can be convenient and allows
use by unit tests, so add this trivial driver to the always-enable list.

Quoted 7 lines

---
I'm not sure if we want this to be always enabled or not, so sending this as an RFC. I can see definite advantages to doing so, but I also dislike having too many components on the always-enable list.

Since I'm ambivilent myself, including this patch so the community can decide.

I don't think real applications use this.
If they do, they can include it manually.

My main objection is:
We are setting the wrong precedence if we make stuff like this mandatory for convenience.

But I agree with the reason you are suggesting it.

Quoted 9 lines

Is there some other way it can be enabled for unit tests? Maybe the null driver can depend on the unit tests being built?

I don't mind that the driver is being built.
I just don't want it included by default when statically linking a monolithic application.

I'm flexible on this RFC, so it's a very soft NAK from me.
If it can be disabled at build time, I'm OK with it. (But still concerned about setting the wrong precedence.)

Yes, I agree.

Why I'm proposing this is because, in order to give me faster rebuilds and because of the hardware I have available to me, I generally set up my builds with "-Denable_drivers=net/intel/*", since that really speeds up my dev-build-test cycle. In doing so, though, I do miss out on having some unit tests available when I run the fast-test suite, which is why I suggested this addition in case there are others who limit the builds to just the hardware they are using.

/Bruce

#11 lore raw

RE: [PATCH 3/3] drivers: always enable the null net driver [RFC]

Quoted 47 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Thursday, 22 January 2026 14.32

Quoted 8 lines · Morten Brørup
Quoted 8 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Thursday, 22 January 2026 13.24

Having the net_null driver always available can be convenient and allows
use by unit tests, so add this trivial driver to the always-enable list.

Quoted 4 lines
Quoted 4 lines

---
I'm not sure if we want this to be always enabled or not, so

sending

Quoted 1 line
Quoted 1 line

this as an RFC. I can see definite advantages to doing so, but I

also

Quoted 3 lines
Quoted 3 lines

dislike having too many components on the always-enable list.

Since I'm ambivilent myself, including this patch so the community

can

Quoted 7 lines
Quoted 1 line

decide.

I don't think real applications use this.
If they do, they can include it manually.

My main objection is:
We are setting the wrong precedence if we make stuff like this

mandatory for convenience.

Quoted 8 lines

But I agree with the reason you are suggesting it.

Is there some other way it can be enabled for unit tests? Maybe the null driver can depend on the unit tests being built?

I don't mind that the driver is being built.
I just don't want it included by default when statically linking a

monolithic application.

Quoted 3 lines

I'm flexible on this RFC, so it's a very soft NAK from me. If it can be disabled at build time, I'm OK with it. (But still

concerned about setting the wrong precedence.)

Quoted 1 line

Yes, I agree.

Quoted 10 lines

Why I'm proposing this is because, in order to give me faster rebuilds and
because of the hardware I have available to me, I generally set up my builds with "-Denable_drivers=net/intel/*", since that really speeds up my
dev-build-test cycle. In doing so, though, I do miss out on having some unit tests available when I run the fast-test suite, which is why I suggested this addition in case there are others who limit the builds to
just the hardware they are using.

You can build with "-Denable_drivers=net/intel/*,net/null".

Then I'll suggest an alternative to this patch:
Change the fast-test application, so it emits an informational message about which tests are being skipped because the net/null driver is missing.

#12 lore raw

Re: [PATCH 3/3] drivers: always enable the null net driver [RFC]

Quoted 58 lines · Morten Brørup
Quoted 47 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Thursday, 22 January 2026 14.32

Quoted 8 lines · Morten Brørup
Quoted 8 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Thursday, 22 January 2026 13.24

Having the net_null driver always available can be convenient and allows
use by unit tests, so add this trivial driver to the always-enable list.

Quoted 4 lines
Quoted 4 lines

---
I'm not sure if we want this to be always enabled or not, so

sending

Quoted 1 line
Quoted 1 line

this as an RFC. I can see definite advantages to doing so, but I

also

Quoted 3 lines
Quoted 3 lines

dislike having too many components on the always-enable list.

Since I'm ambivilent myself, including this patch so the community

can

Quoted 7 lines
Quoted 1 line

decide.

I don't think real applications use this.
If they do, they can include it manually.

My main objection is:
We are setting the wrong precedence if we make stuff like this

mandatory for convenience.

Quoted 8 lines

But I agree with the reason you are suggesting it.

Is there some other way it can be enabled for unit tests? Maybe the null driver can depend on the unit tests being built?

I don't mind that the driver is being built.
I just don't want it included by default when statically linking a

monolithic application.

Quoted 3 lines

I'm flexible on this RFC, so it's a very soft NAK from me. If it can be disabled at build time, I'm OK with it. (But still

concerned about setting the wrong precedence.)

Quoted 1 line

Yes, I agree.

Quoted 10 lines

Why I'm proposing this is because, in order to give me faster rebuilds and
because of the hardware I have available to me, I generally set up my builds with "-Denable_drivers=net/intel/*", since that really speeds up my
dev-build-test cycle. In doing so, though, I do miss out on having some unit tests available when I run the fast-test suite, which is why I suggested this addition in case there are others who limit the builds to
just the hardware they are using.

Quoted 5 lines

You can build with "-Denable_drivers=net/intel/*,net/null".

Then I'll suggest an alternative to this patch:
Change the fast-test application, so it emits an informational message about which tests are being skipped because the net/null driver is missing.

That is sadly non-trivial, and if we do so for net-null, we should also do so for a bunch of other components where we disable tests if they are missing. But the idea of just informing the user rather than force-enabling the driver is a good one.

#13 lore raw

Re: [PATCH 3/3] drivers: always enable the null net driver [RFC]

Quoted 8 lines · On Thu, 22 Jan 2026 14:59:21 +0000 Bruce Richardson…
Quoted 4 lines

Then I'll suggest an alternative to this patch:
Change the fast-test application, so it emits an informational message about which tests are being skipped because the net/null driver is missing.

That is sadly non-trivial, and if we do so for net-null, we should also do so for a bunch of other components where we disable tests if they are missing. But the idea of just informing the user rather than force-enabling the driver is a good one.

I am ok with either of three solutions:
- require it to be always enabled
- in meson.build, add dependency on net_null for tests that need it. (that is what my patches did)
- add per test checks for vdev_init failing and return TEST_SKIPPED There also is unsupported status, but that doesn't appear to be used or work right

Doing dependency at build time is my preference.

#14 lore raw

Re: [PATCH 3/3] drivers: always enable the null net driver [RFC]

In reply to Bruce Richardson
Quoted 26 lines · Bruce Richardson
Quoted 24 lines · Morten Brørup
Quoted 10 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Thursday, 22 January 2026 13.24

Having the net_null driver always available can be convenient and allows
use by unit tests, so add this trivial driver to the always-enable list.

Quoted 7 lines

---
I'm not sure if we want this to be always enabled or not, so sending this as an RFC. I can see definite advantages to doing so, but I also dislike having too many components on the always-enable list.

Since I'm ambivilent myself, including this patch so the community can decide.

I don't think real applications use this.
If they do, they can include it manually.

My main objection is:
We are setting the wrong precedence if we make stuff like this mandatory for convenience.

Quoted 7 lines
Quoted 7 lines

But I agree with the reason you are suggesting it.

Is there some other way it can be enabled for unit tests? Maybe the null driver can depend on the unit tests being built?

I don't mind that the driver is being built.
I just don't want it included by default when statically linking a monolithic application.

Same, I don't want a driver with almost no maintenance on it (even if it is trivial code) to be linked in a final application. (it would be a pity to get a CVE because of net/null ;-))

Quoted 6 lines
Quoted 4 lines

I'm flexible on this RFC, so it's a very soft NAK from me.
If it can be disabled at build time, I'm OK with it. (But still concerned about setting the wrong precedence.)

Yes, I agree.

Quoted 7 lines

Why I'm proposing this is because, in order to give me faster rebuilds and because of the hardware I have available to me, I generally set up my builds with "-Denable_drivers=net/intel/*", since that really speeds up my dev-build-test cycle. In doing so, though, I do miss out on having some unit tests available when I run the fast-test suite, which is why I suggested this addition in case there are others who limit the builds to just the hardware they are using.

Unit tests are mainly run by the CI or DPDK developers, so how about putting this addition in the always enabled list under the developer_mode check?

Signature · 1 line
David Marchand
#15 lore raw

Re: [PATCH 3/3] drivers: always enable the null net driver [RFC]

Quoted 55 lines · David Marchand
Quoted 26 lines · Bruce Richardson
Quoted 24 lines · Morten Brørup
Quoted 10 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Thursday, 22 January 2026 13.24

Having the net_null driver always available can be convenient and allows
use by unit tests, so add this trivial driver to the always-enable list.

Quoted 7 lines

---
I'm not sure if we want this to be always enabled or not, so sending this as an RFC. I can see definite advantages to doing so, but I also dislike having too many components on the always-enable list.

Since I'm ambivilent myself, including this patch so the community can decide.

I don't think real applications use this.
If they do, they can include it manually.

My main objection is:
We are setting the wrong precedence if we make stuff like this mandatory for convenience.

Quoted 7 lines
Quoted 7 lines

But I agree with the reason you are suggesting it.

Is there some other way it can be enabled for unit tests? Maybe the null driver can depend on the unit tests being built?

I don't mind that the driver is being built.
I just don't want it included by default when statically linking a monolithic application.

Same, I don't want a driver with almost no maintenance on it (even if it is trivial code) to be linked in a final application. (it would be a pity to get a CVE because of net/null ;-))

Quoted 6 lines
Quoted 4 lines

I'm flexible on this RFC, so it's a very soft NAK from me.
If it can be disabled at build time, I'm OK with it. (But still concerned about setting the wrong precedence.)

Yes, I agree.

Quoted 7 lines

Why I'm proposing this is because, in order to give me faster rebuilds and because of the hardware I have available to me, I generally set up my builds with "-Denable_drivers=net/intel/*", since that really speeds up my dev-build-test cycle. In doing so, though, I do miss out on having some unit tests available when I run the fast-test suite, which is why I suggested this addition in case there are others who limit the builds to just the hardware they are using.

Quoted 4 lines

Unit tests are mainly run by the CI or DPDK developers, so how about putting this addition in the always enabled list under the developer_mode check?

Yep could work. Possibly also taking a modified version of Morten's suggestion about warning about skipped tests, what about just emitting a warning from meson if we are in developer mode and we haven't the net-null driver enabled?

/Bruce

#16 lore raw

RE: [PATCH 3/3] drivers: always enable the null net driver [RFC]

Quoted 62 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Thursday, 22 January 2026 15.57

Quoted 8 lines · David Marchand
Quoted 6 lines · Bruce Richardson
Quoted 4 lines · Morten Brørup
Quoted 4 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Thursday, 22 January 2026 13.24

Having the net_null driver always available can be convenient

and

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

allows
use by unit tests, so add this trivial driver to the always-

enable

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

list.

---
I'm not sure if we want this to be always enabled or not, so

sending

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

this as an RFC. I can see definite advantages to doing so, but

I also

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

dislike having too many components on the always-enable list.

Since I'm ambivilent myself, including this patch so the

community can

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line

decide.

I don't think real applications use this.
If they do, they can include it manually.

My main objection is:
We are setting the wrong precedence if we make stuff like this

mandatory for convenience.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

But I agree with the reason you are suggesting it.

Is there some other way it can be enabled for unit tests? Maybe the null driver can depend on the unit tests being built?

I don't mind that the driver is being built.
I just don't want it included by default when statically linking

a monolithic application.

Quoted 9 lines

Same, I don't want a driver with almost no maintenance on it (even if it is trivial code) to be linked in a final application. (it would be a pity to get a CVE because of net/null ;-))

Quoted 3 lines
Quoted 3 lines

I'm flexible on this RFC, so it's a very soft NAK from me. If it can be disabled at build time, I'm OK with it. (But still

concerned about setting the wrong precedence.)

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

Yes, I agree.

Why I'm proposing this is because, in order to give me faster

rebuilds and

Quoted 1 line
Quoted 1 line

because of the hardware I have available to me, I generally set up

Quoted 14 lines

my

Quoted 1 line
Quoted 1 line

builds with "-Denable_drivers=net/intel/*", since that really

speeds up my

Quoted 1 line
Quoted 1 line

dev-build-test cycle. In doing so, though, I do miss out on having

some

Quoted 2 lines
Quoted 2 lines

unit tests available when I run the fast-test suite, which is why I suggested this addition in case there are others who limit the

builds to

Quoted 6 lines
Quoted 1 line

just the hardware they are using.

Unit tests are mainly run by the CI or DPDK developers, so how about putting this addition in the always enabled list under the developer_mode check?

I like this idea, but there's a similar risk of adding unnecessary stuff; now it's only limited to developer_mode.

E.g. what else should be added in developer_mode to extend testing beyond what the developer explicitly configures?

And what if the developer doesn't want these added tests (considering them a waste of time and resources)?

Quoted 7 lines

Yep could work. Possibly also taking a modified version of Morten's suggestion about warning about skipped tests, what about just emitting a
warning from meson if we are in developer mode and we haven't the net- null
driver enabled?

I like this idea.
But it requires some sort of coordination/synchronization between development of the test applications and the meson build script. I.e. when developing a new test case, dependencies need to be considered and possibly worked into the meson build script. This coordination will probably be forgotten.
But even if forgotten, it will be remembered again next time a real need occurs.

#17 lore raw

v2 cover improve net/null dependency handling for tests

In reply to Bruce Richardson

A number of unit tests take advantage of net_null driver to use as a dummy packet source. When this driver is disabled we then get tests failures in fast-tests. Fix these by recording the dependency appropriately or by skipping test sections if the dependency isn't present.

V2: reworked changes following feedback, discussion and other upstream
changes

Bruce Richardson (4):
test/event_eth_rx_adapter: skip tests if no ethdevs test/event_eth_tx_adapter: remove dependency on NULL PMD
test: fix missing dependency on null networking driver build/tests: add warning for missing NULL PMD dependency

 app/test/meson.build                 | 10 ++++++++--
 app/test/test_event_eth_rx_adapter.c | 14 ++++++++++----
 app/test/test_event_eth_tx_adapter.c |  4 ++++
 3 files changed, 22 insertions(+), 6 deletions(-)

--
2.51.0

#18 lore raw

PATCH v2 1/4 test/event_eth_rx_adapter: skip tests if no ethdevs

If no ethdevs are present and devices cannot be created via net_null driver, skip the tests rather than failing them.

---
 app/test/test_event_eth_rx_adapter.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
app/test/test_event_eth_rx_adapter.c +10 -4
index 2b623bfb28..ae428b3333 100644
@@ -251,8 +251,11 @@ testsuite_setup(void)
 	if (!count) {
 		printf("Testing with net_null device\n");
 		err = rte_vdev_init("net_null", NULL);
-		TEST_ASSERT(err == 0, "Failed to create net_null. err=%d",
-			    err);
+		if (err != 0) {
+			printf("Failed to create net_null, skipping tests. err=%d\n",
+				err);
+			return TEST_SKIPPED;
+		}
 		eth_dev_created = true;
 	}
 
@@ -311,8 +314,11 @@ testsuite_setup_rx_intr(void)
 	if (!count) {
 		printf("Testing with net_null device\n");
 		err = rte_vdev_init("net_null", NULL);
-		TEST_ASSERT(err == 0, "Failed to create net_null. err=%d",
-			    err);
+		if (err != 0) {
+			printf("Failed to create net_null, skipping tests. err=%d\n",
+				err);
+			return TEST_SKIPPED;
+		}
 		eth_dev_created = true;
 	}
 
Signature · 1 line
2.51.0
#19 lore raw

PATCH v2 2/4 test/event_eth_tx_adapter: remove dependency on NULL PMD

In reply to Bruce Richardson

The eventdev eth Tx adapter only uses the net_null driver for the final test case within the suite. Rather than adding an explicit dependency on that driver, just report the last case as skipped if not present.

---
 app/test/test_event_eth_tx_adapter.c | 4 ++++
 1 file changed, 4 insertions(+)
app/test/test_event_eth_tx_adapter.c +4 -0
index a128a4f2c2..bec298a8b8 100644
@@ -937,6 +937,7 @@ tx_adapter_set_get_params(void)
 static int
 tx_adapter_dynamic_device(void)
 {
+#ifdef RTE_NET_NULL
 	uint16_t port_id = rte_eth_dev_count_avail();
 	const char *null_dev[2] = { "eth_null0", "eth_null1" };
 	struct rte_eth_conf dev_conf;
@@ -977,6 +978,9 @@ tx_adapter_dynamic_device(void)
 		rte_vdev_uninit(null_dev[i]);
 
 	return TEST_SUCCESS;
+#else
+	return TEST_SKIPPED;
+#endif
 }
 
 static struct unit_test_suite event_eth_tx_tests = {
Signature · 1 line
2.51.0
#20 lore raw

PATCH v2 3/4 test: fix missing dependency on null networking driver

In reply to Bruce Richardson

A number of tests depend upon the null networking driver in order to run, so record that dependency in the meson file, so they are skipped if it's not present.

Fixes 50823f30f0c8 ("test: build using per-file dependencies")
---
 app/test/meson.build | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
app/test/meson.build +2 -2
index 4fd8670e05..31c966d97e 100644
@@ -112,7 +112,7 @@ source_file_deps = {
         'net'] + packet_burst_generator_deps + virtual_pmd_deps,
     'test_link_bonding_mode4.c': ['ethdev', 'net_ring', 'net_bond',
         'net'] + packet_burst_generator_deps,
-    'test_link_bonding_rssconf.c': ['ethdev', 'bus_vdev', 'net_bond'],
+    'test_link_bonding_rssconf.c': ['ethdev', 'bus_vdev', 'net_bond', 'net_null'],
     'test_logs.c': [],
     'test_lpm.c': ['net', 'lpm'],
     'test_lpm6.c': ['lpm'],
@@ -209,7 +209,7 @@ source_file_deps = {
     'test_trace.c': [],
     'test_trace_perf.c': [],
     'test_trace_register.c': [],
-    'test_vdev.c': ['kvargs', 'bus_vdev'],
+    'test_vdev.c': ['kvargs', 'bus_vdev', 'net_null'],
     'test_version.c': [],
 }
 
Signature · 1 line
2.51.0
#21 lore raw

PATCH v2 4/4 build/tests: add warning for missing NULL PMD dependency

In reply to Bruce Richardson

In developer builds, warn the user if they are building the unit tests but don't have net_null enabled, since a number of suites and test cases within suites depend on that to create dummy ethdev devices for testing.

---
 app/test/meson.build | 6 ++++++
 1 file changed, 6 insertions(+)
app/test/meson.build +6 -0
index 31c966d97e..5dde50b181 100644
@@ -218,6 +218,12 @@ source_file_ext_deps = {
     'test_pcapng.c': ['pcap'],
 }
 
+# the NULL ethdev is used by a number of tests, in some cases as an optional dependency.
+# for developer builds, warn user if its missing and we are building the tests.
+if not dpdk_conf.has('RTE_NET_NULL') and developer_mode
+    warning('For unit testing, the net/null PMD should be enabled in the build to enable tests that depend on it.')
+endif
+
 def_lib = get_option('default_library')
 foreach f, f_deps : source_file_deps
     has_deps = true
Signature · 1 line
2.51.0
#22 lore raw

RE: [PATCH v2 0/4] improve net/null dependency handling for tests

In reply to Bruce Richardson
Quoted 11 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Thursday, 19 February 2026 18.40

A number of unit tests take advantage of net_null driver to use as a dummy packet source. When this driver is disabled we then get tests failures in fast-tests. Fix these by recording the dependency appropriately or by skipping test sections if the dependency isn't present.

V2: reworked changes following feedback, discussion and other upstream
changes

A solution very much to my taste!

#23 lore raw

Re: [PATCH v2 0/4] improve net/null dependency handling for tests

In reply to Bruce Richardson
Quoted 16 lines · Bruce Richardson

A number of unit tests take advantage of net_null driver to use as a dummy packet source. When this driver is disabled we then get tests failures in fast-tests. Fix these by recording the dependency appropriately or by skipping test sections if the dependency isn't present.

V2: reworked changes following feedback, discussion and other upstream
changes

Bruce Richardson (4):
test/event_eth_rx_adapter: skip tests if no ethdevs test/event_eth_tx_adapter: remove dependency on NULL PMD
test: fix missing dependency on null networking driver build/tests: add warning for missing NULL PMD dependency

Quoted 4 lines
 app/test/meson.build                 | 10 ++++++++--
 app/test/test_event_eth_rx_adapter.c | 14 ++++++++++----
 app/test/test_event_eth_tx_adapter.c |  4 ++++
 3 files changed, 22 insertions(+), 6 deletions(-)

Series applied, thanks.

Signature · 1 line
David Marchand