summaryrefslogtreecommitdiffstats
path: root/tests/io.test
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2015-09-23 16:58:34 (GMT)
committerdgp <dgp@users.sourceforge.net>2015-09-23 16:58:34 (GMT)
commitfe70ef2e7949c720d01eb97b30effc6294794cac (patch)
treee7797faca326702677562ea6a76ce219a161dac5 /tests/io.test
parent401ea793a5691a5dc91795371922de138ea7f68c (diff)
parente52bf0ecd422e64401d71475c5995f18c49c8561 (diff)
downloadtcl-fe70ef2e7949c720d01eb97b30effc6294794cac.zip
tcl-fe70ef2e7949c720d01eb97b30effc6294794cac.tar.gz
tcl-fe70ef2e7949c720d01eb97b30effc6294794cac.tar.bz2
[32ae34e63a] Prevent segfaults and data corruption when CopyData() is called recursively.
Mark new test io-53.20 as "knownBug". It demos some unknown flaw in MoveBytes().
Diffstat (limited to 'tests/io.test')
-rw-r--r--tests/io.test185
1 files changed, 185 insertions, 0 deletions
diff --git a/tests/io.test b/tests/io.test
index 6b6ad6d..783bc75 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -8003,6 +8003,191 @@ test io-53.17 {[7c187a3773] MBWrite: proper inQueueTail handling} -setup {
close $c
removeFile out
} -result {line 100 line}
+test io-53.18 {[32ae34e63a] recursive CopyData} -setup {
+ proc driver {cmd args} {
+ variable buffer
+ variable index
+ set chan [lindex $args 0]
+ switch -- $cmd {
+ initialize {
+ set index($chan) 0
+ set buffer($chan) [encoding convertto utf-8 \
+ [string repeat a 100]]
+ return {initialize finalize watch read}
+ }
+ finalize {
+ unset index($chan) buffer($chan)
+ return
+ }
+ watch {
+ if {"read" in [lindex $args 1]} {
+ chan postevent $chan read
+ }
+ return
+ }
+ read {
+ set n [lindex $args 1]
+ set new [expr {$index($chan) + $n}]
+ set result [string range $buffer($chan) $index($chan) $new-1]
+ set index($chan) $new
+ return $result
+ }
+ }
+ }
+ proc more {c outChan bytes args} {
+ if {[eof $c]} {
+ set ::done eof
+ catch {close $c}
+ return
+ }
+ if {[llength $args]} {
+ set ::done error
+ } else {
+ chan copy $c $outChan -command [list [namespace which more] $c $outChan]
+ }
+ }
+ set c [chan create read [namespace which driver]]
+ chan configure $c -encoding utf-8
+ set out [makeFile {} out]
+ set outChan [open $out w]
+ # Different encoding to force use of DoReadChars()
+ chan configure $outChan -encoding iso8859-1
+} -body {
+ after 100 {set ::done timeout}
+ chan copy $c $outChan -size 99 -command [list [namespace which more] $c $outChan]
+ vwait ::done
+ set ::done
+} -cleanup {
+ close $outChan
+ removeFile out
+ rename driver {}
+ rename more {}
+ unset ::done
+} -result eof
+
+test io-53.19 {[32ae34e63a] stop ReflectWatch filtering} -setup {
+ proc driver {cmd args} {
+ variable buffer
+ variable index
+ set chan [lindex $args 0]
+ switch -- $cmd {
+ initialize {
+ set index($chan) 0
+ set buffer($chan) [encoding convertto utf-8 \
+ [string repeat a 100]]
+ return {initialize finalize watch read}
+ }
+ finalize {
+ unset index($chan) buffer($chan)
+ return
+ }
+ watch {
+ if {"read" in [lindex $args 1]} {
+ chan postevent $chan read
+ }
+ return
+ }
+ read {
+ set n [lindex $args 1]
+ set new [expr {$index($chan) + $n}]
+ set result [string range $buffer($chan) $index($chan) $new-1]
+ set index($chan) $new
+ return $result
+ }
+ }
+ }
+ proc more {c outChan bytes args} {
+ if {[eof $c]} {
+ set ::done eof
+ catch {close $c}
+ return
+ }
+ if {[llength $args]} {
+ set ::done error
+ } else {
+ chan copy $c $outChan -size 30 -command [list [namespace which more] $c $outChan]
+ }
+ }
+ set c [chan create read [namespace which driver]]
+ chan configure $c -encoding utf-8 -buffersize 20
+ set out [makeFile {} out]
+ set outChan [open $out w]
+ # Different encoding to force use of DoReadChars()
+ chan configure $outChan -encoding iso8859-1
+} -body {
+ after 100 {set ::done timeout}
+ chan copy $c $outChan -size 30 -command [list [namespace which more] $c $outChan]
+ vwait ::done
+ set ::done
+} -cleanup {
+ catch {close $outChan}
+ removeFile out
+ rename driver {}
+ rename more {}
+ unset ::done
+} -result eof
+
+test io-53.20 {[e0a7b3e5f8] DoRead calls to UpdateInterest} -constraints knownBug -setup {
+ proc driver {cmd args} {
+ variable buffer
+ variable index
+ set chan [lindex $args 0]
+ switch -- $cmd {
+ initialize {
+ set index($chan) 0
+ set buffer($chan) [encoding convertto utf-8 \
+ [string repeat a 100]]
+ return {initialize finalize watch read}
+ }
+ finalize {
+ unset index($chan) buffer($chan)
+ return
+ }
+ watch {
+ if {"read" in [lindex $args 1]} {
+ chan postevent $chan read
+ }
+ return
+ }
+ read {
+ set n [lindex $args 1]
+ set new [expr {$index($chan) + $n}]
+ set result [string range $buffer($chan) $index($chan) $new-1]
+ set index($chan) $new
+ return $result
+ }
+ }
+ }
+ proc more {c outChan bytes args} {
+ if {[eof $c]} {
+ set ::done eof
+ catch {close $c}
+ return
+ }
+ if {[llength $args]} {
+ set ::done error
+ } else {
+ chan copy $c $outChan -size 10 -command [list [namespace which more] $c $outChan]
+ }
+ }
+ set c [chan create read [namespace which driver]]
+ chan configure $c -encoding utf-8 -buffersize 20
+ set out [makeFile {} out]
+ set outChan [open $out w]
+ # Same encoding to force use of DoRead()
+ chan configure $outChan -encoding utf-8
+} -body {
+ after 100 {set ::done timeout}
+ chan copy $c $outChan -size 10 -command [list [namespace which more] $c $outChan]
+ vwait ::done
+ set ::done
+} -cleanup {
+ catch {close $outChan}
+ removeFile out
+ rename driver {}
+ rename more {}
+ unset ::done
+} -result eof
test io-54.1 {Recursive channel events} {socket fileevent} {
# This test checks to see if file events are delivered during recursive