Skip to contentSkip to conversation

selftests/ublk: use the configured kernel UAPI headers

PATCH In review Sasha Levin 2 participants 2 messages Nov 3

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 selftests/ublk: use the configured kernel UAPI headers

With generated headers in an output directory, the hardcoded source-tree include path falls through to distribution headers. New ublk flags and structure members, including UBLK_F_IO_DESC_SIZE, are then missing.

Use KHDR_INCLUDES to consume the headers from the kernel under test, and add the headers target as an order-only prerequisite of the ublk programs, as nolibc-test does, so that a standalone build installs them first. Baseline builds fail on the missing definitions; GCC 14 and Clang 21 builds succeed with the output-directory headers and target liburing development files available.

Fixes e371b9d3368c ("selftests: ublk: kublk: fix include path")

---
Changes since v1:
- Rebased on v7.4-rc1. ublk_cancel_ready got its own rule next to kublk in the meantime, no other changes.

v1: https://lore.kernel.org/all/[email protected]/

 tools/testing/selftests/ublk/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/ublk/Makefile +2 -1
index fc64b8f028332..b8142bad63a1b 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CFLAGS += -O3 -Wl,-no-as-needed -Wall -I $(top_srcdir)/usr/include
+CFLAGS += -O3 -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
 ifneq ($(WERROR),0)
 	CFLAGS += -Werror
 endif
@@ -85,6 +85,7 @@ include ../lib.mk
 
 $(OUTPUT)/kublk: $(filter-out $(STANDALONE_UTILS),$(wildcard *.c))
 $(OUTPUT)/ublk_cancel_ready: ublk_cancel_ready.c ctrl.c
+$(TEST_GEN_PROGS_EXTENDED): | headers
 
 check:
 	shellcheck -x -f gcc *.sh
Signature · 1 line
2.53.0
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 12 lines · Sasha Levin

With generated headers in an output directory, the hardcoded source-tree include path falls through to distribution headers. New ublk flags and structure members, including UBLK_F_IO_DESC_SIZE, are then missing.

Use KHDR_INCLUDES to consume the headers from the kernel under test, and add the headers target as an order-only prerequisite of the ublk programs, as nolibc-test does, so that a standalone build installs them first. Baseline builds fail on the missing definitions; GCC 14 and Clang 21 builds succeed with the output-directory headers and target liburing development files available.

Quoted 6 lines
Fixes e371b9d3368c ("selftests: ublk: kublk: fix include path")

---
Changes since v1:
- Rebased on v7.4-rc1. ublk_cancel_ready got its own rule next to kublk in the meantime, no other changes.

Thanks,