diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-04-11 10:04:00 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-04-11 10:04:00 (GMT) |
commit | ede10ae95dd4130bfa17359dae62a0ddf7d0b4d5 (patch) | |
tree | ef20ef3f00b8d97a81694f9eb9be77c83200119e /tests | |
parent | 6db7cf0c224af9fed08b4721e66a76448cfd8151 (diff) | |
parent | bbfc7b1ea2d467b198933a82184a6c53de48ac00 (diff) | |
download | tcl-ede10ae95dd4130bfa17359dae62a0ddf7d0b4d5.zip tcl-ede10ae95dd4130bfa17359dae62a0ddf7d0b4d5.tar.gz tcl-ede10ae95dd4130bfa17359dae62a0ddf7d0b4d5.tar.bz2 |
merge trunk
Diffstat (limited to 'tests')
-rw-r--r-- | tests/socket.test | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/tests/socket.test b/tests/socket.test index 80b0251..9a09c0f 100644 --- a/tests/socket.test +++ b/tests/socket.test @@ -60,8 +60,13 @@ # listening at port 2048. If all fails, a message is printed and the tests # using the remote server are not performed. -package require tcltest 2 -namespace import -force ::tcltest::* +if {[lsearch [namespace children] ::tcltest] == -1} { + package require tcltest + namespace import -force ::tcltest::* +} + +::tcltest::loadTestedCommands +catch [list package require -exact Tcltest [info patchlevel]] # Some tests require the Thread package or exec command testConstraint thread [expr {0 == [catch {package require Thread 2.7-}]}] @@ -71,6 +76,14 @@ testConstraint exec [llength [info commands exec]] # from 49152 through 65535. proc randport {} { expr {int(rand()*16383+49152)} } +# Check if testsocket testflags is available +testConstraint testsocket_testflags [expr {![catch { + set h [socket -async localhost [randport]] + testsocket testflags $h 0 + close $h + }]}] + + # Test the latency of tcp connections over the loopback interface. Some OSes # (e.g. NetBSD) seem to use the Nagle algorithm and delayed ACKs, so it takes # up to 200ms for a packet sent to localhost to arrive. We're measuring this @@ -2266,12 +2279,17 @@ test socket-14.11.0 {pending [socket -async] and nonblocking [puts], no listener unset x } -result {socket is not connected} -returnCodes 1 test socket-14.11.1 {pending [socket -async] and nonblocking [puts], no listener, flush} \ - -constraints {socket nonPortable} \ + -constraints {socket testsocket_testflags} \ -body { set sock [socket -async localhost [randport]] + # Set the socket in async test mode. + # The async connect will not be continued on the following fconfigure + # and puts/flush. Thus, the connect will fail after them. + testsocket testflags $sock 1 fconfigure $sock -blocking 0 puts $sock ok flush $sock + testsocket testflags $sock 0 fileevent $sock writable {set x 1} vwait x close $sock |