aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2017-04-20 15:35:15 +0000
committerJustus Winter <[email protected]>2017-04-24 13:59:49 +0000
commit06a177ceea529269a7404740c60416bd6a4567b1 (patch)
treefd7286cdb8fbfdca50b94953f50947025fa0c915
parentgpgscm: Fix test. (diff)
downloadgnupg-06a177ceea529269a7404740c60416bd6a4567b1.tar.gz
gnupg-06a177ceea529269a7404740c60416bd6a4567b1.zip
tests: Deduplicate and simplify code.
* tests/gpgme/gpgme-defs.scm (create-file): Move... * tests/gpgsm/gpgsm-defs.scm (create-file): ... likewise... * tests/openpgp/defs.scm (create-file): Here. (create-gpghome): Use 'create-file'. * tests/openpgp/gpg-agent.conf.tmpl: Delete file. * tests/openpgp/gpg.conf.tmpl: Likewise. Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to '')
-rw-r--r--tests/gpgme/gpgme-defs.scm5
-rw-r--r--tests/gpgsm/gpgsm-defs.scm6
-rw-r--r--tests/openpgp/defs.scm39
-rw-r--r--tests/openpgp/gpg-agent.conf.tmpl3
-rw-r--r--tests/openpgp/gpg.conf.tmpl4
5 files changed, 24 insertions, 33 deletions
diff --git a/tests/gpgme/gpgme-defs.scm b/tests/gpgme/gpgme-defs.scm
index 1e215b1e3..690d097fd 100644
--- a/tests/gpgme/gpgme-defs.scm
+++ b/tests/gpgme/gpgme-defs.scm
@@ -45,11 +45,6 @@
;; The tests expect the pinentry to return the passphrase "abc".
(setenv "PINENTRY_USER_DATA" "abc" #t)
-(define (create-file name . lines)
- (letfd ((fd (open name (logior O_WRONLY O_CREAT O_BINARY) #o600)))
- (let ((port (fdopen fd "wb")))
- (for-each (lambda (line) (display line port) (newline port)) lines))))
-
(define (create-gpgmehome . path)
;; Support for various environments.
(define mode
diff --git a/tests/gpgsm/gpgsm-defs.scm b/tests/gpgsm/gpgsm-defs.scm
index c978c32b3..711922a27 100644
--- a/tests/gpgsm/gpgsm-defs.scm
+++ b/tests/gpgsm/gpgsm-defs.scm
@@ -61,12 +61,6 @@
(equal? key::fpr (:fpr l))))
(gpgsm-with-colons `(--list-secret-keys ,key::fpr))))))
-(define (create-file name . lines)
- (letfd ((fd (open name (logior O_WRONLY O_CREAT O_BINARY) #o600)))
- (let ((port (fdopen fd "wb")))
- (for-each (lambda (line) (display line port) (newline port))
- lines))))
-
(define (create-gpgsmhome)
(create-file "gpgsm.conf"
"disable-crl-checks"
diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm
index 38d25d8de..9e681bf92 100644
--- a/tests/openpgp/defs.scm
+++ b/tests/openpgp/defs.scm
@@ -309,6 +309,12 @@
(lambda (port)
(display (make-random-string size) port))))
+(define (create-file name . lines)
+ (letfd ((fd (open name (logior O_WRONLY O_CREAT O_BINARY) #o600)))
+ (let ((port (fdopen fd "wb")))
+ (for-each (lambda (line) (display line port) (newline port))
+ lines))))
+
(define (create-gpghome)
(log "Creating test environment...")
@@ -316,21 +322,24 @@
(make-test-data "random_seed" 600)
(log "Creating configuration files")
- (for-each
- (lambda (name)
- (file-copy (in-srcdir "tests" "openpgp" (string-append name ".tmpl")) name)
- (let ((p (open-input-output-file name)))
- (cond
- ((string=? "gpg.conf" name)
- (if have-opt-always-trust
- (display "no-auto-check-trustdb\n" p))
- (display (string-append "agent-program "
- (tool 'gpg-agent)
- "|--debug-quick-random\n") p)
- (display "allow-weak-digest-algos\n" p))
- ((string=? "gpg-agent.conf" name)
- (display (string-append "pinentry-program " PINENTRY "\n") p)))))
- '("gpg.conf" "gpg-agent.conf")))
+ (create-file "gpg.conf"
+ "no-greeting"
+ "no-secmem-warning"
+ "no-permission-warning"
+ "batch"
+ "allow-weak-digest-algos"
+ (if have-opt-always-trust
+ "no-auto-check-trustdb" "#no-auto-check-trustdb")
+ (string-append "agent-program "
+ (tool 'gpg-agent)
+ "|--debug-quick-random\n")
+ )
+ (create-file "gpg-agent.conf"
+ "allow-preset-passphrase"
+ "no-grab"
+ "enable-ssh-support"
+ (string-append "pinentry-program " (tool 'pinentry))
+ ))
;; Initialize the test environment, install appropriate configuration
;; and start the agent, without any keys.
diff --git a/tests/openpgp/gpg-agent.conf.tmpl b/tests/openpgp/gpg-agent.conf.tmpl
deleted file mode 100644
index 355915015..000000000
--- a/tests/openpgp/gpg-agent.conf.tmpl
+++ /dev/null
@@ -1,3 +0,0 @@
-allow-preset-passphrase
-no-grab
-enable-ssh-support
diff --git a/tests/openpgp/gpg.conf.tmpl b/tests/openpgp/gpg.conf.tmpl
deleted file mode 100644
index 19f31808a..000000000
--- a/tests/openpgp/gpg.conf.tmpl
+++ /dev/null
@@ -1,4 +0,0 @@
-no-greeting
-no-secmem-warning
-no-permission-warning
-batch