diff options
-rw-r--r-- | tests/socket.test | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/tests/socket.test b/tests/socket.test index d474a0c..20a5f2e 100644 --- a/tests/socket.test +++ b/tests/socket.test @@ -4,6 +4,20 @@ needs constraint jim needs cmd socket needs cmd os.fork +catch {[socket -ipv6 stream ::1:5000]} res +set ipv6 1 +if {[string match "*not supported" $res]} { + set ipv6 0 +} else { + # Also, if we can't bind an IPv6 socket, don't run IPv6 tests + if {[catch { + [socket -ipv6 stream.server ::1:5000] close + } msg opts]} { + set ipv6 0 + } +} +testConstraint ipv6 $ipv6 + test socket-1.1 {stream} -body { # Let the system choose a port set s [socket stream.server 127.0.0.1:0] @@ -116,7 +130,7 @@ test socket-1.7 {socketpair} -body { set buf } -result {hello} -test socket-1.8 {stream - ipv6} -body { +test socket-1.8 {stream - ipv6} -constraints ipv6 -body { # Let the system choose a port set s [socket -ipv6 stream.server localhost:0] stdout flush @@ -135,7 +149,7 @@ test socket-1.8 {stream - ipv6} -body { set buf } -result {hello} -test socket-1.9 {dgram - ipv6 - unconnected} -body { +test socket-1.9 {dgram - ipv6 - unconnected} -constraints ipv6 -body { # Let the system choose a port set s [socket -ipv6 dgram.server localhost:0] set c [socket -ipv6 dgram] @@ -166,7 +180,7 @@ test socket-1.10 {stream - port only} -body { set buf } -result {hello} -test socket-1.11 {stream - ipv6 - port only} -body { +test socket-1.11 {stream - ipv6 - port only} -constraints ipv6 -body { # Let the system choose a port set s [socket -ipv6 stream.server 0] stdout flush @@ -280,7 +294,7 @@ test socket-3.4 {listen not a socket} -body { $f close } -test socket-4.1 {invalid ipv6 address} -body { +test socket-4.1 {invalid ipv6 address} -constraints ipv6 -body { socket -ipv6 stream "- invalid - address -" } -returnCodes error -result {Not a valid address: :::- invalid - address -} |