(no subject)

classic Classic list List threaded Threaded
7 messages Options
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

(no subject)

This implementation adds add_exit_function (and rm_exit_function)
which can also be used for other things in the future.

Now that I did this simpler way would be to just check for
existence of $GNUPGHOME for indication to exit gpg processes.

If that path is taken this series can be used for future reference
if need for atexit functionality arises.

From Tomi Ollila <[hidden email]> # This line is ignored.
From: Tomi Ollila <[hidden email]>
Subject: stop gpg-agent (among other) processes at test module exit
In-Reply-To:

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/2] test-lib.sh: add "atexit" functionality

New function at_exit_function registers given function to be called
at script termination.

Functions so registered are called in the reverse order of their
registration; no arguments are passed.

Function is called only once; re-adding with function name already
registered will remove previous registration.

New function rm_exit_function can be used to remove registration.

Modules (and possibly test-lib.sh functions) in future commits will
register such functions.
---
 test/test-lib.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 988b00a..37f8ddf 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -219,10 +219,21 @@ test_fixed=0
 test_broken=0
 test_success=0
 
+declare -a _exit_functions=()
+
+at_exit_function () {
+ _exit_functions=($1 ${_exit_functions[@]/$1})
+}
+
+rm_exit_function () {
+ _exit_functions=(${_exit_functions[@]/$1})
+}
+
 _exit_common () {
  code=$?
  trap - EXIT
  set +ex
+ for _fn in ${_exit_functions[@]}; do $_fn; done
  rm -rf "$TEST_TMPDIR"
 }
 
--
2.9.3

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

[PATCH 2/2] exit lingering gpg agents at the end of relevant tests

In reply to this post by Tomi Ollila-2
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 | 2 ++
 test/T355-smime.sh  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/test/T350-crypto.sh b/test/T350-crypto.sh
index b7d3a2c..d21cad1 100755
--- a/test/T350-crypto.sh
+++ b/test/T350-crypto.sh
@@ -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"
diff --git a/test/T355-smime.sh b/test/T355-smime.sh
index 639ca69..0f39bc6 100755
--- a/test/T355-smime.sh
+++ b/test/T355-smime.sh
@@ -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 [hidden email] | sed -n 's/.*fingerprint: //p')
--
2.9.3

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Daniel Kahn Gillmor Daniel Kahn Gillmor
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 2/2] exit lingering gpg agents at the end of relevant tests

On Tue 2017-05-23 21:54:25 +0300, Tomi Ollila wrote:
> 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.

this pair of patches LGTM.

     --dkg
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 2/2] exit lingering gpg agents at the end of relevant tests

In reply to this post by Tomi Ollila-2
Tomi Ollila <[hidden email]> writes:

> 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`
>

Did you test this on some machines with old gpg (1.x)? I think I don't
have easy access to such, although I could try in a chroot/container.

d
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 2/2] exit lingering gpg agents at the end of relevant tests

David Bremner <[hidden email]> writes:

> Tomi Ollila <[hidden email]> writes:
>
>> 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`
>>
>
> Did you test this on some machines with old gpg (1.x)? I think I don't
> have easy access to such, although I could try in a chroot/container.
>

Which I did, and it seems to work fine with gpg 1.4.18 on debian stable
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re:

In reply to this post by Tomi Ollila-2
Tomi Ollila <[hidden email]> writes:

> This implementation adds add_exit_function (and rm_exit_function)
> which can also be used for other things in the future.
>

Pushed to master.

d
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch