[CRIU] [RFC PATCH 09/21] zdtm: cleanup and deduplicate Makefiles
Ivan Shapovalov
intelfx at intelfx.name
Fri Feb 19 06:50:32 PST 2016
Signed-off-by: Ivan Shapovalov <intelfx at intelfx.name>
---
test/zdtm/Makefile.inc | 3 +-
test/zdtm/lib/Makefile | 7 ++-
test/zdtm/live/Makefile.live | 97 ++++++++++++++++++++++++++++++++++
test/zdtm/live/static/Makefile | 104 +++----------------------------------
test/zdtm/live/streaming/Makefile | 70 +------------------------
test/zdtm/live/transition/Makefile | 70 +------------------------
6 files changed, 112 insertions(+), 239 deletions(-)
create mode 100644 test/zdtm/live/Makefile.live
diff --git a/test/zdtm/Makefile.inc b/test/zdtm/Makefile.inc
index d388bda..fd7d872 100644
--- a/test/zdtm/Makefile.inc
+++ b/test/zdtm/Makefile.inc
@@ -29,7 +29,8 @@ ifeq ($(shell echo $(ARCH) | sed -e 's/ppc64.*/ppc64/'),ppc64)
SRCARCH := ppc64
endif
-CPPFLAGS += -iquote $(LIBDIR)/include -iquote $(LIBDIR)/arch/$(SRCARCH)/include
+override CPPFLAGS += -I$(LIBDIR) -iquote $(LIBDIR)/include -iquote $(LIBDIR)/arch/$(SRCARCH)/include
+CFLAGS += -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
ifeq ($(strip $(V)),)
E = @echo
diff --git a/test/zdtm/lib/Makefile b/test/zdtm/lib/Makefile
index 13569de..1ea4976 100644
--- a/test/zdtm/lib/Makefile
+++ b/test/zdtm/lib/Makefile
@@ -1,8 +1,7 @@
include ../Makefile.inc
-CFLAGS = -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -fPIC
-CFLAGS += $(USERCFLAGS)
-LDFLAGS = -fPIC -shared
+override CFLAGS += -fPIC
+override LDFLAGS += -fPIC -shared
LIBDIR = .
LIB = libzdtmtst.so
@@ -22,7 +21,7 @@ install: all
.PHONY: all install
$(LIB): $(LIBOBJ)
- $(LINK.c) $^ $(OUTPUT_OPTION)
+ $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION)
clean:
$(RM) -f $(LIBOBJ) $(LIB) *~
diff --git a/test/zdtm/live/Makefile.live b/test/zdtm/live/Makefile.live
new file mode 100644
index 0000000..160abb3
--- /dev/null
+++ b/test/zdtm/live/Makefile.live
@@ -0,0 +1,97 @@
+# this file is ran from test/zdtm/live/*, hence ../../
+
+include ../../Makefile.inc
+
+LIBDIR = ../../lib
+LDLIBS = -lzdtmtst
+override CFLAGS += -fPIC
+override LDFLAGS += -fPIC -pie -rdynamic -L$(LIBDIR) -Wl,-rpath,\$$ORIGIN/$(LIBDIR)
+
+TST = $(TST_NOFILE) $(TST_FILE) $(TST_DIR) $(TST_DIR_FILE) $(TST_OTHER)
+SRC = $(TST:%=%.c)
+OBJ = $(SRC:%.c=%.o)
+DEP = $(SRC:%.c=%.d)
+PID = $(TST:%=%.pid)
+OUT = $(TST:%=%.out)
+STATE = $(TST_STATE:%=%.state)
+STATE_OUT = $(TST_STATE:%=%.out)
+
+DEPEND.c = $(COMPILE.c) -MM -MP
+%.d: %.c
+ $(DEPEND.c) $(OUTPUT_OPTION) $<
+
+all: $(TST)
+install: all
+.PHONY: all install
+
+$(TST_NOFILE:%=%.pid): %.pid: %
+ $(<D)/$(<F) --pidfile=$@ --outfile=$<.out
+
+$(TST_FILE:%=%.pid): %.pid: %
+ $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --filename=$<.test
+
+$(TST_DIR:%=%.pid): %.pid: %
+ $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --dirname=$<.test
+
+$(TST_DIR_FILE:%=%.pid): %.pid: %
+ $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --dirname=$<.dir.test --filename=$<.test
+
+%.out: %.pid %
+ -kill -TERM `cat $<`
+
+$(STATE): %.state: %
+ $(<D)/$(<F) --statefile=$@ --outfile=$<.out start
+
+$(STATE_OUT): %.out: %
+ -$(<D)/$(<F) --statefile=$<.state --outfile=$@ stop
+
+start: $(PID) $(STATE)
+
+%.is_running: %.pid
+ kill -0 `cat $<`
+
+check_start: $(PID:%.pid=%.is_running)
+
+stop: $(STATE_OUT)
+ -kill -TERM `cat *.pid`
+
+WAIT_TIME=240
+%.stop: %.pid %
+ kill -TERM `cat $<`; \
+ i=0; \
+ while [ $$i -lt $(WAIT_TIME) ] ; do \
+ kill -0 `cat $< 2>/dev/null` 2>/dev/null || break; \
+ sleep 1; \
+ echo -n .; \
+ i=`expr $$i + 1`; \
+ done; \
+ echo; \
+ [ $$i -lt $(WAIT_TIME) ]
+
+wait_stop:
+ i=0; \
+ while [ $$i -lt $(WAIT_TIME) ] ; do \
+ kill -0 `cat *.pid 2>/dev/null` 2>/dev/null || break; \
+ sleep 1; \
+ i=`expr $$i + 1`; \
+ done
+
+clean::
+ $(RM) -f $(OBJ) $(TST) *~
+
+cleandep: clean
+ $(RM) -f $(DEP)
+
+%.cleanout: %
+ $(Q) $(RM) -f -r $<.pid $<.init.pid $<.out* *$<.test* $<.*.test $<.state
+
+cleanout:
+ $(Q) $(RM) -f -r *.pid *.out* *.test* *.state
+
+realclean: cleandep cleanout
+
+.PHONY: force clean cleandep cleanout realclean start check_start stop wait_stop
+
+ifeq ($(filter-out no-deps-targets, $(MAKECMDGOALS)),)
+-include $(DEP)
+endif
diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index 6e7f93b..2fc88d2 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -1,11 +1,4 @@
-include ../../Makefile.inc
-
-LIBDIR = ../../lib
-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 -L$(LIBDIR) -Wl,-rpath,\$$ORIGIN/$(LIBDIR)
+# the include is at the end
TST_NOFILE = \
busyloop00 \
@@ -233,11 +226,7 @@ TST_DIR_FILE = \
chroot \
chroot-file
-TST = \
- $(TST_NOFILE) \
- $(TST_FILE) \
- $(TST_DIR) \
- $(TST_DIR_FILE) \
+TST_OTHER = \
env00 \
fifo-rowo-pair \
umask00 \
@@ -248,37 +237,11 @@ TST_STATE = \
route_rules \
-SRC = $(TST:%=%.c)
-OBJ = $(SRC:%.c=%.o)
-DEP = $(SRC:%.c=%.d)
-PID = $(TST:%=%.pid)
-OUT = $(TST:%=%.out)
-STATE = $(TST_STATE:%=%.state)
-STATE_OUT = $(TST_STATE:%=%.out)
-
-DEPEND.c = $(COMPILE.c) -MM -MP
-%.d: %.c
- $(DEPEND.c) $(OUTPUT_OPTION) $<
-
-all: $(TST) criu-rtc.so
-install: all
-.PHONY: all install
+all: criu-rtc.so
inotify_system_nodel.c: inotify_system.c
ln -sf inotify_system.c inotify_system_nodel.c
-$(TST_NOFILE:%=%.pid): %.pid: %
- $(<D)/$(<F) --pidfile=$@ --outfile=$<.out
-
-$(TST_FILE:%=%.pid): %.pid: %
- $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --filename=$<.test
-
-$(TST_DIR:%=%.pid): %.pid: %
- $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --dirname=$<.test
-
-$(TST_DIR_FILE:%=%.pid): %.pid: %
- $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --dirname=$<.dir.test --filename=$<.test
-
cmdlinenv00.pid: cmdlinenv00
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --arg1=arg1 --arg2=arg2 --arg3=arg3
@@ -290,46 +253,6 @@ umask00.pid: umask00
fifo-rowo-pair.pid: fifo-rowo-pair
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --name_master=$<.master.test --name_slave=$<.slave.test
-%.out: %.pid %
- -kill -TERM `cat $<`
-
-$(TST_STATE:%=%.state): %.state: %
- $(<D)/$(<F) --statefile=$@ --outfile=$<.out start
-
-$(TST_STATE:%=%.out): %.out: %
- -$(<D)/$(<F) --statefile=$<.state --outfile=$@ stop
-
-start: $(PID) $(STATE)
-
-%.is_running: %.pid
- kill -0 `cat $<`
-
-check_start: $(PID:%.pid=%.is_running)
-
-stop: $(STATE_OUT)
- -kill -TERM `cat *.pid`
-
-WAIT_TIME=240
-%.stop: %.pid %
- kill -TERM `cat $<`; \
- i=0; \
- while [ $$i -lt $(WAIT_TIME) ] ; do \
- kill -0 `cat $< 2>/dev/null` 2>/dev/null || break; \
- sleep 1; \
- echo -n .; \
- i=`expr $$i + 1`; \
- done; \
- echo; \
- [ $$i -lt $(WAIT_TIME) ]
-
-wait_stop:
- i=0; \
- while [ $$i -lt $(WAIT_TIME) ] ; do \
- kill -0 `cat *.pid 2>/dev/null` 2>/dev/null || break; \
- sleep 1; \
- i=`expr $$i + 1`; \
- done
-
aio00: override LDLIBS += -laio
different_creds: override LDLIBS += -lcap
futex.o: override CFLAGS += -pthread
@@ -375,19 +298,8 @@ stopped01: override CFLAGS += -DZDTM_STOPPED_KILL
stopped02: override CFLAGS += -DZDTM_STOPPED_TKILL
stopped12: override CFLAGS += -DZDTM_STOPPED_KILL -DZDTM_STOPPED_TKILL
-clean:
- $(RM) -f $(OBJ) $(TST) *~ criu-rtc.so criu-rtc.pb-c.c criu-rtc.pb-c.h get_smaps_bits.o
-
-cleandep: clean
- $(RM) -f $(DEP)
-
-cleanout:
- $(RM) -f -r *.pid *.out* *.test* *.state
-
-%.cleanout: %
- $(Q) $(RM) -f -r $<.pid $<.out* *$<.test* $<.*.test $<.state $<.init.pid
-
-realclean: cleandep cleanout
+clean::
+ $(RM) -f criu-rtc.so criu-rtc.pb-c.c criu-rtc.pb-c.h get_smaps_bits.o
rtc.c: criu-rtc.so
@@ -397,8 +309,4 @@ criu-rtc.pb-c.c: criu-rtc.proto
criu-rtc.so: criu-rtc.c criu-rtc.pb-c.c
$(CC) -g -Wall -shared -nostartfiles criu-rtc.c criu-rtc.pb-c.c -o criu-rtc.so -iquote ../../../../criu/include -fPIC $(USERCFLAGS)
-.PHONY: force clean cleandep cleanout realclean start check_start stop wait_stop
-
-ifeq ($(filter-out no-deps-targets, $(MAKECMDGOALS)),)
--include $(DEP)
-endif
+include ../Makefile.live
diff --git a/test/zdtm/live/streaming/Makefile b/test/zdtm/live/streaming/Makefile
index f1ab5d4..e77f3aa 100644
--- a/test/zdtm/live/streaming/Makefile
+++ b/test/zdtm/live/streaming/Makefile
@@ -1,11 +1,4 @@
-include ../../Makefile.inc
-
-LIBDIR = ../../lib
-LDLIBS = -lzdtmtst
-override CPPFLAGS += -I$(LIBDIR)
-CFLAGS = -g -O2 -Wall -Werror -fno-strict-aliasing -fPIC
-CFLAGS += $(USERCFLAGS)
-LDFLAGS = -fPIC -pie -rdynamic -L$(LIBDIR) -Wl,-rpath,\$$ORIGIN/$(LIBDIR)
+# the include is at the end
TST_NOFILE = \
pipe_loop00 \
@@ -21,67 +14,8 @@ TST_FILE = \
fifo_dyn \
fifo_loop \
-TST = $(TST_NOFILE) $(TST_FILE)
-SRC = $(TST:%=%.c)
-OBJ = $(SRC:%.c=%.o)
-DEP = $(SRC:%.c=%.d)
-PID = $(TST:%=%.pid)
-OUT = $(TST:%=%.out)
-
-DEPEND.c = $(COMPILE.c) -MM -MP
-%.d: %.c
- $(DEPEND.c) $(OUTPUT_OPTION) $<
-
-all: $(TST)
-install: all
-.PHONY: all install
-
-$(TST_NOFILE:%=%.pid): %.pid: %
- $(<D)/$(<F) --pidfile=$@ --outfile=$<.out
-
-$(TST_FILE:%=%.pid): %.pid: %
- $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --filename=$<.test
-
-%.out: %.pid %
- -kill -TERM `cat $<`
-
-start: $(PID)
-
-%.is_running: %.pid
- kill -0 `cat $<`
-
-check_start: $(PID:%.pid=%.is_running)
-
-stop:
- -kill -TERM `cat *.pid`
-
-WAIT_TIME=10
-wait_stop:
- -for i in `seq 1 $(WAIT_TIME)`; do \
- kill -0 `cat *.pid 2>/dev/null` 2>/dev/null || break; \
- sleep 1; \
- done
-
file_aio: override LDLIBS += -lrt -pthread
socket-tcp: override CFLAGS += -D STREAM
socket-tcp6: override CFLAGS += -D ZDTM_IPV6 -D STREAM
-clean:
- $(RM) -f $(OBJ) $(TST) *~
-
-cleandep: clean
- $(RM) -f $(DEP)
-
-%.cleanout: %
- $(Q) $(RM) -f -r $<.pid $<.init.pid $<.out* $<.test
-
-cleanout:
- $(RM) -f *.pid *.out* *.test*
-
-realclean: cleandep cleanout
-
-.PHONY: force clean cleandep cleanout realclean start check_start stop wait_stop
-
-ifeq ($(filter-out no-deps-targets, $(MAKECMDGOALS)),)
--include $(DEP)
-endif
+include ../Makefile.live
diff --git a/test/zdtm/live/transition/Makefile b/test/zdtm/live/transition/Makefile
index 26c84e5..43b3d8d 100644
--- a/test/zdtm/live/transition/Makefile
+++ b/test/zdtm/live/transition/Makefile
@@ -1,11 +1,4 @@
-include ../../Makefile.inc
-
-LIBDIR = ../../lib
-LDLIBS = -lzdtmtst
-override CPPFLAGS += -I$(LIBDIR)
-CFLAGS = -g -O2 -Wall -Werror -fPIC
-CFLAGS += $(USERCFLAGS)
-LDFLAGS = -fPIC -pie -rdynamic -L$(LIBDIR) -Wl,-rpath,\$$ORIGIN/$(LIBDIR)
+# the include is at the end
TST_NOFILE = \
ipc \
@@ -19,47 +12,6 @@ TST_NOFILE = \
TST_FILE = \
file_read \
-TST = $(TST_NOFILE) $(TST_FILE)
-SRC = $(TST:%=%.c)
-OBJ = $(SRC:%.c=%.o)
-DEP = $(SRC:%.c=%.d)
-PID = $(TST:%=%.pid)
-OUT = $(TST:%=%.out)
-
-DEPEND.c = $(COMPILE.c) -MM -MP
-%.d: %.c
- $(DEPEND.c) $(OUTPUT_OPTION) $<
-
-all: $(TST)
-install: all
-.PHONY: all install
-
-$(TST_NOFILE:%=%.pid): %.pid: %
- $(<D)/$(<F) --pidfile=$@ --outfile=$<.out
-
-$(TST_FILE:%=%.pid): %.pid: %
- $(<D)/$(<F) --pidfile=$@ --outfile=$<.out --filename=$<.test
-
-%.out: %.pid %
- -kill -TERM `cat $<`
-
-start: $(PID)
-
-%.is_running: %.pid
- kill -0 `cat $<`
-
-check_start: $(PID:%.pid=%.is_running)
-
-stop:
- -kill -TERM `cat *.pid`
-
-WAIT_TIME=10
-wait_stop:
- -for i in `seq 1 $(WAIT_TIME)`; do \
- kill -0 `cat *.pid 2>/dev/null` 2>/dev/null || break; \
- sleep 1; \
- done
-
ptrace: override LDFLAGS += -pthread
fork2.o: override CFLAGS += -D FORK2
thread-bomb: override LDFLAGS += -pthread
@@ -68,22 +20,4 @@ thread-bomb: override LDFLAGS += -pthread
cp $< $@
chmod +x $@
-clean:
- $(RM) -f $(OBJ) $(TST) *~
-
-cleandep: clean
- $(RM) -f $(DEP)
-
-%.cleanout: %
- $(Q) $(RM) -f -r $<.pid $<.init.pid $<.out* $<.test chew_$<.test*
-
-cleanout:
- $(RM) -f *.pid *.out* *.test chew*
-
-realclean: cleandep cleanout
-
-.PHONY: force clean cleandep cleanout realclean start check_start stop wait_stop
-
-ifeq ($(filter-out no-deps-targets, $(MAKECMDGOALS)),)
--include $(DEP)
-endif
+include ../Makefile.live
--
2.7.1
More information about the CRIU
mailing list