[CRIU] [RFC PATCH 07/21] zdtm: make libzdtmtst a shared object

Ivan Shapovalov intelfx at intelfx.name
Fri Feb 19 06:50:30 PST 2016


This is needed for the multiple-tests-in-one-process mode, to be able
to use the same binaries both as standalone executables and as dlopen()'d
by the launcher shared objects. In the latter case the launcher will
communicate with tests' helper routines via global weak variables
defined in libzdtmtst.

Signed-off-by: Ivan Shapovalov <intelfx at intelfx.name>
---
 test/zdtm.py                       |  2 +-
 test/zdtm/.gitignore               |  2 +-
 test/zdtm/lib/Makefile             |  5 +++--
 test/zdtm/live/static/Makefile     | 10 ++--------
 test/zdtm/live/streaming/Makefile  | 10 +++-------
 test/zdtm/live/transition/Makefile | 14 ++++----------
 6 files changed, 14 insertions(+), 29 deletions(-)

diff --git a/test/zdtm.py b/test/zdtm.py
index ef521f4..b1a58aa 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -488,7 +488,7 @@ class zdtm_test:
 	def available():
 		if not os.access("zdtm_ct", os.X_OK):
 			subprocess.check_call(["make", "zdtm_ct"])
-		if not os.access("zdtm/lib/libzdtmtst.a", os.F_OK):
+		if not os.access("zdtm/lib/libzdtmtst.so", os.F_OK):
 			subprocess.check_call(["make", "-C", "zdtm/"])
 		subprocess.check_call(["flock", "zdtm_mount_cgroups", "./zdtm_mount_cgroups"])
 
diff --git a/test/zdtm/.gitignore b/test/zdtm/.gitignore
index 5a48199..6cdaf4a 100644
--- a/test/zdtm/.gitignore
+++ b/test/zdtm/.gitignore
@@ -1,4 +1,4 @@
-/lib/libzdtmtst.a
+/lib/libzdtmtst.so
 /live/static/apparmor
 /live/static/arm-neon00
 /live/static/bind-mount
diff --git a/test/zdtm/lib/Makefile b/test/zdtm/lib/Makefile
index 8f89fd9..13569de 100644
--- a/test/zdtm/lib/Makefile
+++ b/test/zdtm/lib/Makefile
@@ -2,9 +2,10 @@ include ../Makefile.inc
 
 CFLAGS	= -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -fPIC
 CFLAGS	+= $(USERCFLAGS)
+LDFLAGS = -fPIC -shared
 
 LIBDIR	= .
-LIB	= libzdtmtst.a
+LIB	= libzdtmtst.so
 GRPS	= groups
 
 LIBSRC	= datagen.c msg.c parseargs.c test.c streamutil.c lock.c ns.c tcp.c fs.c
@@ -21,7 +22,7 @@ install: all
 .PHONY: all install
 
 $(LIB):	$(LIBOBJ)
-	$(Q) ar rv $@ $^
+	$(LINK.c) $^ $(OUTPUT_OPTION)
 
 clean:
 	$(RM) -f $(LIBOBJ) $(LIB) *~
diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index 4bef15b..6e7f93b 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -1,11 +1,11 @@
 include ../../Makefile.inc
 
 LIBDIR	= ../../lib
-LIB	= $(LIBDIR)/libzdtmtst.a
+LDLIBS	= -lzdtmtst
 override CPPFLAGS += -I$(LIBDIR)
 CFLAGS	= -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -fPIC
 CFLAGS	+= $(USERCFLAGS)
-LDFLAGS = -fPIC -pie -rdynamic
+LDFLAGS = -fPIC -pie -rdynamic -L$(LIBDIR) -Wl,-rpath,\$$ORIGIN/$(LIBDIR)
 
 TST_NOFILE	=				\
 		busyloop00			\
@@ -61,7 +61,6 @@ TST_NOFILE	=				\
 		sockets02			\
 		sockets_spair			\
 		socket_queues			\
-		socket_queues02			\
 		socket-tcp			\
 		socket-tcp6			\
 		socket-tcp-local		\
