1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-11-10 21:38:50 +01:00

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 <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-10-20 11:37:26 +02:00
parent 9a34e2142b
commit 2d794779e0
3 changed files with 24 additions and 15 deletions

View File

@ -146,3 +146,20 @@
(let ((verbose (string->number (getenv "verbose")))) (let ((verbose (string->number (getenv "verbose"))))
(if (number? verbose) (if (number? verbose)
(*set-verbose!* 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)))

View File

@ -19,5 +19,4 @@
(load (with-path "defs.scm")) (load (with-path "defs.scm"))
(echo "Killing gpg-agent...") (stop-agent)
(call-check `(,(tool 'gpg-connect-agent) --verbose killagent /bye))

View File

@ -95,13 +95,7 @@
(pipe:spawn `(,@GPG --dearmor)) (pipe:spawn `(,@GPG --dearmor))
(pipe:spawn `(,@GPG --yes --import)))) (pipe:spawn `(,@GPG --yes --import))))
(define (start-agent) (define (preset-passphrases)
(echo "Starting gpg-agent...")
(call-check `(,(tool 'gpg-connect-agent) --verbose
,(string-append "--agent-program=" (tool 'gpg-agent)
"|--debug-quick-random")
/bye))
(info "Preset passphrases") (info "Preset passphrases")
;; one@example.com ;; one@example.com
(call-check `(,(tool 'gpg-preset-passphrase) (call-check `(,(tool 'gpg-preset-passphrase)
@ -119,19 +113,18 @@
"A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD")) "A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD"))
(echo "All set up.")) (echo "All set up."))
(define (kill-agent)
(call-check `(,(tool 'gpg-connect-agent) --verbose killagent /bye)))
(cond (cond
((member "--create-tarball" *args*) ((member "--create-tarball" *args*)
(with-temporary-working-directory (with-temporary-working-directory
(setenv "GNUPGHOME" (getcwd) #t) (setenv "GNUPGHOME" (getcwd) #t)
(create-gpghome) (create-gpghome)
(kill-agent) (stop-agent)
(call-check `(,(tool 'gpgtar) --create --output ,(cadr *args*) ".")))) (call-check `(,(tool 'gpgtar) --create --output ,(cadr *args*) "."))))
((member "--unpack-tarball" *args*) ((member "--unpack-tarball" *args*)
(call-check `(,(tool 'gpgtar) --extract --directory=. ,(cadr *args*))) (call-check `(,(tool 'gpgtar) --extract --directory=. ,(cadr *args*)))
(start-agent)) (start-agent)
(preset-passphrases))
(else (else
(create-gpghome) (create-gpghome)
(start-agent))) (start-agent)
(preset-passphrases)))