summaryrefslogtreecommitdiffstats
path: root/tests/socket.test
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-04-10 12:39:54 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-04-10 12:39:54 (GMT)
commitf15e17cb4325805681b5479390866fae1621a4d9 (patch)
treedb47406be713ada278bfad3b9fd62c29c2c30b39 /tests/socket.test
parent22946a554a465a115602ba3324fb7fd8ea5590b4 (diff)
parent27be6e4e9ada6489a2bb9de775cab72378825b2b (diff)
downloadtcl-f15e17cb4325805681b5479390866fae1621a4d9.zip
tcl-f15e17cb4325805681b5479390866fae1621a4d9.tar.gz
tcl-f15e17cb4325805681b5479390866fae1621a4d9.tar.bz2
Merge Harald's "robust-async-connect-tests" branch. Thanks!
Diffstat (limited to 'tests/socket.test')
-rw-r--r--tests/socket.test24
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