From ba03ff67902f191d4854cf824f8a73ed9f58f3f3 Mon Sep 17 00:00:00 2001 From: Karanbir Singh Date: Nov 18 2011 23:54:02 +0000 Subject: add a new Service handle type: cycle; which will attempt to stop and then start a service. safe to use if you are not sure what the status of the service might have been --- diff --git a/tests/0_lib/functions.sh b/tests/0_lib/functions.sh index 868bd14..41099e5 100755 --- a/tests/0_lib/functions.sh +++ b/tests/0_lib/functions.sh @@ -27,6 +27,8 @@ function t_InstallPackage { t_Log "Attempting yum install: $*" /usr/bin/yum -y -d0 install "$@" + # TODO: add a hook here, to make sure all binary files have ldd run + # against them, and that there are no missing linker targets t_CheckExitStatus $? } @@ -70,12 +72,20 @@ function t_CheckDeps } # Description: perform a service control and sleep for a few seconds to let -# the dust settle. Using this function avoids a race condition wherein -# subsequent tests execute (and typically fail) before a service has had a -# chance to fully start/open a network port etc. +# the dust settle. Using this function avoids a race condition wherein +# subsequent tests execute (and typically fail) before a service has had a +# chance to fully start/open a network port etc. +# Call it with cycle instead of start, and it will stop+start +# handy, if you dont know the service might already be running function t_ServiceControl { - /sbin/service $1 $2 + if [ $2 -eq 'cycle' ]; then + /sbin/service $1 stop > /dev/null 2>&1 + sleep 3 + /sbin/service $1 start + else + /sbin/service $1 $2 + fi # aaaand relax... sleep 3