Imported Upstream version 2.1.18
[platform/upstream/gpg2.git] / tests / openpgp / gpgconf.scm
1 #!/usr/bin/env gpgscm
2
3 ;; Copyright (C) 2017 g10 Code GmbH
4 ;;
5 ;; This file is part of GnuPG.
6 ;;
7 ;; GnuPG is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3 of the License, or
10 ;; (at your option) any later version.
11 ;;
12 ;; GnuPG is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ;; GNU General Public License for more details.
16 ;;
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program; if not, see <http://www.gnu.org/licenses/>.
19
20 (load (with-path "defs.scm"))
21 (setup-environment)
22
23 (for-each-p'
24  "Checking reading and writing configuration via gpgconf... "
25  (lambda (name opt make-value)
26    (call-with-progress
27     ""
28     (lambda (progress)
29       (do ((i 0 (+ 1 i))) ((> i 12) #t)
30         (let ((value (make-value i)))
31           (if value
32               (begin
33                 (opt::update value)
34                 (assert (string=? value (list-ref (opt::value) 9))))
35               (begin
36                 (opt::clear)
37                 (let ((v (opt::value)))
38                   (assert (or (< (length v) 10)
39                               (string=? "" (list-ref v 9))))))))
40         (progress ".")))))
41  (lambda (name . rest) name)
42  (list "keyserver" "verbose" "quiet")
43  (list (gpg-config 'gpg "keyserver")
44        (gpg-config 'gpg "verbose")
45        (gpg-config 'gpg "quiet"))
46  (list (lambda (i) (if (even? i) "\"hkp://foo.bar" "\"hkps://bar.baz"))
47        (lambda (i) (number->string
48                     ;; gpgconf: argument for option verbose of type 0
49                     ;; (none) must be positive
50                     (+ 1 i)))
51        (lambda (i) (if (even? i) #f "1"))))