2016-11-17 13:11:48 +01:00
|
|
|
#!/usr/bin/env gpgscm
|
|
|
|
|
|
|
|
;; Copyright (C) 2016 g10 Code GmbH
|
|
|
|
;;
|
|
|
|
;; This file is part of GnuPG.
|
|
|
|
;;
|
|
|
|
;; GnuPG is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation; either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; GnuPG is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2017-03-22 12:40:42 +01:00
|
|
|
(load (in-srcdir "tests" "openpgp" "defs.scm"))
|
2016-11-17 13:11:48 +01:00
|
|
|
|
|
|
|
(define gpgme-srcdir (getenv "XTEST_GPGME_SRCDIR"))
|
|
|
|
|
|
|
|
(define (in-gpgme-srcdir . names)
|
|
|
|
(canonical-path (apply path-join (cons gpgme-srcdir names))))
|
|
|
|
|
|
|
|
(define gpgme-builddir (getenv "XTEST_GPGME_BUILDDIR"))
|
2017-03-20 10:30:08 +01:00
|
|
|
|
|
|
|
(define (have-gpgme?)
|
|
|
|
(cond
|
|
|
|
((string=? "" gpgme-srcdir)
|
|
|
|
(info
|
|
|
|
"SKIP: Environment variable 'XTEST_GPGME_SRCDIR' not set. Please"
|
|
|
|
"point it to a recent GPGME source tree to run the GPGME test suite.")
|
|
|
|
#f)
|
|
|
|
((string=? "" gpgme-builddir)
|
2016-11-17 13:11:48 +01:00
|
|
|
(info
|
|
|
|
"SKIP: Environment variable 'XTEST_GPGME_BUILDDIR' not set. Please"
|
|
|
|
"point it to a recent GPGME build tree to run the GPGME test suite.")
|
2017-03-20 10:30:08 +01:00
|
|
|
#f)
|
|
|
|
(else
|
|
|
|
#t)))
|
2016-11-17 13:11:48 +01:00
|
|
|
|
|
|
|
;; Make sure that GPGME picks up our gpgconf. This makes GPGME use
|
|
|
|
;; and thus executes the tests with GnuPG components from the build
|
|
|
|
;; tree.
|
|
|
|
(setenv "PATH" (string-append (path-join (getenv "GNUPG_BUILDDIR") "tools")
|
|
|
|
(string *pathsep*) (getenv "PATH")) #t)
|
|
|
|
|
2017-01-25 16:53:40 +01:00
|
|
|
;; The tests expect the pinentry to return the passphrase "abc".
|
|
|
|
(setenv "PINENTRY_USER_DATA" "abc" #t)
|
|
|
|
|
2016-11-17 13:11:48 +01:00
|
|
|
(define (create-gpgmehome . path)
|
2017-03-09 14:33:02 +01:00
|
|
|
;; Support for various environments.
|
|
|
|
(define mode
|
|
|
|
(cond
|
|
|
|
((equal? path '("lang" "python" "tests"))
|
|
|
|
(set! path '("tests" "gpg")) ;; Mostly uses files from tests/gpg.
|
|
|
|
'python)
|
|
|
|
(else
|
|
|
|
'gpg)))
|
|
|
|
|
|
|
|
(create-file
|
|
|
|
"gpg.conf"
|
|
|
|
"no-force-v3-sigs"
|
|
|
|
(string-append "agent-program " (tool 'gpg-agent) "|--debug-quick-random\n"))
|
2016-11-17 13:11:48 +01:00
|
|
|
(create-file
|
|
|
|
"gpg-agent.conf"
|
2017-05-16 16:07:25 +02:00
|
|
|
(string-append "pinentry-program " (tool 'pinentry))
|
2019-02-21 04:26:09 +01:00
|
|
|
"disable-scdaemon")
|
2017-03-06 17:16:41 +01:00
|
|
|
|
|
|
|
(start-agent)
|
2016-11-17 13:11:48 +01:00
|
|
|
|
|
|
|
(log "Storing private keys")
|
|
|
|
(for-each
|
|
|
|
(lambda (name)
|
|
|
|
(file-copy (apply in-gpgme-srcdir `(,@path ,name))
|
|
|
|
(path-join "private-keys-v1.d"
|
|
|
|
(string-append name ".key"))))
|
|
|
|
'("13CD0F3BDF24BE53FE192D62F18737256FF6E4FD"
|
|
|
|
"76F7E2B35832976B50A27A282D9B87E44577EB66"
|
|
|
|
"A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD"
|
|
|
|
"13CBE3758AFE42B5E5E2AE4CED27AFA455E3F87F"
|
|
|
|
"7A030357C0F253A5BBCD282FFC4E521B37558F5C"))
|
|
|
|
|
|
|
|
(log "Importing public demo and test keys")
|
|
|
|
(for-each
|
|
|
|
(lambda (file)
|
|
|
|
(call-check `(,@GPG --yes --import ,(apply in-gpgme-srcdir
|
|
|
|
`(,@path ,file)))))
|
|
|
|
(list "pubdemo.asc" "secdemo.asc"))
|
2017-03-09 14:33:02 +01:00
|
|
|
|
|
|
|
(when (equal? mode 'python)
|
|
|
|
(log "Importing extra keys for Python tests")
|
|
|
|
(for-each
|
|
|
|
(lambda (file)
|
|
|
|
(call-check `(,@GPG --yes --import
|
|
|
|
,(apply in-gpgme-srcdir
|
|
|
|
`("lang" "python" "tests" ,file)))))
|
|
|
|
(list "encrypt-only.asc" "sign-only.asc"))
|
|
|
|
|
|
|
|
(log "Marking key as trusted")
|
|
|
|
(pipe:do
|
|
|
|
(pipe:echo "A0FF4590BB6122EDEF6E3C542D727CC768697734:6:\n")
|
|
|
|
(pipe:spawn `(,(tool 'gpg) --import-ownertrust))))
|
|
|
|
|
2016-11-17 13:11:48 +01:00
|
|
|
(stop-agent))
|
|
|
|
|
|
|
|
;; Initialize the test environment, install appropriate configuration
|
|
|
|
;; and start the agent, with the keys from the legacy test suite.
|
|
|
|
(define (setup-gpgme-environment . path)
|
|
|
|
(if (member "--unpack-tarball" *args*)
|
|
|
|
(begin
|
|
|
|
(call-check `(,(tool 'gpgtar) --extract --directory=. ,(cadr *args*)))
|
|
|
|
(start-agent))
|
|
|
|
(apply create-gpgme-gpghome path)))
|
|
|
|
|
2017-04-24 17:32:41 +02:00
|
|
|
(define python
|
|
|
|
(let loop ((pythons (list "python" "python2" "python3")))
|
|
|
|
(if (null? pythons)
|
|
|
|
#f
|
|
|
|
(catch (loop (cdr pythons))
|
|
|
|
(unless (file-exists? (path-join gpgme-builddir "lang" "python"
|
|
|
|
(string-append (car pythons) "-gpg")))
|
|
|
|
(throw "next please"))
|
|
|
|
(path-expand (car pythons) (string-split (getenv "PATH") *pathsep*))))))
|
|
|
|
|
2017-03-14 12:45:29 +01:00
|
|
|
(define (run-python-tests?)
|
2017-04-24 17:32:41 +02:00
|
|
|
(not (not python)))
|