diff options
author | Tim Rühsen <tim.ruehsen@gmx.de> | 2018-11-27 14:05:00 +0000 |
---|---|---|
committer | Tim Rühsen <tim.ruehsen@gmx.de> | 2018-11-27 14:05:00 +0000 |
commit | e8450eb997fe2c5c5c259078ab5ea2ef3f694577 (patch) | |
tree | 8dcca3990f040ffa6817f13e2782432d582cfbd0 /tests | |
parent | eef0b3a541926980e266cf1580a15aca73a109fc (diff) | |
parent | c53ca559180a79a3b831246dd73c4e9a5468199b (diff) | |
download | gnutls-e8450eb997fe2c5c5c259078ab5ea2ef3f694577.tar.gz |
Merge branch 'tpm12_extend_testcase' into 'master'
Fix some minor issue in the TPM test cases
See merge request gnutls/gnutls!814
Diffstat (limited to 'tests')
-rw-r--r-- | tests/scripts/common.sh | 21 | ||||
-rwxr-xr-x | tests/tpmtool_test.sh | 8 |
2 files changed, 24 insertions, 5 deletions
diff --git a/tests/scripts/common.sh b/tests/scripts/common.sh index 94333f19b3..1567d8e614 100644 --- a/tests/scripts/common.sh +++ b/tests/scripts/common.sh @@ -238,6 +238,25 @@ kill_quiet() { local sig="$1" local pid="$2" - sh -c "kill $sig $pid &>/dev/null" + sh -c "kill $sig $pid 2>/dev/null" return $? } + +# Terminate a process first using SIGTERM, wait 1s and if still avive use +# SIGKILL +# @1: pid +terminate_proc() { + local pid="$1" + + local ctr=0 + + kill_quiet -15 $pid + while [ $ctr -lt 10 ]; do + sleep 0.1 + kill -0 $pid 2>/dev/null + [ $? -ne 0 ] && return + ctr=$((ctr + 1)) + done + kill_quiet -9 $pid + sleep 0.1 +} diff --git a/tests/tpmtool_test.sh b/tests/tpmtool_test.sh index 50ba23e3f2..c6e4bc42ef 100755 --- a/tests/tpmtool_test.sh +++ b/tests/tpmtool_test.sh @@ -54,13 +54,13 @@ if [ -z "$(which expect 2>/dev/null)" ]; then exit 77 fi -$TPMTOOL --help &>/dev/null +$TPMTOOL --help >/dev/null if [ $? -ne 0 ]; then echo "tpmtool cannot show help screen (TPMTOOL=$TPMTOOL)." exit 77 fi -$CERTTOOL --help &>/dev/null +$CERTTOOL --help >/dev/null if [ $? -ne 0 ]; then echo "certtool cannot show help screen (CERTTOOL=$CERTTOOL)." exit 77 @@ -126,7 +126,7 @@ start_swtpm() stop_swtpm() { if [ -n "$SWTPM_PID" ]; then - kill_quiet -15 $SWTPM_PID + terminate_proc $SWTPM_PID unset SWTPM_PID fi } @@ -165,7 +165,7 @@ _EOF_ stop_tcsd() { if [ -n "$TCSD_PID" ]; then - kill_quiet -15 $TCSD_PID + terminate_proc $TCSD_PID unset TCSD_PID fi stop_swtpm |