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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
# Max number of seconds for programs to be available in test run.
MAX_WAIT=60
#
# Waits until the specified URL is reachable.
#
function waitforurl {
local url=$1
i=0
wget $url
while [ $? -ne 8 ]
do
((i=i+1))
if [[ "$i" -gt $MAX_WAIT ]]; then
return -1
fi
sleep 1s
wget $url
done
return 0
}
#
# Waits until the procdump child process has become available
#
function waitforprocdump {
local -n result=$1
i=0
pid=$(ps -o pid= -C "procdump" | tr -d ' ')
while [ ! $pid ]
do
((i=i+1))
if [[ "$i" -gt $MAX_WAIT ]]; then
result=-1
return
fi
sleep 1s
pid=$(ps -o pid= -C "procdump" | tr -d ' ')
done
result=$pid
}
#
# Waits until the procdump status socket (in case of .net apps) is available
#
function waitforprocdumpsocket {
local procdumpchildpid=$1
local testchildpid=$2
local -n result=$3
ps -A -l
if [[ -v TMPDIR ]];
then
tmpfolder=$TMPDIR
else
tmpfolder="/tmp"
fi
prefixname="/procdump/procdump-status-"
socketpath=$tmpfolder$prefixname$procdumpchildpid"-"$testchildpid
echo "ProcDump .NET status socket: "$socketpath
echo "List of ProcDump sockets:"
sudo ls /tmp/procdump
i=0
while [ ! -S $socketpath ]
do
((i=i+1))
if [[ "$i" -gt $MAX_WAIT ]]; then
echo "List of ProcDump sockets:"
sudo ls /tmp/procdump
echo "ProcDump .NET status socket not available within alloted time"
result=-1
return
fi
sleep 1s
done
sudo ls /tmp/procdump
echo "ProcDump .NET status socket found"
result=$socketpath
}
|