From 1e822654c1dcfc23a9ef689f4e18c0ebba18baca Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Thu, 23 Jun 2016 17:14:07 +0200 Subject: [PATCH] tests/openpgp: Improve tests. * tests/openpgp/multisig.scm: Simplify test. * tests/openpgp/setup.scm (dearmor): Use pipe. Signed-off-by: Justus Winter --- tests/openpgp/multisig.scm | 20 ++++++++------------ tests/openpgp/setup.scm | 9 ++++++--- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/tests/openpgp/multisig.scm b/tests/openpgp/multisig.scm index 3788f672f..53c905fe1 100755 --- a/tests/openpgp/multisig.scm +++ b/tests/openpgp/multisig.scm @@ -156,17 +156,13 @@ cnksIEkgY2FuJ3QgZG8gdGhhdAo= (for-each-p "Checking that an invalid signature is verified as such" (lambda (armored-file) - (tr:do - (tr:pipe-do - (pipe:echo (eval armored-file (current-environment))) - (pipe:spawn `(,@GPG --dearmor))) - ;; XXX: this is ugly - (lambda args - (if (catch #f ;; verifikation failed, this is what we want - (apply (tr:spawn "" `(,@GPG --verify **in**)) args) - ;; verification succeded, this is an error. - #t) - (error "invalid signature is valid") - args)))) + (lettmp (file) + (pipe:do + (pipe:echo (eval armored-file (current-environment))) + (pipe:spawn `(,@GPG --dearmor)) + (pipe:write-to file (logior O_WRONLY O_CREAT O_BINARY) #o600)) + + (if (= 0 (call `(,@GPG --verify ,file))) + (error "Bad signature verified ok"))) '(sig-1ls1ls-valid sig-ls-valid sig-1lsls-invalid sig-lsls-invalid sig-lss-invalid sig-slsl-invalid)) diff --git a/tests/openpgp/setup.scm b/tests/openpgp/setup.scm index 6518dae41..ce2e42c44 100755 --- a/tests/openpgp/setup.scm +++ b/tests/openpgp/setup.scm @@ -56,9 +56,12 @@ '(500 9000 32000 80000)) (define (dearmor source-name sink-name) - (letfd ((source (open source-name (logior O_RDONLY O_BINARY))) - (sink (open sink-name (logior O_WRONLY O_CREAT O_BINARY) #o600))) - (call-with-fds `(,@GPG --dearmor) source sink STDERR_FILENO))) + (pipe:do + (pipe:open source-name (logior O_RDONLY O_BINARY)) + (pipe:spawn `(,@GPG --dearmor)) + (pipe:write-to sink-name + (logior O_WRONLY O_CREAT O_BINARY) + #o600))) (for-each-p "Unpacking samples" (lambda (name)