Skip to contentSkip to conversation

KVM: selftests: Install sanitised kernel headers before compilation

PATCH In review Like Xu 2 participants 2 messages Dec 19, 2022

Subsystems (2)
lore
Share & tools
lore

Like Xu

author
#0 lore raw

PATCH 1/1 KVM: selftests: Install sanitised kernel headers before compilation

From: Like Xu <[email protected]>

On many automated test boxes, selftests in a completely clean src tree will be compiled independently: "make -j -C tools/testing/selftests/kvm". Sometimes the compilation will fail and produce a false positive just due to missing kernel headers (or others hidden behind the complete kernel compilation or installation).

Optimize this situation by explicitly adding the installation of sanitised kernel headers before compilation to the Makefile.

---
 tools/testing/selftests/kvm/Makefile | 5 +++++
 1 file changed, 5 insertions(+)
tools/testing/selftests/kvm/Makefile +5 -0
index 947676983da1..a33e2f72d745 100644
@@ -202,6 +202,11 @@ TEST_GEN_PROGS_EXTENDED += $(TEST_GEN_PROGS_EXTENDED_$(UNAME_M))
 LIBKVM += $(LIBKVM_$(UNAME_M))
 
 INSTALL_HDR_PATH = $(top_srcdir)/usr
+
+ifeq ($(shell make -j -C ../../../.. headers_install),)
+	$(error "Please install sanitised kernel headers manually.")
+endif
+
 LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
 LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
 ifeq ($(ARCH),x86_64)
Signature · 1 line
2.39.0
#1 lore raw
Quoted 22 lines · Like Xu

From: Like Xu <[email protected]>

On many automated test boxes, selftests in a completely clean src tree will be compiled independently: "make -j -C tools/testing/selftests/kvm". Sometimes the compilation will fail and produce a false positive just due to missing kernel headers (or others hidden behind the complete kernel compilation or installation).

Optimize this situation by explicitly adding the installation of sanitised kernel headers before compilation to the Makefile.

---
 tools/testing/selftests/kvm/Makefile | 5 +++++
 1 file changed, 5 insertions(+)
tools/testing/selftests/kvm/Makefile +0 -0
index 947676983da1..a33e2f72d745 100644

tools/testing/selftests/kvm/Makefile TEST_GEN_PROGS_EXTENDED += $(TEST_GEN_PROGS_EXTENDED_$(UNAME_M)) · line 208

Quoted 7 lines
tools/testing/selftests/kvm/Makefile +4 -0
@@ -202,6 +202,11 @@ TEST_GEN_PROGS_EXTENDED += $(TEST_GEN_PROGS_EXTENDED_$(UNAME_M))
 LIBKVM += $(LIBKVM_$(UNAME_M))
 
 INSTALL_HDR_PATH = $(top_srcdir)/usr
+
+ifeq ($(shell make -j -C ../../../.. headers_install),)
+	$(error "Please install sanitised kernel headers manually.")
+endif

Auto-installation of headers was recently removed[*], presumably whatever problem existed with KSFT_KHDR_INSTALL also exists with this approach.

FWIW, I also find the need to manually do headers_install annoying, but it's easy to workaround via bash aliases.

[*] https://lore.kernel.org/lkml/[email protected]