aboutsummaryrefslogtreecommitdiff
path: root/regtest_util.sh
blob: 69a04d6a965ed28cee8803697b64d0dd8e396a6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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"
}