aboutsummaryrefslogtreecommitdiff
path: root/regtest_util.sh
diff options
context:
space:
mode:
Diffstat (limited to 'regtest_util.sh')
-rwxr-xr-xregtest_util.sh60
1 files changed, 60 insertions, 0 deletions
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"
+}