From 888eaffd36ff841a0b7c562de67e498336270ce7 Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Fri, 26 Dec 2014 16:19:46 +1100 Subject: import --- regtest_util.sh | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 regtest_util.sh (limited to 'regtest_util.sh') diff --git a/regtest_util.sh b/regtest_util.sh new file mode 100755 index 0000000..69a04d6 --- /dev/null +++ b/regtest_util.sh @@ -0,0 +1,60 @@ + +f_ok () +{ + printf "%-60s[ok]\n" "$1" +} + +f_no () +{ + printf "%-60s[error]\n" "$1" + test -n "$2" && printf "\t%s\n" "$2" +} + +f_abort () +{ + printf "%-60s[fatal] aborting...\n" "$1" + exit 1 +} + +check_start () +{ + ntries=0 + while test $ntries -lt 20 && + { test ! -p $ppin || + test "`ps -p \"\`fuser $ppout 2>/dev/null\`\" -ocomm= \ + 2>/dev/null`" != "$locrthub";}; do + ntries=`expr $ntries + 1` + sleep 2; + done; + msg="Regression Test switch started" + test $ntries -ge 20 && f_abort "$msg" || f_ok "$msg" + rtpid=`fuser $ppout 2>/dev/null` +} + +start () +{ + $locrthub -f$H/etc/$1.conf 2>$H/log/$1 1>&2 + check_start +} + +restart () +{ + $locrthub -f$H/etc/$1.conf 2>>$H/log/$1 1>&2 + check_start +} + +stop() +{ + msg="Regression Test switch signaled to terminate" + if kill $rtpid; then f_ok "$msg"; else f_abort "$msg"; fi + #----------------------------------- + ntries=0 + while test $ntries -lt 20 && + test "`ps -p \"\`fuser $ppout 2>/dev/null\`\" -ocomm= \ + 2>/dev/null`" = "$locrthub"; do + ntries=`expr $ntries + 1` + sleep 2; + done; + msg="Regression Test switch terminated" + test $ntries -ge 20 && f_no "$msg" && exit 1 || f_ok "$msg" +} -- cgit v1.2.3