[PATCH 3/6] test: fix race condition in ELF load tests

Stephen Hemminger stephen at networkplumber.org
Mon Jan 19 19:24:29 CET 2026


On Sun, 18 Jan 2026 12:09:10 -0800
Stephen Hemminger <stephen at networkplumber.org> wrote:

> The BPF ELF tests sporadically fail with EINVAL when loading from
> the temporary file. This is a race condition where the BPF loader
> reads the file before the data is fully flushed to disk.
> 
> Add fsync() before close() in create_temp_bpf_file() to ensure the
> BPF object data is visible on the filesystem before attempting to
> load it.
> 
> Also fix two related issues found during review
> - Add missing TEST_ASSERT for mempool creation in test_bpf_elf_tx_load
> - Initialize port variable in test_bpf_elf_rx_load to avoid undefined
>   behavior in cleanup path if null_vdev_setup fails early
> 
> Fixes: cf1e03f881af ("test/bpf: add ELF loading")
> Cc: stable at dpdk.org
> 
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> ---
>  app/test/test_bpf.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/app/test/test_bpf.c b/app/test/test_bpf.c
> index a7d56f8d86..03705075d8 100644
> --- a/app/test/test_bpf.c
> +++ b/app/test/test_bpf.c
> @@ -3311,6 +3311,8 @@ create_temp_bpf_file(const uint8_t *data, size_t size, const char *name)
>  
>  	/* Write BPF object data */
>  	written = write(fd, data, size);
> +	if (written == (ssize_t)size)
> +		fsync(fd);

Agree, I don't think fsync is really needed.
This was a bandaid that changed the timing. The root cause of the
test failures was the overlap of parallel tests, so let me drop this bit.


More information about the stable mailing list