summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-05-21 15:34:22 +0200
committerLudovic Courtès <ludo@gnu.org>2014-05-21 15:34:22 +0200
commitc497bfb1f6e58c118aa35087104ab821dca5030c (patch)
tree9297ebfc58542e225dc53f9a2bb0bcd1d2e73a31
parent5e793ad8517d4036b115d2dbaaf105aad0414a20 (diff)
downloadguile-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.test24
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.