📄 iocmd.test
字号:
close $cli; close $srv; unset cli srv port rename iocmdSRV {} }}test iocmd-8.15 {fconfigure command / tcp channel} {socket} { iocmdSSETUP set r [list [catch {fconfigure $cli -blah} msg] $msg]; iocmdSSHTDWN set r;} {1 {bad option "-blah": should be one of -blocking, -buffering, -buffersize, -eofchar, -translation, -peername, or -sockname}}test iocmd-8.16 {fconfigure command / tcp channel} {socket} { iocmdSSETUP set r [expr [lindex [fconfigure $cli -peername] 2]==$port]; iocmdSSHTDWN set r} 1test iocmd-8.17 {fconfigure command / tcp channel} {nonPortable} { # It is possible that you don't get the connection reset by peer # error but rather a valid answer. depends of the tcp implementation iocmdSSETUP update; puts $cli "blah"; flush $cli; # that flush could/should fail too update; set r [catch {fconfigure $cli -peername} msg] iocmdSSHTDWN regsub -all {can([^:])+: } $r {} r; set r} 1test iocmd-8.18 {fconfigure command / unix tty channel} {nonPortable unixOnly} { # might fail if /dev/ttya is unavailable set tty [open /dev/ttya] set r [list [catch {fconfigure $tty -blah blih} msg] $msg]; close $tty; set r;} {1 {bad option "-blah": should be one of -blocking, -buffering, -buffersize, -eofchar, -translation, or -mode}}test iocmd-8.19 {fconfigure command / win tty channel} {pcOnly && !win32s} { # None of the com port functions are implemented on Win32s. # Also, might fail if com1 is unavailable set tty [open com1] set r [list [catch {fconfigure $tty -blah blih} msg] $msg]; close $tty; set r;} {1 {bad option "-blah": should be one of -blocking, -buffering, -buffersize, -eofchar, -translation, or -mode}}test iocmd-9.1 {eof command} { list [catch {eof} msg] $msg $errorCode} {1 {wrong # args: should be "eof channelId"} NONE}test iocmd-9.2 {eof command} { list [catch {eof a b} msg] $msg $errorCode} {1 {wrong # args: should be "eof channelId"} NONE}test iocmd-9.3 {eof command} { catch {close file100} list [catch {eof file100} msg] $msg $errorCode} {1 {can not find channel named "file100"} NONE}test iocmd-10.1 {fblocked command} { list [catch {fblocked} msg] $msg} {1 {wrong # args: should be "fblocked channelId"}}test iocmd-10.2 {fblocked command} { list [catch {fblocked a b c d e f g} msg] $msg} {1 {wrong # args: should be "fblocked channelId"}}test iocmd-10.3 {fblocked command} { list [catch {fblocked file1000} msg] $msg} {1 {can not find channel named "file1000"}}test iocmd-10.4 {fblocked command} { list [catch {fblocked stdout} msg] $msg} {1 {channel "stdout" wasn't opened for reading}}test iocmd-10.5 {fblocked command} { fblocked stdin} 0removeFile test5test iocmd-11.1 {I/O to command pipelines} {unixOrPc unixExecs} { set f [open test4 w] close $f list [catch {open "| cat < test4 > test5" w} msg] $msg $errorCode} {1 {can't write input to command: standard input was redirected} NONE}test iocmd-11.2 {I/O to command pipelines} {unixOrPc unixExecs} { list [catch {open "| echo > test5" r} msg] $msg $errorCode} {1 {can't read output from command: standard output was redirected} NONE}test iocmd-11.3 {I/O to command pipelines} {unixOrPc unixExecs} { list [catch {open "| echo > test5" r+} msg] $msg $errorCode} {1 {can't read output from command: standard output was redirected} NONE}test iocmd-12.1 {POSIX open access modes: RDONLY} { removeFile test1 set f [open test1 w] puts $f "Two lines: this one" puts $f "and this one" close $f set f [open test1 RDONLY] set x [list [gets $f] [catch {puts $f Test} msg] $msg] close $f string compare $x \ "{Two lines: this one} 1 [list [format "channel \"%s\" wasn't opened for writing" $f]]"} 0test iocmd-12.2 {POSIX open access modes: RDONLY} { removeFile test3 string tolower [list [catch {open test3 RDONLY} msg] $msg]} {1 {couldn't open "test3": no such file or directory}}test iocmd-12.3 {POSIX open access modes: WRONLY} { removeFile test3 string tolower [list [catch {open test3 WRONLY} msg] $msg]} {1 {couldn't open "test3": no such file or directory}}## Test 13.4 relies on assigning the same channel name twice.#test iocmd-12.4 {POSIX open access modes: WRONLY} {unixOnly} { removeFile test3 set f [open test3 w] fconfigure $f -eofchar {} puts $f xyzzy close $f set f [open test3 WRONLY] fconfigure $f -eofchar {} puts -nonewline $f "ab" seek $f 0 current set x [list [catch {gets $f} msg] $msg] close $f set f [open test3 r] fconfigure $f -eofchar {} lappend x [gets $f] close $f set y [list 1 [format "channel \"%s\" wasn't opened for reading" $f] abzzy] string compare $x $y} 0test iocmd-12.5 {POSIX open access modes: RDWR} { removeFile test3 string tolower [list [catch {open test3 RDWR} msg] $msg]} {1 {couldn't open "test3": no such file or directory}}test iocmd-12.6 {POSIX open access modes: errors} { concat [catch {open test3 "FOO \{BAR BAZ"} msg] $msg\n$errorInfo} "1 unmatched open brace in listunmatched open brace in list while processing open access modes \"FOO {BAR BAZ\" invoked from within\"open test3 \"FOO \\{BAR BAZ\"\""test iocmd-12.7 {POSIX open access modes: errors} { list [catch {open test3 {FOO BAR BAZ}} msg] $msg} {1 {invalid access mode "FOO": must be RDONLY, WRONLY, RDWR, APPEND, CREAT EXCL, NOCTTY, NONBLOCK, or TRUNC}}test iocmd-12.8 {POSIX open access modes: errors} { list [catch {open test3 {TRUNC CREAT}} msg] $msg} {1 {access mode must include either RDONLY, WRONLY, or RDWR}}test iocmd-13.1 {errors in open command} { list [catch {open} msg] $msg} {1 {wrong # args: should be "open fileName ?access? ?permissions?"}}test iocmd-13.2 {errors in open command} { list [catch {open a b c d} msg] $msg} {1 {wrong # args: should be "open fileName ?access? ?permissions?"}}test iocmd-13.3 {errors in open command} { list [catch {open test1 x} msg] $msg} {1 {illegal access mode "x"}}test iocmd-13.4 {errors in open command} { list [catch {open test1 rw} msg] $msg} {1 {illegal access mode "rw"}}test iocmd-13.5 {errors in open command} { list [catch {open test1 r+1} msg] $msg} {1 {illegal access mode "r+1"}}test iocmd-13.6 {errors in open command} { string tolower [list [catch {open _non_existent_} msg] $msg $errorCode]} {1 {couldn't open "_non_existent_": no such file or directory} {posix enoent {no such file or directory}}}test iocmd-14.1 {file id parsing errors} { list [catch {eof gorp} msg] $msg $errorCode} {1 {can not find channel named "gorp"} NONE}test iocmd-14.2 {file id parsing errors} { list [catch {eof filex} msg] $msg} {1 {can not find channel named "filex"}}test iocmd-14.3 {file id parsing errors} { list [catch {eof file12a} msg] $msg} {1 {can not find channel named "file12a"}}test iocmd-14.4 {file id parsing errors} { list [catch {eof file123} msg] $msg} {1 {can not find channel named "file123"}}test iocmd-14.5 {file id parsing errors} { list [catch {eof stdout} msg] $msg} {0 0}test iocmd-14.6 {file id parsing errors} { list [catch {eof stdin} msg] $msg} {0 0}test iocmd-14.7 {file id parsing errors} { list [catch {eof stdout} msg] $msg} {0 0}test iocmd-14.8 {file id parsing errors} { list [catch {eof stderr} msg] $msg} {0 0}test iocmd-14.9 {file id parsing errors} { list [catch {eof stderr1} msg] $msg} {1 {can not find channel named "stderr1"}}set f [open test1 w]close $fset expect "1 {can not find channel named \"$f\"}"test iocmd-14.10 {file id parsing errors} { list [catch {eof $f} msg] $msg} $expecttest iocmd-15.1 {Tcl_FcopyObjCmd} { list [catch {fcopy} msg] $msg} {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}test iocmd-15.2 {Tcl_FcopyObjCmd} { list [catch {fcopy 1} msg] $msg} {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}test iocmd-15.3 {Tcl_FcopyObjCmd} { list [catch {fcopy 1 2 3 4 5 6 7} msg] $msg} {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}test iocmd-15.4 {Tcl_FcopyObjCmd} { list [catch {fcopy 1 2 3} msg] $msg} {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}test iocmd-15.5 {Tcl_FcopyObjCmd} { list [catch {fcopy 1 2 3 4 5} msg] $msg} {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}set f [open test1 w]close $fset rfile [open test1 r]set wfile [open test2 w]test iocmd-15.6 {Tcl_FcopyObjCmd} { list [catch {fcopy foo $wfile} msg] $msg} {1 {can not find channel named "foo"}}test iocmd-15.7 {Tcl_FcopyObjCmd} { list [catch {fcopy $rfile foo} msg] $msg} {1 {can not find channel named "foo"}}test iocmd-15.8 {Tcl_FcopyObjCmd} { list [catch {fcopy $wfile $wfile} msg] $msg} "1 {channel \"$wfile\" wasn't opened for reading}"test iocmd-15.9 {Tcl_FcopyObjCmd} { list [catch {fcopy $rfile $rfile} msg] $msg} "1 {channel \"$rfile\" wasn't opened for writing}"test iocmd-15.10 {Tcl_FcopyObjCmd} { list [catch {fcopy $rfile $wfile foo bar} msg] $msg} {1 {bad switch "foo": must be -size, or -command}}test iocmd-15.11 {Tcl_FcopyObjCmd} { list [catch {fcopy $rfile $wfile -size foo} msg] $msg} {1 {expected integer but got "foo"}}test iocmd-15.12 {Tcl_FcopyObjCmd} { list [catch {fcopy $rfile $wfile -command bar -size foo} msg] $msg} {1 {expected integer but got "foo"}}close $rfileclose $wfileremoveFile test1removeFile test2removeFile test3removeFile test4# delay long enough for background processes to finishafter 500removeFile test5removeFile piperemoveFile outputset x ""set x
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -