diff options
author | NIIBE Yutaka <[email protected]> | 2023-06-08 05:39:50 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2023-06-08 05:39:50 +0000 |
commit | 1b0ce9918c321a5060fb7c59a234ab683187e8c1 (patch) | |
tree | ec7b4e3edeb030c6d5ff751cab445c7488b41a3c /tests/gpgscm/tests.scm | |
parent | kbx: Fix datastream_thread and use the data pipe. (diff) | |
download | gnupg-1b0ce9918c321a5060fb7c59a234ab683187e8c1.tar.gz gnupg-1b0ce9918c321a5060fb7c59a234ab683187e8c1.zip |
tests: Fix call-with-io deadlock.
* tests/gpgscm/ffi.c (es_wrap): Ifdef-out.
[HAVE_W32_SYSTEM] (read_from_pipe): New.
(do_process_spawn_io): Rename from do_process_spawn. Do I/O
with no deadlock.
* tests/gpgscm/tests.scm (call-with-io): Use process-spawn-io.
(es-read-all): Remove.
--
GnuPG-bug-id: 6523
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'tests/gpgscm/tests.scm')
-rw-r--r-- | tests/gpgscm/tests.scm | 35 |
1 files changed, 8 insertions, 27 deletions
diff --git a/tests/gpgscm/tests.scm b/tests/gpgscm/tests.scm index 6a11e55f1..1e6d7fea0 100644 --- a/tests/gpgscm/tests.scm +++ b/tests/gpgscm/tests.scm @@ -92,24 +92,16 @@ (define :stdin car) (define :stdout cadr) (define :stderr caddr) -(define :proc cadddr) (define (call-with-io what in) - (let ((h (process-spawn what 0))) - (es-write (:stdin h) in) - (es-fclose (:stdin h)) - (let* ((out (es-read-all (:stdout h))) - (err (es-read-all (:stderr h))) - (result (process-wait (:proc h) #t))) - (es-fclose (:stdout h)) - (es-fclose (:stderr h)) - (if (> (*verbose*) 2) - (info "Child" (:proc h) "returned:" - `((command ,(stringify what)) - (status ,result) - (stdout ,out) - (stderr ,err)))) - (list result out err)))) + (let ((proc-result (process-spawn-io what in))) + (if (> (*verbose*) 2) + (info "Child #proc returned:" + `((command ,(stringify what)) + (status ,(car proc-result)) + (stdout ,(cadr proc-result)) + (stderr ,(caddr proc-result))))) + proc-result)) ;; Accessor function for the results of 'call-with-io'. ':stdout' and ;; ':stderr' can also be used. @@ -129,17 +121,6 @@ (throw (:stderr result))))) ;; -;; estream helpers. -;; - -(define (es-read-all stream) - (let loop - ((acc "")) - (if (es-feof stream) - acc - (loop (string-append acc (es-read stream 4096)))))) - -;; ;; File management. ;; (define (file-exists? name) |