Skip to contentSkip to conversation

selftests: ublk: Fix include path for out-of-tree builds

PATCH In review Thomas Huth 2 participants 2 messages Nov 4

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

PATCH 1/1 selftests: ublk: Fix include path for out-of-tree builds

When building the seltests out of tree with "make kselftest-all", the compilation of the ublk tests can currently fail since they are using the headers from the distro instead the headers from the kernel source. For example, I'm getting:

kublk.c: In function ‘ublk_ctrl_dump’:
kublk.c:190:27: error: ‘UBLK_F_IO_DESC_SIZE’ undeclared (first use in
this function); did you mean ‘UBLK_F_UPDATE_SIZE’?

   190 |         if (info->flags & UBLK_F_IO_DESC_SIZE)
       |                           ^~~~~~~~~~~~~~~~~~~
       |                           UBLK_F_UPDATE_SIZE

kublk.c:190:27: note: each undeclared identifier is reported only once
for each function it appears in
kublk.c:191:53: error: ‘struct ublksrv_ctrl_dev_info’ has no member
named ‘io_desc_size’
191 | ublk_log("\tio_desc_size %u\n", info->io_desc_size);
| ^~
... etc ...

Fix it by using the KHDR_INCLUDES from the main selftest Makefile that should contain the right include path in either case.

---
 tools/testing/selftests/ublk/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ublk/Makefile +1 -1
index fc64b8f028332..ba6df7c0b530b 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
Signature · 1 line
2.56.0
#1 lore raw
Quoted 33 lines · Thomas Huth

When building the seltests out of tree with "make kselftest-all", the compilation of the ublk tests can currently fail since they are using the headers from the distro instead the headers from the kernel source. For example, I'm getting:

kublk.c: In function ‘ublk_ctrl_dump’:
kublk.c:190:27: error: ‘UBLK_F_IO_DESC_SIZE’ undeclared (first use in
this function); did you mean ‘UBLK_F_UPDATE_SIZE’?

   190 |         if (info->flags & UBLK_F_IO_DESC_SIZE)
       |                           ^~~~~~~~~~~~~~~~~~~
       |                           UBLK_F_UPDATE_SIZE

kublk.c:190:27: note: each undeclared identifier is reported only once
for each function it appears in
kublk.c:191:53: error: ‘struct ublksrv_ctrl_dev_info’ has no member
named ‘io_desc_size’
191 | ublk_log("\tio_desc_size %u\n", info->io_desc_size);
| ^~
... etc ...

Fix it by using the KHDR_INCLUDES from the main selftest Makefile that should contain the right include path in either case.

---
 tools/testing/selftests/ublk/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ublk/Makefile +0 -0
index fc64b8f028332..ba6df7c0b530b 100644

tools/testing/selftests/ublk/Makefile line 3

Quoted 4 lines
tools/testing/selftests/ublk/Makefile +1 -1
@@ -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)

Sasha Levin already sent a patch for this:
https://lore.kernel.org/linux-block/[email protected]/

Best,
Caleb