From 8ac348d19a38b0f1d84488d85152524449da767a Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Fri, 26 Jul 2019 10:17:07 -0600 Subject: [PATCH] tests/gpg: Use exit hook to kill agent in temporary GPG homedir This wasn't available when I originally wrote this, but it ensures that the running gpg-agent in tmpgpghome is killed in case the tests exit early. Closes: #1892 Approved by: jlebon --- tests/test-gpg-signed-commit.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test-gpg-signed-commit.sh b/tests/test-gpg-signed-commit.sh index 3e41efb8..2fc2cf2f 100755 --- a/tests/test-gpg-signed-commit.sh +++ b/tests/test-gpg-signed-commit.sh @@ -100,6 +100,12 @@ fi tmpgpg_home=${test_tmpdir}/tmpgpghome mkdir -m700 ${tmpgpg_home} +# Wire up an exit hook to kill the gpg-agent in it +cleanup_tmpgpg_home() { + libtest_cleanup_gpg ${tmpgpg_home} +} +libtest_exit_cmds+=(cleanup_tmpgpg_home) + # Create an temporary trusted GPG directory tmpgpg_trusted=${test_tmpdir}/tmpgpgtrusted tmpgpg_trusted_keyring=${tmpgpg_trusted}/keyring.gpg @@ -301,5 +307,3 @@ if [ -f ${key1_rev} ]; then else echo "ok # SKIP could not find key revocation certificate" fi - -libtest_cleanup_gpg ${tmpgpg_home}