tests: Always cleanup gpg-agent when exiting

Add `libtest_cleanup_gpg()` to the array of commands to run when
exiting. This provides 2 improvements:

1. You don't need to worry about whether the test will spawn a gpg-agent
   and therefore require adding a call to `libtest_cleanup_gpg()`.

2. All the existing users were calling `libtest_cleanup_gpg()` at the
   end of the script. If there was a failure and the script exited
   early, then it wouldn't cleanup and there may be a stray gpg-agent
   hanging around.

Closes: #1799
Approved by: cgwalters
This commit is contained in:
Dan Nicholson 2019-06-13 16:26:47 -05:00 committed by Atomic Bot
parent 0dd27bbf4b
commit abb173352d
7 changed files with 1 additions and 11 deletions

View File

@ -648,6 +648,7 @@ libtest_cleanup_gpg () {
local gpg_homedir=${1:-${test_tmpdir}/gpghome}
gpg-connect-agent --homedir "${gpg_homedir}" killagent /bye || true
}
libtest_exit_cmds+=(libtest_cleanup_gpg)
is_bare_user_only_repo () {
grep -q 'mode=bare-user-only' $1/config

View File

@ -140,4 +140,3 @@ assert_not_file_has_content show.txt 'Found.*signature'
echo "ok pull sig deleted"
rm -rf repo gnomerepo-files
libtest_cleanup_gpg

View File

@ -89,8 +89,6 @@ if ${OSTREE} show test2 | grep -o 'Found [[:digit:]] signature'; then
assert_not_reached
fi
libtest_cleanup_gpg
echo "ok"
# Remaining tests require gpg

View File

@ -120,5 +120,3 @@ echo "ok pull mirror with invalid summary sig and no verification"
# assert_file_has_content deltas.txt "${origmain}-${newmain}"
# echo "ok pull mirror with signed summary covering static deltas"
libtest_cleanup_gpg

View File

@ -274,5 +274,3 @@ cmp repo/tmp/cache/summaries/origin ${test_tmpdir}/ostree-srv/gnomerepo/summary.
cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig.2 >&2
echo "ok pull with signed summary broken cache"
libtest_cleanup_gpg

View File

@ -280,5 +280,3 @@ ${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo summary -u --gpg
${OSTREE} pull --require-static-deltas R1:main
echo "ok gpg trusted signed commit for delta upgrades"
libtest_cleanup_gpg

View File

@ -62,5 +62,3 @@ assert_file_has_content_literal raw-summary.txt "('main', ("
assert_file_has_content_literal raw-summary.txt "('other', ("
assert_file_has_content_literal raw-summary.txt "{'ostree.summary.last-modified': <uint64"
echo "ok view summary raw"
libtest_cleanup_gpg