summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/gpgme/Makefile.am3
-rw-r--r--tests/gpgme/gpgme-defs.scm3
-rw-r--r--tests/gpgscm/tests.scm13
-rw-r--r--tests/gpgsm/Makefile.am3
-rw-r--r--tests/gpgsm/gpgsm-defs.scm2
-rw-r--r--tests/migrations/Makefile.am3
-rw-r--r--tests/migrations/common.scm8
-rwxr-xr-xtests/migrations/extended-pkf.scm18
-rwxr-xr-xtests/migrations/from-classic.scm47
-rw-r--r--tests/openpgp/Makefile.am3
-rw-r--r--tests/openpgp/README2
-rw-r--r--tests/openpgp/defs.scm15
-rwxr-xr-xtests/openpgp/setup.scm1
13 files changed, 58 insertions, 63 deletions
diff --git a/tests/gpgme/Makefile.am b/tests/gpgme/Makefile.am
index d7fd87c71..0d0edc03c 100644
--- a/tests/gpgme/Makefile.am
+++ b/tests/gpgme/Makefile.am
@@ -28,12 +28,9 @@ include $(top_srcdir)/am/cmacros.am
AM_CFLAGS =
-TMP ?= /tmp
-
TESTS_ENVIRONMENT = LC_ALL=C \
EXEEXT=$(EXEEXT) \
PATH=../gpgscm:$(PATH) \
- TMP=$(TMP) \
srcdir=$(abs_srcdir) \
objdir=$(abs_top_builddir) \
GPGSCM_PATH=$(abs_top_srcdir)/tests/gpgscm:$(abs_top_srcdir)/tests/openpgp:$(abs_top_srcdir)/tests/gpgme
diff --git a/tests/gpgme/gpgme-defs.scm b/tests/gpgme/gpgme-defs.scm
index c102c9386..7a7166c58 100644
--- a/tests/gpgme/gpgme-defs.scm
+++ b/tests/gpgme/gpgme-defs.scm
@@ -54,7 +54,8 @@
(create-file
"gpg-agent.conf"
(string-append "pinentry-program " (tool 'pinentry)))
- (mkdir "private-keys-v1.d" "-rwx")
+
+ (start-agent)
(log "Storing private keys")
(for-each
diff --git a/tests/gpgscm/tests.scm b/tests/gpgscm/tests.scm
index e5858d960..b3da919d4 100644
--- a/tests/gpgscm/tests.scm
+++ b/tests/gpgscm/tests.scm
@@ -268,14 +268,13 @@
;; Make a temporary directory. If arguments are given, they are
;; joined using path-join, and must end in a component ending in
;; "XXXXXX". If no arguments are given, a suitable location and
-;; generic name is used.
+;; generic name is used. Returns an absolute path.
(define (mkdtemp . components)
- (_mkdtemp (if (null? components)
- (path-join (getenv "TMP")
- (string-append "gpgscm-" (get-isotime) "-"
- (basename-suffix *scriptname* ".scm")
- "-XXXXXX"))
- (apply path-join components))))
+ (canonical-path (_mkdtemp (if (null? components)
+ (string-append "gpgscm-" (get-isotime) "-"
+ (basename-suffix *scriptname* ".scm")
+ "-XXXXXX")
+ (apply path-join components)))))
(define-macro (with-temporary-working-directory . expressions)
(let ((tmp-sym (gensym)))
diff --git a/tests/gpgsm/Makefile.am b/tests/gpgsm/Makefile.am
index aad328bef..28db50133 100644
--- a/tests/gpgsm/Makefile.am
+++ b/tests/gpgsm/Makefile.am
@@ -28,12 +28,9 @@ include $(top_srcdir)/am/cmacros.am
AM_CFLAGS =
-TMP ?= /tmp
-
TESTS_ENVIRONMENT = LC_ALL=C \
EXEEXT=$(EXEEXT) \
PATH=../gpgscm:$(PATH) \
- TMP=$(TMP) \
srcdir=$(abs_srcdir) \
objdir=$(abs_top_builddir) \
GPGSCM_PATH=$(abs_top_srcdir)/tests/gpgscm:$(abs_top_srcdir)/tests/openpgp:$(abs_top_srcdir)/tests/gpgsm
diff --git a/tests/gpgsm/gpgsm-defs.scm b/tests/gpgsm/gpgsm-defs.scm
index aa5af3d59..5f9be7f0f 100644
--- a/tests/gpgsm/gpgsm-defs.scm
+++ b/tests/gpgsm/gpgsm-defs.scm
@@ -73,6 +73,7 @@
"faked-system-time 1008241200")
(create-file "gpg-agent.conf"
(string-append "pinentry-program " (tool 'pinentry)))
+ (start-agent)
(create-file
"trustlist.txt"
"32100C27173EF6E9C4E9A25D3D69F86D37A4F939"
@@ -80,7 +81,6 @@
"3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E S")
(log "Storing private keys")
- (mkdir "private-keys-v1.d" "-rwx")
(for-each
(lambda (name)
(file-copy (in-srcdir name)
diff --git a/tests/migrations/Makefile.am b/tests/migrations/Makefile.am
index d0cd9ee60..0895aff04 100644
--- a/tests/migrations/Makefile.am
+++ b/tests/migrations/Makefile.am
@@ -28,12 +28,9 @@ include $(top_srcdir)/am/cmacros.am
AM_CFLAGS =
-TMP ?= /tmp
-
TESTS_ENVIRONMENT = GPG_AGENT_INFO= LC_ALL=C \
EXEEXT=$(EXEEXT) \
PATH=../gpgscm:$(PATH) \
- TMP=$(TMP) \
srcdir=$(abs_srcdir) \
objdir=$(abs_top_builddir) \
GPGSCM_PATH=$(abs_top_srcdir)/tests/gpgscm:$(abs_top_srcdir)/tests/migrations
diff --git a/tests/migrations/common.scm b/tests/migrations/common.scm
index 30ac62ba1..fa8f1295a 100644
--- a/tests/migrations/common.scm
+++ b/tests/migrations/common.scm
@@ -26,6 +26,7 @@
(string-append executable (getenv "EXEEXT")))
;; We may not use a relative name for gpg-agent.
+(define gpgconf (path-join (getenv "objdir") "tools" (qualify "gpgconf")))
(define GPG-AGENT (path-join (getenv "objdir") "agent" (qualify "gpg-agent")))
(define GPG `(,(path-join (getenv "objdir") "g10" (qualify "gpg"))
--no-permission-warning --no-greeting
@@ -51,4 +52,9 @@
(info message)
(untar-armored src-tarball)
(setenv "GNUPGHOME" (getcwd) #t)
- (test (getcwd))))
+
+ (catch (log "Warning: Creating socket directory failed:" (car *error*))
+ (call-popen `(,gpgconf --create-socketdir) ""))
+ (test (getcwd))
+ (catch (log "Warning: Removing socket directory failed.")
+ (call-popen `(,gpgconf --remove-socketdir) ""))))
diff --git a/tests/migrations/extended-pkf.scm b/tests/migrations/extended-pkf.scm
index bf2c49e20..1317cd4f8 100755
--- a/tests/migrations/extended-pkf.scm
+++ b/tests/migrations/extended-pkf.scm
@@ -22,15 +22,6 @@
(catch (skip "gpgtar not built")
(call-check `(,GPGTAR --help)))
-(define src-tarball (in-srcdir "extended-pkf.tar.asc"))
-
-(define (setup)
- (untar-armored src-tarball)
- (setenv "GNUPGHOME" (getcwd) #t))
-
-(define (trigger-migration)
- (call-check `(,@GPG --list-secret-keys)))
-
(define (assert-keys-usable)
(for-each
(lambda (keyid)
@@ -38,9 +29,10 @@
(call-check `(,@GPG --list-secret-keys ,keyid))))
'("C40FDECF" "ECABF51D")))
-(info "Testing the extended private key format ...")
-(with-temporary-working-directory
- (setup)
- (assert-keys-usable))
+(run-test
+ "Testing the extended private key format ..."
+ (in-srcdir "extended-pkf.tar.asc")
+ (lambda (gpghome)
+ (assert-keys-usable)))
;; XXX try changing a key, and check that the format is not changed.
diff --git a/tests/migrations/from-classic.scm b/tests/migrations/from-classic.scm
index d540470c3..ace458e22 100755
--- a/tests/migrations/from-classic.scm
+++ b/tests/migrations/from-classic.scm
@@ -22,12 +22,6 @@
(catch (skip "gpgtar not built")
(call-check `(,GPGTAR --help)))
-(define src-tarball (in-srcdir "from-classic.tar.asc"))
-
-(define (setup)
- (untar-armored src-tarball)
- (setenv "GNUPGHOME" (getcwd) #t))
-
(define (trigger-migration)
(call-check `(,@GPG --list-secret-keys)))
@@ -41,24 +35,27 @@
(call-check `(,@GPG --list-secret-keys ,keyid))))
'("D74C5F22" "C40FDECF" "ECABF51D")))
-(info "Testing a clean migration ...")
-(with-temporary-working-directory
- (setup)
- (trigger-migration)
- (assert-migrated))
-
-(info "Testing a migration with existing private-keys-v1.d ...")
-(with-temporary-working-directory
- (setup)
- (mkdir "private-keys-v1.d" "-rwx")
- (trigger-migration)
- (assert-migrated))
-
-(info "Testing a migration with existing but weird private-keys-v1.d ...")
-(with-temporary-working-directory
- (setup)
- (mkdir "private-keys-v1.d" "")
- (trigger-migration)
- (assert-migrated))
+(run-test
+ "Testing a clean migration ..."
+ (in-srcdir "from-classic.tar.asc")
+ (lambda (gpghome)
+ (trigger-migration)
+ (assert-migrated)))
+
+(run-test
+ "Testing a migration with existing private-keys-v1.d ..."
+ (in-srcdir "from-classic.tar.asc")
+ (lambda (gpghome)
+ (mkdir "private-keys-v1.d" "-rwx")
+ (trigger-migration)
+ (assert-migrated)))
+
+(run-test
+ "Testing a migration with existing but weird private-keys-v1.d ..."
+ (in-srcdir "from-classic.tar.asc")
+ (lambda (gpghome)
+ (mkdir "private-keys-v1.d" "")
+ (trigger-migration)
+ (assert-migrated)))
;; XXX Check a case where the migration fails.
diff --git a/tests/openpgp/Makefile.am b/tests/openpgp/Makefile.am
index afac58fc8..518af200c 100644
--- a/tests/openpgp/Makefile.am
+++ b/tests/openpgp/Makefile.am
@@ -33,12 +33,9 @@ noinst_PROGRAMS = fake-pinentry
fake_pinentry_SOURCES = fake-pinentry.c
-TMP ?= /tmp
-
TESTS_ENVIRONMENT = LC_ALL=C \
EXEEXT=$(EXEEXT) \
PATH=../gpgscm:$(PATH) \
- TMP=$(TMP) \
srcdir=$(abs_srcdir) \
objdir=$(abs_top_builddir) \
GPGSCM_PATH=$(abs_top_srcdir)/tests/gpgscm:$(abs_top_srcdir)/tests/openpgp
diff --git a/tests/openpgp/README b/tests/openpgp/README
index eba77b1ae..b9d560797 100644
--- a/tests/openpgp/README
+++ b/tests/openpgp/README
@@ -30,7 +30,7 @@ This is a bit tricky because one needs to manually set some
environment variables. We should make that easier. See discussion
below. From your build directory, do:
- obj $ TMP=/tmp srcdir=<path to>/tests/openpgp \
+ obj $ srcdir=<path to>/tests/openpgp \
GPGSCM_PATH=<path to>/tests/gpgscm:<path to>/tests/openpgp \
$(pwd)/tests/gpgscm/gpgscm [gpgscm args] \
run-tests.scm [test suite runner args]
diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm
index a06a570ac..568ffab18 100644
--- a/tests/openpgp/defs.scm
+++ b/tests/openpgp/defs.scm
@@ -278,6 +278,15 @@
;; GnuPG helper.
;;
+;; Evaluate a sequence of expressions with the given home directory.
+(define-macro (with-home-directory gnupghome . expressions)
+ (let ((original-home-directory (gensym)))
+ `(let ((,original-home-directory (getenv "GNUPGHOME")))
+ (dynamic-wind
+ (lambda () (setenv "GNUPGHOME" ,gnupghome #t))
+ (lambda () ,@expressions)
+ (lambda () (setenv "GNUPGHOME" ,original-home-directory #t))))))
+
;; Evaluate a sequence of expressions with an ephemeral home
;; directory.
(define-macro (with-ephemeral-home-directory . expressions)
@@ -364,7 +373,6 @@
(define (create-legacy-gpghome)
(create-sample-files)
- (mkdir "private-keys-v1.d" "-rwx")
(log "Storing private keys")
(for-each
@@ -434,7 +442,10 @@
;; Create the socket dir and start the agent.
(define (start-agent)
(log "Starting gpg-agent...")
- (atexit stop-agent)
+ (let ((gnupghome (getenv "GNUPGHOME")))
+ (atexit (lambda ()
+ (with-home-directory gnupghome
+ (stop-agent)))))
(catch (log "Warning: Creating socket directory failed:" (car *error*))
(call-popen `(,(tool 'gpgconf) --create-socketdir) ""))
(call-check `(,(tool 'gpg-connect-agent) --verbose
diff --git a/tests/openpgp/setup.scm b/tests/openpgp/setup.scm
index d13799d90..bf1876e2d 100755
--- a/tests/openpgp/setup.scm
+++ b/tests/openpgp/setup.scm
@@ -25,6 +25,7 @@
(with-ephemeral-home-directory
(chdir (getenv "GNUPGHOME"))
(create-gpghome)
+ (start-agent)
(create-legacy-gpghome)
(stop-agent)
(call-check `(,(tool 'gpgtar) --create --output ,(cadr *args*) ".")))