aboutsummaryrefslogtreecommitdiffstats
path: root/tests/gpg/start-stop-agent
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2013-08-12 12:32:21 +0000
committerWerner Koch <[email protected]>2013-08-12 12:32:21 +0000
commit3ca7e96e384d5872c71ceb3b2e2a05b0c1b7e1a0 (patch)
tree217f1467bb82074b3983b5a6854e2e75e9d66a7b /tests/gpg/start-stop-agent
parentImprove detection of default gpg by configure. (diff)
downloadgpgme-3ca7e96e384d5872c71ceb3b2e2a05b0c1b7e1a0.tar.gz
gpgme-3ca7e96e384d5872c71ceb3b2e2a05b0c1b7e1a0.zip
Make test suite workable with GnuPG 2.1.
* tests/gpg/start-stop-agent: New. * tests/gpg/initial.test: New. * tests/gpg/final.test: New. * tests/gpg/Makefile.am (c_tests): New. (TESTS): Move all to c_tests. Add initial.test, final.test, and c_tests. (TESTS_ENVIRONMENT): Add C_ALL=C (private_keys): New. (EXTRA_DIST): Add new files. (./private-keys-v1.d/gpg-sample.stamp): Copy private keys. (all-local): Depend on gpg-sample.stamp. * tests/gpg/13CBE3758AFE42B5E5E2AE4CED27AFA455E3F87F: New. * tests/gpg/13CD0F3BDF24BE53FE192D62F18737256FF6E4FD: New. * tests/gpg/76F7E2B35832976B50A27A282D9B87E44577EB66: New. * tests/gpg/7A030357C0F253A5BBCD282FFC4E521B37558F5C: New. * tests/gpg/A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD: New. -- GnuPG 2.1 requires that the agent knows the private keys. Thus we need to install them. The code should still work with GnuPG < 2.1. To make the whole testing using a agent more robust, the way to start the agent has also be changed.
Diffstat (limited to '')
-rwxr-xr-xtests/gpg/start-stop-agent45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/gpg/start-stop-agent b/tests/gpg/start-stop-agent
new file mode 100755
index 00000000..ab47d8d9
--- /dev/null
+++ b/tests/gpg/start-stop-agent
@@ -0,0 +1,45 @@
+#!/bin/sh
+# Copyright (C) 2013 g10 Code GmbH
+#
+# This file is free software; as a special exception the author gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved. This file is
+# distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY, to the extent permitted by law; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+if [ -z "$(command -v gpg-connect-agent)" ]; then
+ echo "gpg-agent not installed and thus not started" >&2
+ exit 0;
+fi
+
+GPG_AGENT_INFO=
+export GPG_AGENT_INFO
+
+token=$(echo "gpgme-$(pwd)" | tr ' ' '_')
+
+if [ "$1" = "--stop" ]; then
+ if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \
+ != "D set" ]; then
+ echo "gpg-agent not running" >&2
+ exit 0
+ fi
+ echo "stopping gpg-agent " >&2
+ gpg-connect-agent KILLAGENT /bye >/dev/null 2>&1
+ exit 0
+fi
+
+if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \
+ = "D set" ]; then
+ echo "gpg-agent already running" >&2
+ exit 0
+fi
+
+echo "starting gpg-agent " >&2
+gpg-connect-agent putval\ $token\ set /bye >/dev/null 2>&1
+if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \
+ != "D set" ]; then
+ echo "error starting gpg-agent" >&2
+ exit 1
+fi
+exit 0