summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-11-06 16:24:02 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-11-06 16:24:02 (GMT)
commitb424e5a7b43887204c5dab2486e61aa3de1ba905 (patch)
treef8b76525d88e681667025f5f174e1baf8f3cd720 /tests
parentbce5edef8b197d622f6f22b25021afd987743698 (diff)
parent4cb80cd4e64044f5891b073788734efd753e5100 (diff)
downloadtcl-b424e5a7b43887204c5dab2486e61aa3de1ba905.zip
tcl-b424e5a7b43887204c5dab2486e61aa3de1ba905.tar.gz
tcl-b424e5a7b43887204c5dab2486e61aa3de1ba905.tar.bz2
[5adc350683] Stop Tcl forcing EOF condition on channels to be permanent.
It may be fleeting, and all parts of Tcl channel ecosystem have to deal with that. New assertions and tests to keep us on track.
Diffstat (limited to 'tests')
-rw-r--r--tests/io.test20
-rw-r--r--tests/iogt.test72
2 files changed, 92 insertions, 0 deletions
diff --git a/tests/io.test b/tests/io.test
index f6690ad..d533957 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -8399,6 +8399,26 @@ test io-73.2 {channel Tcl_Obj SetChannelFromAny, bug 2407783} {} {
list $code [string map [list $f @@] $msg]
} {1 {can not find channel named "@@"}}
+test io-73.3 {[5adc350683] [gets] after EOF} -setup {
+ set fn [makeFile {} io-73.3]
+ set rfd [open $fn r]
+ set wfd [open $fn a]
+ chan configure $wfd -buffering line
+ read $rfd
+} -body {
+ set result [eof $rfd]
+ puts $wfd "more data"
+ lappend result [eof $rfd]
+ lappend result [gets $rfd]
+ lappend result [eof $rfd]
+ lappend result [gets $rfd]
+ lappend result [eof $rfd]
+} -cleanup {
+ close $wfd
+ close $rfd
+ removeFile io-73.3
+} -result {1 1 {more data} 0 {} 1}
+
# ### ### ### ######### ######### #########
# cleanup
diff --git a/tests/iogt.test b/tests/iogt.test
index 5fe3dc2..89e62d4 100644
--- a/tests/iogt.test
+++ b/tests/iogt.test
@@ -996,6 +996,78 @@ test iogt-6.1 {Push back and up} {testchannel knownBug} {
set res
} {xxxghi}
+# Driver for a base channel that emits several short "files"
+# with each terminated by a fleeting EOF
+ proc driver {cmd args} {
+ variable buffer
+ variable index
+ set chan [lindex $args 0]
+ switch -- $cmd {
+ initialize {
+ set index($chan) 0
+ set buffer($chan) .....
+ return {initialize finalize watch read}
+ }
+ finalize {
+ if {![info exists index($chan)]} {return}
+ unset index($chan) buffer($chan)
+ return
+ }
+ watch {}
+ read {
+ set n [lindex $args 1]
+ if {![info exists index($chan)]} {
+ driver initialize $chan
+ }
+ set new [expr {$index($chan) + $n}]
+ set result [string range $buffer($chan) $index($chan) $new-1]
+ set index($chan) $new
+ if {[string length $result] == 0} {
+ driver finalize $chan
+ }
+ return $result
+ }
+ }
+ }
+
+test iogt-7.0 {Handle fleeting EOF} -constraints {testchannel} -body {
+ set chan [chan create read [namespace which driver]]
+ identity -attach $chan
+ list [eof $chan] [read $chan] [eof $chan] [read $chan 0] [eof $chan] \
+ [read $chan] [eof $chan]
+} -cleanup {
+ close $chan
+} -result {0 ..... 1 {} 0 ..... 1}
+
+proc delay {op data} {
+ variable store
+ switch -- $op {
+ create/write - create/read -
+ delete/write - delete/read -
+ flush/write - write -
+ clear_read {;#ignore}
+ flush/read -
+ read {
+ if {![info exists store]} {set store {}}
+ set reply $store
+ set store $data
+ return $reply
+ }
+ query/maxRead {return -1}
+ }
+}
+
+test iogt-7.1 {Handle fleeting EOF} -constraints {testchannel} -body {
+ set chan [chan create read [namespace which driver]]
+ testchannel transform $chan -command [namespace code delay]
+ list [eof $chan] [read $chan] [eof $chan] [read $chan 0] [eof $chan] \
+ [read $chan] [eof $chan]
+} -cleanup {
+ close $chan
+} -result {0 ..... 1 {} 0 ..... 1}
+
+rename delay {}
+rename driver {}
# cleanup
foreach file [list dummy dummyout __echo_srv__.tcl] {