Skip to content

Commit

Permalink
tests: Always cleanup gpg-agent when exiting
Browse files Browse the repository at this point in the history
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: ostreedev#1799
Approved by: cgwalters
  • Loading branch information
dbnicholson authored and rh-atomic-bot committed Jun 19, 2019
1 parent 0dd27bb commit abb1733
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 11 deletions.
1 change: 1 addition & 0 deletions tests/libtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/test-commit-sign.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions tests/test-gpg-signed-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions tests/test-pull-mirror-summary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions tests/test-pull-summary-sigs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions tests/test-remote-gpg-import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions tests/test-summary-view.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit abb1733

Please sign in to comment.