@@ -331,8 +330,6 @@ wait_stop:
 		i=`expr $$i + 1`; \
 	done
 
-$(TST):	$(LIB)
-
 aio00:			override LDLIBS += -laio
 different_creds:	override LDLIBS += -lcap
 futex.o:		override CFLAGS += -pthread
@@ -378,9 +375,6 @@ stopped01:	override CFLAGS += -DZDTM_STOPPED_KILL
 stopped02:	override CFLAGS += -DZDTM_STOPPED_TKILL
 stopped12:	override CFLAGS += -DZDTM_STOPPED_KILL -DZDTM_STOPPED_TKILL
 
-$(LIB):	force
-	$(Q) $(MAKE) -C $(LIBDIR)
-
 clean:
 	$(RM) -f $(OBJ) $(TST) *~ criu-rtc.so criu-rtc.pb-c.c criu-rtc.pb-c.h get_smaps_bits.o
 
diff --git a/test/zdtm/live/streaming/Makefile b/test/zdtm/live/streaming/Makefile
index e65e3fd..6ca1661 100644
--- a/test/zdtm/live/streaming/Makefile
+++ b/test/zdtm/live/streaming/Makefile
@@ -1,10 +1,11 @@
 include ../../Makefile.inc
 
 LIBDIR	= ../../lib
-LIB	= $(LIBDIR)/libzdtmtst.a
+LDLIBS	= -lzdtmtst
 override CPPFLAGS += -I$(LIBDIR)
-CFLAGS	= -g -O2 -Wall -Werror -fno-strict-aliasing
+CFLAGS	= -g -O2 -Wall -Werror -fno-strict-aliasing -fPIC
 CFLAGS	+= $(USERCFLAGS)
+LDFLAGS = -fPIC -pie -rdynamic -L$(LIBDIR) -Wl,-rpath,$(LIBDIR)
 
 TST_NOFILE	=	\
 		pipe_loop00	\
@@ -61,15 +62,10 @@ wait_stop:
 		sleep 1; \
 	done
 
-$(TST):	$(LIB)
-
 file_aio: override LDLIBS += -lrt -pthread
 socket-tcp: override CFLAGS += -D STREAM
 socket-tcp6: override CFLAGS += -D ZDTM_IPV6 -D STREAM
 
-$(LIB):	force
-	$(Q) $(MAKE) -C $(LIBDIR)
-
 clean:
 	$(RM) -f $(OBJ) $(TST) *~
 
diff --git a/test/zdtm/live/transition/Makefile b/test/zdtm/live/transition/Makefile
index c791e62..3a16122 100644
--- a/test/zdtm/live/transition/Makefile
+++ b/test/zdtm/live/transition/Makefile
@@ -1,10 +1,11 @@
 include ../../Makefile.inc
 
 LIBDIR	= ../../lib
-LIB	= $(LIBDIR)/libzdtmtst.a
+LDLIBS	= -lzdtmtst
 override CPPFLAGS += -I$(LIBDIR)
-CFLAGS	= -g -O2 -Wall -Werror
+CFLAGS	= -g -O2 -Wall -Werror -fPIC
 CFLAGS	+= $(USERCFLAGS)
+LDFLAGS = -fPIC -pie -rdynamic -L$(LIBDIR) -Wl,-rpath,$(LIBDIR)
 
 TST_NOFILE	=	\
 		ipc		\
@@ -59,21 +60,14 @@ wait_stop:
 		sleep 1; \
 	done
 
-$(TST):	$(LIB)
-
-ptrace.o:	override CFLAGS += -pthread
 ptrace:		override LDFLAGS += -pthread
-fork2:		override CFLAGS += -D FORK2
-thread-bomb.o:		override CFLAGS += -pthread
+fork2.o:		override CFLAGS += -D FORK2
 thread-bomb:		override LDFLAGS += -pthread
 
 %: %.sh
 	cp $< $@
 	chmod +x $@
 
-$(LIB):	force
-	$(Q) $(MAKE) -C $(LIBDIR)
-
 clean:
 	$(RM) -f $(OBJ) $(TST) *~
 
-- 
2.7.1



More information about the CRIU mailing list