aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2020-05-06 11:40:27 +1000
committerSteve Bennett <steveb@workware.net.au>2020-05-06 11:40:27 +1000
commit659f043196f313c69e32876e3641d0865a1e49cd (patch)
treef78d69ecf73b8440fc4be38ae344cd60bf75eab2
parent46bbf5470e373d3b2a8282fe7b90d30c8da598fa (diff)
downloadjimtcl-659f043196f313c69e32876e3641d0865a1e49cd.zip
jimtcl-659f043196f313c69e32876e3641d0865a1e49cd.tar.gz
jimtcl-659f043196f313c69e32876e3641d0865a1e49cd.tar.bz2
tests: socket.test check for ipv6 support
Skip ipv6 tests if not supported Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r--tests/socket.test22
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 -}