[CRIU] [RFC PATCHv2 16/32] zdtm: Makefile: support passing various path prefixes to test Makefiles

Ivan Shapovalov intelfx at intelfx.name
Sat Mar 12 00:42:15 PST 2016


This is in preparation to running tests from different cwd (which is needed
by the single-process group test mode). Those prefixes are taken into account
by targets which print out argument strings to be passed to tests and to the
test launcher.

Signed-off-by: Ivan Shapovalov <intelfx at intelfx.name>
---
 test/zdtm/Makefile.live | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/test/zdtm/Makefile.live b/test/zdtm/Makefile.live
index 127ce66..119e498 100644
--- a/test/zdtm/Makefile.live
+++ b/test/zdtm/Makefile.live
@@ -7,6 +7,25 @@ LDLIBS	= -lzdtmtst
 override CFLAGS += -fPIC
 override LDFLAGS += -fPIC -pie -rdynamic -L$(LIBDIR) -Wl,-rpath,\$$ORIGIN/$(LIBDIR)
 
+# This is the "cwd-compensation" prefix for those targets which print out
+# various arguments to the tests and the multi-test launcher.
+#
+# If the launcher is started from another directory compared to directory
+# of the test binary (and of the Makefile containing definitions for that
+# binary), this variable should contain a relative path from the launcher's
+# intended working directory to the test binary's directory.
+ZDTM_PATH_PREFIX ?= .
+
+# This is the "disambiguation" prefix for those targets which print out
+# various arguments to the tests and the multi-test launcher.
+#
+# It will be prepended to names of per-test temporary files returned in
+# arguments (e. g. --filename or --dirname). It is intended to avoid clashes
+# when multiple groups containing the same test are ran in parallel.
+# To avoid clashes, the prefix should be set to a per-group unique value
+# (such as the name of test group itself).
+ZDTM_NAME_PREFIX ?=
+
 TST     = $(TST_NOFILE) $(TST_FILE) $(TST_DIR) $(TST_DIR_FILE) $(TST_OTHER)
 SRC	= $(TST:%=%.c)
 OBJ	= $(SRC:%.c=%.o)
@@ -28,18 +47,18 @@ install: all
 	@echo --pidfile=$(basename $@).pid --outfile=$(basename $@).out
 
 %.args-multi:
-	@echo --lib $(basename $(@D)/$(@F))
+	@echo --lib $(ZDTM_PATH_PREFIX)/$(basename $@)
 
 $(TST_BUSY_LOOP:%=%.args-multi):
-	@echo --lib-threaded $(basename $(@D)/$(@F))
+	@echo --lib-threaded $(ZDTM_PATH_PREFIX)/$(basename $@)
 
 $(TST_NOFILE:%=%.args)::
 
 $(TST_FILE:%=%.args)::
-	@echo --filename=$(basename $@).test
+	@echo --filename=$(ZDTM_NAME_PREFIX)$(basename $@).test
 
 $(TST_DIR:%=%.args)::
-	@echo --dirname=$(basename $@).test.dir
+	@echo --dirname=$(ZDTM_NAME_PREFIX)$(basename $@).test.dir
 
 %.pid: %
 	$(<D)/$(<F) $(shell $(make) -s $<.args-global $<.args)
-- 
2.7.2



More information about the CRIU mailing list