summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2024-05-17 13:21:47 (GMT)
committersebres <sebres@users.sourceforge.net>2024-05-17 13:21:47 (GMT)
commitbd7cebd73af9307fdbb4ca12588bc41192f97f26 (patch)
treec1e3cff6a6f011f6ce8eae1732a65d56cebbeb80
parentc61a5211fee9d7e1e8c6a94f2e7e50d9a5c1f22e (diff)
downloadtcl-bd7cebd73af9307fdbb4ca12588bc41192f97f26.zip
tcl-bd7cebd73af9307fdbb4ca12588bc41192f97f26.tar.gz
tcl-bd7cebd73af9307fdbb4ca12588bc41192f97f26.tar.bz2
split iocmd-32.3 in two tests (move cycle outside of the test)
-rw-r--r--tests/ioCmd.test97
1 files changed, 48 insertions, 49 deletions
diff --git a/tests/ioCmd.test b/tests/ioCmd.test
index a2061fa..74fabe7 100644
--- a/tests/ioCmd.test
+++ b/tests/ioCmd.test
@@ -2117,13 +2117,15 @@ test iocmd-32.2 {delete interp of reflected chan} {
interp delete child
} {}
-test iocmd-32.3 {prevent copy-state against segfault by finalize, bug [79474c58800cdf94]} -setup {
- proc test_chan {writeErr args} {
+# 1st attempt without error in write, another with error in write:
+foreach ::writeErr {0 1} {
+test iocmd-32.3.$::writeErr {prevent copy-state against segfault by finalize, bug [79474c58800cdf94]} -setup {
+ proc test_chan {args} {
set rest [lassign $args mode chan]
lappend ::ret $mode
switch -exact $mode {
read {puts $chan "Test" ; close $chan}
- write {if {$writeErr} {return}; set data [lindex $rest 0]; string length $data}
+ write {if {$::writeErr} {return "boom"}; set data [lindex $rest 0]; string length $data}
finalize {after 20 {set ::done done}}
initialize {return "initialize watch finalize read write"}
}
@@ -2132,59 +2134,56 @@ test iocmd-32.3 {prevent copy-state against segfault by finalize, bug [79474c588
set toev [after 5000 {set ::done tout}]
} -body {
set ::ret {}
- # 1st attempt without error in write, another with error in write:
- foreach i {0 1} {
- set ch [chan create "read write" [list test_chan $i]]
- lappend clchlst $ch
-
- lassign [chan pipe] in1 out1
- lappend clchlst $in1 $out1
- lassign [chan pipe] in2 out2
- lappend clchlst $in2 $out2
- lassign [chan pipe] in3 out3
- lappend clchlst $in3 $out3
-
- # simulate exec: echo test >@ $out2 2>@ $out3 <@ $in1 &:
- fileevent $out2 writable [list apply {{cho che} {
- puts $cho test; close $cho; close $che
- }} $out2 $out3]
- # recopy to given chans in handler
- fileevent $in2 readable [list apply {{in out} {
- if {[catch {
- chan copy $in $out
- } msg]} {
- #puts err:$msg
- fileevent $in readable {}
- }
- }} $in2 $ch]
- fileevent $in3 readable [list apply {{in out} {
- if {[catch {
- chan copy $in $out
- } msg]} {
- #puts err:$msg
- fileevent $in readable {}
- }
- }} $in3 $ch]
- fileevent $out1 writable [list apply {{in out} {
- if {[catch {
- chan copy $in $out
- } msg]} {
- #puts err:$msg
- fileevent $out writable {}
- }
- }} $ch $out1]
+ set ch [chan create "read write" test_chan]
+ lappend clchlst $ch
+
+ lassign [chan pipe] in1 out1
+ lappend clchlst $in1 $out1
+ lassign [chan pipe] in2 out2
+ lappend clchlst $in2 $out2
+ lassign [chan pipe] in3 out3
+ lappend clchlst $in3 $out3
+
+ # simulate exec: echo test >@ $out2 2>@ $out3 <@ $in1 &:
+ fileevent $out2 writable [list apply {{cho che} {
+ puts $cho test; close $cho; close $che
+ }} $out2 $out3]
+ # recopy to given chans in handler
+ fileevent $in2 readable [list apply {{in out} {
+ if {[catch {
+ chan copy $in $out
+ } msg]} {
+ #puts err:$msg
+ fileevent $in readable {}
+ }
+ }} $in2 $ch]
+ fileevent $in3 readable [list apply {{in out} {
+ if {[catch {
+ chan copy $in $out
+ } msg]} {
+ #puts err:$msg
+ fileevent $in readable {}
+ }
+ }} $in3 $ch]
+ fileevent $out1 writable [list apply {{in out} {
+ if {[catch {
+ chan copy $in $out
+ } msg]} {
+ #puts err:$msg
+ fileevent $out writable {}
+ }
+ }} $ch $out1]
- vwait ::done
- lappend ::ret $::done
- }
- set ::ret
+ vwait ::done
+ lappend ::ret $::done
} -cleanup {
foreach ch $clchlst {
catch {close $ch}
}
after cancel $toev
unset -nocomplain ::done ::ret ch in1 in2 in3 out1 out2 out3 toev clchlst
-} -result [lrepeat 2 initialize read write finalize done]
+} -result {initialize read write finalize done}
+}; unset ::writeErr
# ### ### ### ######### ######### #########
## Same tests as above, but exercising the code forwarding and