os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/ioCmd.test
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 # -*- tcl -*-
     2 # Commands covered: open, close, gets, read, puts, seek, tell, eof, flush,
     3 #		    fblocked, fconfigure, open, channel, fcopy
     4 #
     5 # This file contains a collection of tests for one or more of the Tcl
     6 # built-in commands.  Sourcing this file into Tcl runs the tests and
     7 # generates output for errors.  No output means no errors were found.
     8 #
     9 # Copyright (c) 1991-1994 The Regents of the University of California.
    10 # Copyright (c) 1994-1996 Sun Microsystems, Inc.
    11 # Copyright (c) 1998-1999 by Scriptics Corporation.
    12 #
    13 # See the file "license.terms" for information on usage and redistribution
    14 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    15 #
    16 # RCS: @(#) $Id: ioCmd.test,v 1.16.2.3 2006/03/16 18:23:24 andreas_kupries Exp $
    17 
    18 if {[lsearch [namespace children] ::tcltest] == -1} {
    19     package require tcltest
    20     namespace import -force ::tcltest::*
    21 }
    22 
    23 testConstraint fcopy [llength [info commands fcopy]]
    24 
    25 test iocmd-1.1 {puts command} {
    26    list [catch {puts} msg] $msg
    27 } {1 {wrong # args: should be "puts ?-nonewline? ?channelId? string"}}
    28 test iocmd-1.2 {puts command} {
    29    list [catch {puts a b c d e f g} msg] $msg
    30 } {1 {wrong # args: should be "puts ?-nonewline? ?channelId? string"}}
    31 test iocmd-1.3 {puts command} {
    32    list [catch {puts froboz -nonewline kablooie} msg] $msg
    33 } {1 {bad argument "kablooie": should be "nonewline"}}
    34 test iocmd-1.4 {puts command} {
    35    list [catch {puts froboz hello} msg] $msg
    36 } {1 {can not find channel named "froboz"}}
    37 test iocmd-1.5 {puts command} {
    38    list [catch {puts stdin hello} msg] $msg
    39 } {1 {channel "stdin" wasn't opened for writing}}
    40 
    41 set path(test1) [makeFile {} test1]
    42 
    43 test iocmd-1.6 {puts command} {
    44     set f [open $path(test1) w]
    45     fconfigure $f -translation lf -eofchar {}
    46     puts -nonewline $f foobar
    47     close $f
    48     file size $path(test1)
    49 } 6
    50 test iocmd-1.7 {puts command} {
    51     set f [open $path(test1) w]
    52     fconfigure $f -translation lf -eofchar {}
    53     puts $f foobar
    54     close $f
    55     file size $path(test1)
    56 } 7
    57 test iocmd-1.8 {puts command} {
    58     set f [open $path(test1) w]
    59     fconfigure $f -translation lf -eofchar {} -encoding iso8859-1
    60     puts -nonewline $f [binary format a4a5 foo bar]
    61     close $f
    62     file size $path(test1)
    63 } 9
    64 
    65 
    66 test iocmd-2.1 {flush command} {
    67    list [catch {flush} msg] $msg
    68 } {1 {wrong # args: should be "flush channelId"}}
    69 test iocmd-2.2 {flush command} {
    70    list [catch {flush a b c d e} msg] $msg
    71 } {1 {wrong # args: should be "flush channelId"}}
    72 test iocmd-2.3 {flush command} {
    73    list [catch {flush foo} msg] $msg
    74 } {1 {can not find channel named "foo"}}
    75 test iocmd-2.4 {flush command} {
    76    list [catch {flush stdin} msg] $msg
    77 } {1 {channel "stdin" wasn't opened for writing}}
    78 
    79 test iocmd-3.1 {gets command} {
    80    list [catch {gets} msg] $msg
    81 } {1 {wrong # args: should be "gets channelId ?varName?"}}
    82 test iocmd-3.2 {gets command} {
    83    list [catch {gets a b c d e f g} msg] $msg
    84 } {1 {wrong # args: should be "gets channelId ?varName?"}}
    85 test iocmd-3.3 {gets command} {
    86    list [catch {gets aaa} msg] $msg
    87 } {1 {can not find channel named "aaa"}}
    88 test iocmd-3.4 {gets command} {
    89    list [catch {gets stdout} msg] $msg
    90 } {1 {channel "stdout" wasn't opened for reading}}
    91 test iocmd-3.5 {gets command} {
    92     set f [open $path(test1) w]
    93     puts $f [binary format a4a5 foo bar]
    94     close $f
    95     set f [open $path(test1) r]
    96     set result [gets $f]
    97     close $f
    98     set x foo\x00
    99     set x "${x}bar\x00\x00"
   100     string compare $x $result
   101 } 0
   102 
   103 test iocmd-4.1 {read command} {
   104    list [catch {read} msg] $msg
   105 } {1 {wrong # args: should be "read channelId ?numChars?" or "read ?-nonewline? channelId"}}
   106 test iocmd-4.2 {read command} {
   107    list [catch {read a b c d e f g h} msg] $msg
   108 } {1 {wrong # args: should be "read channelId ?numChars?" or "read ?-nonewline? channelId"}}
   109 test iocmd-4.3 {read command} {
   110    list [catch {read aaa} msg] $msg
   111 } {1 {can not find channel named "aaa"}}
   112 test iocmd-4.4 {read command} {
   113    list [catch {read -nonewline} msg] $msg
   114 } {1 {wrong # args: should be "read channelId ?numChars?" or "read ?-nonewline? channelId"}}
   115 test iocmd-4.5 {read command} {
   116    list [catch {read -nonew file4} msg] $msg $errorCode
   117 } {1 {can not find channel named "-nonew"} NONE}
   118 test iocmd-4.6 {read command} {
   119    list [catch {read stdout} msg] $msg
   120 } {1 {channel "stdout" wasn't opened for reading}}
   121 test iocmd-4.7 {read command} {
   122    list [catch {read -nonewline stdout} msg] $msg
   123 } {1 {channel "stdout" wasn't opened for reading}}
   124 test iocmd-4.8 {read command with incorrect combination of arguments} {
   125     file delete $path(test1)
   126     set f [open $path(test1) w]
   127     puts $f "Two lines: this one"
   128     puts $f "and this one"
   129     close $f
   130     set f [open $path(test1)]
   131     set x [list [catch {read -nonewline $f 20 z} msg] $msg $errorCode]
   132     close $f
   133     set x
   134 } {1 {wrong # args: should be "read channelId ?numChars?" or "read ?-nonewline? channelId"} NONE}
   135 test iocmd-4.9 {read command} {
   136     list [catch {read stdin foo} msg] $msg $errorCode
   137 } {1 {bad argument "foo": should be "nonewline"} NONE}
   138 test iocmd-4.10 {read command} {
   139     list [catch {read file107} msg] $msg $errorCode
   140 } {1 {can not find channel named "file107"} NONE}
   141 
   142 set path(test3) [makeFile {} test3]
   143 
   144 test iocmd-4.11 {read command} {
   145     set f [open $path(test3) w]
   146     set x [list [catch {read $f} msg] $msg $errorCode]
   147     close $f
   148     string compare [string tolower $x] \
   149 	[list 1 [format "channel \"%s\" wasn't opened for reading" $f] none]
   150 } 0
   151 test iocmd-4.12 {read command} {
   152     set f [open $path(test1)]
   153     set x [list [catch {read $f 12z} msg] $msg $errorCode]
   154     close $f
   155     set x
   156 } {1 {expected integer but got "12z"} NONE}
   157 
   158 test iocmd-5.1 {seek command} {
   159     list [catch {seek} msg] $msg
   160 } {1 {wrong # args: should be "seek channelId offset ?origin?"}}
   161 test iocmd-5.2 {seek command} {
   162     list [catch {seek a b c d e f g} msg] $msg
   163 } {1 {wrong # args: should be "seek channelId offset ?origin?"}}
   164 test iocmd-5.3 {seek command} {
   165     list [catch {seek stdin gugu} msg] $msg
   166 } {1 {expected integer but got "gugu"}}
   167 test iocmd-5.4 {seek command} {
   168     list [catch {seek stdin 100 gugu} msg] $msg
   169 } {1 {bad origin "gugu": must be start, current, or end}}
   170 
   171 test iocmd-6.1 {tell command} {
   172     list [catch {tell} msg] $msg
   173 } {1 {wrong # args: should be "tell channelId"}}
   174 test iocmd-6.2 {tell command} {
   175     list [catch {tell a b c d e} msg] $msg
   176 } {1 {wrong # args: should be "tell channelId"}}
   177 test iocmd-6.3 {tell command} {
   178     list [catch {tell aaa} msg] $msg
   179 } {1 {can not find channel named "aaa"}}
   180 
   181 test iocmd-7.1 {close command} {
   182     list [catch {close} msg] $msg
   183 } {1 {wrong # args: should be "close channelId"}}
   184 test iocmd-7.2 {close command} {
   185     list [catch {close a b c d e} msg] $msg
   186 } {1 {wrong # args: should be "close channelId"}}
   187 test iocmd-7.3 {close command} {
   188     list [catch {close aaa} msg] $msg
   189 } {1 {can not find channel named "aaa"}}
   190 
   191 test iocmd-8.1 {fconfigure command} {
   192     list [catch {fconfigure} msg] $msg
   193 } {1 {wrong # args: should be "fconfigure channelId ?optionName? ?value? ?optionName value?..."}}
   194 test iocmd-8.2 {fconfigure command} {
   195     list [catch {fconfigure a b c d e f} msg] $msg
   196 } {1 {wrong # args: should be "fconfigure channelId ?optionName? ?value? ?optionName value?..."}}
   197 test iocmd-8.3 {fconfigure command} {
   198     list [catch {fconfigure a b} msg] $msg
   199 } {1 {can not find channel named "a"}}
   200 test iocmd-8.4 {fconfigure command} {
   201     file delete $path(test1)
   202     set f1 [open $path(test1) w]
   203     set x [list [catch {fconfigure $f1 froboz} msg] $msg]
   204     close $f1
   205     set x
   206 } {1 {bad option "froboz": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, or -translation}}
   207 test iocmd-8.5 {fconfigure command} {
   208     list [catch {fconfigure stdin -buffering froboz} msg] $msg
   209 } {1 {bad value for -buffering: must be one of full, line, or none}}
   210 test iocmd-8.6 {fconfigure command} {
   211     list [catch {fconfigure stdin -translation froboz} msg] $msg
   212 } {1 {bad value for -translation: must be one of auto, binary, cr, lf, crlf, or platform}}
   213 test iocmd-8.7 {fconfigure command} {
   214     file delete $path(test1)
   215     set f1 [open $path(test1) w]
   216     fconfigure $f1 -translation lf -eofchar {} -encoding unicode
   217     set x [fconfigure $f1]
   218     close $f1
   219     set x
   220 } {-blocking 1 -buffering full -buffersize 4096 -encoding unicode -eofchar {} -translation lf}
   221 test iocmd-8.8 {fconfigure command} {
   222     file delete $path(test1)
   223     set f1 [open $path(test1) w]
   224     fconfigure $f1 -translation lf -buffering line -buffersize 3030 \
   225 		-eofchar {} -encoding unicode
   226     set x ""
   227     lappend x [fconfigure $f1 -buffering]
   228     lappend x [fconfigure $f1]
   229     close $f1
   230     set x
   231 } {line {-blocking 1 -buffering line -buffersize 3030 -encoding unicode -eofchar {} -translation lf}}
   232 test iocmd-8.9 {fconfigure command} {
   233     file delete $path(test1)
   234     set f1 [open $path(test1) w]
   235     fconfigure $f1 -translation binary -buffering none -buffersize 4040 \
   236 		-eofchar {} -encoding binary
   237     set x [fconfigure $f1]
   238     close $f1
   239     set x
   240 } {-blocking 1 -buffering none -buffersize 4040 -encoding binary -eofchar {} -translation lf}
   241 test iocmd-8.10 {fconfigure command} {
   242     list [catch {fconfigure a b} msg] $msg
   243 } {1 {can not find channel named "a"}}
   244 
   245 set path(fconfigure.dummy) [makeFile {} fconfigure.dummy]
   246 
   247 test iocmd-8.11 {fconfigure command} {
   248     set chan [open $path(fconfigure.dummy) r]
   249     set res [list [catch {fconfigure $chan -froboz blarfo} msg] $msg]
   250     close $chan
   251     set res
   252 } {1 {bad option "-froboz": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, or -translation}}
   253 
   254 test iocmd-8.12 {fconfigure command} {
   255     set chan [open $path(fconfigure.dummy) r]
   256     set res [list [catch {fconfigure $chan -b blarfo} msg] $msg]
   257     close $chan
   258     set res
   259 } {1 {bad option "-b": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, or -translation}}
   260 
   261 test iocmd-8.13 {fconfigure command} {
   262     set chan [open $path(fconfigure.dummy) r]
   263     set res [list [catch {fconfigure $chan -buffer blarfo} msg] $msg]
   264     close $chan
   265     set res
   266 } {1 {bad option "-buffer": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, or -translation}}
   267 
   268 removeFile fconfigure.dummy
   269 
   270 test iocmd-8.14 {fconfigure command} {
   271     fconfigure stdin -buffers
   272 } 4096
   273 
   274 proc iocmdSSETUP {} {
   275     uplevel {
   276 	set srv [socket -server iocmdSRV 0]
   277 	set port [lindex [fconfigure $srv -sockname] 2]
   278 	proc iocmdSRV {sock ip port} {close $sock}
   279 	set cli [socket 127.0.0.1 $port]
   280     }
   281 }
   282 proc iocmdSSHTDWN {} {
   283     uplevel {
   284 	close $cli
   285 	close $srv
   286 	unset cli srv port
   287 	rename iocmdSRV {}
   288     }
   289 }
   290 
   291 test iocmd-8.15.0 {fconfigure command / tcp channel} {socket macOnly} {
   292 	iocmdSSETUP
   293 	set r [list [catch {fconfigure $cli -blah} msg] $msg]
   294 	iocmdSSHTDWN
   295 	set r
   296 } {1 {bad option "-blah": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -translation, -error, -peername, or -sockname}}
   297 test iocmd-8.15.1 {fconfigure command / tcp channel} {socket unixOrPc} {
   298 	iocmdSSETUP
   299 	set r [list [catch {fconfigure $cli -blah} msg] $msg]
   300 	iocmdSSHTDWN
   301 	set r
   302 } {1 {bad option "-blah": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -translation, -peername, or -sockname}}
   303 test iocmd-8.16 {fconfigure command / tcp channel} {socket} {
   304 	iocmdSSETUP
   305 	set r [expr [lindex [fconfigure $cli -peername] 2]==$port]
   306 	iocmdSSHTDWN
   307 	set r
   308 } 1
   309 test iocmd-8.17 {fconfigure command / tcp channel} {nonPortable} {
   310 	# It is possible that you don't get the connection reset by peer
   311         # error but rather a valid answer. depends of the tcp implementation
   312 	iocmdSSETUP
   313 	update;
   314 	puts $cli "blah"; flush $cli; # that flush could/should fail too
   315 	update;
   316 	set r [catch {fconfigure $cli -peername} msg]
   317 	iocmdSSHTDWN
   318 	regsub -all {can([^:])+: } $r {} r;
   319 	set r
   320 } 1
   321 test iocmd-8.18 {fconfigure command / unix tty channel} {nonPortable unixOnly} {
   322 	# might fail if /dev/ttya is unavailable
   323 	set tty [open /dev/ttya]
   324 	set r [list [catch {fconfigure $tty -blah blih} msg] $msg];
   325 	close $tty;
   326 	set r;
   327 } {1 {bad option "-blah": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -translation, or -mode}}
   328 test iocmd-8.19 {fconfigure command / win tty channel} {nonPortable pcOnly} {
   329 	# might fail if com1 is unavailable
   330 	set tty [open com1]
   331 	set r [list [catch {fconfigure $tty -blah blih} msg] $msg];
   332 	close $tty;
   333 	set r;
   334 } {1 {bad option "-blah": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -translation, -mode, or -pollinterval}}
   335 
   336 test iocmd-9.1 {eof command} {
   337     list [catch {eof} msg] $msg $errorCode
   338 } {1 {wrong # args: should be "eof channelId"} NONE}
   339 test iocmd-9.2 {eof command} {
   340     list [catch {eof a b} msg] $msg $errorCode
   341 } {1 {wrong # args: should be "eof channelId"} NONE}
   342 test iocmd-9.3 {eof command} {
   343     catch {close file100}
   344     list [catch {eof file100} msg] $msg $errorCode
   345 } {1 {can not find channel named "file100"} NONE}
   346 
   347 # The tests for Tcl_ExecObjCmd are in exec.test
   348 
   349 test iocmd-10.1 {fblocked command} {
   350     list [catch {fblocked} msg] $msg
   351 } {1 {wrong # args: should be "fblocked channelId"}}
   352 test iocmd-10.2 {fblocked command} {
   353     list [catch {fblocked a b c d e f g} msg] $msg
   354 } {1 {wrong # args: should be "fblocked channelId"}}
   355 test iocmd-10.3 {fblocked command} {
   356     list [catch {fblocked file1000} msg] $msg
   357 } {1 {can not find channel named "file1000"}}
   358 test iocmd-10.4 {fblocked command} {
   359     list [catch {fblocked stdout} msg] $msg
   360 } {1 {channel "stdout" wasn't opened for reading}}
   361 test iocmd-10.5 {fblocked command} {
   362     fblocked stdin
   363 } 0
   364 
   365 set path(test4) [makeFile {} test4]
   366 set path(test5) [makeFile {} test5]
   367 
   368 file delete $path(test5)
   369 test iocmd-11.1 {I/O to command pipelines} {unixOrPc unixExecs} {
   370     set f [open $path(test4) w]
   371     close $f
   372     list [catch {open "| cat < $path(test4) > $path(test5)" w} msg] $msg $errorCode
   373 } {1 {can't write input to command: standard input was redirected} NONE}
   374 test iocmd-11.2 {I/O to command pipelines} {unixOrPc unixExecs} {
   375     list [catch {open "| echo > $path(test5)" r} msg] $msg $errorCode
   376 } {1 {can't read output from command: standard output was redirected} NONE}
   377 test iocmd-11.3 {I/O to command pipelines} {unixOrPc unixExecs} {
   378     list [catch {open "| echo > $path(test5)" r+} msg] $msg $errorCode
   379 } {1 {can't read output from command: standard output was redirected} NONE}
   380 
   381 test iocmd-12.1 {POSIX open access modes: RDONLY} {
   382     file delete $path(test1)
   383     set f [open $path(test1) w]
   384     puts $f "Two lines: this one"
   385     puts $f "and this one"
   386     close $f
   387     set f [open $path(test1) RDONLY]
   388     set x [list [gets $f] [catch {puts $f Test} msg] $msg]
   389     close $f
   390     string compare $x \
   391 	"{Two lines: this one} 1 [list [format "channel \"%s\" wasn't opened for writing" $f]]"
   392 } 0
   393 test iocmd-12.2 {POSIX open access modes: RDONLY} -match regexp -body {
   394     file delete $path(test3)
   395     open $path(test3) RDONLY
   396 } -returnCodes error -result {(?i)couldn't open ".*test3": no such file or directory}
   397 test iocmd-12.3 {POSIX open access modes: WRONLY} -match regexp -body {
   398     file delete $path(test3)
   399     open $path(test3) WRONLY
   400 } -returnCodes error -result {(?i)couldn't open ".*test3": no such file or directory}
   401 #
   402 # Test 13.4 relies on assigning the same channel name twice.
   403 #
   404 test iocmd-12.4 {POSIX open access modes: WRONLY} {unixOnly} {
   405     file delete $path(test3)
   406     set f [open $path(test3) w]
   407     fconfigure $f -eofchar {}
   408     puts $f xyzzy
   409     close $f
   410     set f [open $path(test3) WRONLY]
   411     fconfigure $f -eofchar {}
   412     puts -nonewline $f "ab"
   413     seek $f 0 current
   414     set x [list [catch {gets $f} msg] $msg]
   415     close $f
   416     set f [open $path(test3) r]
   417     fconfigure $f -eofchar {}
   418     lappend x [gets $f]
   419     close $f
   420     set y [list 1 [format "channel \"%s\" wasn't opened for reading" $f] abzzy]
   421     string compare $x $y
   422 } 0
   423 test iocmd-12.5 {POSIX open access modes: RDWR} -match regexp -body {
   424     file delete $path(test3)
   425     open $path(test3) RDWR
   426 } -returnCodes error -result {(?i)couldn't open ".*test3": no such file or directory}
   427 test iocmd-12.6 {POSIX open access modes: errors} {
   428     concat [catch {open $path(test3) "FOO \{BAR BAZ"} msg] $msg\n$errorInfo
   429 } "1 unmatched open brace in list
   430 unmatched open brace in list
   431     while processing open access modes \"FOO {BAR BAZ\"
   432     invoked from within
   433 \"open \$path(test3) \"FOO \\{BAR BAZ\"\""
   434 test iocmd-12.7 {POSIX open access modes: errors} {
   435   list [catch {open $path(test3) {FOO BAR BAZ}} msg] $msg
   436 } {1 {invalid access mode "FOO": must be RDONLY, WRONLY, RDWR, APPEND, CREAT EXCL, NOCTTY, NONBLOCK, or TRUNC}}
   437 test iocmd-12.8 {POSIX open access modes: errors} {
   438     list [catch {open $path(test3) {TRUNC CREAT}} msg] $msg
   439 } {1 {access mode must include either RDONLY, WRONLY, or RDWR}}
   440 close [open $path(test3) w]
   441 
   442 test iocmd-13.1 {errors in open command} {
   443     list [catch {open} msg] $msg
   444 } {1 {wrong # args: should be "open fileName ?access? ?permissions?"}}
   445 test iocmd-13.2 {errors in open command} {
   446     list [catch {open a b c d} msg] $msg
   447 } {1 {wrong # args: should be "open fileName ?access? ?permissions?"}}
   448 test iocmd-13.3 {errors in open command} {
   449     list [catch {open $path(test1) x} msg] $msg
   450 } {1 {illegal access mode "x"}}
   451 test iocmd-13.4 {errors in open command} {
   452     list [catch {open $path(test1) rw} msg] $msg
   453 } {1 {illegal access mode "rw"}}
   454 test iocmd-13.5 {errors in open command} {
   455     list [catch {open $path(test1) r+1} msg] $msg
   456 } {1 {illegal access mode "r+1"}}
   457 test iocmd-13.6 {errors in open command} {
   458     set msg [list [catch {open _non_existent_} msg] $msg $errorCode]
   459     regsub [file join {} _non_existent_] $msg "_non_existent_" msg
   460 	string tolower $msg
   461 } {1 {couldn't open "_non_existent_": no such file or directory} {posix enoent {no such file or directory}}}
   462 
   463 
   464 test iocmd-13.7.1 {open for append, a mode} -setup {
   465     set log   [makeFile {} out]
   466     set chans {}
   467 } -body {
   468     foreach i { 0 1 2 3 4 5 6 7 8 9 } {
   469 	puts [set ch [open $log a]] $i
   470 	lappend chans $ch
   471     }
   472     foreach ch $chans {catch {close $ch}}
   473     lsort [split [string trim [viewFile out]] \n]
   474 } -cleanup {
   475     removeFile out
   476     # Ensure that channels are gone, even if body failed to do so
   477     foreach ch $chans {catch {close $ch}}
   478 } -result {0 1 2 3 4 5 6 7 8 9}
   479 
   480 test iocmd-13.7.2 {open for append, O_APPEND} -setup {
   481     set log   [makeFile {} out]
   482     set chans {}
   483 } -body {
   484     foreach i { 0 1 2 3 4 5 6 7 8 9 } {
   485 	puts [set ch [open $log {WRONLY CREAT APPEND}]] $i
   486 	lappend chans $ch
   487     }
   488     foreach ch $chans {catch {close $ch}}
   489     lsort [split [string trim [viewFile out]] \n]
   490 } -cleanup {
   491     removeFile out
   492     # Ensure that channels are gone, even if body failed to do so
   493     foreach ch $chans {catch {close $ch}}
   494 } -result {0 1 2 3 4 5 6 7 8 9}
   495 
   496 
   497 
   498 
   499 test iocmd-14.1 {file id parsing errors} {
   500     list [catch {eof gorp} msg] $msg $errorCode
   501 } {1 {can not find channel named "gorp"} NONE}
   502 test iocmd-14.2 {file id parsing errors} {
   503     list [catch {eof filex} msg] $msg
   504 } {1 {can not find channel named "filex"}}
   505 test iocmd-14.3 {file id parsing errors} {
   506     list [catch {eof file12a} msg] $msg
   507 } {1 {can not find channel named "file12a"}}
   508 test iocmd-14.4 {file id parsing errors} {
   509     list [catch {eof file123} msg] $msg
   510 } {1 {can not find channel named "file123"}}
   511 test iocmd-14.5 {file id parsing errors} {
   512     list [catch {eof stdout} msg] $msg
   513 } {0 0}
   514 test iocmd-14.6 {file id parsing errors} {
   515     list [catch {eof stdin} msg] $msg
   516 } {0 0}
   517 test iocmd-14.7 {file id parsing errors} {
   518     list [catch {eof stdout} msg] $msg
   519 } {0 0}
   520 test iocmd-14.8 {file id parsing errors} {
   521     list [catch {eof stderr} msg] $msg
   522 } {0 0}
   523 test iocmd-14.9 {file id parsing errors} {
   524     list [catch {eof stderr1} msg] $msg
   525 } {1 {can not find channel named "stderr1"}}
   526 
   527 set f [open $path(test1) w]
   528 close $f
   529 
   530 set expect "1 {can not find channel named \"$f\"}"
   531 test iocmd-14.10 {file id parsing errors} {
   532     list [catch {eof $f} msg] $msg
   533 } $expect
   534 
   535 test iocmd-15.1 {Tcl_FcopyObjCmd} {fcopy} {
   536     list [catch {fcopy} msg] $msg
   537 } {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}
   538 test iocmd-15.2 {Tcl_FcopyObjCmd} {fcopy} {
   539     list [catch {fcopy 1} msg] $msg
   540 } {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}
   541 test iocmd-15.3 {Tcl_FcopyObjCmd} {fcopy} {
   542     list [catch {fcopy 1 2 3 4 5 6 7} msg] $msg
   543 } {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}
   544 test iocmd-15.4 {Tcl_FcopyObjCmd} {fcopy} {
   545     list [catch {fcopy 1 2 3} msg] $msg
   546 } {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}
   547 test iocmd-15.5 {Tcl_FcopyObjCmd} {fcopy} {
   548     list [catch {fcopy 1 2 3 4 5} msg] $msg
   549 } {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}
   550 
   551 set path(test2) [makeFile {} test2]
   552 
   553 set f [open $path(test1) w]
   554 close $f
   555 
   556 set rfile [open $path(test1) r]
   557 set wfile [open $path(test2) w]
   558 
   559 test iocmd-15.6 {Tcl_FcopyObjCmd} {fcopy} {
   560     list [catch {fcopy foo $wfile} msg] $msg
   561 } {1 {can not find channel named "foo"}}
   562 test iocmd-15.7 {Tcl_FcopyObjCmd} {fcopy} {
   563     list [catch {fcopy $rfile foo} msg] $msg
   564 } {1 {can not find channel named "foo"}}
   565 test iocmd-15.8 {Tcl_FcopyObjCmd} {fcopy} {
   566     list [catch {fcopy $wfile $wfile} msg] $msg
   567 } "1 {channel \"$wfile\" wasn't opened for reading}"
   568 test iocmd-15.9 {Tcl_FcopyObjCmd} {fcopy} {
   569     list [catch {fcopy $rfile $rfile} msg] $msg
   570 } "1 {channel \"$rfile\" wasn't opened for writing}"
   571 test iocmd-15.10 {Tcl_FcopyObjCmd} {fcopy} {
   572     list [catch {fcopy $rfile $wfile foo bar} msg] $msg
   573 } {1 {bad switch "foo": must be -size or -command}}
   574 test iocmd-15.11 {Tcl_FcopyObjCmd} {fcopy} {
   575     list [catch {fcopy $rfile $wfile -size foo} msg] $msg
   576 } {1 {expected integer but got "foo"}}
   577 test iocmd-15.12 {Tcl_FcopyObjCmd} {fcopy} {
   578     list [catch {fcopy $rfile $wfile -command bar -size foo} msg] $msg
   579 } {1 {expected integer but got "foo"}}
   580 
   581 close $rfile
   582 close $wfile
   583 
   584 # cleanup
   585 foreach file [list test1 test2 test3 test4] {
   586     removeFile $file
   587 }
   588 # delay long enough for background processes to finish
   589 after 500
   590 foreach file [list test5] {
   591     removeFile $file
   592 }
   593 cleanupTests
   594 return