From abb173352da5fa6017746c27fab1eff220c4cfbd Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Thu, 13 Jun 2019 16:26:47 -0500 Subject: [PATCH] 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 --- tests/libtest.sh | 1 + tests/test-commit-sign.sh | 1 - tests/test-gpg-signed-commit.sh | 2 -- tests/test-pull-mirror-summary.sh | 2 -- tests/test-pull-summary-sigs.sh | 2 -- tests/test-remote-gpg-import.sh | 2 -- tests/test-summary-view.sh | 2 -- 7 files changed, 1 insertion(+), 11 deletions(-) diff --git a/tests/libtest.sh b/tests/libtest.sh index e70b7b87..632ccee8 100755 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -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 diff --git a/tests/test-commit-sign.sh b/tests/test-commit-sign.sh index d789d2fb..e9e7a6da 100755 --- a/tests/test-commit-sign.sh +++ b/tests/test-commit-sign.sh @@ -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 diff --git a/tests/test-gpg-signed-commit.sh b/tests/test-gpg-signed-commit.sh index 7bd59502..3e41efb8 100755 --- a/tests/test-gpg-signed-commit.sh +++ b/tests/test-gpg-signed-commit.sh @@ -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 diff --git a/tests/test-pull-mirror-summary.sh b/tests/test-pull-mirror-summary.sh index cc3c6a2c..504cf545 100755 --- a/tests/test-pull-mirror-summary.sh +++ b/tests/test-pull-mirror-summary.sh @@ -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 diff --git a/tests/test-pull-summary-sigs.sh b/tests/test-pull-summary-sigs.sh index e2864beb..0b6b806c 100755 --- a/tests/test-pull-summary-sigs.sh +++ b/tests/test-pull-summary-sigs.sh @@ -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 diff --git a/tests/test-remote-gpg-import.sh b/tests/test-remote-gpg-import.sh index 1bb42d82..4d73fa11 100755 --- a/tests/test-remote-gpg-import.sh +++ b/tests/test-remote-gpg-import.sh @@ -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 diff --git a/tests/test-summary-view.sh b/tests/test-summary-view.sh index a5ddf93e..d26d3431 100755 --- a/tests/test-summary-view.sh +++ b/tests/test-summary-view.sh @@ -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':