mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-29 00:10:21 +02:00
tests: Add test for _IOLBF.
* test-suite/tests/ports.test ("pipe, fdopen, and _IOLBF"): New test.
This commit is contained in:
parent
5e793ad851
commit
c497bfb1f6
1 changed files with 24 additions and 0 deletions
|
@ -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.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue