From: Marcin Siodelski Date: Wed, 28 May 2014 13:55:28 +0000 (+0200) Subject: [3406] Moved script with common functions to testutils. X-Git-Tag: trac3434_base~17^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b76d7a6367f81d73463bb27c97190ce58bc5f5e5;p=thirdparty%2Fkea.git [3406] Moved script with common functions to testutils. --- diff --git a/src/bin/dhcp6/tests/Makefile.am b/src/bin/dhcp6/tests/Makefile.am index 6afab0e409..7dae97193b 100644 --- a/src/bin/dhcp6/tests/Makefile.am +++ b/src/bin/dhcp6/tests/Makefile.am @@ -1,16 +1,14 @@ PYCOVERAGE_RUN = @PYCOVERAGE_RUN@ PYTESTS = dhcp6_test.py -SHLIBS = SHTESTS = # The test of dynamic reconfiguration based on signals will work only # if we are using file based configuration approach. if CONFIG_BACKEND_JSON -SHLIBS += dhcp6_test_func.sh SHTESTS += dhcp6_reconfigure_test.sh SHTESTS += dhcp6_sigterm_test.sh SHTESTS += dhcp6_sigint_test.sh endif -EXTRA_DIST = $(PYTESTS) $(SHTESTS) $(SHLIBS) +EXTRA_DIST = $(PYTESTS) $(SHTESTS) # Explicitly specify paths to dynamic libraries required by loadable python # modules. That is required on Mac OS systems. Otherwise we will get exception @@ -32,7 +30,7 @@ check-local: for shtest in $(SHTESTS) ; do \ echo Running test: $$shtest ; \ - B10_LOCKFILE_DIR_FROM_BUILD=$(abs_top_builddir) \ + export B10_LOCKFILE_DIR_FROM_BUILD=$(abs_top_builddir); \ $(abs_srcdir)/$$shtest || exit ; \ done diff --git a/src/bin/dhcp6/tests/dhcp6_reconfigure_test.sh b/src/bin/dhcp6/tests/dhcp6_reconfigure_test.sh index f341dc9a11..3100c6c739 100755 --- a/src/bin/dhcp6/tests/dhcp6_reconfigure_test.sh +++ b/src/bin/dhcp6/tests/dhcp6_reconfigure_test.sh @@ -62,8 +62,12 @@ CONFIG_INVALID="{ } }" +# Set the location of the executable. +BIN="b10-dhcp6" +BIN_PATH=".." + # Import common test library. -. $(dirname $0)/dhcp6_test_func.sh +. $(dirname $0)/../../../lib/testutils/dhcp_test_lib.sh # Log the start of the test and print test name. test_start diff --git a/src/bin/dhcp6/tests/dhcp6_shutdown_test.sh b/src/bin/dhcp6/tests/dhcp6_shutdown_test.sh index 0ecee5dce1..52810cb91d 100755 --- a/src/bin/dhcp6/tests/dhcp6_shutdown_test.sh +++ b/src/bin/dhcp6/tests/dhcp6_shutdown_test.sh @@ -47,8 +47,12 @@ CONFIG="{ } }" +# Set the location of the executable. +BIN="b10-dhcp6" +BIN_PATH=".." + # Import common test library. -. $(dirname $0)/dhcp6_test_func.sh +. $(dirname $0)/../../../lib/testutils/dhcp_test_lib.sh # Log the start of the test and print test name. test_start diff --git a/src/lib/testutils/Makefile.am b/src/lib/testutils/Makefile.am index 0c88b843bf..0f105dc06c 100644 --- a/src/lib/testutils/Makefile.am +++ b/src/lib/testutils/Makefile.am @@ -15,4 +15,7 @@ libkea_testutils_la_LIBADD = $(top_builddir)/src/lib/asiolink/libkea-asiolink.l libkea_testutils_la_LIBADD += $(top_builddir)/src/lib/dns/libkea-dns++.la endif -EXTRA_DIST = portconfig.h socket_request.h +# Include common libraries being used by shell-based tests. +SHLIBS = dhcp_test_lib.sh + +EXTRA_DIST = portconfig.h socket_request.h $(SHLIBS) diff --git a/src/bin/dhcp6/tests/dhcp6_test_func.sh b/src/lib/testutils/dhcp_test_lib.sh similarity index 92% rename from src/bin/dhcp6/tests/dhcp6_test_func.sh rename to src/lib/testutils/dhcp_test_lib.sh index 666e91d857..94a6a62866 100755 --- a/src/bin/dhcp6/tests/dhcp6_test_func.sh +++ b/src/lib/testutils/dhcp_test_lib.sh @@ -12,8 +12,11 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# Name of the Kea executable. -BIN="../b10-dhcp6" +# The following two parameters must to be specified in a script +# including this library. +# - BIN - Name of the Kea executable (excluding a path), e.g. b10-dhcp6 +# - BIN_PATH - Path to the Kea executable (excluding an executable name), +# e.g. ../ # Begins a test by prining its name. # It requires the ${TEST_NAME} variable to hold the test name. @@ -35,12 +38,11 @@ set_logger() { export B10_LOGGER_DESTINATION=${LOG_FILE} } -# Returns the number of running b10-dhcp6 process pids and -# the list of pids. +# Returns the number of running process pids and the list of pids. _GET_PIDS= # Return value: holds space separated list of DHCPv6 pids. _GET_PIDS_NUM= # Return value: holds the number of DHCPv6 server pids. get_pids() { - _GET_PIDS=`ps axo pid,command | grep b10-dhcp6 | grep -v grep | awk '{print $1}'` + _GET_PIDS=`ps axo pid,command | grep ${BIN} | grep -v grep | awk '{print $1}'` _GET_PIDS_NUM=`printf "%s" "${_GET_PIDS}" | wc -w | awk '{print $1}'` } @@ -111,8 +113,8 @@ clean_exit() { # Starts Kea process in background using a configuration file specified # in the global variable ${CFG_FILE} start_kea() { - printf "Running command %s.\n" "\"$BIN -c ${CFG_FILE}\"" - $BIN -c ${CFG_FILE} & + printf "Running command %s.\n" "\"${BIN_PATH}/${BIN} -c ${CFG_FILE}\"" + ${BIN_PATH}/$BIN -c ${CFG_FILE} & } # Waits for Kea to startup with timeout.