tests: Improve gpgconf test.

* tests/openpgp/defs.scm (valgrind): New variable.
(gpg-config): Fix clearing an option.
* tests/openpgp/gpgconf.scm: Also toggle 'quiet'.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2017-01-10 15:50:57 +01:00
parent 1f5caf90bf
commit 88e42ef08d
2 changed files with 25 additions and 6 deletions

View File

@ -131,6 +131,15 @@
(string-append bin-prefix "/" (basename (caddr t))) (string-append bin-prefix "/" (basename (caddr t)))
(string-append (getenv "objdir") "/" (caddr t))))))) (string-append (getenv "objdir") "/" (caddr t)))))))
;; You can splice VALGRIND into your argument vector to run programs
;; under valgrind. For example, to run valgrind on gpg, you may want
;; to redefine gpg:
;;
;; (set! gpg `(,@valgrind ,@gpg))
;;
(define valgrind
'("/usr/bin/valgrind" --leak-check=full --error-exitcode=154))
(define (gpg-conf . args) (define (gpg-conf . args)
(gpg-conf' "" args)) (gpg-conf' "" args))
(define (gpg-conf' input args) (define (gpg-conf' input args)
@ -149,7 +158,7 @@
(gpg-conf' (string-append key ":0:" (percent-encode value)) (gpg-conf' (string-append key ":0:" (percent-encode value))
`(--change-options ,component))) `(--change-options ,component)))
(define (clear) (define (clear)
(gpg-conf' (string-append key ":1:") (gpg-conf' (string-append key ":16:")
`(--change-options ,component))))) `(--change-options ,component)))))

View File

@ -27,15 +27,25 @@
"" ""
(lambda (progress) (lambda (progress)
(do ((i 0 (+ 1 i))) ((> i 12) #t) (do ((i 0 (+ 1 i))) ((> i 12) #t)
(opt::update (make-value i)) (let ((value (make-value i)))
(assert (string=? (make-value i) (list-ref (opt::value) 9))) (if value
(begin
(opt::update value)
(assert (string=? value (list-ref (opt::value) 9))))
(begin
(opt::clear)
(let ((v (opt::value)))
(assert (or (< (length v) 10)
(string=? "" (list-ref v 9))))))))
(progress "."))))) (progress ".")))))
(lambda (name . rest) name) (lambda (name . rest) name)
(list "keyserver" "verbose") (list "keyserver" "verbose" "quiet")
(list (gpg-config 'gpg "keyserver") (list (gpg-config 'gpg "keyserver")
(gpg-config 'gpg "verbose")) (gpg-config 'gpg "verbose")
(gpg-config 'gpg "quiet"))
(list (lambda (i) (if (even? i) "\"hkp://foo.bar" "\"hkps://bar.baz")) (list (lambda (i) (if (even? i) "\"hkp://foo.bar" "\"hkps://bar.baz"))
(lambda (i) (number->string (lambda (i) (number->string
;; gpgconf: argument for option verbose of type 0 ;; gpgconf: argument for option verbose of type 0
;; (none) must be positive ;; (none) must be positive
(+ 1 i))))) (+ 1 i)))
(lambda (i) (if (even? i) #f "1"))))