tests: Locate resources and scripts relative to top source dir.

--

Locate every resource and every script used in the tests using a path
relative to the top of the source tree.

This is a purely mechanical change, mostly done using regular
expressions, with a few manual fixups here and there.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2017-03-22 12:40:42 +01:00
parent f03d6897be
commit ed4d23d75e
No known key found for this signature in database
GPG Key ID: DD1A52F9DA8C9020
87 changed files with 208 additions and 182 deletions

View File

@ -54,6 +54,8 @@ noinst_PROGRAMS += gpgcompose
endif
noinst_PROGRAMS += $(module_tests)
TESTS = $(module_tests)
TESTS_ENVIRONMENT = \
abs_top_srcdir=$(abs_top_srcdir)
if ENABLE_BZIP2_SUPPORT
bzip2_source = compress-bz2.c

View File

@ -58,6 +58,8 @@
#include "dek.h"
#include "../common/logging.h"
#include "test.c"
static void
log_hexdump (byte *buffer, int length)
{
@ -368,8 +370,8 @@ oracle_test (unsigned int d, int b, int debug)
return oracle (debug, probe, blocksize + 2, NULL, NULL) == 0;
}
int
main (int argc, char *argv[])
static void
do_test (int argc, char *argv[])
{
int i;
int debug = 0;
@ -379,8 +381,6 @@ main (int argc, char *argv[])
byte *raw_data;
int raw_data_len;
int failed = 0;
for (i = 1; i < argc; i ++)
{
if (strcmp (argv[i], "--debug") == 0)
@ -396,11 +396,10 @@ main (int argc, char *argv[])
}
}
if (! blocksize && ! filename && (filename = getenv ("srcdir")))
if (! blocksize && ! filename && (filename = prepend_srcdir ("t-stutter-data.asc")))
/* Try defaults. */
{
parse_session_key ("9:9274A8EC128E850C6DDDF9EAC68BFA84FC7BC05F340DA41D78C93D0640C7C503");
filename = xasprintf ("%s/t-stutter-data.asc", filename);
}
if (help || ! blocksize || ! filename)
@ -601,7 +600,7 @@ main (int argc, char *argv[])
isprint (pt[0]) ? pt[0] : '?',
isprint (pt[1]) ? pt[1] : '?',
hexstr (m));
failed = 1;
tests_failed++;
}
}
@ -610,5 +609,4 @@ main (int argc, char *argv[])
}
xfree (filename);
return failed;
}

View File

@ -154,12 +154,12 @@ prepend_srcdir (const char *fname)
static const char *srcdir;
char *result;
if (!srcdir && !(srcdir = getenv ("srcdir")))
if (!srcdir && !(srcdir = getenv ("abs_top_srcdir")))
srcdir = ".";
result = malloc (strlen (srcdir) + 1 + strlen (fname) + 1);
result = malloc (strlen (srcdir) + strlen ("/g10/") + strlen (fname) + 1);
strcpy (result, srcdir);
strcat (result, "/");
strcat (result, "/g10/");
strcat (result, fname);
return result;
}

View File

