The tests probe whether the host has IPv6 support and, if it doesn't, skip
the tests that require IPv6.  However, until now, when the host lacks
support, this caused a Python exception to be printed, like this:

Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "/usr/lib64/python2.7/socket.py", line 187, in __init__
    _sock = _realsocket(family, type, proto)
socket.error: [Errno 97] Address family not supported by protocol

This exception is expected and harmless, but it reasonably surprised some
users.  This commit fixes the problem.

Reported-by: Paul Greenberg
Reported-at: 
https://github.com/openvswitch/ovs-issues/issues/146#issuecomment-390081887
Signed-off-by: Ben Pfaff <[email protected]>
---
 tests/atlocal.in | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/tests/atlocal.in b/tests/atlocal.in
index 0cc183e33fa6..4e626266b01b 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -116,14 +116,22 @@ if test x"$PYTHON3" != x && test "$IS_WIN32" = yes; then
 fi
 
 # Check whether to run IPv6 tests.
-if $PYTHON -c '
+$PYTHON -c '
+import errno
 import socket
-socket.socket(family=socket.AF_INET6).bind(("::1", 0, 0, 0))
-'; then
-    HAVE_IPV6=yes
-else
-    HAVE_IPV6=no
-fi
+import sys
+try:
+    socket.socket(family=socket.AF_INET6).bind(("::1", 0, 0, 0))
+except socket.error as e:
+    if e.errno == errno.EAFNOSUPPORT:
+        sys.exit(2)
+    raise
+'
+case $? in
+    0) HAVE_IPV6=yes ;;
+    2) HAVE_IPV6=no ;;
+    *) echo "$0: unexpected error probing $PYTHON for IPv6 support" >&2 ;;
+esac
 
 # Look for a python L7 library 'LIB' in the system. If it is found, defines
 # HAVE_LIB="yes", otherwise HAVE_LIB="no"
-- 
2.16.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to