exit lingering gpg agents at the end of relevant tests
authorTomi Ollila <tomi.ollila@iki.fi>
Tue, 23 May 2017 18:54:25 +0000 (21:54 +0300)
committerDavid Bremner <david@tethera.net>
Fri, 26 May 2017 10:26:06 +0000 (07:26 -0300)
Since gnupg 2.1.20, gpg-agent no longer shut itself down when
$GNUPGHOME directory is removed.

Add exit hooks to the test modules which execute `gpgconf --kill all`

Add exit hooks to execute `gpgconf --kill all` in the modules that
create $GNUPGHOME for gpg to work with.

test/T350-crypto.sh
test/T355-smime.sh

index b7d3a2cf662e91ac30eab12f1210fa062505312e..d21cad144cb15311aec1a39ae5fb0aa830ad62ad 100755 (executable)
@@ -11,6 +11,8 @@ add_gnupg_home ()
 {
     local output
     [ -d ${GNUPGHOME} ] && return
+    _gnupg_exit () { gpgconf --kill all 2>/dev/null || true; }
+    at_exit_function _gnupg_exit
     mkdir -m 0700 "$GNUPGHOME"
     gpg --no-tty --import <$TEST_DIRECTORY/gnupg-secret-key.asc >"$GNUPGHOME"/import.log 2>&1
     test_debug "cat $GNUPGHOME/import.log"
index 639ca697c734f6e5f82d51a522fe756a6c40eac9..0f39bc6933945144086ad2ac4b05ab9765f5dd14 100755 (executable)
@@ -7,6 +7,8 @@ add_gpgsm_home ()
 {
     local fpr
     [ -d ${GNUPGHOME} ] && return
+    _gnupg_exit () { gpgconf --kill all 2>/dev/null || true; }
+    at_exit_function _gnupg_exit
     mkdir -m 0700 "$GNUPGHOME"
     gpgsm --no-tty --no-common-certs-import --disable-dirmngr --import < $TEST_DIRECTORY/smime/test.crt >"$GNUPGHOME"/import.log 2>&1
     fpr=$(gpgsm  --list-key test_suite@notmuchmail.org | sed -n 's/.*fingerprint: //p')