diff options
author | Ludovic Courtès <ludo@gnu.org> | 2014-05-21 15:34:22 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2014-05-21 15:34:22 +0200 |
commit | c497bfb1f6e58c118aa35087104ab821dca5030c (patch) | |
tree | 9297ebfc58542e225dc53f9a2bb0bcd1d2e73a31 | |
parent | 5e793ad8517d4036b115d2dbaaf105aad0414a20 (diff) | |
download | guile-c497bfb1f6e58c118aa35087104ab821dca5030c.tar.gz |
tests: Add test for _IOLBF.
* test-suite/tests/ports.test ("pipe, fdopen, and _IOLBF"): New test.
-rw-r--r-- | test-suite/tests/ports.test | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test index c1a185f17..d87257e04 100644 --- a/test-suite/tests/ports.test +++ b/test-suite/tests/ports.test @@ -623,6 +623,30 @@ (equal? in-string "Mommy, why does everybody have a bomb?\n"))) (delete-file filename)) +(pass-if-equal "pipe, fdopen, and _IOLBF" + "foo\nbar\n" + (let ((in+out (pipe)) + (pid (primitive-fork))) + (if (zero? pid) + (dynamic-wind + (const #t) + (lambda () + (close-port (car in+out)) + (let ((port (cdr in+out))) + (setvbuf port _IOLBF ) + ;; Strings containing '\n' or should be flushed; others + ;; should be kept in PORT's buffer. + (display "foo\n" port) + (display "bar\n" port) + (display "this will be kept in PORT's buffer" port))) + (lambda () + (primitive-_exit 0))) + (begin + (close-port (cdr in+out)) + (let ((str (read-all (car in+out)))) + (waitpid pid) + str))))) + ;;;; Void ports. These are so trivial we don't test them. |