[CRIU] [RFC PATCHv2 10/32] zdtm: lib: make libzdtmtst a shared object
Ivan Shapovalov
intelfx at intelfx.name
Sat Mar 12 00:42:09 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.desc | 2 +-
test/zdtm.py | 2 +-
test/zdtm/.gitignore | 2 +-
test/zdtm/lib/Makefile | 7 +++++--
test/zdtm/static/Makefile | 10 ++--------
test/zdtm/transition/Makefile | 12 +++---------
6 files changed, 13 insertions(+), 22 deletions(-)
diff --git a/test/zdtm.desc b/test/zdtm.desc
index 0671d49..1436cb0 100644
--- a/test/zdtm.desc
+++ b/test/zdtm.desc
@@ -1 +1 @@
-{ 'dir': 'zdtm/', 'exclude': [ 'static/route_rules', 'static/criu-rtc.so', 'lib/parseargs.sh', 'lib/stop_and_chk.sh' ] }
+{ 'dir': 'zdtm/', 'exclude': [ 'static/route_rules', 'static/criu-rtc.so', 'lib/parseargs.sh', 'lib/stop_and_chk.sh', 'lib/libzdtmtst.so' ] }
diff --git a/test/zdtm.py b/test/zdtm.py
index bdf50b2..5f58959 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -437,7 +437,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.lock", "./zdtm_mount_cgroups"])
diff --git a/test/zdtm/.gitignore b/test/zdtm/.gitignore
index 408d5c0..29c9740 100644
--- a/test/zdtm/.gitignore
+++ b/test/zdtm/.gitignore
@@ -1,4 +1,4 @@
-/lib/libzdtmtst.a
+/lib/libzdtmtst.so
/static/apparmor
/static/arm-neon00
/static/bind-mount
diff --git a/test/zdtm/lib/Makefile b/test/zdtm/lib/Makefile
index 8f89fd9..a4b581a 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
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
@@ -20,8 +21,9 @@ all: $(LIB)
install: all
.PHONY: all install
+$(LIB): LDFLAGS += -shared
$(LIB): $(LIBOBJ)
- $(Q) ar rv $@ $^
+ $(LINK.c) $^ $(OUTPUT_OPTION)
clean:
$(RM) -f $(LIBOBJ) $(LIB) *~
@@ -32,6 +34,7 @@ cleandep:
cleanout:
@true
+$(GRPS): override LDFLAGS += -Wl,-rpath,\$$ORIGIN
$(GRPS): $(LIB)
$(GRPS:%=%.pid): $(GRPS)
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index 9453899..9735d07 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/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 \
@@ -334,8 +333,6 @@ wait_stop:
i=`expr $$i + 1`; \
done
-$(TST): $(LIB)
-
aio00: override LDLIBS += -laio
different_creds: override LDLIBS += -lcap
futex.o: override CFLAGS += -pthread
@@ -381,9 +378,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/transition/Makefile b/test/zdtm/transition/Makefile
index 2f3b6e8..09450f9 100644
--- a/test/zdtm/transition/Makefile
+++ b/test/zdtm/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 -fno-strict-aliasing
+CFLAGS = -g -O2 -Wall -Werror -fno-strict-aliasing -fPIC
CFLAGS += $(USERCFLAGS)
+LDFLAGS = -fPIC -pie -rdynamic -L$(LIBDIR) -Wl,-rpath,\$$ORIGIN/$(LIBDIR)
TST_NOFILE = \
ipc \
@@ -71,24 +72,17 @@ 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
-ptrace.o: override CFLAGS += -pthread
ptrace: override LDFLAGS += -pthread
fork2: override CFLAGS += -D FORK2
-thread-bomb.o: override CFLAGS += -pthread
thread-bomb: override LDFLAGS += -pthread
%: %.sh
cp $< $@
chmod +x $@
-$(LIB): force
- $(Q) $(MAKE) -C $(LIBDIR)
-
clean:
$(RM) -f $(OBJ) $(TST) *~
--
2.7.2
More information about the CRIU
mailing list