Browse Source

[master] Merge branch 'trac4224'

Marcin Siodelski 9 years ago
parent
commit
94edccc50c

+ 4 - 4
src/bin/d2/tests/d2_process_tests.sh.in

@@ -99,7 +99,7 @@ dynamic_reconfiguration_test() {
 
 
     # Check if it is still running. It could have terminated (e.g. as a result
     # Check if it is still running. It could have terminated (e.g. as a result
     # of configuration failure).
     # of configuration failure).
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
         printf "ERROR: expected one D2 process to be started. Found %d processes\
         printf "ERROR: expected one D2 process to be started. Found %d processes\
  started.\n" ${_GET_PIDS_NUM}
  started.\n" ${_GET_PIDS_NUM}
@@ -139,7 +139,7 @@ dynamic_reconfiguration_test() {
     fi
     fi
 
 
     # Make sure the server is still operational.
     # Make sure the server is still operational.
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
         printf "ERROR: D2 was killed when attempting reconfiguration.\n"
         printf "ERROR: D2 was killed when attempting reconfiguration.\n"
         clean_exit 1
         clean_exit 1
@@ -166,7 +166,7 @@ dynamic_reconfiguration_test() {
     fi
     fi
 
 
     # Make sure the server is still operational.
     # Make sure the server is still operational.
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
         printf "ERROR: D2 was killed when attempting reconfiguration.\n"
         printf "ERROR: D2 was killed when attempting reconfiguration.\n"
         clean_exit 1
         clean_exit 1
@@ -200,7 +200,7 @@ shutdown_test() {
 
 
     # Check if it is still running. It could have terminated (e.g. as a result
     # Check if it is still running. It could have terminated (e.g. as a result
     # of configuration failure).
     # of configuration failure).
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
         printf "ERROR: expected one D2 process to be started. Found %d processes\
         printf "ERROR: expected one D2 process to be started. Found %d processes\
  started.\n" ${_GET_PIDS_NUM}
  started.\n" ${_GET_PIDS_NUM}

+ 6 - 6
src/bin/dhcp4/tests/dhcp4_process_tests.sh.in

@@ -132,7 +132,7 @@ dynamic_reconfiguration_test() {
 
 
     # Check if it is still running. It could have terminated (e.g. as a result
     # Check if it is still running. It could have terminated (e.g. as a result
     # of configuration failure).
     # of configuration failure).
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
         printf "ERROR: expected one Kea process to be started. Found %d processes\
         printf "ERROR: expected one Kea process to be started. Found %d processes\
  started.\n" ${_GET_PIDS_NUM}
  started.\n" ${_GET_PIDS_NUM}
@@ -172,7 +172,7 @@ dynamic_reconfiguration_test() {
     fi
     fi
 
 
     # Make sure the server is still operational.
     # Make sure the server is still operational.
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
         printf "ERROR: Kea process was killed when attempting reconfiguration.\n"
         printf "ERROR: Kea process was killed when attempting reconfiguration.\n"
         clean_exit 1
         clean_exit 1
@@ -199,7 +199,7 @@ dynamic_reconfiguration_test() {
     fi
     fi
 
 
     # Make sure the server is still operational.
     # Make sure the server is still operational.
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
         printf "ERROR: Kea process was killed when attempting reconfiguration.\n"
         printf "ERROR: Kea process was killed when attempting reconfiguration.\n"
         clean_exit 1
         clean_exit 1
@@ -240,7 +240,7 @@ shutdown_test() {
 
 
     # Check if it is still running. It could have terminated (e.g. as a result
     # Check if it is still running. It could have terminated (e.g. as a result
     # of configuration failure).
     # of configuration failure).
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
         printf "ERROR: expected one Kea process to be started. Found %d processes\
         printf "ERROR: expected one Kea process to be started. Found %d processes\
  started.\n" ${_GET_PIDS_NUM}
  started.\n" ${_GET_PIDS_NUM}
@@ -308,7 +308,7 @@ lfc_timer_test() {
 
 
     # Check if it is still running. It could have terminated (e.g. as a result
     # Check if it is still running. It could have terminated (e.g. as a result
     # of configuration failure).
     # of configuration failure).
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
         printf "ERROR: expected one Kea process to be started. Found %d processes\
         printf "ERROR: expected one Kea process to be started. Found %d processes\
  started.\n" ${_GET_PIDS_NUM}
  started.\n" ${_GET_PIDS_NUM}
@@ -348,7 +348,7 @@ lfc_timer_test() {
     fi
     fi
 
 
     # Make sure the server is still operational.
     # Make sure the server is still operational.
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
         printf "ERROR: Kea process was killed when attempting reconfiguration.\n"
         printf "ERROR: Kea process was killed when attempting reconfiguration.\n"
         clean_exit 1
         clean_exit 1

+ 6 - 6
src/bin/dhcp6/tests/dhcp6_process_tests.sh.in

@@ -133,7 +133,7 @@ dynamic_reconfiguration_test() {
 
 
     # Check if it is still running. It could have terminated (e.g. as a result
     # Check if it is still running. It could have terminated (e.g. as a result
     # of configuration failure).
     # of configuration failure).
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
         printf "ERROR: expected one Kea process to be started. Found %d processes\
         printf "ERROR: expected one Kea process to be started. Found %d processes\
  started.\n" ${_GET_PIDS_NUM}
  started.\n" ${_GET_PIDS_NUM}
@@ -173,7 +173,7 @@ dynamic_reconfiguration_test() {
     fi
     fi
 
 
     # Make sure the server is still operational.
     # Make sure the server is still operational.
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
         printf "ERROR: Kea process was killed when attempting reconfiguration.\n"
         printf "ERROR: Kea process was killed when attempting reconfiguration.\n"
         clean_exit 1
         clean_exit 1
@@ -200,7 +200,7 @@ dynamic_reconfiguration_test() {
     fi
     fi
 
 
     # Make sure the server is still operational.
     # Make sure the server is still operational.
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
         printf "ERROR: Kea process was killed when attempting reconfiguration.\n"
         printf "ERROR: Kea process was killed when attempting reconfiguration.\n"
         clean_exit 1
         clean_exit 1
@@ -242,7 +242,7 @@ shutdown_test() {
 
 
     # Check if it is still running. It could have terminated (e.g. as a result
     # Check if it is still running. It could have terminated (e.g. as a result
     # of configuration failure).
     # of configuration failure).
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
         printf "ERROR: expected one Kea process to be started. Found %d processes\
         printf "ERROR: expected one Kea process to be started. Found %d processes\
  started.\n" ${_GET_PIDS_NUM}
  started.\n" ${_GET_PIDS_NUM}
@@ -311,7 +311,7 @@ lfc_timer_test() {
 
 
     # Check if it is still running. It could have terminated (e.g. as a result
     # Check if it is still running. It could have terminated (e.g. as a result
     # of configuration failure).
     # of configuration failure).
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
         printf "ERROR: expected one Kea process to be started. Found %d processes\
         printf "ERROR: expected one Kea process to be started. Found %d processes\
  started.\n" ${_GET_PIDS_NUM}
  started.\n" ${_GET_PIDS_NUM}
@@ -351,7 +351,7 @@ lfc_timer_test() {
     fi
     fi
 
 
     # Make sure the server is still operational.
     # Make sure the server is still operational.
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
         printf "ERROR: Kea process was killed when attempting reconfiguration.\n"
         printf "ERROR: Kea process was killed when attempting reconfiguration.\n"
         clean_exit 1
         clean_exit 1

+ 32 - 30
src/bin/keactrl/tests/keactrl_tests.sh.in

@@ -20,8 +20,10 @@
 # Set location of the keactrl.
 # Set location of the keactrl.
 keactrl=@abs_top_builddir@/src/bin/keactrl/keactrl
 keactrl=@abs_top_builddir@/src/bin/keactrl/keactrl
 
 
+# Name of the configuration file without its extension.
+CFG_FILE_NAME="test_config"
 # A name of the configuration file to be used by Kea.
 # A name of the configuration file to be used by Kea.
-CFG_FILE=@abs_top_builddir@/src/bin/keactrl/tests/test_config.json
+CFG_FILE=@abs_top_builddir@/src/bin/keactrl/tests/${CFG_FILE_NAME}.json
 # A name of the keactrl config file
 # A name of the keactrl config file
 KEACTRL_CFG_FILE=@abs_top_builddir@/src/bin/keactrl/tests/keactrl_test.conf
 KEACTRL_CFG_FILE=@abs_top_builddir@/src/bin/keactrl/tests/keactrl_test.conf
 # Path to the Kea log file.
 # Path to the Kea log file.
@@ -186,15 +188,15 @@ Expected wait_for_message return %d, returned %d."
     sleep 3
     sleep 3
 
 
     # Make sure that all servers are running.
     # Make sure that all servers are running.
-    get_pids ${kea4_name}
+    get_pid ${kea4_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${kea4_name} process running, found %d processes running"
         "Expected %d ${kea4_name} process running, found %d processes running"
 
 
-    get_pids ${kea6_name}
+    get_pid ${kea6_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${kea6_name} process running, found %d processes running"
         "Expected %d ${kea6_name} process running, found %d processes running"
 
 
-    get_pids ${d2_name}
+    get_pid ${d2_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${d2_name} process running, found %d processes running"
         "Expected %d ${d2_name} process running, found %d processes running"
 
 
@@ -290,15 +292,15 @@ Expected wait_for_message return %d, returned %d."
     sleep 3
     sleep 3
 
 
     # Make sure that all servers are running.
     # Make sure that all servers are running.
-    get_pids ${kea4_name}
+    get_pid ${kea4_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${kea4_name} process running, found %d processes running"
         "Expected %d ${kea4_name} process running, found %d processes running"
 
 
-    get_pids ${kea6_name}
+    get_pid ${kea6_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${kea6_name} process running, found %d processes running"
         "Expected %d ${kea6_name} process running, found %d processes running"
 
 
-    get_pids ${d2_name}
+    get_pid ${d2_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${d2_name} process running, found %d processes running"
         "Expected %d ${d2_name} process running, found %d processes running"
 
 
@@ -369,17 +371,17 @@ Expected wait_for_message return %d, returned %d."
     sleep 3
     sleep 3
 
 
     # Make sure that DHCPv4 server is running.
     # Make sure that DHCPv4 server is running.
-    get_pids ${kea4_name}
+    get_pid ${kea4_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${kea4_name} process running, found %d processes running"
         "Expected %d ${kea4_name} process running, found %d processes running"
 
 
     # Make sure that DHCPv6 server is not running.
     # Make sure that DHCPv6 server is not running.
-    get_pids ${kea6_name}
+    get_pid ${kea6_name}
     assert_eq 0 ${_GET_PIDS_NUM} \
     assert_eq 0 ${_GET_PIDS_NUM} \
         "Expected %d ${kea6_name} process running, found %d processes running"
         "Expected %d ${kea6_name} process running, found %d processes running"
 
 
     # Make sure that D2 server is not running.
     # Make sure that D2 server is not running.
-    get_pids ${d2_name}
+    get_pid ${d2_name}
     assert_eq 0 ${_GET_PIDS_NUM} \
     assert_eq 0 ${_GET_PIDS_NUM} \
         "Expected %d ${d2_name} process running, found %d processes running"
         "Expected %d ${d2_name} process running, found %d processes running"
 
 
@@ -450,17 +452,17 @@ Expected wait_for_message return %d, returned %d."
     sleep 3
     sleep 3
 
 
     # Make sure that DHCPv6 server is running.
     # Make sure that DHCPv6 server is running.
-    get_pids ${kea6_name}
+    get_pid ${kea6_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${kea6_name} process running, found %d processes running"
         "Expected %d ${kea6_name} process running, found %d processes running"
 
 
     # Make sure that DHCPv4 server is not running.
     # Make sure that DHCPv4 server is not running.
-    get_pids ${kea4_name}
+    get_pid ${kea4_name}
     assert_eq 0 ${_GET_PIDS_NUM} \
     assert_eq 0 ${_GET_PIDS_NUM} \
         "Expected %d ${kea4_name} process running, found %d processes running"
         "Expected %d ${kea4_name} process running, found %d processes running"
 
 
     # Make sure that D2 server is not running.
     # Make sure that D2 server is not running.
-    get_pids ${d2_name}
+    get_pid ${d2_name}
     assert_eq 0 ${_GET_PIDS_NUM} \
     assert_eq 0 ${_GET_PIDS_NUM} \
         "Expected %d ${d2_name} process running, found %d processes running"
         "Expected %d ${d2_name} process running, found %d processes running"
 
 
@@ -532,12 +534,12 @@ Expected wait_for_message return %d, returned %d."
     sleep 3
     sleep 3
 
 
     # Make sure that DHCPv6 server is running.
     # Make sure that DHCPv6 server is running.
-    get_pids ${kea6_name}
+    get_pid ${kea6_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${kea6_name} process running, found %d processes running"
         "Expected %d ${kea6_name} process running, found %d processes running"
 
 
     # Make sure that DHCPv4 server is not running.
     # Make sure that DHCPv4 server is not running.
-    get_pids ${kea4_name}
+    get_pid ${kea4_name}
     assert_eq 0 ${_GET_PIDS_NUM} \
     assert_eq 0 ${_GET_PIDS_NUM} \
         "Expected %d ${kea4_name} process running, found %d processes running"
         "Expected %d ${kea4_name} process running, found %d processes running"
 
 
@@ -577,17 +579,17 @@ Expected wait_for_message return %d, returned %d."
 
 
 
 
     # Make sure that DHCPv6 server is running.
     # Make sure that DHCPv6 server is running.
-    get_pids ${kea6_name}
+    get_pid ${kea6_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${kea6_name} process running, found %d processes running"
         "Expected %d ${kea6_name} process running, found %d processes running"
 
 
     # Make sure that DHCPv4 server is running.
     # Make sure that DHCPv4 server is running.
-    get_pids ${kea4_name}
+    get_pid ${kea4_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${kea4_name} process running, found %d processes running"
         "Expected %d ${kea4_name} process running, found %d processes running"
 
 
     # Make sure that D2 server is running.
     # Make sure that D2 server is running.
-    get_pids ${d2_name}
+    get_pid ${d2_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${d2_name} process running, found %d processes running"
         "Expected %d ${d2_name} process running, found %d processes running"
 
 
@@ -681,17 +683,17 @@ Expected wait_for_message return %d, returned %d."
     sleep 3
     sleep 3
 
 
     # Make sure that DHCPv4 server is running.
     # Make sure that DHCPv4 server is running.
-    get_pids ${kea4_name}
+    get_pid ${kea4_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${kea4_name} process running, found %d processes running"
         "Expected %d ${kea4_name} process running, found %d processes running"
 
 
     # Make sure that DHCPv6 server is not running.
     # Make sure that DHCPv6 server is not running.
-    get_pids ${kea6_name}
+    get_pid ${kea6_name}
     assert_eq 0 ${_GET_PIDS_NUM} \
     assert_eq 0 ${_GET_PIDS_NUM} \
         "Expected %d ${kea6_name} process running, found %d processes running"
         "Expected %d ${kea6_name} process running, found %d processes running"
 
 
     # Make sure that D2 server is not running.
     # Make sure that D2 server is not running.
-    get_pids ${d2_name}
+    get_pid ${d2_name}
     assert_eq 0 ${_GET_PIDS_NUM} \
     assert_eq 0 ${_GET_PIDS_NUM} \
         "Expected %d ${d2_name} process running, found %d processes running"
         "Expected %d ${d2_name} process running, found %d processes running"
 
 
@@ -731,17 +733,17 @@ Expected wait_for_message return %d, returned %d."
 
 
 
 
     # Make sure that DHCPv6 server is running.
     # Make sure that DHCPv6 server is running.
-    get_pids ${kea6_name}
+    get_pid ${kea6_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${kea6_name} process running, found %d processes running"
         "Expected %d ${kea6_name} process running, found %d processes running"
 
 
     # Make sure that DHCPv4 server is running.
     # Make sure that DHCPv4 server is running.
-    get_pids ${kea4_name}
+    get_pid ${kea4_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${kea4_name} process running, found %d processes running"
         "Expected %d ${kea4_name} process running, found %d processes running"
 
 
     # Make sure that D2 server is running.
     # Make sure that D2 server is running.
-    get_pids ${d2_name}
+    get_pid ${d2_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${d2_name} process running, found %d processes running"
         "Expected %d ${d2_name} process running, found %d processes running"
 
 
@@ -858,15 +860,15 @@ Expected wait_for_message return %d, returned %d."
     sleep 3
     sleep 3
 
 
     # Make sure that both servers are running.
     # Make sure that both servers are running.
-    get_pids ${kea4_name}
+    get_pid ${kea4_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${kea4_name} process running, found %d processes running"
         "Expected %d ${kea4_name} process running, found %d processes running"
 
 
-    get_pids ${kea6_name}
+    get_pid ${kea6_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${kea6_name} process running, found %d processes running"
         "Expected %d ${kea6_name} process running, found %d processes running"
 
 
-    get_pids ${d2_name}
+    get_pid ${d2_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${d2_name} process running, found %d processes running"
         "Expected %d ${d2_name} process running, found %d processes running"
 
 
@@ -888,12 +890,12 @@ Expected wait_for_message return %d, returned %d."
         "Expected wait_for_server_down return %d, returned %d"
         "Expected wait_for_server_down return %d, returned %d"
 
 
     # Make sure DHCPv6 server is still running
     # Make sure DHCPv6 server is still running
-    get_pids ${kea6_name}
+    get_pid ${kea6_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${kea6_name} process running, found %d processes running"
         "Expected %d ${kea6_name} process running, found %d processes running"
 
 
     # Make sure D2 server is still running
     # Make sure D2 server is still running
-    get_pids ${kea6_name}
+    get_pid ${kea6_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${d2_name} process running, found %d processes running"
         "Expected %d ${d2_name} process running, found %d processes running"
 
 
@@ -915,7 +917,7 @@ Expected wait_for_message return %d, returned %d."
         "Expected wait_for_server_down return %d, returned %d"
         "Expected wait_for_server_down return %d, returned %d"
 
 
     # Make sure D2 server is still running
     # Make sure D2 server is still running
-    get_pids ${d2_name}
+    get_pid ${d2_name}
     assert_eq 1 ${_GET_PIDS_NUM} \
     assert_eq 1 ${_GET_PIDS_NUM} \
         "Expected %d ${d2_name} process running, found %d processes running"
         "Expected %d ${d2_name} process running, found %d processes running"
 
 

+ 60 - 23
src/lib/testutils/dhcp_test_lib.sh.in

@@ -170,19 +170,57 @@ set_logger() {
     export KEA_LOGGER_DESTINATION=${LOG_FILE}
     export KEA_LOGGER_DESTINATION=${LOG_FILE}
 }
 }
 
 
-# Returns the number of running process pids and the list of pids.
-# Return values:
-#   _GET_PIDS: holds space separated list of pids.
-#   _GET_PIDS_NUM: holds the number pids.
-get_pids() {
-    local proc_name=${1} # Process name
+# PID file path is by default <kea-install-dir>/var/kea, but can be
+# overriden by the environmental variable.
+PID_FILE_PATH=@localstatedir@/@PACKAGE@/
+if [ ! -z ${KEA_PIDFILE_DIR} ]; then
+    PID_FILE_PATH="${KEA_PIDFILE_DIR}"
+fi
+
+# Checks if specified process is running.
+#
+# This function uses PID file to obtain the PID and then calls
+# 'kill -0 <pid>' to check if the process is alive.
+# The PID files are expected to be located in the ${PID_FILE_PATH},
+# and their names should match the follwing pattern:
+# <cfg_file_name>.<proc_name>.pid. If the <cfg_file_name> is not
+# specified a 'test_config' is used by default.
+#
+# Return value:
+#   _GET_PID: holds a PID if process is running
+#   _GET_PIDS_NUM: holds 1 if process is running, 0 otherwise
+get_pid() {
+    local proc_name=${1}     # Process name
+    local cfg_file_name=${2} # Configuration file name without extension.
+
+    # PID file name includes process name. The process name is required.
     if [ -z ${proc_name} ]; then
     if [ -z ${proc_name} ]; then
-        test_lib_error "get_pids requires process name"
+        test_lib_error "get_pid requires process name"
         clean_exit 1
         clean_exit 1
     fi
     fi
-    _GET_PIDS=$( ps axwwo pid,command | grep ${proc_name} \
-        | grep -v grep | awk '{print $1}' )
-    _GET_PIDS_NUM=$( printf "%s" "${_GET_PIDS}" | wc -w | awk '{print $1}' )
+
+    # PID file name includes server configuration file name. For most of
+    # the tests it is 'test-config' (excluding .json extension). It is
+    # possible to specify custom name if required.
+    if [ -z ${cfg_file_name} ]; then
+        cfg_file_name="test_config"
+    fi
+
+    # Get the absolute location of the PID file for the specified process
+    # name.
+    abs_pidfile_path="${PID_FILE_PATH}/${cfg_file_name}.${proc_name}.pid"
+    _GET_PID=0
+    _GET_PIDS_NUM=0
+
+    # If the PID file exists, get the PID and see if the process is alive.
+    if [ -e ${abs_pidfile_path} ]; then
+        pid=$( cat $abs_pidfile_path )
+        kill -0 ${pid} > /dev/null 2>&1
+        if [ $? -eq 0 ]; then
+            _GET_PID=${pid}
+            _GET_PIDS_NUM=1
+        fi
+    fi
 }
 }
 
 
 # Returns the number of occurrences of the Kea log message in the log file.
 # Returns the number of occurrences of the Kea log message in the log file.
@@ -236,13 +274,12 @@ cleanup() {
     # of them if running.
     # of them if running.
     for proc_name in ${KEA_PROCS}
     for proc_name in ${KEA_PROCS}
     do
     do
-        get_pids ${proc_name}
-        # Shut down running Kea processes.
-        for pid in ${_GET_PIDS}
-        do
-            printf "Shutting down Kea proccess having pid %d.\n" ${pid}
-            kill -9 ${pid}
-        done
+        get_pid ${proc_name}
+        # Shut down running Kea process.
+        if [ ${_GET_PIDS_NUM} -ne 0 ]; then
+            printf "Shutting down Kea proccess having pid %d.\n" ${_GET_PID}
+            kill -9 ${_GET_PID}
+        fi
     done
     done
 
 
     # Remove temporary files.
     # Remove temporary files.
@@ -391,7 +428,7 @@ wait_for_server_down() {
     test_lib_info "wait_for_server_down ${proc_name}: " "skip-new-line"
     test_lib_info "wait_for_server_down ${proc_name}: " "skip-new-line"
     while [ ${loops} -le ${timeout} ]; do
     while [ ${loops} -le ${timeout} ]; do
         printf "."
         printf "."
-        get_pids ${proc_name}
+        get_pid ${proc_name}
         if [ ${_GET_PIDS_NUM} -eq 0 ]; then
         if [ ${_GET_PIDS_NUM} -eq 0 ]; then
             printf "\n"
             printf "\n"
             _WAIT_FOR_SERVER_DOWN=1
             _WAIT_FOR_SERVER_DOWN=1
@@ -421,15 +458,15 @@ must be a number"
         clean_exit 1
         clean_exit 1
     fi
     fi
     # Get Kea pid.
     # Get Kea pid.
-    get_pids ${proc_name}
+    get_pid ${proc_name}
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
     if [ ${_GET_PIDS_NUM} -ne 1 ]; then
         printf "ERROR: expected one Kea process to be started.\
         printf "ERROR: expected one Kea process to be started.\
  Found %d processes started.\n" ${_GET_PIDS_NUM}
  Found %d processes started.\n" ${_GET_PIDS_NUM}
         clean_exit 1
         clean_exit 1
     fi
     fi
-    printf "Sending signal ${sig} to Kea process (pid=%s).\n" ${_GET_PIDS}
+    printf "Sending signal ${sig} to Kea process (pid=%s).\n" ${_GET_PID}
     # Actually send a signal.
     # Actually send a signal.
-    kill -${sig} ${_GET_PIDS}
+    kill -${sig} ${_GET_PID}
 }
 }
 
 
 # Verifies that a server is up running by its PID file
 # Verifies that a server is up running by its PID file
@@ -537,7 +574,7 @@ logger_vars_test() {
     sleep 1
     sleep 1
 
 
     # Check if it is still running. It should have terminated.
     # Check if it is still running. It should have terminated.
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 0 ]; then
     if [ ${_GET_PIDS_NUM} -ne 0 ]; then
         printf "ERROR: expected Kea process to not start. Found %d processes"
         printf "ERROR: expected Kea process to not start. Found %d processes"
         printf " running.\n" ${_GET_PIDS_NUM}
         printf " running.\n" ${_GET_PIDS_NUM}
@@ -569,7 +606,7 @@ logger_vars_test() {
     sleep 1
     sleep 1
 
 
     # Check if it is still running. It should have terminated.
     # Check if it is still running. It should have terminated.
-    get_pids ${bin}
+    get_pid ${bin}
     if [ ${_GET_PIDS_NUM} -ne 0 ]; then
     if [ ${_GET_PIDS_NUM} -ne 0 ]; then
         printf "ERROR: expected Kea process to not start. Found %d processes"
         printf "ERROR: expected Kea process to not start. Found %d processes"
         printf " running.\n" ${_GET_PIDS_NUM}
         printf " running.\n" ${_GET_PIDS_NUM}