diff --git a/Makefile b/Makefile index 2148a3575bd..303c4c754eb 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,8 @@ # # Use "make doc" to build documentation. # -# Use "make test" to build unit tests. +# Use "make test" to build unit tests. Add "SKIP_SYNC_REMOTES=y" to skip +# or "FORCE_SYNC_REMOTES=y" to force syncing remote nodes if any is defined. # # Use "make check" to run unit tests. # diff --git a/src/test/.gitignore b/src/test/.gitignore index b9447d6276b..1fa8db97c4a 100644 --- a/src/test/.gitignore +++ b/src/test/.gitignore @@ -10,3 +10,5 @@ testfile* *.static-debug *.static-nondebug libs.tar +*.synced +.sync-dir diff --git a/src/test/Makefile b/src/test/Makefile index a79d245bb58..2008720accc 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -326,9 +326,16 @@ ifeq ($(CHECK_POOL),y) CHECK_POOL_OPT="-c" endif +DIR_SYNC=$(TOP)/src/test/.sync-dir +SYNC_EXT=synced + all test cstyle format: $(TESTS_BUILD) +test: sync-remotes + clean clobber: $(TESTS_BUILD) + $(RM) -r $(DIR_SYNC) + $(RM) *.$(SYNC_EXT) $(TESTS) $(OBJ_DEPS) $(LIBPMEMPOOL_DEPS): $(TEST_DEPS) @@ -411,7 +418,32 @@ pcheck-remote: TARGET = pcheck pcheck-remote: $(REMOTE_TESTS) @echo "No failures." +TESTCONFIG=$(TOP)/src/test/testconfig.sh + +$(TESTCONFIG): + +SUPP_SYNC_FILES=$(shell echo *.supp | sed s/supp/$(SYNC_EXT)/g) + +%.$(SYNC_EXT): %.supp $(TESTCONFIG) + cp $^ $(DIR_SYNC) + @touch $@ + +# sync remote nodes +sync-remotes: +ifeq ($(FORCE_SYNC_REMOTES),y) + @touch $(TESTCONFIG) +endif +ifneq ($(SKIP_SYNC_REMOTES),y) + @rm -rf $(DIR_SYNC) && mkdir -p $(DIR_SYNC) + $(MAKE) $(SUPP_SYNC_FILES) + $(MAKE) -C tools $@ + $(MAKE) -C ../tools $@ + $(MAKE) -C sync-remotes $@ + $(foreach test, $(REMOTE_TESTS), $(MAKE) -C $(test) sync-test;) + @rm -rf $(DIR_SYNC) +endif + .PHONY: all check clean clobber cstyle pcheck pcheck-blk pcheck-log pcheck-obj\ pcheck-other pcheck-pmem pcheck-pmempool pcheck-vmem pcheck-vmmalloc\ test unittest tools check-remote format pcheck-libpmempool\ - pcheck-rpmem pcheck-local pcheck-remote $(TESTS_BUILD) + pcheck-rpmem pcheck-local pcheck-remote sync-remotes $(TESTS_BUILD) diff --git a/src/test/Makefile.inc b/src/test/Makefile.inc index 2ec876df150..7e0fb021088 100644 --- a/src/test/Makefile.inc +++ b/src/test/Makefile.inc @@ -223,6 +223,15 @@ TARGET_STATIC_NONDEBUG=$(TARGET).static-nondebug endif endif +SCP=../sync-remotes/copy-to-remote-nodes.sh +TESTCONFIG=../testconfig.sh +SYNC_FILE=.synced + +ifdef TARGET +SCP_TARGET=$(TARGET) +SCP_SRC_DIR=. +endif + MAKEFILE_DEPS=Makefile ../Makefile.inc $(TOP)/src/common.inc all: $(TARGET) $(TARGET_STATIC_DEBUG) $(TARGET_STATIC_NONDEBUG) @@ -252,26 +261,36 @@ objdir=. $(create-deps) clean: - $(RM) *.o */*.o core a.out *.log testfile* + $(RM) *.o */*.o core a.out *.log testfile* $(SYNC_FILE) clobber: clean $(RM) $(TARGET) $(TARGET_STATIC_DEBUG) $(TARGET_STATIC_NONDEBUG) $(RM) -r .deps +$(TESTCONFIG): + +$(SYNC_FILE): $(TARGET) $(TESTCONFIG) +ifeq ($(SCP_TO_REMOTE_NODES), y) + $(SCP) test $(SCP_SRC_DIR)/$(SCP_TARGET) $(SCP_SRC_DIR)/$(SCP_TARGET).static-debug $(SCP_SRC_DIR)/$(SCP_TARGET).static-nondebug + @touch $(SYNC_FILE) +endif + +sync-test: all $(SYNC_FILE) $(TESTCONFIG) + TST=$(shell basename `pwd`) TSTCHECKS=$(shell ls -1 TEST* | grep -v -i -e "\.ps1" | sort -V) -$(TSTCHECKS): all +$(TSTCHECKS): all sync-test @cd .. && ./RUNTESTS ${TST} -b $(TEST_BUILD) -t $(TEST_TYPE) -f $(TEST_FS) -o $(TEST_TIME) -m $(MEMCHECK) -p $(PMEMCHECK) -e $(HELGRIND) -d $(DRD) -s $@ -check: all +check: all sync-test @cd .. && ./RUNTESTS ${TST} -b $(TEST_BUILD) -t $(TEST_TYPE) -f $(TEST_FS) -o $(TEST_TIME) -m $(MEMCHECK) -p $(PMEMCHECK) -e $(HELGRIND) -d $(DRD) pcheck: export NOTTY=1 pcheck: $(TSTCHECKS) -test: all +test: all sync-test TOOLS=../tools @@ -308,6 +327,6 @@ $(TOOLS)/pmemdetect/pmemdetect.static-nondebug: all: $(TOOLS)/pmemdetect/pmemdetect.static-nondebug -.PHONY: all check clean clobber pcheck test $(TSTCHECKS) +.PHONY: all check clean clobber pcheck test sync-test $(TSTCHECKS) -include .deps/*.P diff --git a/src/test/obj_basic_integration/Makefile.inc b/src/test/obj_basic_integration/Makefile.inc index ff5ed34674a..970dc1afac4 100644 --- a/src/test/obj_basic_integration/Makefile.inc +++ b/src/test/obj_basic_integration/Makefile.inc @@ -36,9 +36,9 @@ # unit tests # +include ../Makefile.inc + ../obj_basic_integration/obj_basic_integration: $(MAKE) -C ../obj_basic_integration all all: ../obj_basic_integration/obj_basic_integration - -include ../Makefile.inc diff --git a/src/test/obj_rpmem_basic_integration/Makefile b/src/test/obj_rpmem_basic_integration/Makefile index 3f1b06b1da2..812667c3972 100644 --- a/src/test/obj_rpmem_basic_integration/Makefile +++ b/src/test/obj_rpmem_basic_integration/Makefile @@ -34,5 +34,8 @@ # src/test/obj_rpmem_basic_integration/Makefile -- unit test for LIBPMEMOBJ # basic operations using remote replication (LIBRPMEM) # +SCP_TO_REMOTE_NODES = y +SCP_TARGET = obj_basic_integration +SCP_SRC_DIR = ../obj_basic_integration include ../obj_basic_integration/Makefile.inc diff --git a/src/test/obj_rpmem_basic_integration/TEST0 b/src/test/obj_rpmem_basic_integration/TEST0 index 12aa6ccc234..0224736baac 100755 --- a/src/test/obj_rpmem_basic_integration/TEST0 +++ b/src/test/obj_rpmem_basic_integration/TEST0 @@ -79,7 +79,7 @@ create_poolset $DIR/$TEST_SET_LOCAL 8M:${NODE_DIRS[1]}/$TEST_FILE_LOCAL:x \ create_poolset $DIR/$TEST_SET_REMOTE 9M:${NODE_DIRS[0]}/$TEST_FILE_REMOTE:x copy_files_to_node 0 . $DIR/$TEST_SET_REMOTE -copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL ../$EXE/$EXE$EXESUFFIX +copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL rm_files_from_node 0 $TEST_FILE_REMOTE rm_files_from_node 1 $TEST_FILE_LOCAL diff --git a/src/test/obj_rpmem_basic_integration/TEST1 b/src/test/obj_rpmem_basic_integration/TEST1 index a31e7eedce4..a2c34d024ba 100755 --- a/src/test/obj_rpmem_basic_integration/TEST1 +++ b/src/test/obj_rpmem_basic_integration/TEST1 @@ -77,7 +77,7 @@ create_poolset $DIR/$TEST_SET_LOCAL 8M:${NODE_DIRS[1]}/$TEST_FILE_LOCAL:x \ create_poolset $DIR/$TEST_SET_REMOTE 9M:${NODE_DIRS[0]}/$TEST_FILE_REMOTE:x copy_files_to_node 0 . $DIR/$TEST_SET_REMOTE -copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL ../$EXE/$EXE$EXESUFFIX +copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL rm_files_from_node 0 $TEST_FILE_REMOTE rm_files_from_node 1 $TEST_FILE_LOCAL diff --git a/src/test/obj_rpmem_basic_integration/TEST2 b/src/test/obj_rpmem_basic_integration/TEST2 index 605702c7fb5..fd4654181ce 100755 --- a/src/test/obj_rpmem_basic_integration/TEST2 +++ b/src/test/obj_rpmem_basic_integration/TEST2 @@ -78,7 +78,7 @@ create_poolset $DIR/$TEST_SET_LOCAL \ create_poolset $DIR/$TEST_SET_REMOTE 18M:${NODE_DIRS[0]}/$TEST_FILE_REMOTE:x copy_files_to_node 0 . $DIR/$TEST_SET_REMOTE -copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL ../$EXE/$EXE$EXESUFFIX +copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL rm_files_from_node 0 $TEST_FILE_REMOTE rm_files_from_node 1 $TEST_FILE_LOCAL part1 part2 diff --git a/src/test/obj_rpmem_basic_integration/TEST3 b/src/test/obj_rpmem_basic_integration/TEST3 index b9321cf83f3..34d2272cc4a 100755 --- a/src/test/obj_rpmem_basic_integration/TEST3 +++ b/src/test/obj_rpmem_basic_integration/TEST3 @@ -80,7 +80,7 @@ create_poolset $DIR/$TEST_SET_REMOTE \ 8M:${NODE_DIRS[0]}/${TEST_FILE_REMOTE}1:x copy_files_to_node 0 . $DIR/$TEST_SET_REMOTE -copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL ../$EXE/$EXE$EXESUFFIX +copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL rm_files_from_node 0 ${TEST_FILE_REMOTE}0 ${TEST_FILE_REMOTE}1 rm_files_from_node 1 ${TEST_FILE_LOCAL}0 ${TEST_FILE_LOCAL}1 diff --git a/src/test/obj_rpmem_basic_integration/TEST4 b/src/test/obj_rpmem_basic_integration/TEST4 index 16878937ad7..cc35ecdeac5 100755 --- a/src/test/obj_rpmem_basic_integration/TEST4 +++ b/src/test/obj_rpmem_basic_integration/TEST4 @@ -82,7 +82,7 @@ create_poolset $DIR/$TEST_SET_REMOTE \ r 12M:${NODE_DIRS[0]}/${TEST_FILE_REMOTE}1:x copy_files_to_node 0 . $DIR/$TEST_SET_REMOTE -copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL ../$EXE/$EXE$EXESUFFIX +copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL rm_files_from_node 0 $TEST_FILE_REMOTE rm_files_from_node 1 $TEST_FILE_LOCAL diff --git a/src/test/obj_rpmem_constructor/Makefile b/src/test/obj_rpmem_constructor/Makefile index b6f8df2abf1..ffff3dd58f1 100644 --- a/src/test/obj_rpmem_constructor/Makefile +++ b/src/test/obj_rpmem_constructor/Makefile @@ -33,5 +33,8 @@ # # src/test/obj_rpmem_constructor/Makefile -- build obj_rpmem_constructor test # +SCP_TO_REMOTE_NODES = y +SCP_TARGET = obj_constructor +SCP_SRC_DIR = ../obj_constructor include ../obj_constructor/Makefile.inc diff --git a/src/test/obj_rpmem_constructor/TEST0 b/src/test/obj_rpmem_constructor/TEST0 index 3ad5df1c686..f4859ead9d6 100755 --- a/src/test/obj_rpmem_constructor/TEST0 +++ b/src/test/obj_rpmem_constructor/TEST0 @@ -87,7 +87,7 @@ create_poolset $DIR/$TEST_SET_LOCAL 8M:${NODE_DIRS[1]}/$TEST_FILE_LOCAL:x \ create_poolset $DIR/$TEST_SET_REMOTE 9M:${NODE_DIRS[0]}/$TEST_FILE_REMOTE:x copy_files_to_node 0 . $DIR/$TEST_SET_REMOTE -copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL ../$EXE/$EXE$EXESUFFIX +copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL # create remote holey pool files create_holey_file_on_node 1 8M ${NODE_DIRS[1]}/$TEST_FILE_LOCAL diff --git a/src/test/obj_rpmem_heap_interrupt/Makefile b/src/test/obj_rpmem_heap_interrupt/Makefile index f17aa5a9785..62a6ab8a5be 100644 --- a/src/test/obj_rpmem_heap_interrupt/Makefile +++ b/src/test/obj_rpmem_heap_interrupt/Makefile @@ -34,5 +34,8 @@ # src/test/obj_rpmem_heap_interrupt/Makefile -- build obj_rpmem_heap_interrupt # test # +SCP_TO_REMOTE_NODES = y +SCP_TARGET = obj_heap_interrupt +SCP_SRC_DIR = ../obj_heap_interrupt include ../obj_heap_interrupt/Makefile.inc diff --git a/src/test/obj_rpmem_heap_interrupt/TEST0 b/src/test/obj_rpmem_heap_interrupt/TEST0 index 8e1307f0d4f..3119a5e88e9 100755 --- a/src/test/obj_rpmem_heap_interrupt/TEST0 +++ b/src/test/obj_rpmem_heap_interrupt/TEST0 @@ -83,7 +83,7 @@ create_poolset $DIR/$TEST_SET_LOCAL 8M:${NODE_DIRS[1]}/$TEST_FILE_LOCAL:x \ create_poolset $DIR/$TEST_SET_REMOTE 9M:${NODE_DIRS[0]}/$TEST_FILE_REMOTE:x copy_files_to_node 0 . $DIR/$TEST_SET_REMOTE -copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL ../$EXE/$EXE$EXESUFFIX +copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL # create remote holey pool files create_holey_file_on_node 1 8M ${NODE_DIRS[1]}/$TEST_FILE_LOCAL diff --git a/src/test/obj_rpmem_heap_state/Makefile b/src/test/obj_rpmem_heap_state/Makefile index 376968adf88..510652a901b 100644 --- a/src/test/obj_rpmem_heap_state/Makefile +++ b/src/test/obj_rpmem_heap_state/Makefile @@ -33,5 +33,8 @@ # # src/test/obj_rpmem_heap_state/Makefile -- build obj_rpmem_heap_state test # +SCP_TO_REMOTE_NODES = y +SCP_TARGET = obj_heap_state +SCP_SRC_DIR = ../obj_heap_state include ../obj_heap_state/Makefile.inc diff --git a/src/test/obj_rpmem_heap_state/TEST0 b/src/test/obj_rpmem_heap_state/TEST0 index a77748250da..e941641a12c 100755 --- a/src/test/obj_rpmem_heap_state/TEST0 +++ b/src/test/obj_rpmem_heap_state/TEST0 @@ -77,7 +77,7 @@ create_poolset $DIR/$TEST_SET_LOCAL 8M:${NODE_DIRS[1]}/$TEST_FILE_LOCAL:x \ create_poolset $DIR/$TEST_SET_REMOTE 9M:${NODE_DIRS[0]}/$TEST_FILE_REMOTE:x copy_files_to_node 0 . $DIR/$TEST_SET_REMOTE -copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL ../$EXE/$EXE$EXESUFFIX +copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL # create remote holey pool files create_holey_file_on_node 1 8M ${NODE_DIRS[1]}/$TEST_FILE_LOCAL diff --git a/src/test/obj_rpmem_heap_state/TEST1 b/src/test/obj_rpmem_heap_state/TEST1 index ffdb2ec5087..3a23e745a09 100755 --- a/src/test/obj_rpmem_heap_state/TEST1 +++ b/src/test/obj_rpmem_heap_state/TEST1 @@ -77,7 +77,7 @@ create_poolset $DIR/$TEST_SET_REMOTE \ 16M:${NODE_DIRS[0]}/${TEST_FILE_REMOTE}_part2:x copy_files_to_node 0 . $DIR/$TEST_SET_REMOTE -copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL ../$EXE/$EXE$EXESUFFIX +copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL rm_files_from_node 0 "${TEST_FILE_REMOTE} ${TEST_FILE_REMOTE}_part1 ${TEST_FILE_REMOTE}_part2" rm_files_from_node 1 "${TEST_FILE_LOCAL} ${TEST_FILE_LOCAL}_part1 ${TEST_FILE_LOCAL}_part2" diff --git a/src/test/obj_rpmem_heap_state/TEST2 b/src/test/obj_rpmem_heap_state/TEST2 index d1ef121266b..dfee44fe3d7 100755 --- a/src/test/obj_rpmem_heap_state/TEST2 +++ b/src/test/obj_rpmem_heap_state/TEST2 @@ -77,7 +77,7 @@ create_poolset $DIR/$TEST_SET_LOCAL 8M:${NODE_DIRS[1]}/$TEST_FILE_LOCAL:x \ create_poolset $DIR/$TEST_SET_REMOTE 9M:${NODE_DIRS[0]}/$TEST_FILE_REMOTE:x copy_files_to_node 0 . $DIR/$TEST_SET_REMOTE -copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL ../$EXE/$EXE$EXESUFFIX +copy_files_to_node 1 . $DIR/$TEST_SET_LOCAL PMEM_IS_PMEM_FORCE=1 export_vars_node 1 PMEM_IS_PMEM_FORCE diff --git a/src/test/remote_basic/Makefile b/src/test/remote_basic/Makefile index c40fa061707..a909b7e6592 100644 --- a/src/test/remote_basic/Makefile +++ b/src/test/remote_basic/Makefile @@ -33,6 +33,8 @@ # # src/test/remote_basic/Makefile -- build remote_basic unit test # +SCP_TO_REMOTE_NODES = y + TARGET = remote_basic OBJS = remote_basic.o diff --git a/src/test/remote_obj_basic/Makefile b/src/test/remote_obj_basic/Makefile index 026a702ad14..eba86c53c34 100644 --- a/src/test/remote_obj_basic/Makefile +++ b/src/test/remote_obj_basic/Makefile @@ -33,6 +33,8 @@ # # src/test/remote_obj_basic/Makefile -- build remote_obj_basic unit test # +SCP_TO_REMOTE_NODES = y + TARGET = remote_obj_basic OBJS = remote_obj_basic.o diff --git a/src/test/rpmem_basic/Makefile b/src/test/rpmem_basic/Makefile index ab769f9c655..ce691318230 100644 --- a/src/test/rpmem_basic/Makefile +++ b/src/test/rpmem_basic/Makefile @@ -33,6 +33,8 @@ # # src/test/rpmem_basic/Makefile -- build rpmem_basic test # +SCP_TO_REMOTE_NODES = y + include ../../common.inc vpath %.c ../../common diff --git a/src/test/rpmem_fip/Makefile b/src/test/rpmem_fip/Makefile index 44ff1aab018..727895da8c4 100644 --- a/src/test/rpmem_fip/Makefile +++ b/src/test/rpmem_fip/Makefile @@ -33,6 +33,8 @@ # # src/test/rpmem_fip/Makefile -- build rpmem_fip test # +SCP_TO_REMOTE_NODES = y + include ../../common.inc vpath %.c ../../librpmem/ diff --git a/src/test/rpmem_obc/Makefile b/src/test/rpmem_obc/Makefile index f21763a74eb..595aa96c8c7 100644 --- a/src/test/rpmem_obc/Makefile +++ b/src/test/rpmem_obc/Makefile @@ -33,6 +33,8 @@ # # src/test/rpmem_obc/Makefile -- build rpmem_obc test # +SCP_TO_REMOTE_NODES = y + vpath %.c ../../librpmem/ vpath %.c ../../rpmem_common/ diff --git a/src/test/rpmem_obc_int/Makefile b/src/test/rpmem_obc_int/Makefile index 2fac6857d8e..e51693fb8cb 100644 --- a/src/test/rpmem_obc_int/Makefile +++ b/src/test/rpmem_obc_int/Makefile @@ -33,6 +33,8 @@ # # src/test/rpmem_obc_int/Makefile -- build rpmem_obc_int test # +SCP_TO_REMOTE_NODES = y + vpath %.c ../../librpmem/ vpath %.c ../../rpmem_common/ vpath %.c ../../tools/rpmemd diff --git a/src/test/rpmemd_obc/Makefile b/src/test/rpmemd_obc/Makefile index 7687e035169..d947e28442c 100644 --- a/src/test/rpmemd_obc/Makefile +++ b/src/test/rpmemd_obc/Makefile @@ -33,6 +33,8 @@ # # src/test/rpmemd_obc/Makefile -- build rpmemd_obc test # +SCP_TO_REMOTE_NODES = y + vpath %.c ../../tools/rpmemd vpath %.c ../../rpmem_common vpath %.c ../../librpmem diff --git a/src/test/sync-remotes/Makefile b/src/test/sync-remotes/Makefile new file mode 100644 index 00000000000..75e53b5b25b --- /dev/null +++ b/src/test/sync-remotes/Makefile @@ -0,0 +1,43 @@ +# +# Copyright 2016, Intel Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# +# src/test/sync-remote/Makefile -- copy common files to remote nodes +# + +DIR_SYNC=../.sync-dir + +# sync remote nodes +sync-remotes: + @./copy-to-remote-nodes.sh common $(DIR_SYNC) + +.PHONY: sync-remotes diff --git a/src/test/sync-remotes/copy-to-remote-nodes.sh b/src/test/sync-remotes/copy-to-remote-nodes.sh new file mode 100755 index 00000000000..45047252b70 --- /dev/null +++ b/src/test/sync-remotes/copy-to-remote-nodes.sh @@ -0,0 +1,62 @@ +#!/bin/bash -e +# +# Copyright 2016, Intel Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# copy-to-remote-nodes.sh -- helper script used to sync remote nodes + +if [ ! -f ../testconfig.sh ]; then + echo "SKIP: testconfig.sh does not exist" + exit 0 +fi + +# defined only to be able to source unittest.sh +UNITTEST_NAME=0 +UNITTEST_NUM=0 + +. ../unittest/unittest.sh + +COPY_TYPE=$1 +shift + +case "$COPY_TYPE" in + common) + copy_common_to_remote_nodes $* + exit 0 + ;; + test) + copy_test_to_remote_nodes $* + exit 0 + ;; +esac + +echo "Error: unknown copy type: $COPY_TYPE" +exit 1 diff --git a/src/test/tools/Makefile b/src/test/tools/Makefile index 43ae9c8ac6d..676e1e46ce0 100644 --- a/src/test/tools/Makefile +++ b/src/test/tools/Makefile @@ -34,6 +34,10 @@ # src/test/tools/Makefile -- build unit test helpers # +TOP = ../../.. + +TESTCONFIG=$(TOP)/src/test/testconfig.sh + DIRS = \ pmemspoil\ pmemwrite\ @@ -44,14 +48,23 @@ DIRS = \ bttcreate\ fip +REMOTE_TOOLS = \ + ctrld\ + fip + all : TARGET = all clean : TARGET = clean clobber : TARGET = clobber cstyle : TARGET = cstyle format : TARGET = format +sync-remotes : TARGET = sync-remotes all test cstyle clean clobber format: $(DIRS) +$(TESTCONFIG): + +sync-remotes: $(REMOTE_TOOLS) $(TESTCONFIG) + $(DIRS): $(MAKE) -C $@ $(TARGET) diff --git a/src/test/tools/ctrld/Makefile b/src/test/tools/ctrld/Makefile index ba79c7a039b..959d23b6ac2 100644 --- a/src/test/tools/ctrld/Makefile +++ b/src/test/tools/ctrld/Makefile @@ -31,6 +31,8 @@ # Makefile -- Makefile for ctrld tool # +SCP_TO_REMOTE_NODES = y + TOP = ../../../.. TARGET = ctrld diff --git a/src/test/tools/fip/Makefile b/src/test/tools/fip/Makefile index 63314541be6..d09fad31aad 100644 --- a/src/test/tools/fip/Makefile +++ b/src/test/tools/fip/Makefile @@ -32,6 +32,8 @@ # Makefile -- Makefile for fip tool # +SCP_TO_REMOTE_NODES = y + TOP = ../../../.. include $(TOP)/src/common.inc diff --git a/src/test/unittest/unittest.sh b/src/test/unittest/unittest.sh index 039fa240ea2..82b3ba1ca2f 100644 --- a/src/test/unittest/unittest.sh +++ b/src/test/unittest/unittest.sh @@ -895,7 +895,7 @@ function require_valgrind() { exit 0 fi [ $NODES_MAX -lt 0 ] && return; - for (( N=$NODES_MAX ; $(($N + 1)) ; N=$(($N - 1)) )); do + for N in $NODES_SEQ; do if [ "${NODE_VALGRINDEXE[$N]}" = "" ]; then set +e NODE_VALGRINDEXE[$N]=$(ssh $SSH_OPTS ${NODE[$N]} "which valgrind 2>/dev/null") @@ -1014,7 +1014,7 @@ function set_valgrind_exe_name() { fi [ $NODES_MAX -lt 0 ] && return; - for (( N=$NODES_MAX ; $(($N + 1)) ; N=$(($N - 1)) )); do + for N in $NODES_SEQ; do local COMMAND="\ [ -x $(dirname ${NODE_VALGRINDEXE[$N]})/valgrind.bin ] && \ echo $(dirname ${NODE_VALGRINDEXE[$N]})/valgrind.bin || \ @@ -1213,7 +1213,7 @@ function clean_all_remote_nodes() { local N=0 set +e - for (( N=$NODES_MAX ; $(($N + 1)) ; N=$(($N - 1)) )); do + for N in $NODES_SEQ; do local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir for pidfile in ${NODE_PID_FILES[$N]}; do run_command ssh $SSH_OPTS ${NODE[$N]} "\ @@ -1254,7 +1254,7 @@ function require_node_libfabric() { require_node_pkg $N libfabric local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir - local COMMAND="$COMMAND LD_LIBRARY_PATH=.:${NODE_LD_LIBRARY_PATH[$N]} ../fip $*" + local COMMAND="$COMMAND LD_LIBRARY_PATH=$REMOTE_LD_LIBRARY_PATH:${NODE_LD_LIBRARY_PATH[$N]} ../fip $*" set +e fip_out=$(ssh $SSH_OPTS ${NODE[$N]} "cd $DIR && $COMMAND" 2>&1) @@ -1282,6 +1282,17 @@ function require_rpmem_port() { fi } +# +# check_if_node_is_reachable -- check if the $1 node is reachable +# +function check_if_node_is_reachable() { + set +e + run_command ssh $SSH_OPTS ${NODE[$1]} exit + local ret=$? + set -e + return $ret +} + # # require_nodes -- only allow script to continue for a certain number # of defined and reachable nodes @@ -1300,9 +1311,10 @@ function require_nodes() { && exit 0 NODES_MAX=$(($N - 1)) + NODES_SEQ=$(seq -s' ' 0 $NODES_MAX) # check if all required nodes are reachable - for (( N=$NODES_MAX ; $(($N + 1)) ; N=$(($N - 1)) )); do + for N in $NODES_SEQ; do # validate node's address [ "${NODE[$N]}" = "" ] \ && echo "$UNITTEST_NAME: SKIP: address of node #$N is not provided" \ @@ -1314,12 +1326,9 @@ function require_nodes() { && exit 1 # check if the node is reachable - set +e - run_command ssh $SSH_OPTS ${NODE[$N]} exit - local ret=$? - set -e - [ $ret -ne 0 ] \ - && echo "error: host ${NODE[$N]} is unreachable" >&2 \ + check_if_node_is_reachable $N + [ $? -ne 0 ] \ + && echo "error: node #$N (${NODE[$N]}) is unreachable" >&2 \ && exit 1 # clear the list of PID files for each node @@ -1340,42 +1349,15 @@ function require_nodes() { fi done - # files to be copied to all remote nodes - local FILES_TO_COPY="" - - # add all libraries to the 'to-copy' list - local LIBS_TAR=libs.tar - local LIBS_TAR_DIR=$(pwd)/$LIBS_TAR - cd $DIR_SRC - tar -cf $LIBS_TAR_DIR ./debug/*.so* ./nondebug/*.so* - cd - > /dev/null - FILES_COMMON_DIR="$FILES_COMMON_DIR $LIBS_TAR" - - # copy a binary if it exists - local TEST_NAME=`echo $UNITTEST_NAME | cut -d"/" -f1` - local BINARY=$TEST_NAME$EXESUFFIX - [ -f $BINARY ] && FILES_TO_COPY="$FILES_TO_COPY $BINARY" - - # copy all required files to all required nodes - for (( N=$NODES_MAX ; $(($N + 1)) ; N=$(($N - 1)) )); do - # create a new test dir - local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir - run_command ssh $SSH_OPTS ${NODE[$N]} "rm -rf $DIR && mkdir -p $DIR" - run_command scp $SCP_OPTS $FILES_COMMON_DIR ${NODE[$N]}:${NODE_WORKING_DIR[$N]} - run_command ssh $SSH_OPTS ${NODE[$N]} "cd ${NODE_WORKING_DIR[$N]} && tar -xf $LIBS_TAR && rm -f $LIBS_TAR" - - # copy all required files - if [ "$FILES_TO_COPY" != "" ]; then - run_command scp $SCP_OPTS $FILES_TO_COPY ${NODE[$N]}:$DIR - fi + for N in $NODES_SEQ; do + # remove all log files from the node N + rm -f $(find . -name "node_${N}_*$UNITTEST_NUM.log") export_vars_node $N $REMOTE_VARS done - rm -f $LIBS_TAR - # remove all log files from required nodes - for (( N=$NODES_MAX ; $(($N + 1)) ; N=$(($N - 1)) )); do + for N in $NODES_SEQ; do for f in $(get_files "node_${N}.*\.log"); do rm -f $f done @@ -1389,6 +1371,7 @@ function require_nodes() { # # copy_files_to_node -- copy all required files to the given remote node +# usage: copy_files_to_node [] ... # function copy_files_to_node() { @@ -1397,7 +1380,7 @@ function copy_files_to_node() { local N=$1 local DEST_DIR=$2 shift 2 - [ "$*" == "" ] &&\ + [ $# -eq 0 ] &&\ echo "error: copy_files_to_node(): no files provided" >&2 && exit 1 # copy all required files @@ -1418,7 +1401,7 @@ function copy_files_from_node() { local N=$1 local DEST_DIR=$2 shift 2 - [ "$*" == "" ] &&\ + [ $# -eq 0 ] &&\ echo "error: copy_files_from_node(): no files provided" >&2 && exit 1 # copy all required files @@ -1441,7 +1424,7 @@ function copy_files_from_node() { # function copy_log_files() { local NODE_SCP_LOG_FILES[0]="" - for (( N=$NODES_MAX ; $(($N + 1)) ; N=$(($N - 1)) )); do + for N in $NODES_SEQ; do local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir for file in ${NODE_LOG_FILES[$N]}; do NODE_SCP_LOG_FILES[$N]="${NODE_SCP_LOG_FILES[$N]} ${NODE[$N]}:$DIR/${file}" @@ -1453,6 +1436,28 @@ function copy_log_files() { done } +# +# rm_files_from_node -- removes all listed files from the given remote node +# usage: rm_files_from_node [] ... +# +function rm_files_from_node() { + + validate_node_number $1 + + local N=$1 + shift + [ $# -eq 0 ] &&\ + echo "error: rm_files_from_node(): no files provided" >&2 && exit 1 + + # copy all required files + local REMOTE_DIR=${NODE_WORKING_DIR[$N]}/$curtestdir + + run_command ssh $SSH_OPTS ${NODE[$N]} "cd $REMOTE_DIR && rm -f $@" + + return 0 +} + +# # # require_node_log_files -- store log files which must be copied from # specified node on failure @@ -1707,7 +1712,7 @@ function check() { NODE_SCP_MATCH_FILES[$N]="${NODE_SCP_MATCH_FILES[$N]} ${NODE[$N]}:$DIR/$FILE" done - for (( N=$NODES_MAX ; $(($N + 1)) ; N=$(($N - 1)) )); do + for N in $NODES_SEQ; do [ "${NODE_SCP_MATCH_FILES[$N]}" ] && run_command scp $SCP_OPTS ${NODE_SCP_MATCH_FILES[$N]} . for file in ${NODE_MATCH_FILES[$N]}; do mv $file node_${N}_${file} @@ -2026,8 +2031,12 @@ function init_rpmem_on_node() { export_vars_node $master RPMEM_ENABLE_VERBS export_vars_node $master RPMEM_LOG_LEVEL export_vars_node $master RPMEM_LOG_FILE + export_vars_node $master PMEMOBJ_LOG_LEVEL + export_vars_node $master PMEMOBJ_LOG_FILE require_node_log_files $master rpmem$UNITTEST_NUM.log + require_node_log_files $slave rpmemd$UNITTEST_NUM.log + require_node_log_files $master $PMEMOBJ_LOG_FILE # Workaround for SIGSEGV in the infinipath-psm during abort # The infinipath-psm is registering a signal handler and do not unregister @@ -2037,3 +2046,96 @@ function init_rpmem_on_node() { IPATH_NO_BACKTRACE=1 export_vars_node $master IPATH_NO_BACKTRACE } + +# +# pack_all_libs -- put all libraries and their links to one tarball +# +function pack_all_libs() { + local LIBS_TAR_DIR=$(pwd)/$1 + cd $DIR_SRC + tar -cf $LIBS_TAR_DIR ./debug/*.so* ./nondebug/*.so* + cd - > /dev/null +} + +# +# copy_common_to_remote_nodes -- copy common files to all remote nodes +# +function copy_common_to_remote_nodes() { + + local NODES_ALL_MAX=$((${#NODE[@]} - 1)) + local NODES_ALL_SEQ=$(seq -s' ' 0 $NODES_ALL_MAX) + + DIR_SYNC=$1 + [ ! -d $DIR_SYNC ] \ + && echo "error: $DIR_SYNC does not exist or is not a directory" >&2 \ + && exit 1 + + # add all libraries to the 'to-copy' list + local LIBS_TAR=libs.tar + pack_all_libs $LIBS_TAR + + if [ "$(ls $DIR_SYNC)" != "" ]; then + FILES_COMMON_DIR="$DIR_SYNC/* $LIBS_TAR" + else + FILES_COMMON_DIR="$LIBS_TAR" + fi + + for N in $NODES_ALL_SEQ; do + # validate node's address + [ "${NODE[$N]}" = "" ] \ + && echo "error: address of node #$N is not provided" >&2 \ + && exit 1 + + check_if_node_is_reachable $N + [ $? -ne 0 ] \ + && echo "warning: node #$N (${NODE[$N]}) is unreachable, skipping..." >&2 \ + && continue + + # validate the working directory + [ "${NODE_WORKING_DIR[$N]}" = "" ] \ + && echo ": warning: working directory for node #$N (${NODE[$N]}) is not provided, skipping..." >&2 \ + && continue + + # create the working dir if it does not exist + run_command ssh $SSH_OPTS ${NODE[$N]} "mkdir -p ${NODE_WORKING_DIR[$N]}" + # copy all common files + run_command scp $SCP_OPTS $FILES_COMMON_DIR ${NODE[$N]}:${NODE_WORKING_DIR[$N]} + # unpack libraries + run_command ssh $SSH_OPTS ${NODE[$N]} "cd ${NODE_WORKING_DIR[$N]} \ + && tar -xf $LIBS_TAR && rm -f $LIBS_TAR" + done + + rm -f $LIBS_TAR +} + +# +# copy_test_to_remote_nodes -- copy all unit test binaries to all remote nodes +# +function copy_test_to_remote_nodes() { + + local NODES_ALL_MAX=$((${#NODE[@]} - 1)) + local NODES_ALL_SEQ=$(seq -s' ' 0 $NODES_ALL_MAX) + + for N in $NODES_ALL_SEQ; do + # validate node's address + [ "${NODE[$N]}" = "" ] \ + && echo "error: address of node #$N is not provided" >&2 \ + && exit 1 + + check_if_node_is_reachable $N + [ $? -ne 0 ] \ + && echo "warning: node #$N (${NODE[$N]}) is unreachable, skipping..." >&2 \ + && continue + + # validate the working directory + [ "${NODE_WORKING_DIR[$N]}" = "" ] \ + && echo ": warning: working directory for node #$N (${NODE[$N]}) is not provided, skipping..." >&2 \ + && continue + + local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir + # create a new test dir + run_command ssh $SSH_OPTS ${NODE[$N]} "rm -rf $DIR && mkdir -p $DIR" + # copy all required files + [ $# -gt 0 ] && run_command scp $SCP_OPTS $* ${NODE[$N]}:$DIR + done +} diff --git a/src/tools/.gitignore b/src/tools/.gitignore index 6b94b87d1a4..11dc3fb7618 100644 --- a/src/tools/.gitignore +++ b/src/tools/.gitignore @@ -4,3 +4,4 @@ cscope.po.out cscope.out *.static-debug *.static-nondebug +.synced diff --git a/src/tools/Makefile b/src/tools/Makefile index 3737030c519..3d5a23067ca 100644 --- a/src/tools/Makefile +++ b/src/tools/Makefile @@ -31,6 +31,10 @@ # Makefile -- top Makefile for tools # +TOP = ../.. + +TESTCONFIG=$(TOP)/src/test/testconfig.sh + TARGETS = pmempool rpmemd SCOPEDIRS=$(TARGETS) SCOPEFILES=$(foreach dir, $(SCOPEDIRS), $(shell find $(dir) -name *.[ch] )) @@ -44,9 +48,14 @@ cstyle : TARGET = cstyle format : TARGET = format install: TARGET = install uninstall: TARGET = uninstall +sync-remotes: TARGET = sync-remotes all clean clobber cstyle install uninstall check format test: $(TARGETS) +$(TESTCONFIG): + +sync-remotes: $(TARGETS) $(TESTCONFIG) + $(TARGETS): $(MAKE) -C $@ $(TARGET) @@ -59,4 +68,4 @@ cscope: cscope -q -b $(SCOPEFILES) ctags -e $(SCOPEFILES) -.PHONY: all clean clobber cstyle format install uninstall common cscope $(TARGETS) +.PHONY: all clean clobber cstyle format install uninstall common cscope sync-remotes $(TARGETS) diff --git a/src/tools/Makefile.inc b/src/tools/Makefile.inc index 26bfad31873..a05bb283a68 100644 --- a/src/tools/Makefile.inc +++ b/src/tools/Makefile.inc @@ -176,8 +176,10 @@ else all: endif +SYNC_FILE=.synced + clean: - $(RM) $(OBJS) $(CLEAN_FILES) + $(RM) $(OBJS) $(CLEAN_FILES) $(SYNC_FILE) clobber: clean ifneq ($(TARGET),) @@ -253,6 +255,19 @@ objdir=. test check pcheck: all +TESTCONFIG=$(TOP)/src/test/testconfig.sh +DIR_SYNC=$(TOP)/src/test/.sync-dir + +$(TESTCONFIG): + +sync-remotes: all $(SYNC_FILE) + +$(SYNC_FILE): $(TARGET) $(TESTCONFIG) +ifeq ($(SCP_TO_REMOTE_NODES), y) + cp $(TARGET) $(DIR_SYNC) + @touch $(SYNC_FILE) +endif + .PHONY: all clean clobber install uninstall test check pcheck -include .deps/*.P diff --git a/src/tools/pmempool/Makefile b/src/tools/pmempool/Makefile index f23057938bb..43b50411335 100644 --- a/src/tools/pmempool/Makefile +++ b/src/tools/pmempool/Makefile @@ -30,6 +30,8 @@ # # Makefile -- top Makefile for pmempool # +SCP_TO_REMOTE_NODES = y + vpath %.c ../../libpmemobj/ TARGET = pmempool diff --git a/src/tools/rpmemd/Makefile b/src/tools/rpmemd/Makefile index 0b377e1096d..dce8809215d 100644 --- a/src/tools/rpmemd/Makefile +++ b/src/tools/rpmemd/Makefile @@ -31,6 +31,8 @@ # Makefile -- top Makefile for rpmemd # +SCP_TO_REMOTE_NODES = y + vpath %.c ../../rpmem_common/ TOP = ../../.. diff --git a/utils/build-dpkg.sh b/utils/build-dpkg.sh index 1d2589acd19..54d80da52ea 100755 --- a/utils/build-dpkg.sh +++ b/utils/build-dpkg.sh @@ -196,12 +196,14 @@ override_dh_auto_test: else\ cp src/test/testconfig.sh.example src/test/testconfig.sh;\ fi - make pcheck $PCHECK_OPTS " -if [ "${BUILD_PACKAGE_CHECK}" != "y" ] +if [ "${BUILD_PACKAGE_CHECK}" == "y" ] then - CHECK_CMD="" +CHECK_CMD=" +${CHECK_CMD} + make pcheck ${PCHECK_OPTS} +" fi check_tool debuild diff --git a/utils/build-rpm.sh b/utils/build-rpm.sh index b22effe0a13..f5e789434dd 100755 --- a/utils/build-rpm.sh +++ b/utils/build-rpm.sh @@ -442,6 +442,11 @@ Usefull applications for administration and diagnostic purposes. %setup -q -n $PACKAGE_SOURCE %build +if [ -f $TEST_CONFIG_FILE ]; then + cp $TEST_CONFIG_FILE src/test/testconfig.sh +else + cp src/test/testconfig.sh.example src/test/testconfig.sh +fi %{__make} %install