From 88e42ef08d65d4d1bc29c6cea48df19ca0d5e2bd Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Tue, 10 Jan 2017 15:50:57 +0100 Subject: [PATCH] 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 --- tests/openpgp/defs.scm | 11 ++++++++++- tests/openpgp/gpgconf.scm | 20 +++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm index 1895a7587..548476bdb 100644 --- a/tests/openpgp/defs.scm +++ b/tests/openpgp/defs.scm @@ -131,6 +131,15 @@ (string-append bin-prefix "/" (basename (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) (gpg-conf' "" args)) (define (gpg-conf' input args) @@ -149,7 +158,7 @@ (gpg-conf' (string-append key ":0:" (percent-encode value)) `(--change-options ,component))) (define (clear) - (gpg-conf' (string-append key ":1:") + (gpg-conf' (string-append key ":16:") `(--change-options ,component))))) diff --git a/tests/openpgp/gpgconf.scm b/tests/openpgp/gpgconf.scm index cdb6b760a..b4cc9cb13 100644 --- a/tests/openpgp/gpgconf.scm +++ b/tests/openpgp/gpgconf.scm @@ -27,15 +27,25 @@ "" (lambda (progress) (do ((i 0 (+ 1 i))) ((> i 12) #t) - (opt::update (make-value i)) - (assert (string=? (make-value i) (list-ref (opt::value) 9))) + (let ((value (make-value i))) + (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 "."))))) (lambda (name . rest) name) - (list "keyserver" "verbose") + (list "keyserver" "verbose" "quiet") (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")) (lambda (i) (number->string ;; gpgconf: argument for option verbose of type 0 ;; (none) must be positive - (+ 1 i))))) + (+ 1 i))) + (lambda (i) (if (even? i) #f "1"))))