summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2021-10-15 09:45:26 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2021-10-15 09:55:54 +0200
commit2e2d67378007ee850792396f933900e71f0ea80d (patch)
tree2db226e4c303766b8015498e514d094c703cf7ad
parent037165300ea1f6d9c9f8587360792505b2f3988d (diff)
downloadlvm2-2e2d67378007ee850792396f933900e71f0ea80d.tar.gz
makefile: enhance run-unit-test target
Use TMPDIR for executing test and also ensure all libraries linked to the test are from builddir.
-rw-r--r--test/unit/Makefile7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/unit/Makefile b/test/unit/Makefile
index 455c18d2a..5826f41c2 100644
--- a/test/unit/Makefile
+++ b/test/unit/Makefile
@@ -54,7 +54,12 @@ $(UNIT_TARGET): $(UNIT_OBJECTS) $(LVMINTERNAL_LIBS)
unit-test: $(UNIT_TARGET)
run-unit-test: $(UNIT_TARGET)
@echo "Running unit tests"
- LD_LIBRARY_PATH=$(top_builddir)/libdm $(UNIT_TARGET) run
+ test -n "$$LVM_TEST_DIR" || LVM_TEST_DIR=$${TMPDIR:-/tmp} ;\
+ TESTDIR=$$(mktemp -d -t -p "$$LVM_TEST_DIR" "LVMTEST.XXXXXXXXXX") ;\
+ cd "$$TESTDIR" ;\
+ LD_LIBRARY_PATH=$(abs_top_builddir)/libdm:$(abs_top_builddir)/daemons/dmeventd $(abs_top_builddir)/$(UNIT_TARGET) run ;\
+ cd $$OLDPWD ;\
+ $(RM) -r "$${TESTDIR:?}"
ifeq ("$(DEPENDS)","yes")
-include $(UNIT_SOURCE:%.c=%.d)