aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-11-03 13:37:15 +0000
committerJustus Winter <[email protected]>2016-11-03 13:43:23 +0000
commit1ec07cbc209f247fd85704f5701564e31aa56d0b (patch)
tree305188a94dc0351cb3bf7f08dceef4ef96790c93
parentgpgconf: Add a new field to the --query-swdb output. (diff)
downloadgnupg-1ec07cbc209f247fd85704f5701564e31aa56d0b.tar.gz
gnupg-1ec07cbc209f247fd85704f5701564e31aa56d0b.zip
gpgscm,tests: Add new functions to the test environment.
* tests/gpgscm/lib.scm (first, last, powerset): New functions. * tests/gpgscm/tests.scm (interactive-shell): New function. * tests/openpgp/Makefile.am (EXTRA_DIST): Add new file. * tests/openpgp/README: Document 'interactive-shell'. * tests/openpgp/shell.scm: New file. Signed-off-by: Justus Winter <[email protected]>
-rw-r--r--tests/gpgscm/lib.scm18
-rw-r--r--tests/gpgscm/tests.scm8
-rw-r--r--tests/openpgp/Makefile.am2
-rw-r--r--tests/openpgp/README5
-rw-r--r--tests/openpgp/shell.scm32
5 files changed, 63 insertions, 2 deletions
diff --git a/tests/gpgscm/lib.scm b/tests/gpgscm/lib.scm
index e4ab48303..316eacf87 100644
--- a/tests/gpgscm/lib.scm
+++ b/tests/gpgscm/lib.scm
@@ -42,6 +42,24 @@
((not (p (car l))) #f)
(else (all p (cdr l)))))
+;; Return the first element of a list.
+(define first car)
+
+;; Return the last element of a list.
+(define (last lst)
+ (if (null? (cdr lst))
+ (car lst)
+ (last (cdr lst))))
+
+;; Compute the powerset of a list.
+(define (powerset set)
+ (if (null? set)
+ '(())
+ (let ((rst (powerset (cdr set))))
+ (append (map (lambda (x) (cons (car set) x))
+ rst)
+ rst))))
+
;; Is PREFIX a prefix of S?
(define (string-prefix? s prefix)
(and (>= (string-length s) (string-length prefix))
diff --git a/tests/gpgscm/tests.scm b/tests/gpgscm/tests.scm
index 8986a705a..d89a96f88 100644
--- a/tests/gpgscm/tests.scm
+++ b/tests/gpgscm/tests.scm
@@ -481,3 +481,11 @@
(catch (list tmpfiles source *error*)
(apply function `(,(call-with-input-file source read-all) ,@args)))
(list tmpfiles source #f)))
+
+;;
+;; Developing and debugging tests.
+;;
+
+;; Spawn an os shell.
+(define (interactive-shell)
+ (call-with-fds `(,(getenv "SHELL")) 0 1 2))
diff --git a/tests/openpgp/Makefile.am b/tests/openpgp/Makefile.am
index bb9b2f4db..5725e110c 100644
--- a/tests/openpgp/Makefile.am
+++ b/tests/openpgp/Makefile.am
@@ -188,7 +188,7 @@ sample_msgs = samplemsgs/issue2419.asc
EXTRA_DIST = defs.scm $(XTESTS) $(TEST_FILES) \
mkdemodirs signdemokey $(priv_keys) $(sample_keys) \
$(sample_msgs) ChangeLog-2011 run-tests.scm \
- setup.scm finish.scm
+ setup.scm finish.scm shell.scm
CLEANFILES = prepared.stamp x y yy z out err $(data_files) \
plain-1 plain-2 plain-3 trustdb.gpg *.lock .\#lk* \
diff --git a/tests/openpgp/README b/tests/openpgp/README
index 8845afd34..75d818e9e 100644
--- a/tests/openpgp/README
+++ b/tests/openpgp/README
@@ -110,7 +110,10 @@ You can also get an interactive repl by dropping
(interactive-repl (current-environment))
-anywhere you like.
+anywhere you like. Or, if you want to examine the environment from an
+operating system shell, use
+
+ (interactive-shell)
** Interfacing with gpg
diff --git a/tests/openpgp/shell.scm b/tests/openpgp/shell.scm
new file mode 100644
index 000000000..dadafff05
--- /dev/null
+++ b/tests/openpgp/shell.scm
@@ -0,0 +1,32 @@
+#!/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/>.
+
+(load (with-path "defs.scm"))
+
+;; This is not a test, but can be used to inspect the test
+;; environment. Simply execute
+;;
+;; make -Ctests/openpgp check XTESTS=shell.scm
+;;
+;; to run it.
+
+(echo "Note that gpg.conf includes 'batch'. If you want to use gpg")
+(echo "interactively you should drop that.")
+(echo)
+(interactive-shell)