tests: Use the common test framework for the migration tests.
authorJustus Winter <justus@g10code.com>
Mon, 19 Dec 2016 16:28:43 +0000 (17:28 +0100)
committerJustus Winter <justus@g10code.com>
Mon, 19 Dec 2016 16:47:10 +0000 (17:47 +0100)
* tests/migrations/Makefile.am (reqired_pgms): Add 'gpgscm'.
(TESTS_ENVIRONMENT): Populate.
(TESTS): Rename to 'XTESTS'.
(xcheck): New target.
(EXTRA_DIST): Add new files.
(CLEANFILES): Remove log files.
* tests/migrations/common.scm: Honor 'verbose', fix paths.
* tests/migrations/run-tests.scm: New file.
* tests/migrations/setup.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
tests/migrations/Makefile.am
tests/migrations/common.scm
tests/migrations/run-tests.scm [new file with mode: 0644]
tests/migrations/setup.scm [new file with mode: 0644]

index 2773969..d0cd9ee 100644 (file)
@@ -20,7 +20,8 @@
 
 # Programs required before we can run these tests.
 required_pgms = ../../g10/gpg$(EXEEXT) ../../agent/gpg-agent$(EXEEXT) \
-       ../../tools/gpgtar$(EXEEXT)
+       ../../tools/gpgtar$(EXEEXT) \
+       ../gpgscm/gpgscm$(EXEEXT)
 
 AM_CPPFLAGS = -I$(top_srcdir)/common
 include $(top_srcdir)/am/cmacros.am
@@ -30,11 +31,14 @@ AM_CFLAGS =
 TMP ?= /tmp
 
 TESTS_ENVIRONMENT = GPG_AGENT_INFO= LC_ALL=C \
+       EXEEXT=$(EXEEXT) \
        PATH=../gpgscm:$(PATH) \
        TMP=$(TMP) \
-       GPGSCM_PATH=$(top_srcdir)/tests/gpgscm:$(top_srcdir)/tests/migrations
+       srcdir=$(abs_srcdir) \
+       objdir=$(abs_top_builddir) \
+       GPGSCM_PATH=$(abs_top_srcdir)/tests/gpgscm:$(abs_top_srcdir)/tests/migrations
 
-TESTS = from-classic.scm \
+XTESTS = from-classic.scm \
        extended-pkf.scm \
        issue2276.scm
 
@@ -42,17 +46,22 @@ TEST_FILES = from-classic.tar.asc \
             extended-pkf.tar.asc \
             issue2276.tar.asc
 
-EXTRA_DIST = common.scm $(TESTS) $(TEST_FILES)
+# XXX: Currently, one cannot override automake's 'check' target.  As a
+# workaround, we avoid defining 'TESTS', thus automake will not emit
+# the 'check' target.  For extra robustness, we merely define a
+# dependency on 'xcheck', so this hack should also work even if
+# automake would emit the 'check' target, as adding dependencies to
+# targets is okay.
+check: xcheck
 
-CLEANFILES = prepared.stamp x y yy z out err  $(data_files) \
-            plain-1 plain-2 plain-3 trustdb.gpg *.lock .\#lk* \
-            *.test.log gpg_dearmor gpg.conf gpg-agent.conf S.gpg-agent \
-            pubring.gpg pubring.gpg~ pubring.kbx pubring.kbx~ \
-            secring.gpg pubring.pkr secring.skr \
-            gnupg-test.stop random_seed gpg-agent.log tofu.db
+.PHONY: xcheck
+xcheck:
+       $(TESTS_ENVIRONMENT) $(abs_top_builddir)/tests/gpgscm/gpgscm \
+         run-tests.scm $(TESTFLAGS) $(XTESTS)
 
-clean-local:
-       -rm -rf from-classic.gpghome/*.gpg
+EXTRA_DIST = common.scm run-tests.scm setup.scm $(XTESTS) $(TEST_FILES)
+
+CLEANFILES = *.log
 
 # We need to depend on a couple of programs so that the tests don't
 # start before all programs are built.
index 944d4f6..30ac62b 100644 (file)
 (if (string=? "" (getenv "srcdir"))
     (error "not called from make"))
 
-(setenv "GNUPGHOME" "" #t)
+(let ((verbose (string->number (getenv "verbose"))))
+  (if (number? verbose)
+      (*set-verbose!* verbose)))
 
 (define (qualify executable)
   (string-append executable (getenv "EXEEXT")))
 
 ;; We may not use a relative name for gpg-agent.
-(define GPG-AGENT (qualify (string-append (getcwd) "/../../agent/gpg-agent")))
-(define GPG `(,(qualify (string-append (getcwd) "/../../g10/gpg"))
+(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
              --no-secmem-warning --batch
              ,(string-append "--agent-program=" GPG-AGENT
@@ -33,7 +35,7 @@
 (define GPG-no-batch
   (filter (lambda (arg) (not (equal? arg '--batch))) GPG))
 
-(define GPGTAR (qualify (string-append (getcwd) "/../../tools/gpgtar")))
+(define GPGTAR (path-join (getenv "objdir") "tools" (qualify "gpgtar")))
 
 (define (untar-armored source-name)
   (pipe:do
diff --git a/tests/migrations/run-tests.scm b/tests/migrations/run-tests.scm
new file mode 100644 (file)
index 0000000..069af5b
--- /dev/null
@@ -0,0 +1,26 @@
+;; Test-suite runner.
+;;
+;; 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/>.
+
+(let* ((tests (filter (lambda (arg) (not (string-prefix? arg "--"))) *args*))
+       (runner (if (and (member "--parallel" *args*)
+                       (> (length tests) 1))
+                  run-tests-parallel
+                  run-tests-sequential)))
+  (runner (test::scm "setup.scm" "setup.scm")
+         (map (lambda (t) (test::scm t t)) tests)))
diff --git a/tests/migrations/setup.scm b/tests/migrations/setup.scm
new file mode 100644 (file)
index 0000000..76a5840
--- /dev/null
@@ -0,0 +1,20 @@
+#!/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/>.
+
+;; Nothing to do for now.