selftests: ublk: Fix include path for out-of-tree builds
Subsystems (3)
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
@@ -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
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_SIZEkublk.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_INCLUDESfrom the main selftestMakefilethat should contain the right include path in either case.Signed-off-by Thomas Huth <[email protected]>--- tools/testing/selftests/ublk/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/ublk/Makefile +0
-0
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