##// END OF EJS Templates
runtests: add a function to test if IPv6 is available...
Jun Wu -
r30984:15f9084a default
parent child Browse files
Show More
@@ -112,6 +112,29 b' else:'
112 # For Windows support
112 # For Windows support
113 wifexited = getattr(os, "WIFEXITED", lambda x: False)
113 wifexited = getattr(os, "WIFEXITED", lambda x: False)
114
114
115 # Whether to use IPv6
116 def checkipv6available(port=20058):
117 """return true if we can listen on localhost's IPv6 ports"""
118 family = getattr(socket, 'AF_INET6', None)
119 if family is None:
120 return False
121 try:
122 s = socket.socket(family, socket.SOCK_STREAM)
123 s.bind(('localhost', port))
124 s.close()
125 return True
126 except socket.error as exc:
127 if exc.errno == errno.EADDRINUSE:
128 return True
129 elif exc.errno in (errno.EADDRNOTAVAIL, errno.EPROTONOSUPPORT):
130 return False
131 else:
132 raise
133 else:
134 return False
135
136 useipv6 = checkipv6available()
137
115 def checkportisavailable(port):
138 def checkportisavailable(port):
116 """return true if a port seems free to bind on localhost"""
139 """return true if a port seems free to bind on localhost"""
117 families = [getattr(socket, i, None)
140 families = [getattr(socket, i, None)
General Comments 0
You need to be logged in to leave comments. Login now