@ -31,9 +31,9 @@ AM_CFLAGS =
TESTS_ENVIRONMENT = LC_ALL=C \
EXEEXT=$(EXEEXT) \
PATH=../gpgscm:$(PATH) \
srcdir=$(abs_srcdir) \
abs_top_srcdir=$(abs_top_srcdir) \
objdir=$(abs_top_builddir) \
GPGSCM_PATH=$(abs_top_srcdir)/tests/gpgscm:$(abs_top_srcdir)/tests/openpgp:$(abs_top_srcdir)/tests/gpgme
GPGSCM_PATH=$(abs_top_srcdir)/tests/gpgscm
# XXX: Currently, one cannot override automake's 'check' target. As a
# workaround, we avoid defining 'TESTS', thus automake will not emit

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(define gpgme-srcdir (getenv "XTEST_GPGME_SRCDIR"))
(when (string=? "" gpgme-srcdir)

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgme-defs.scm"))
(load (in-srcdir "tests" "gpgme" "gpgme-defs.scm"))
(info "Running GPGME's test suite...")
@ -40,11 +40,17 @@
run-tests-parallel
run-tests-sequential))
(setup-c (make-environment-cache
(test::scm #f "setup.scm (tests/gpg)" (in-srcdir "setup.scm")
"--" "tests" "gpg")))
(test::scm
#f
(path-join "tests" "gpgme" "setup.scm" "tests" "gpg")
(in-srcdir "tests" "gpgme" "setup.scm")
"--" "tests" "gpg")))
(setup-py (make-environment-cache
(test::scm #f "setup.scm (lang/python/tests)" (in-srcdir "setup.scm")
"--" "lang" "python" "tests")))
(test::scm
#f
(path-join "tests" "gpgme" "setup.scm" "lang" "python" "tests")
(in-srcdir "tests" "gpgme" "setup.scm")
"--" "lang" "python" "tests")))
(tests (filter (lambda (arg) (not (string-prefix? arg "--"))) *args*)))
(runner
(apply
@ -66,7 +72,10 @@
(map (lambda (name)
(apply test::scm
`(,(:setup cmpnts)
,name ,(in-srcdir "wrap.scm") --executable
,(apply path-join
`("tests" "gpgme" ,@(:path cmpnts) ,name))
,(in-srcdir "tests" "gpgme" "wrap.scm")
--executable
,(find-test name)
-- ,@(:path cmpnts))))
(if (null? tests) (all-tests makefile (:key cmpnts)) tests))))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgme-defs.scm"))
(load (in-srcdir "tests" "gpgme" "gpgme-defs.scm"))
(define tarball (flag "--create-tarball" *args*))
(unless (and tarball (not (null? tarball)))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgme-defs.scm"))
(load (in-srcdir "tests" "gpgme" "gpgme-defs.scm"))
(define executable (flag "--executable" *args*))
(unless (and executable (not (null? executable)))
@ -28,6 +28,7 @@
(setenv "abs_builddir" (getcwd) #t)
(setenv "top_srcdir" gpgme-srcdir #t)
(setenv "srcdir" (path-join gpgme-srcdir "tests" "gpg") #t)
(setenv "abs_top_srcdir" (path-join gpgme-srcdir "tests" "gpg") #t)
(define (run what)
(if (string-suffix? (car what) ".py")

View File

@ -189,7 +189,7 @@
(if (absolute-path? path) path (path-join (getcwd) path)))
(define (in-srcdir . names)
(canonical-path (apply path-join (cons (getenv "srcdir") names))))
(canonical-path (apply path-join (cons (getenv "abs_top_srcdir") names))))
;; Try to find NAME in PATHS. Returns the full path name on success,
;; or raises an error.

View File

@ -31,9 +31,9 @@ AM_CFLAGS =
TESTS_ENVIRONMENT = LC_ALL=C \
EXEEXT=$(EXEEXT) \
PATH=../gpgscm:$(PATH) \
srcdir=$(abs_srcdir) \
abs_top_srcdir=$(abs_top_srcdir) \
objdir=$(abs_top_builddir) \
GPGSCM_PATH=$(abs_top_srcdir)/tests/gpgscm:$(abs_top_srcdir)/tests/openpgp:$(abs_top_srcdir)/tests/gpgsm
GPGSCM_PATH=$(abs_top_srcdir)/tests/gpgscm
XTESTS = \
import.scm \

View File

@ -17,14 +17,14 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgsm-defs.scm"))
(load (in-srcdir "tests" "gpgsm" "gpgsm-defs.scm"))
(setup-gpgsm-environment)
(for-each-p
"Checking decryption of supplied files."
(lambda (name)
(tr:do
(tr:open (in-srcdir (string-append name ".cms.asc")))
(tr:open (in-srcdir "tests" "gpgsm" (string-append name ".cms.asc")))
(tr:gpgsm "" '(--decrypt))
(tr:assert-identity name)))
plain-files)

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgsm-defs.scm"))
(load (in-srcdir "tests" "gpgsm" "gpgsm-defs.scm"))
(setup-gpgsm-environment)
(for-each-p

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgsm-defs.scm"))
(load (in-srcdir "tests" "gpgsm" "gpgsm-defs.scm"))
(setup-gpgsm-environment)
(for-each-p'

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
;; This is the list of certificates that we install in the test
;; environment.
@ -83,13 +83,13 @@
(log "Storing private keys")
(for-each
(lambda (name)
(file-copy (in-srcdir name)
(file-copy (in-srcdir "tests" "gpgsm" name)
(path-join "private-keys-v1.d"
(string-append name ".key"))))
'("32100C27173EF6E9C4E9A25D3D69F86D37A4F939"))
(log "Importing public demo and test keys")
(call-check `(,@gpgsm --import ,(in-srcdir "cert_g10code_test1.der")))
(call-check `(,@gpgsm --import ,(in-srcdir "tests" "gpgsm" "cert_g10code_test1.der")))
(create-sample-files)
(stop-agent))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgsm-defs.scm"))
(load (in-srcdir "tests" "gpgsm" "gpgsm-defs.scm"))
(setup-gpgsm-environment)
(define certs-for-import
@ -47,7 +47,7 @@
"Checking certificate import."
(lambda (test)
(assert (not (sm-have-public-key? (:cert test))))
(call-check `(,@gpgsm --import ,(in-srcdir (:name test))))
(call-check `(,@gpgsm --import ,(in-srcdir "tests" "gpgsm" (:name test))))
(assert (sm-have-public-key? (:cert test))))
(lambda (test) (:name test))
certs-for-import)

View File

@ -17,16 +17,22 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(if (string=? "" (getenv "srcdir"))
(if (string=? "" (getenv "abs_top_srcdir"))
(begin
(echo "Environment variable 'srcdir' not set. Please point it to"
(echo "Environment variable 'abs_top_srcdir' not set. Please point it to"
"tests/gpgsm.")
(exit 2)))
(let* ((tests (filter (lambda (arg) (not (string-prefix? arg "--"))) *args*))
(setup (make-environment-cache (test::scm #f "setup.scm" "setup.scm")))
(setup (make-environment-cache (test::scm
#f
(path-join "tests" "gpgsm" "setup.scm")
(in-srcdir "tests" "gpgsm" "setup.scm"))))
(runner (if (and (member "--parallel" *args*)
(> (length tests) 1))
run-tests-parallel
run-tests-sequential)))
(runner (map (lambda (t) (test::scm setup t t)) tests)))
(runner (map (lambda (name)
(test::scm setup
(path-join "tests" "gpgsm" name)
(in-srcdir "tests" "gpgsm" name))) tests)))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgsm-defs.scm"))
(load (in-srcdir "tests" "gpgsm" "gpgsm-defs.scm"))
(define tarball (flag "--create-tarball" *args*))
(unless (and tarball (not (null? tarball)))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgsm-defs.scm"))
(load (in-srcdir "tests" "gpgsm" "gpgsm-defs.scm"))
(setup-gpgsm-environment)
;; This is not a test, but can be used to inspect the test

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgsm-defs.scm"))
(load (in-srcdir "tests" "gpgsm" "gpgsm-defs.scm"))
(setup-gpgsm-environment)
(for-each-p

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgsm-defs.scm"))
(load (in-srcdir "tests" "gpgsm" "gpgsm-defs.scm"))
(setup-gpgsm-environment)
;;

View File

@ -31,9 +31,9 @@ AM_CFLAGS =
TESTS_ENVIRONMENT = GPG_AGENT_INFO= LC_ALL=C \
EXEEXT=$(EXEEXT) \
PATH=../gpgscm:$(PATH) \
srcdir=$(abs_srcdir) \
abs_top_srcdir=$(abs_top_srcdir) \
objdir=$(abs_top_builddir) \
GPGSCM_PATH=$(abs_top_srcdir)/tests/gpgscm:$(abs_top_srcdir)/tests/migrations
GPGSCM_PATH=$(abs_top_srcdir)/tests/gpgscm
XTESTS = from-classic.scm \
extended-pkf.scm \
@ -54,7 +54,7 @@ check: xcheck
.PHONY: xcheck
xcheck:
$(TESTS_ENVIRONMENT) $(abs_top_builddir)/tests/gpgscm/gpgscm \
run-tests.scm $(TESTFLAGS) $(XTESTS)
$(abs_srcdir)/run-tests.scm $(TESTFLAGS) $(XTESTS)
EXTRA_DIST = common.scm run-tests.scm setup.scm $(XTESTS) $(TEST_FILES)

View File

@ -15,7 +15,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(if (string=? "" (getenv "srcdir"))
(if (string=? "" (getenv "abs_top_srcdir"))
(error "not called from make"))
(let ((verbose (string->number (getenv "verbose"))))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "common.scm"))
(load (in-srcdir "tests" "migrations" "common.scm"))
(catch (skip "gpgtar not built")
(call-check `(,GPGTAR --help)))
@ -31,7 +31,7 @@
(run-test
"Testing the extended private key format ..."
(in-srcdir "extended-pkf.tar.asc")
(in-srcdir "tests" "migrations" "extended-pkf.tar.asc")
(lambda (gpghome)
(assert-keys-usable)))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "common.scm"))
(load (in-srcdir "tests" "migrations" "common.scm"))
(catch (skip "gpgtar not built")
(call-check `(,GPGTAR --help)))
@ -37,14 +37,14 @@
(run-test
"Testing a clean migration ..."
(in-srcdir "from-classic.tar.asc")
(in-srcdir "tests" "migrations" "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")
(in-srcdir "tests" "migrations" "from-classic.tar.asc")
(lambda (gpghome)
(mkdir "private-keys-v1.d" "-rwx")
(trigger-migration)
@ -52,7 +52,7 @@
(run-test
"Testing a migration with existing but weird private-keys-v1.d ..."
(in-srcdir "from-classic.tar.asc")
(in-srcdir "tests" "migrations" "from-classic.tar.asc")
(lambda (gpghome)
(mkdir "private-keys-v1.d" "")
(trigger-migration)

View File

@ -17,12 +17,12 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "common.scm"))
(load (in-srcdir "tests" "migrations" "common.scm"))
(run-test
"Checking migration with legacy key (issue2276)..."
;; This tarball contains a keyring with a legacy key.
(in-srcdir "issue2276.tar.asc")
(in-srcdir "tests" "migrations" "issue2276.tar.asc")
(lambda (gpghome)
;; GnuPG up to 2.1.14 failed to skip the legacy key when updating
;; the trust database and thereby rebuilding the keyring cache.

View File

@ -22,4 +22,7 @@
(> (length tests) 1))
run-tests-parallel
run-tests-sequential)))
(runner (map (lambda (t) (test::scm #f t t)) tests)))
(runner (map (lambda (name)
(test::scm #f
(path-join "tests" "migrations" name)
(in-srcdir "tests" "migrations" name))) tests)))

View File

@ -20,10 +20,10 @@
;; GnuPG through 2.1.7 would incorrect mark packets whose size is
;; 2^32-1 as invalid and exit with status code 2.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-environment)
(unless (have-compression-algo? "BZIP2")
(skip "BZIP2 support not compiled in."))
(call-check `(,@GPG --list-packets ,(in-srcdir "4gb-packet.asc")))
(call-check `(,@GPG --list-packets ,(in-srcdir "tests" "openpgp" "4gb-packet.asc")))

View File

@ -36,9 +36,9 @@ fake_pinentry_SOURCES = fake-pinentry.c
TESTS_ENVIRONMENT = LC_ALL=C \
EXEEXT=$(EXEEXT) \
PATH=../gpgscm:$(PATH) \
srcdir=$(abs_srcdir) \
abs_top_srcdir=$(abs_top_srcdir) \
objdir=$(abs_top_builddir) \
GPGSCM_PATH=$(abs_top_srcdir)/tests/gpgscm:$(abs_top_srcdir)/tests/openpgp
GPGSCM_PATH=$(abs_top_srcdir)/tests/gpgscm
XTESTS = \
version.scm \
@ -109,7 +109,7 @@ check: xcheck
.PHONY: xcheck
xcheck:
$(TESTS_ENVIRONMENT) $(abs_top_builddir)/tests/gpgscm/gpgscm \
run-tests.scm $(TESTFLAGS) $(XTESTS)
$(abs_srcdir)/run-tests.scm $(TESTFLAGS) $(XTESTS)
TEST_FILES = pubring.asc secring.asc plain-1o.asc plain-2o.asc plain-3o.asc \
plain-1.asc plain-2.asc plain-3.asc plain-1-pgp.asc \

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(define files (append plain-files data-files))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(define armored_key_8192 "-----BEGIN PGP PUBLIC KEY BLOCK-----

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(define (check-signing args input)

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(define s2k '--s2k-count=65536)

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(define s2k '--s2k-count=65536)

View File

@ -17,14 +17,14 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p
"Checking decryption of supplied DSA encrypted file"
(lambda (name)
(tr:do
(tr:open (in-srcdir (string-append name "-pgp.asc")))
(tr:open (in-srcdir "tests" "openpgp" (string-append name "-pgp.asc")))
(tr:gpg "" '(--yes --decrypt))
(tr:assert-identity name)))
(list (car plain-files)))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(info "Checking decryption of supplied files using --multifile.")
@ -31,7 +31,7 @@
;; First, copy the files so that GnuPG writes the decrypted files here
;; and not into the source directory.
(for-each (lambda (name)
(file-copy (in-srcdir name) name))
(file-copy (in-srcdir "tests" "openpgp" name) name))
encrypted-files)
;; Now decrypt all files.

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(define (get-session-key filename)
@ -35,7 +35,7 @@
(for-each-p
"Checking decryption of supplied files using the session key."
(lambda (name)
(let* ((source (in-srcdir (string-append name ".asc")))
(let* ((source (in-srcdir "tests" "openpgp" (string-append name ".asc")))
(key (get-session-key source)))
(with-ephemeral-home-directory setup-environment
(tr:do

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(lettmp (steve's-key)
@ -29,7 +29,7 @@
;; First, unwrap the encrypted message using Steve's secret key.
(lettmp (unwrapped)
(tr:do
(tr:open (in-srcdir "samplemsgs" (string-append name ".asc")))
(tr:open (in-srcdir "tests" "openpgp" "samplemsgs" (string-append name ".asc")))
(tr:gpg "" `(--yes --decrypt --unwrap))
(tr:write-to unwrapped))

View File

@ -17,14 +17,14 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p
"Checking decryption of supplied files"
(lambda (name)
(tr:do
(tr:open (in-srcdir (string-append name ".asc")))
(tr:open (in-srcdir "tests" "openpgp" (string-append name ".asc")))
(tr:gpg "" '(--yes --decrypt))
(tr:assert-identity name)))
plain-files)

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
;; Import the sample key
@ -33,7 +33,7 @@
(info "Importing public key.")
(call-check
`(,(tool 'gpg) --import
,(in-srcdir "samplekeys/E657FB607BB4F21C90BB6651BC067AF28BC90111.asc")))
,(in-srcdir "tests" "openpgp" "samplekeys/E657FB607BB4F21C90BB6651BC067AF28BC90111.asc")))
;; By default, the most recent, valid signing subkey (1EA97479).
(for-each-p

View File

@ -318,7 +318,7 @@
(log "Creating configuration files")
(for-each
(lambda (name)
(file-copy (in-srcdir (string-append name ".tmpl")) name)
(file-copy (in-srcdir "tests" "openpgp" (string-append name ".tmpl")) name)
(let ((p (open-input-output-file name)))
(cond
((string=? "gpg.conf" name)
@ -349,7 +349,7 @@
(log "Unpacking samples")
(for-each
(lambda (name)
(dearmor (in-srcdir ".." "openpgp" (string-append name "o.asc")) name))
(dearmor (in-srcdir "tests" "openpgp" (string-append name "o.asc")) name))
plain-files))
(define (create-legacy-gpghome)
@ -358,7 +358,7 @@
(log "Storing private keys")
(for-each
(lambda (name)
(dearmor (in-srcdir (string-append "/privkeys/" name ".asc"))
(dearmor (in-srcdir "tests" "openpgp" "privkeys" (string-append name ".asc"))
(string-append "private-keys-v1.d/" name ".key")))
'("50B2D4FA4122C212611048BC5FC31BD44393626E"
"7E201E28B6FEB2927B321F443205F4724EBE637E"
@ -382,11 +382,11 @@
(log "Importing public demo and test keys")
(for-each
(lambda (file)
(call-check `(,@GPG --yes --import ,(in-srcdir file))))
(call-check `(,@GPG --yes --import ,(in-srcdir "tests" "openpgp" file))))
(list "pubdemo.asc" "pubring.asc" key-file1))
(pipe:do
(pipe:open (in-srcdir "pubring.pkr.asc") (logior O_RDONLY O_BINARY))
(pipe:open (in-srcdir "tests" "openpgp" "pubring.pkr.asc") (logior O_RDONLY O_BINARY))
(pipe:spawn `(,@GPG --dearmor))
(pipe:spawn `(,@GPG --yes --import))))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(let* ((key keys::alfa)

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(define files (append plain-files data-files))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(define keygrips '("8E06A180EFFE4C65B812150CAF19BF30C0689A4C"
@ -48,7 +48,7 @@
(for-each
(lambda (n)
(call-check `(,(tool 'gpg) --import
,(in-srcdir (string-append
,(in-srcdir "tests" "openpgp" (string-append
"samplekeys/ecc-sample-"
(number->string n)
"-pub.asc")))))
@ -117,7 +117,7 @@ Ic1RdzgeCfosMF+l/zVRchcLKzenEQA=
(lambda (n)
(call-check `(,(tool 'gpg) --import
,@(if (> n 1) '(--allow-non-selfsigned-uid) '())
,(in-srcdir (string-append
,(in-srcdir "tests" "openpgp" (string-append
"samplekeys/ecc-sample-"
(number->string n)
"-sec.asc")))))
@ -242,7 +242,7 @@ Rg==
(lambda (n)
(call-check `(,(tool 'gpg) --import
,@(if (> n 1) '(--allow-non-selfsigned-uid) '())
,(in-srcdir (string-append
,(in-srcdir "tests" "openpgp" (string-append
"samplekeys/ecc-sample-"
(number->string n)
"-sec.asc")))))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(define files (append plain-files data-files))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p
@ -54,8 +54,8 @@
(tr:do
(tr:open source)
(tr:gpg "" `(--yes -v --no-keyring --encrypt
--recipient-file ,(in-srcdir key-file1)
--hidden-recipient-file ,(in-srcdir key-file2)))
--recipient-file ,(in-srcdir "tests" "openpgp" key-file1)
--hidden-recipient-file ,(in-srcdir "tests" "openpgp" key-file2)))
(tr:gpg "" '(--yes --decrypt))
(tr:assert-identity source)))
plain-files)

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(define (check-for predicate lines message)

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-environment)
(define (genkey config)

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-environment)
(for-each-p'

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(catch (skip "gpgtar not built")

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(define msg_signed_asc "
@ -63,6 +63,6 @@ N1Glbw1OJfP1q+QFPMPKoCsTYmZpuugq2b5gV/eH0Abvk2pG4Fo/YTDPHhec7Jk=
(catch '()
(pipe:do
(pipe:echo (eval armored-file (current-environment)))
(pipe:spawn `(,@GPGV --keyring ,(in-srcdir "forged-keyring.gpg"))))
(pipe:spawn `(,@GPGV --keyring ,(in-srcdir "tests" "openpgp" "forged-keyring.gpg"))))
(fail "verification succeeded but should not")))
'(msg_signed_asc))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
;; XXX because of --always-trust, the trustdb is not created.
@ -25,7 +25,7 @@
(define gpg `(,(tool 'gpg) --no-permission-warning))
(info "Checking key revocation.")
(call-check `(,@gpg --import ,(in-srcdir "samplemsgs"
(call-check `(,@gpg --import ,(in-srcdir "tests" "openpgp" "samplemsgs"
"revoke-2D727CC768697734.asc")))
(let loop ((output (gpg-with-colons '(--list-secret-keys "2D727CC768697734"))))
(unless (null? output)

View File

@ -17,17 +17,17 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-environment)
(info "Checking bug 894: segv importing certain keys.")
(call-check `(,(tool 'gpg) --import ,(in-srcdir "bug894-test.asc")))
(call-check `(,(tool 'gpg) --import ,(in-srcdir "tests" "openpgp" "bug894-test.asc")))
(define keyid "0xC108E83A")
(info "Checking bug 1223: designated revoker sigs are not properly merged.")
(call `(,(tool 'gpg) --delete-key --batch --yes ,keyid))
(call `(,(tool 'gpg) --import ,(in-srcdir "bug1223-bogus.asc")))
(call `(,(tool 'gpg) --import ,(in-srcdir "bug1223-good.asc")))
(call `(,(tool 'gpg) --import ,(in-srcdir "tests" "openpgp" "bug1223-bogus.asc")))
(call `(,(tool 'gpg) --import ,(in-srcdir "tests" "openpgp" "bug1223-good.asc")))
(tr:do
(tr:pipe-do
(pipe:gpg `(--list-keys --with-colons ,keyid)))
@ -44,8 +44,8 @@
(define fpr2 "A55120427374F3F7AA5F1166DDA252EBB8EBE1AF")
(info "Checking import of two keys with colliding long key ids.")
(call `(,(tool 'gpg) --delete-key --batch --yes ,fpr1 ,fpr2))
(call `(,(tool 'gpg) --import ,(in-srcdir "samplekeys/dda252ebb8ebe1af-1.asc")))
(call `(,(tool 'gpg) --import ,(in-srcdir "samplekeys/dda252ebb8ebe1af-2.asc")))
(call `(,(tool 'gpg) --import ,(in-srcdir "tests" "openpgp" "samplekeys/dda252ebb8ebe1af-1.asc")))
(call `(,(tool 'gpg) --import ,(in-srcdir "tests" "openpgp" "samplekeys/dda252ebb8ebe1af-2.asc")))
(tr:do
(tr:pipe-do
(pipe:gpg `(--list-keys --with-colons ,fpr1 ,fpr2)))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-environment)
(info "Checking passphrase cache (issue2015)...")

View File

@ -17,10 +17,10 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-environment)
(define key (in-srcdir "samplekeys/issue2346.gpg"))
(define key (in-srcdir "tests" "openpgp" "samplekeys/issue2346.gpg"))
(info "Checking import statistics (issue2346)...")
(let ((status (call-popen `(,@GPG --status-fd=1 --import ,key) "")))

View File

@ -17,10 +17,10 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-environment)
(define keyfile (in-srcdir "samplekeys" "rsa-rsa-sample-1.asc"))
(define keyfile (in-srcdir "tests" "openpgp" "samplekeys" "rsa-rsa-sample-1.asc"))
(define (touch file-name)
(close (open file-name (logior O_WRONLY O_BINARY O_CREAT) #o600)))

View File

@ -17,13 +17,13 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-environment)
(info "Checking iobuf_peek corner case (issue2419)...")
(lettmp
(onebyte)
(dearmor (in-srcdir "samplemsgs/issue2419.asc") onebyte)
(dearmor (in-srcdir "tests" "openpgp" "samplemsgs/issue2419.asc") onebyte)
(catch (assert (string-contains? (car *error*) "invalid packet"))
(call-popen `(,@GPG --list-packets ,onebyte) "")
(fail "Expected an error but got none")))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-environment)
(catch (skip "Tofu not supported")

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(define (check-failure options)

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
;; This test assumes a fixed time of 2004-01-01.
@ -52,7 +52,7 @@
(define :comment cadr)
(define :number caddr)
(define (:filename key)
(in-srcdir "key-selection"
(in-srcdir "tests" "openpgp" "key-selection"
(string-append (number->string (:number key)) ".asc")))
(define (delete-keys which)

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-environment)
(define empty-string-hashes

View File

@ -23,7 +23,7 @@
;; Note: We do not support multiple signatures anymore thus this test is
;; not really needed because verify could do the same. We keep it anyway.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(define sig-1ls1ls-valid "

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(load (with-path "time.scm"))
(setup-environment)

View File

@ -17,9 +17,9 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(if (string=? "" (getenv "srcdir"))
(if (string=? "" (getenv "abs_top_srcdir"))
(begin
(echo "Environment variable 'srcdir' not set. Please point it to"
(echo "Environment variable 'abs_top_srcdir' not set. Please point it to"
"tests/openpgp.")
(exit 2)))
@ -27,9 +27,15 @@
(setenv "objdir" (getcwd) #f)
(let* ((tests (filter (lambda (arg) (not (string-prefix? arg "--"))) *args*))
(setup (make-environment-cache (test::scm #f "setup.scm" "setup.scm")))
(setup (make-environment-cache (test::scm
#f
(path-join "tests" "openpgp" "setup.scm")
(in-srcdir "tests" "openpgp" "setup.scm"))))
(runner (if (and (member "--parallel" *args*)
(> (length tests) 1))
run-tests-parallel
run-tests-sequential)))
(runner (map (lambda (t) (test::scm setup t t)) tests))))
(runner (map (lambda (name)
(test::scm setup
(path-join "tests" "openpgp" name)
(in-srcdir "tests" "openpgp" name))) tests)))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(unless (member "--create-tarball" *args*)
(fail "Usage: setup.scm --create-tarball <file>"))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-environment)
;; This is not a test, but can be used to inspect the test

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p
@ -33,7 +33,8 @@
(info "Checking bug 537: MDC problem with old style compressed packets.")
(lettmp (tmp)
(call-popen `(,@GPG --yes --passphrase-fd "0"
--output ,tmp --decrypt ,(in-srcdir "bug537-test.data.asc"))
--output ,tmp --decrypt ,(in-srcdir "tests" "openpgp"
"bug537-test.data.asc"))
usrpass1)
(if (not (string=? "4336AE2A528FAE091E73E59E325B588FEE795F9B"
(cadar (gpg-hash-string `(--print-md SHA1 ,tmp) ""))))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(for-each-p

View File

@ -17,11 +17,11 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-environment)
(define key
`(,(in-srcdir "samplekeys" "authenticate-only.sec.asc")
`(,(in-srcdir "tests" "openpgp" "samplekeys" "authenticate-only.sec.asc")
"927EF377FD1A1B6F795E40C02A87917D8FFBA49F"
"72360FDB6380212D5DAF2FA9E51185A9253C496D"
"ssh-rsa"))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-environment)
(setenv "SSH_AUTH_SOCK"
@ -76,7 +76,7 @@
(for-each-p'
"Importing ssh keys..."
(lambda (key)
(let ((file (path-join (in-srcdir "samplekeys")
(let ((file (path-join (in-srcdir "tests" "openpgp" "samplekeys")
(string-append "ssh-" (car key) ".key")))
(hash (cadr key)))
;; We pipe the key to ssh-add so that it won't complain about
@ -91,7 +91,7 @@
(info "Checking for issue2316...")
(unlink (path-join GNUPGHOME "sshcontrol"))
(pipe:do
(pipe:open (path-join (in-srcdir "samplekeys")
(pipe:open (path-join (in-srcdir "tests" "openpgp" "samplekeys")
(string-append "ssh-rsa.key"))
(logior O_RDONLY O_BINARY))
(pipe:spawn `(,SSH-ADD -)))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(load (with-path "time.scm"))
(setup-environment)
@ -41,7 +41,7 @@
;; Import the test keys.
(for-each (lambda (keyid)
(call-check `(,@GPG --import
,(in-srcdir "tofu/conflicting/"
,(in-srcdir "tests" "openpgp" "tofu" "conflicting"
(string-append keyid ".gpg"))))
(catch (fail "Missing key" keyid)
(call-check `(,@GPG --list-keys ,keyid))))
@ -108,7 +108,7 @@
;; Verify a message. There should be no conflict and the trust
;; policy should be set to auto.
(call-check `(,@GPG --verify ,(in-srcdir "tofu/conflicting/1C005AF3-1.txt")))
(call-check `(,@GPG --verify ,(in-srcdir "tests" "openpgp" "tofu" "conflicting" "1C005AF3-1.txt")))
(checkpolicy "1C005AF3" "auto")
;; Check default trust.
@ -163,7 +163,7 @@
;; auto), but not affect 1C005AF3's policy.
(setpolicy "BE04EB2B" "auto")
(checkpolicy "BE04EB2B" "ask")
(call-check `(,@GPG --verify ,(in-srcdir "tofu/conflicting/B662E42F-1.txt")))
(call-check `(,@GPG --verify ,(in-srcdir "tests" "openpgp" "tofu" "conflicting" "B662E42F-1.txt")))
(checkpolicy "BE04EB2B" "ask")
(checkpolicy "1C005AF3" "bad")
(checkpolicy "B662E42F" "ask")
@ -208,26 +208,26 @@
(check-counts "B662E42F" 0 0 0 0)
;; Verify a message. The signature count should increase by 1.
(call-check `(,@GPG --verify ,(in-srcdir "tofu/conflicting/1C005AF3-1.txt")))
(call-check `(,@GPG --verify ,(in-srcdir "tests" "openpgp" "tofu" "conflicting" "1C005AF3-1.txt")))
(check-counts "1C005AF3" 1 1 0 0)
;; Verify the same message. The signature count should remain the
;; same.
(call-check `(,@GPG --verify ,(in-srcdir "tofu/conflicting/1C005AF3-1.txt")))
(call-check `(,@GPG --verify ,(in-srcdir "tests" "openpgp" "tofu" "conflicting" "1C005AF3-1.txt")))
(check-counts "1C005AF3" 1 1 0 0)
;; Verify another message.
(call-check `(,@GPG --verify ,(in-srcdir "tofu/conflicting/1C005AF3-2.txt")))
(call-check `(,@GPG --verify ,(in-srcdir "tests" "openpgp" "tofu" "conflicting" "1C005AF3-2.txt")))
(check-counts "1C005AF3" 2 1 0 0)
;; Verify another message.
(call-check `(,@GPG --verify ,(in-srcdir "tofu/conflicting/1C005AF3-3.txt")))
(call-check `(,@GPG --verify ,(in-srcdir "tests" "openpgp" "tofu" "conflicting" "1C005AF3-3.txt")))
(check-counts "1C005AF3" 3 1 0 0)
;; Verify a message from a different sender. The signature count
;; should increase by 1 for that key.
(call-check `(,@GPG --verify ,(in-srcdir "tofu/conflicting/BE04EB2B-1.txt")))
(call-check `(,@GPG --verify ,(in-srcdir "tests" "openpgp" "tofu" "conflicting" "BE04EB2B-1.txt")))
(check-counts "1C005AF3" 3 1 0 0)
(check-counts "BE04EB2B" 1 1 0 0)
(check-counts "B662E42F" 0 0 0 0)
@ -236,34 +236,34 @@
;; when the message was first verified, not when the signer claimed
;; that it was signed.)
(call-check `(,@GPG ,(faketime (days->seconds 2))
--verify ,(in-srcdir "tofu/conflicting/1C005AF3-4.txt")))
--verify ,(in-srcdir "tests" "openpgp" "tofu" "conflicting" "1C005AF3-4.txt")))
(check-counts "1C005AF3" 4 2 0 0)
(check-counts "BE04EB2B" 1 1 0 0)
(check-counts "B662E42F" 0 0 0 0)
;; And another.
(call-check `(,@GPG ,(faketime (days->seconds 2))
--verify ,(in-srcdir "tofu/conflicting/1C005AF3-5.txt")))
--verify ,(in-srcdir "tests" "openpgp" "tofu" "conflicting" "1C005AF3-5.txt")))
(check-counts "1C005AF3" 5 2 0 0)
(check-counts "BE04EB2B" 1 1 0 0)
(check-counts "B662E42F" 0 0 0 0)
;; Another, but for a different key.
(call-check `(,@GPG ,(faketime (days->seconds 2))
--verify ,(in-srcdir "tofu/conflicting/BE04EB2B-2.txt")))
--verify ,(in-srcdir "tests" "openpgp" "tofu" "conflicting" "BE04EB2B-2.txt")))
(check-counts "1C005AF3" 5 2 0 0)
(check-counts "BE04EB2B" 2 2 0 0)
(check-counts "B662E42F" 0 0 0 0)
;; And add a third day.
(call-check `(,@GPG ,(faketime (days->seconds 4))
--verify ,(in-srcdir "tofu/conflicting/BE04EB2B-3.txt")))
--verify ,(in-srcdir "tests" "openpgp" "tofu" "conflicting" "BE04EB2B-3.txt")))
(check-counts "1C005AF3" 5 2 0 0)
(check-counts "BE04EB2B" 3 3 0 0)
(check-counts "B662E42F" 0 0 0 0)
(call-check `(,@GPG ,(faketime (days->seconds 4))
--verify ,(in-srcdir "tofu/conflicting/BE04EB2B-4.txt")))
--verify ,(in-srcdir "tests" "openpgp" "tofu" "conflicting" "BE04EB2B-4.txt")))
(check-counts "1C005AF3" 5 2 0 0)
(check-counts "BE04EB2B" 4 3 0 0)
(check-counts "B662E42F" 0 0 0 0)
@ -293,15 +293,15 @@
(lambda (key)
(for-each
(lambda (i)
(let ((fn (in-srcdir DIR (string-append key "-" i ".txt"))))
(let ((fn (in-srcdir "tests" "openpgp" DIR (string-append key "-" i ".txt"))))
(call-check `(,@GPG --verify ,fn))))
(list "1" "2")))
(list KEYIDA KEYIDB)))
;; Import the public keys.
(display " > Two keys. ")
(call-check `(,@GPG --import ,(in-srcdir DIR (string-append KEYIDA "-1.gpg"))))
(call-check `(,@GPG --import ,(in-srcdir DIR (string-append KEYIDB "-1.gpg"))))
(call-check `(,@GPG --import ,(in-srcdir "tests" "openpgp" DIR (string-append KEYIDA "-1.gpg"))))
(call-check `(,@GPG --import ,(in-srcdir "tests" "openpgp" DIR (string-append KEYIDB "-1.gpg"))))
;; Make sure the tofu engine registers the keys.
(verify-messages)
(display "<\n")
@ -312,8 +312,8 @@
;; Import the cross sigs.
(display " > Adding cross signatures. ")
(call-check `(,@GPG --import ,(in-srcdir DIR (string-append KEYIDA "-2.gpg"))))
(call-check `(,@GPG --import ,(in-srcdir DIR (string-append KEYIDB "-2.gpg"))))
(call-check `(,@GPG --import ,(in-srcdir "tests" "openpgp" DIR (string-append KEYIDA "-2.gpg"))))
(call-check `(,@GPG --import ,(in-srcdir "tests" "openpgp" DIR (string-append KEYIDB "-2.gpg"))))
(verify-messages)
(display "<\n")
@ -323,7 +323,7 @@
;; Import the conflicting user id.
(display " > Adding conflicting user id. ")
(call-check `(,@GPG --import ,(in-srcdir DIR (string-append KEYIDB "-3.gpg"))))
(call-check `(,@GPG --import ,(in-srcdir "tests" "openpgp" DIR (string-append KEYIDB "-3.gpg"))))
(verify-messages)
(display "<\n")
@ -333,7 +333,7 @@
;; Import Alice's signature on the conflicting user id. Since there
;; is now a cross signature, we should revert to the default policy.
(display " > Adding cross signature on user id. ")
(call-check `(,@GPG --import ,(in-srcdir DIR (string-append KEYIDB "-4.gpg"))))
(call-check `(,@GPG --import ,(in-srcdir "tests" "openpgp" DIR (string-append KEYIDB "-4.gpg"))))
(verify-messages)
(display "<\n")
@ -385,15 +385,15 @@
(lambda (key)
(for-each
(lambda (i)
(let ((fn (in-srcdir DIR (string-append key "-" i ".txt"))))
(let ((fn (in-srcdir "tests" "openpgp" DIR (string-append key "-" i ".txt"))))
(call-check `(,@GPG --verify ,fn))))
(list "1" "2")))
(list KEYIDA KEYIDB)))
;; Import the public keys.
(display " > Two keys. ")
(call-check `(,@GPG --import ,(in-srcdir DIR (string-append KEYIDA "-1.gpg"))))
(call-check `(,@GPG --import ,(in-srcdir DIR (string-append KEYIDB "-1.gpg"))))
(call-check `(,@GPG --import ,(in-srcdir "tests" "openpgp" DIR (string-append KEYIDA "-1.gpg"))))
(call-check `(,@GPG --import ,(in-srcdir "tests" "openpgp" DIR (string-append KEYIDB "-1.gpg"))))
(display "<\n")
(checkpolicy KEYA "auto")
@ -401,8 +401,8 @@
;; Import the cross sigs.
(display " > Adding cross signatures. ")
(call-check `(,@GPG --import ,(in-srcdir DIR (string-append KEYIDA "-2.gpg"))))
(call-check `(,@GPG --import ,(in-srcdir DIR (string-append KEYIDB "-2.gpg"))))
(call-check `(,@GPG --import ,(in-srcdir "tests" "openpgp" DIR (string-append KEYIDA "-2.gpg"))))
(call-check `(,@GPG --import ,(in-srcdir "tests" "openpgp" DIR (string-append KEYIDB "-2.gpg"))))
(display "<\n")
(checkpolicy KEYA "auto")
@ -423,7 +423,7 @@
;; Import the conflicting user id.
(display " > Adding conflicting user id. ")
(call-check `(,@GPG --import ,(in-srcdir DIR (string-append KEYIDB "-3.gpg"))))
(call-check `(,@GPG --import ,(in-srcdir "tests" "openpgp" DIR (string-append KEYIDB "-3.gpg"))))
(verify-messages)
(display "<\n")
@ -432,7 +432,7 @@
;; Import Alice's signature on the conflicting user id.
(display " > Adding cross signature on user id. ")
(call-check `(,@GPG --import ,(in-srcdir DIR (string-append KEYIDB "-4.gpg"))))
(call-check `(,@GPG --import ,(in-srcdir "tests" "openpgp" DIR (string-append KEYIDB "-4.gpg"))))
(verify-messages)
(display "<\n")

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
;; Import the sample key
@ -33,7 +33,7 @@
(info "Importing public key.")
(call-check
`(,(tool 'gpg) --import
,(in-srcdir "samplekeys/E657FB607BB4F21C90BB6651BC067AF28BC90111.asc")))
,(in-srcdir "tests" "openpgp" "samplekeys/E657FB607BB4F21C90BB6651BC067AF28BC90111.asc")))
;; By default, the most recent, valid signing subkey (1EA97479).
(for-each-p

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
(define files '("clearsig-1-key-1.asc" "signed-1-key-1.asc"))
@ -27,7 +27,7 @@
(let* ((status
(call-popen
`(,@gpg --verify --multifile --status-fd=1
,@(map (lambda (name) (in-srcdir "samplemsgs" name)) files))
,@(map (lambda (name) (in-srcdir "tests" "openpgp" "samplemsgs" name)) files))
""))
(lines (map (lambda (l)
(assert (string-prefix? l "[GNUPG:] "))

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-legacy-environment)
;;
@ -343,7 +343,7 @@ GisM
;;; Need to import the ed25519 sample key used for
;;; the next two tests.
(call-check `(,@GPG --quiet --yes --import ,(in-srcdir key-file2)))
(call-check `(,@GPG --quiet --yes --import ,(in-srcdir "tests" "openpgp" key-file2)))
(for-each-p
"Checking that a valid Ed25519 signature is verified as such"
(lambda (armored-file)

View File

@ -17,7 +17,7 @@
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
(load (in-srcdir "tests" "openpgp" "defs.scm"))
(setup-environment)
(info "Printing the GPG version")