aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-10-20 09:37:26 +0000
committerJustus Winter <[email protected]>2016-10-20 15:01:23 +0000
commit2d794779e0fd9d9a1efc98e7bd77a296a25f4293 (patch)
tree95735cced09cade52951fbdab611ec4fd6c4df92
parentagent, g10: Fix keygen. (diff)
downloadgnupg-2d794779e0fd9d9a1efc98e7bd77a296a25f4293.tar.gz
gnupg-2d794779e0fd9d9a1efc98e7bd77a296a25f4293.zip
tests: Create and remove socket directories.
* tests/openpgp/defs.scm (start-agent): Move function here and create the socket directory prior to starting the agent. (stop-agent): Move function here and remove the socket directory. * tests/openpgp/finish.scm: Adapt. * tests/openpgp/setup.scm: Likewise. Signed-off-by: Justus Winter <[email protected]>
-rw-r--r--tests/openpgp/defs.scm17
-rwxr-xr-xtests/openpgp/finish.scm3
-rwxr-xr-xtests/openpgp/setup.scm19
3 files changed, 24 insertions, 15 deletions
diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm
index e484e8633..48ac46c03 100644
--- a/tests/openpgp/defs.scm
+++ b/tests/openpgp/defs.scm
@@ -146,3 +146,20 @@
(let ((verbose (string->number (getenv "verbose"))))
(if (number? verbose)
(*set-verbose!* verbose)))
+
+;; Create the socket dir and start the agent.
+(define (start-agent)
+ (echo "Starting gpg-agent...")
+ (catch (echo "Warning: Creating socket directory failed:" (car *error*))
+ (call-popen `(,(tool 'gpgconf) --create-socketdir) ""))
+ (call-check `(,(tool 'gpg-connect-agent) --verbose
+ ,(string-append "--agent-program=" (tool 'gpg-agent)
+ "|--debug-quick-random")
+ /bye)))
+
+;; Stop the agent and remove the socket dir.
+(define (stop-agent)
+ (echo "Stopping gpg-agent...")
+ (catch (echo "Warning: Removing socket directory failed.")
+ (call-popen `(,(tool 'gpgconf) --remove-socketdir) ""))
+ (call-check `(,(tool 'gpg-connect-agent) --verbose killagent /bye)))
diff --git a/tests/openpgp/finish.scm b/tests/openpgp/finish.scm
index 48801c861..37845ae4c 100755
--- a/tests/openpgp/finish.scm
+++ b/tests/openpgp/finish.scm
@@ -19,5 +19,4 @@
(load (with-path "defs.scm"))
-(echo "Killing gpg-agent...")
-(call-check `(,(tool 'gpg-connect-agent) --verbose killagent /bye))
+(stop-agent)
diff --git a/tests/openpgp/setup.scm b/tests/openpgp/setup.scm
index 75310d124..99fbdeaf1 100755
--- a/tests/openpgp/setup.scm
+++ b/tests/openpgp/setup.scm
@@ -95,13 +95,7 @@
(pipe:spawn `(,@GPG --dearmor))
(pipe:spawn `(,@GPG --yes --import))))
-(define (start-agent)
- (echo "Starting gpg-agent...")
- (call-check `(,(tool 'gpg-connect-agent) --verbose
- ,(string-append "--agent-program=" (tool 'gpg-agent)
- "|--debug-quick-random")
- /bye))
-
+(define (preset-passphrases)
(info "Preset passphrases")
(call-check `(,(tool 'gpg-preset-passphrase)
@@ -119,19 +113,18 @@
"A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD"))
(echo "All set up."))
-(define (kill-agent)
- (call-check `(,(tool 'gpg-connect-agent) --verbose killagent /bye)))
-
(cond
((member "--create-tarball" *args*)
(with-temporary-working-directory
(setenv "GNUPGHOME" (getcwd) #t)
(create-gpghome)
- (kill-agent)
+ (stop-agent)
(call-check `(,(tool 'gpgtar) --create --output ,(cadr *args*) "."))))
((member "--unpack-tarball" *args*)
(call-check `(,(tool 'gpgtar) --extract --directory=. ,(cadr *args*)))
- (start-agent))
+ (start-agent)
+ (preset-passphrases))
(else
(create-gpghome)
- (start-agent)))
+ (start-agent)
+ (preset-passphrases)))