| ︙ | | |
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-
+
+
+
+
+
+
+
+
+
|
# Copyright (c) 1991-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: io.test,v 1.10 1999/07/01 17:36:18 jenn Exp $
# RCS: @(#) $Id: io.test,v 1.11 1999/08/27 01:17:05 jenn Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
namespace import ::tcltest::*
}
if {"[info commands testchannel]" != "testchannel"} {
puts "Skipping io tests. This application does not seem to have the"
puts "testchannel command that is needed to run these tests."
return
}
::tcltest::saveState
set ::tcltest::testConstraints(knownBugThreadedLinux) [expr \
{($tcl_platform(os) != "Linux") \
&& ([info commands testthread] != {})}]
set ::tcltest::testConstraints(knownBugThreadedSolaris) [expr \
{($tcl_platform(os) != "SunOS") \
&& ([info commands testthread] != {})}]
removeFile test1
removeFile pipe
catch {unset u}
# set up a long data file for some of the following tests
|
| ︙ | | |
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
|
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
|
-
+
|
close $f
set f [open test1]
fconfigure $f -encoding iso2022-jp
set x [list [gets $f line] $line [gets $f line] $line [gets $f line] $line]
close $f
set x
} [list 8 "there\u4e00ok" 11 "\u4e01more bytes" 4 "here"]
test io-6.56 {Tcl_GetsObj: incomplete lines should disable file events} {stdio} {
test io-6.56 {Tcl_GetsObj: incomplete lines should disable file events} {stdio knownBugThreadedSolaris knownBugThreadedLinux} {
update
set f [open "|[list $::tcltest::tcltest cat]" w+]
fconfigure $f -buffering none
puts -nonewline $f "foobar"
fconfigure $f -blocking 0
set x {}
after 500 { lappend x timeout }
|
| ︙ | | |
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
|
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
|
-
+
|
flush $f
vwait x
vwait x
lappend x [catch {close $f} msg] $msg
set x
} "{} timeout {} timeout \u7266 {} eof 0 {}"
test io-13.1 {TranslateInputEOL: cr mode} {
test io-13.1 {TranslateInputEOL: cr mode} {knownBugThreadedLinux} {
set f [open test1 w]
fconfigure $f -translation lf
puts -nonewline $f "abcd\rdef\r"
close $f
set f [open test1]
fconfigure $f -translation cr
set x [read $f]
|
| ︙ | | |
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
|
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
|
-
+
|
close $f
set f [open test1]
fconfigure $f -translation crlf
set x [read $f]
close $f
set x
} "abcd\ndef\nfgh"
test io-13.6 {TranslateInputEOL: auto mode: saw cr in last segment} {stdio} {
test io-13.6 {TranslateInputEOL: auto mode: saw cr in last segment} {stdio knownBugThreadedSolaris knownBugThreadedLinux} {
# (chanPtr->flags & INPUT_SAW_CR)
# This test may fail on slower machines.
set f [open "|[list $::tcltest::tcltest cat]" w+]
fconfigure $f -blocking 0 -buffering none -translation {auto lf}
fileevent $f read "ready $f"
|
| ︙ | | |
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
|
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
|
-
+
|
}
lappend l [file size test1]
close $f
lappend l [file size test1]
set l
} {0 60 72}
test io-27.6 {FlushChannel, async flushing, async close} \
{stdio asyncPipeClose} {
{stdio asyncPipeClose knownBugThreadedLinux} {
removeFile pipe
removeFile output
set f [open pipe w]
puts $f {
set f [open output w]
fconfigure $f -translation lf -buffering none -eofchar {}
while {![eof stdin]} {
|
| ︙ | | |
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
|
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
|
-
+
|
[catch {fileevent $f3 readable}]
} {0 {f script} 1 0 {f3 script} 0 {f script} 1 1 1 1 1}
# Execute these tests only if the "testfevent" command is present.
if {[info commands testfevent] == "testfevent"} {
test io-46.1 {Tcl event loop vs multiple interpreters} {
test io-46.1 {Tcl event loop vs multiple interpreters} {knownBugThreadedLinux} {
testfevent create
testfevent cmd {
set f [open foo r]
set x "no event"
fileevent $f readable {
set x "f triggered: [gets $f]"
fileevent $f readable {}
|
| ︙ | | |
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
|
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
|
-
+
-
+
-
+
|
lappend l [gets $f]
lappend l [tell $f]
lappend l [eof $f]
close $f
set l
} [list 7 a\rb\rc 7 {} 7 1]
test io-50.1 {testing handler deletion} {
test io-50.1 {testing handler deletion} {knownBugThreadedSolaris knownBugThreadedLinux} {
removeFile test1
set f [open test1 w]
close $f
set f [open test1 r]
testchannelevent $f add readable [list delhandler $f]
proc delhandler {f} {
global z
set z called
testchannelevent $f delete 0
}
set z not_called
update
close $f
set z
} called
test io-50.2 {testing handler deletion with multiple handlers} {
test io-50.2 {testing handler deletion with multiple handlers} {knownBugThreadedSolaris knownBugThreadedLinux} {
removeFile test1
set f [open test1 w]
close $f
set f [open test1 r]
testchannelevent $f add readable [list delhandler $f 1]
testchannelevent $f add readable [list delhandler $f 0]
proc delhandler {f i} {
global z
lappend z "called delhandler $f $i"
testchannelevent $f delete 0
}
set z ""
update
close $f
string compare [string tolower $z] \
[list [list called delhandler $f 0] [list called delhandler $f 1]]
} 0
test io-50.3 {testing handler deletion with multiple handlers} {
test io-50.3 {testing handler deletion with multiple handlers} {knownBugThreadedSolaris knownBugThreadedLinux} {
removeFile test1
set f [open test1 w]
close $f
set f [open test1 r]
testchannelevent $f add readable [list notcalled $f 1]
testchannelevent $f add readable [list delhandler $f 0]
set z ""
|
| ︙ | | |
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
|
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
|
-
+
|
set z ""
update
close $f
string compare [string tolower $z] \
[list [list delhandler $f 0 called] \
[list delhandler $f 0 deleted myself]]
} 0
test io-50.4 {testing handler deletion vs reentrant calls} {
test io-50.4 {testing handler deletion vs reentrant calls} {knownBugThreadedSolaris knownBugThreadedLinux} {
removeFile test1
set f [open test1 w]
close $f
set f [open test1 r]
testchannelevent $f add readable [list delrecursive $f]
proc delrecursive {f} {
global z u
|
| ︙ | | |
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
|
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
|
-
+
|
set u toplevel
set z ""
update
close $f
string compare [string tolower $z] \
{{delrecursive calling recursive} {delrecursive deleting recursive}}
} 0
test io-50.5 {testing handler deletion vs reentrant calls} {
test io-50.5 {testing handler deletion vs reentrant calls} {knownBugThreadedSolaris knownBugThreadedLinux} {
removeFile test1
set f [open test1 w]
close $f
set f [open test1 r]
testchannelevent $f add readable [list notcalled $f]
testchannelevent $f add readable [list del $f]
proc notcalled {f} {
|
| ︙ | | |
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
|
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
|
-
+
|
set u toplevel
update
close $f
string compare [string tolower $z] \
[list {del calling recursive} {del deleted notcalled} \
{del deleted myself} {del after update}]
} 0
test io-50.6 {testing handler deletion vs reentrant calls} {
test io-50.6 {testing handler deletion vs reentrant calls} {knownBugThreadedSolaris knownBugThreadedLinux} {
removeFile test1
set f [open test1 w]
close $f
set f [open test1 r]
testchannelevent $f add readable [list second $f]
testchannelevent $f add readable [list first $f]
proc first {f} {
|
| ︙ | | |