From ff1f16f392f7a6eaca8f2ecf144d50b5c357bbad Mon Sep 17 00:00:00 2001 From: Matej Hrica Date: Tue, 14 Jul 2026 13:47:39 +0200 Subject: [PATCH] Makefile: add LIBKRUNFW_SRC= option to build libkrunfw for tests Debugging issues that span both libkrun and the guest kernel (e.g. a virtio driver bug or a TSI networking regression) requires iterating on changes in both repos and re-running the failing test. Without this option, libkrunfw must be manually built and installed into the right prefix each time before running the libkrun test. With LIBKRUNFW_SRC= pointing at a libkrunfw source tree, a single command rebuilds both libkrun and libkrunfw from their current dirty state, installs them into test-prefix/, and runs the test. The same command can be re-run as either repo is edited: make -j11 test TEST=net-passt LIBKRUNFW_SRC=~/src/libkrunfw The sub-make inherits the parent's jobserver for parallelism. A warning is emitted when test-prefix contains a custom libkrunfw from a previous LIBKRUNFW_SRC= run, so the user knows tests are not using the system libkrunfw. Assisted-by: OpenCode:claude-opus-4.6 Signed-off-by: Matej Hrica --- Makefile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Makefile b/Makefile index 1685adf..7b491f7 100644 --- a/Makefile +++ b/Makefile @@ -248,7 +248,24 @@ test-prefix/$(LIBDIR_$(OS))/libkrun.pc: $(LIBRARY_RELEASE_$(OS)) mkdir -p test-prefix PREFIX="$$(realpath test-prefix)" make install +# Build and install libkrunfw from a source tree into test-prefix. +# Usage: make test LIBKRUNFW_SRC=/path/to/libkrunfw +ifdef LIBKRUNFW_SRC +.PHONY: test-prefix-libkrunfw +test-prefix-libkrunfw: + $(MAKE) -C $(LIBKRUNFW_SRC) + mkdir -p test-prefix + PREFIX="$$(realpath test-prefix)" $(MAKE) -C $(LIBKRUNFW_SRC) install + +test-prefix: test-prefix/$(LIBDIR_$(OS))/libkrun.pc test-prefix-libkrunfw +else test-prefix: test-prefix/$(LIBDIR_$(OS))/libkrun.pc + @if ls test-prefix/$(LIBDIR_$(OS))/libkrunfw* >/dev/null 2>&1; then \ + echo "WARNING: test-prefix contains a custom libkrunfw from a previous LIBKRUNFW_SRC= run." >&2; \ + echo " Tests will use it instead of the system libkrunfw." >&2; \ + echo " To reset, run: rm -rf test-prefix" >&2; \ + fi +endif TEST ?= all TEST_FLAGS ?= -- 2.51.2