From 2d03bdbddef0f0a9a475bf1def61cf55797a4d7a Mon Sep 17 00:00:00 2001 From: Mimi Zohar Date: Fri, 16 Oct 2020 08:33:58 -0400 Subject: [PATCH] travis: properly kill the software TPM Send "tsstpmcmd -stop" to properly stop the tpm_server. Send SIGTERM to stop the swtpm process. Signed-off-by: Mimi Zohar --- tests/boot_aggregate.test | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/boot_aggregate.test b/tests/boot_aggregate.test index 936fe77..40948f2 100755 --- a/tests/boot_aggregate.test +++ b/tests/boot_aggregate.test @@ -41,14 +41,12 @@ else fi -# Only stop this test's software TPM. Preferred method: "tsstpmcmd -stop" +# Only stop this test's software TPM cleanup() { - if [ -n "${SWTPM_PPID}" ]; then - if [ -f "${TSSDIR}/tsstpmcmd" ]; then - "${TSSDIR}/tsstpmcmd" -stop - else - pkill -P "${SWTPM_PPID}" - fi + if [ -n "${SWTPM_PID}" ]; then + kill -SIGTERM "${SWTPM_PID}" + elif [ -n "${TPMSERVER_PID}" ]; then + "${TSSDIR}/tsstpmcmd" -stop fi } @@ -72,7 +70,7 @@ swtpm_start() { echo "INFO: Starting software TPM: ${swtpm}" mkdir -p ./myvtpm ${swtpm} socket --tpmstate dir=./myvtpm --tpm2 --ctrl type=tcp,port=2322 --server type=tcp,port=2321 --flags not-need-init > /dev/null 2>&1 & - SWTPM_PPID=$! + SWTPM_PID=$! fi elif [ -n "${tpm_server}" ]; then # tpm_server uses the Microsoft simulator encapsulated packet format @@ -84,7 +82,7 @@ swtpm_start() { else echo "INFO: Starting software TPM: ${tpm_server}" ${tpm_server} > /dev/null 2>&1 & - SWTPM_PPID=$! + TPMSERVER_PID=$! fi fi return 0