mirror of
https://github.com/stefanberger/swtpm.git
synced 2026-08-12 20:24:44 +00:00
test: poll for port closure
Poll for the swtpm with socket interface port to close the port Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
This commit is contained in:
parent
53b55e7145
commit
a8279cfde4
@ -46,6 +46,23 @@ function wait_port_open()
|
||||
return 1
|
||||
}
|
||||
|
||||
function wait_port_closed()
|
||||
{
|
||||
local port=$1
|
||||
local pid=$2
|
||||
|
||||
for ((i = 0; i < 20; i++)); do
|
||||
if [ -z "$(netstat -naptl 2>/dev/null |
|
||||
grep "LISTEN" |
|
||||
grep " $pid/" |
|
||||
grep ":$port ")" ]; then
|
||||
return 0
|
||||
fi
|
||||
sleep 0.2
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Test 1: test port and directory command line parameters
|
||||
|
||||
$SWTPM_EXE socket -p $PORT -i $TPMDIR &>/dev/null &
|
||||
@ -110,8 +127,9 @@ fi
|
||||
|
||||
exec 200>&-
|
||||
|
||||
# Give it time to shut down
|
||||
sleep 2
|
||||
wait_port_closed $PORT $PID
|
||||
# Give it time to fully shut down
|
||||
sleep 0.2
|
||||
|
||||
exec 20<&1-; exec 21<&2-
|
||||
kill -0 $PID
|
||||
|
||||
Loading…
Reference in New Issue
Block a user