* (no subject)
@ 2017-05-23 18:54 Tomi Ollila
2017-05-23 18:54 ` [PATCH 1/2] test-lib.sh: add "atexit" functionality Tomi Ollila
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Tomi Ollila @ 2017-05-23 18:54 UTC (permalink / raw)
To: notmuch; +Cc: tomi.ollila
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 <tomi.ollila@iki.fi> # This line is ignored.
From: Tomi Ollila <tomi.ollila@iki.fi>
Subject: stop gpg-agent (among other) processes at test module exit
In-Reply-To:
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] test-lib.sh: add "atexit" functionality
2017-05-23 18:54 Tomi Ollila
@ 2017-05-23 18:54 ` Tomi Ollila
2017-05-23 18:54 ` [PATCH 2/2] exit lingering gpg agents at the end of relevant tests Tomi Ollila
2017-05-26 10:40 ` David Bremner
2 siblings, 0 replies; 7+ messages in thread
From: Tomi Ollila @ 2017-05-23 18:54 UTC (permalink / raw)
To: notmuch; +Cc: tomi.ollila
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] exit lingering gpg agents at the end of relevant tests
2017-05-23 18:54 Tomi Ollila
2017-05-23 18:54 ` [PATCH 1/2] test-lib.sh: add "atexit" functionality Tomi Ollila
@ 2017-05-23 18:54 ` Tomi Ollila
2017-05-23 21:19 ` Daniel Kahn Gillmor
2017-05-24 17:17 ` David Bremner
2017-05-26 10:40 ` David Bremner
2 siblings, 2 replies; 7+ messages in thread
From: Tomi Ollila @ 2017-05-23 18:54 UTC (permalink / raw)
To: notmuch; +Cc: tomi.ollila
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 test_suite@notmuchmail.org | sed -n 's/.*fingerprint: //p')
--
2.9.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] exit lingering gpg agents at the end of relevant tests
2017-05-23 18:54 ` [PATCH 2/2] exit lingering gpg agents at the end of relevant tests Tomi Ollila
@ 2017-05-23 21:19 ` Daniel Kahn Gillmor
2017-05-24 17:17 ` David Bremner
1 sibling, 0 replies; 7+ messages in thread
From: Daniel Kahn Gillmor @ 2017-05-23 21:19 UTC (permalink / raw)
To: Tomi Ollila, notmuch; +Cc: tomi.ollila
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] exit lingering gpg agents at the end of relevant tests
2017-05-23 18:54 ` [PATCH 2/2] exit lingering gpg agents at the end of relevant tests Tomi Ollila
2017-05-23 21:19 ` Daniel Kahn Gillmor
@ 2017-05-24 17:17 ` David Bremner
2017-05-25 12:05 ` David Bremner
1 sibling, 1 reply; 7+ messages in thread
From: David Bremner @ 2017-05-24 17:17 UTC (permalink / raw)
To: Tomi Ollila, notmuch
Tomi Ollila <tomi.ollila@iki.fi> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] exit lingering gpg agents at the end of relevant tests
2017-05-24 17:17 ` David Bremner
@ 2017-05-25 12:05 ` David Bremner
0 siblings, 0 replies; 7+ messages in thread
From: David Bremner @ 2017-05-25 12:05 UTC (permalink / raw)
To: Tomi Ollila, notmuch
David Bremner <david@tethera.net> writes:
> Tomi Ollila <tomi.ollila@iki.fi> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re:
2017-05-23 18:54 Tomi Ollila
2017-05-23 18:54 ` [PATCH 1/2] test-lib.sh: add "atexit" functionality Tomi Ollila
2017-05-23 18:54 ` [PATCH 2/2] exit lingering gpg agents at the end of relevant tests Tomi Ollila
@ 2017-05-26 10:40 ` David Bremner
2 siblings, 0 replies; 7+ messages in thread
From: David Bremner @ 2017-05-26 10:40 UTC (permalink / raw)
To: Tomi Ollila, notmuch; +Cc: tomi.ollila
Tomi Ollila <tomi.ollila@iki.fi> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-05-26 10:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-23 18:54 Tomi Ollila
2017-05-23 18:54 ` [PATCH 1/2] test-lib.sh: add "atexit" functionality Tomi Ollila
2017-05-23 18:54 ` [PATCH 2/2] exit lingering gpg agents at the end of relevant tests Tomi Ollila
2017-05-23 21:19 ` Daniel Kahn Gillmor
2017-05-24 17:17 ` David Bremner
2017-05-25 12:05 ` David Bremner
2017-05-26 10:40 ` David Bremner
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).