From 04f1b9fb62ec2217f81efaf554cff60f8bf60e49 Mon Sep 17 00:00:00 2001 From: Ahmed Elaidy Date: Tue, 3 Mar 2026 21:00:22 +0200 Subject: [PATCH] test: libcriu: use installed headers and library Install libcriu into a local staging directory (.install/) using 'make install-lib' and reference only that directory during build and test: CFLAGS := -I$(INSTALL_DIR)/include/criu LDFLAGS := -L$(INSTALL_DIR)/lib -lcriu LD_LIBRARY_PATH=${MAIN_DIR}/.install/lib Nothing from the non-test part of the repo is used at compile, link, or run time. The compile rule is also corrected to use $< instead of $^ for gcc -c. Fixes: #2927 Signed-off-by: Ahmed Elaidy --- test/others/libcriu/Makefile | 36 +++++++++++++++++++++++------------- test/others/libcriu/run.sh | 4 +--- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/test/others/libcriu/Makefile b/test/others/libcriu/Makefile index 927f17c23..e3d603788 100644 --- a/test/others/libcriu/Makefile +++ b/test/others/libcriu/Makefile @@ -11,6 +11,16 @@ TESTS += test_pre_dump TESTS += test_check TESTS += test_feature_check +# Install libcriu (headers and library) into a local staging directory so +# that nothing from the non-test part of the repo is referenced directly +# during the build or at runtime. +INSTALL_DIR:= $(CURDIR)/.install +CRIU_INCLUDE:= $(INSTALL_DIR)/include/criu +CRIU_LIB:= $(INSTALL_DIR)/lib + +CFLAGS:= -I$(CRIU_INCLUDE) +LDFLAGS:= -L$(CRIU_LIB) -lcriu + all: $(TESTS) .PHONY: all @@ -18,24 +28,24 @@ run: all ./run.sh .PHONY: run +$(CRIU_LIB)/libcriu.so: + $(MAKE) -C ../../../../criu install-lib \ + DESTDIR=$(INSTALL_DIR) PREFIX=/ LIBDIR=/lib \ + SKIP_PIP_INSTALL=1 + +$(CRIU_INCLUDE): $(CRIU_LIB)/libcriu.so + @: + define genb $(1): $(1).o lib.o - gcc $$^ -L ../../../../criu/lib/c/ -L ../../../../criu/images/ -lcriu -o $$@ + gcc $$^ $(LDFLAGS) -o $$@ endef $(foreach t, $(TESTS), $(eval $(call genb, $(t)))) -%.o: %.c - gcc -c $^ -iquote ../../../../criu/criu/include -I../../../../criu/lib/c/ -I../../../../criu/images/ -o $@ -Werror +%.o: %.c | $(CRIU_INCLUDE) + gcc -c $< $(CFLAGS) -o $@ -Werror -clean: libcriu_clean - rm -rf $(TESTS) $(TESTS:%=%.o) lib.o +clean: + rm -rf $(TESTS) $(TESTS:%=%.o) lib.o $(INSTALL_DIR) .PHONY: clean - -libcriu_clean: - rm -f libcriu.so.${CRIU_SO_VERSION_MAJOR} -.PHONY: libcriu_clean - -libcriu: - ln -s ../../../../criu/lib/c/libcriu.so libcriu.so.${CRIU_SO_VERSION_MAJOR} -.PHONY: libcriu diff --git a/test/others/libcriu/run.sh b/test/others/libcriu/run.sh index 6b36d4496..0278d08e3 100755 --- a/test/others/libcriu/run.sh +++ b/test/others/libcriu/run.sh @@ -14,12 +14,11 @@ source "${MAIN_DIR}/../env.sh" || exit 1 echo "== Clean" make clean -make libcriu rm -rf "${OUTPUT_DIR}" echo "== Run tests" -export LD_LIBRARY_PATH=. +export LD_LIBRARY_PATH=${MAIN_DIR}/.install/lib export PATH="${MAIN_DIR}/../../../criu:${PATH}" RESULT=0 @@ -76,6 +75,5 @@ fi run_test test_feature_check echo "== Tests done" -make libcriu_clean [ "${RESULT}" -eq 0 ] && echo "Success" || echo "FAIL" exit "${RESULT}"