9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
|
removeFile $scriptFile
} -body {
set fd [open |[list [info nameofexecutable] $scriptFile r+]]
fconfigure $fd -encoding utf-8 -profile replace
read $fd
} -result a\uFFFDb
test bug-73bb42fb-1 {
Non-blocking+buffer size+encoding error panic - TCL bug 73bb42fb.
Verify error at offset 0.
} -setup {
writeFile $path(test1) binary \xD6[string repeat _ 20]
} -body {
set fd [open $path(test1)]
fconfigure $fd -blocking 0 -buffersize 10 -translation lf -eofchar {}
list [catch {read $fd 1} e d] [dict get $d -code] [dict get $d -errorcode] [tell $fd]
} -cleanup {
close $fd
} -result {1 1 {POSIX EILSEQ {invalid or incomplete multibyte or wide character}} 0}
test bug-73bb42fb-2 {
Non-blocking+buffer size+encoding error panic - TCL bug 73bb42fb.
Verify single char valid read does not fail.
} -setup {
writeFile $path(test1) binary X\xD6[string repeat _ 20]
} -body {
set fd [open $path(test1)]
fconfigure $fd -blocking 0 -buffersize 10 -translation lf -eofchar {}
read $fd 1
} -cleanup {
close $fd
} -result X
test bug-73bb43fb-3 {
Non-blocking+buffer size+encoding error panic - TCL bug 73bb42fb.
Verify valid data returned before error generated.
} -setup {
writeFile $path(test1) binary X\xD6[string repeat _ 20]
} -body {
set fd [open $path(test1)]
fconfigure $fd -blocking 0 -buffersize 10 -translation lf -eofchar {}
set result {}
lappend result [read $fd]
lappend result [tell $fd]
lappend result [catch {read $fd} e d] [dict get $d -code] [dict get $d -errorcode] [tell $fd]
} -cleanup {
close $fd
} -result {X 1 1 1 {POSIX EILSEQ {invalid or incomplete multibyte or wide character}} 1}
test bug-73bb43fb-4 {
Non-blocking+buffer size+encoding error panic - TCL bug 73bb42fb.
Original Sergey's repro script from ticket. Only check no crash.
} -body {
set f [open [list | [info nameofexecutable] << {fconfigure stdout -translation binary; puts \xD6[string repeat _ 20]}]]
fconfigure $f -blocking 0 -buffersize 10 -translation lf -eofchar {}
catch {while {![string length [set d [read $f]]]} {after 10}} e d
close $f
list [dict get $d -code] [dict get $d -errorcode]
} -result {1 {POSIX EILSEQ {invalid or incomplete multibyte or wide character}}}
# cleanup
foreach file [list fooBar longfile script2 output test1 pipe my_script \
test2 test3 cat stdout kyrillic.txt utf8-fcopy.txt utf8-rp.txt] {
removeFile $file
}
cleanupTests
}
namespace delete ::tcl::test::io
return
|
|
|
|
|
>
>
>
>
>
>
|
>
>
|
>
|
>
>
>
|
|
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
|
removeFile $scriptFile
} -body {
set fd [open |[list [info nameofexecutable] $scriptFile r+]]
fconfigure $fd -encoding utf-8 -profile replace
read $fd
} -result a\uFFFDb
test io-bug-73bb42fb-1 {
Non-blocking+buffer size+encoding error panic - TCL bug 73bb42fb.
Verify error at offset 0.
} -setup {
writeFile $path(test1) binary \xD6[string repeat _ 20]
} -body {
set fd [open $path(test1)]
fconfigure $fd -blocking 0 -buffersize 10 -translation lf -eofchar {}
list [catch {read $fd 1} e d] [dict get $d -code] [dict get $d -errorcode] [tell $fd]
} -cleanup {
close $fd
} -result {1 1 {POSIX EILSEQ {invalid or incomplete multibyte or wide character}} 0}
test io-bug-73bb42fb-2 {
Non-blocking+buffer size+encoding error panic - TCL bug 73bb42fb.
Verify single char valid read does not fail.
} -setup {
writeFile $path(test1) binary X\xD6[string repeat _ 20]
} -body {
set fd [open $path(test1)]
fconfigure $fd -blocking 0 -buffersize 10 -translation lf -eofchar {}
read $fd 1
} -cleanup {
close $fd
} -result X
test io-bug-73bb43fb-3 {
Non-blocking+buffer size+encoding error panic - TCL bug 73bb42fb.
Verify valid data returned before error generated.
} -setup {
writeFile $path(test1) binary X\xD6[string repeat _ 20]
} -body {
set fd [open $path(test1)]
fconfigure $fd -blocking 0 -buffersize 10 -translation lf -eofchar {}
set result {}
lappend result [read $fd]
lappend result [tell $fd]
lappend result [catch {read $fd} e d] [dict get $d -code] [dict get $d -errorcode] [tell $fd]
} -cleanup {
close $fd
} -result {X 1 1 1 {POSIX EILSEQ {invalid or incomplete multibyte or wide character}} 1}
test io-bug-73bb43fb-4 {
Non-blocking+buffer size+encoding error panic - TCL bug 73bb42fb.
Original Sergey's repro script from ticket. Only check no crash.
} -setup {
set e ""
set timer [after 10000 {set d timeout}]
set f ""
} -body {
set f [open [list | [info nameofexecutable] << {fconfigure stdout -translation binary; puts \xD6[string repeat _ 20]}]]
fconfigure $f -blocking 0 -buffersize 10 -translation lf -eofchar {}
set x {}
catch {
while {$e eq "" && ![string length [set e [read $f]]]} {
after 10; update
}
set e
} e d
list $e [dict getd $d -code ""] [dict getd $d -errorcode ""]
} -cleanup {
if {$f ne ""} {close $f}
after cancel $timer
} -match glob -result {{error reading *} 1 {POSIX EILSEQ {invalid or incomplete multibyte or wide character}}}
# cleanup
foreach file [list fooBar longfile script2 output test1 pipe my_script \
test2 test3 cat stdout kyrillic.txt utf8-fcopy.txt utf8-rp.txt] {
removeFile $file
}
cleanupTests
}
namespace delete ::tcl::test::io
return
|