Browse Source

[3406] Moved script with common functions to testutils.

Marcin Siodelski 11 years ago
parent
commit
b76d7a6367

+ 2 - 4
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
 

+ 5 - 1
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

+ 5 - 1
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

+ 4 - 1
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)

+ 9 - 7
src/bin/dhcp6/tests/dhcp6_test_func.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.