[Python-checkins] cpython: Issue 27744: Check for AF_ALG support in Kernel

christian.heimes python-checkins at python.org
Mon Sep 5 18:38:41 EDT 2016


https://hg.python.org/cpython/rev/ee32af890e27
changeset:   103081:ee32af890e27
user:        Christian Heimes <christian at python.org>
date:        Tue Sep 06 00:37:46 2016 +0200
summary:
  Issue 27744: Check for AF_ALG support in Kernel

files:
  Lib/test/test_socket.py |  15 ++++++++++++++-
  1 files changed, 14 insertions(+), 1 deletions(-)


diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -65,10 +65,22 @@
         s.close()
     return True
 
+def _have_socket_alg():
+    """Check whether AF_ALG sockets are supported on this host."""
+    try:
+        s = socket.socket(socket.AF_ALG, socket.SOCK_SEQPACKET, 0)
+    except (AttributeError, OSError):
+        return False
+    else:
+        s.close()
+    return True
+
 HAVE_SOCKET_CAN = _have_socket_can()
 
 HAVE_SOCKET_RDS = _have_socket_rds()
 
+HAVE_SOCKET_ALG = _have_socket_alg()
+
 # Size in bytes of the int type
 SIZEOF_INT = array.array("i").itemsize
 
@@ -5325,7 +5337,8 @@
     def meth_from_sock(self, sock):
         return getattr(sock, "_sendfile_use_sendfile")
 
- at unittest.skipUnless(hasattr(socket, "AF_ALG"), 'AF_ALG required')
+
+ at unittest.skipUnless(HAVE_SOCKET_ALG, 'AF_ALG required')
 class LinuxKernelCryptoAPI(unittest.TestCase):
     # tests for AF_ALG
     def create_alg(self, typ, name):

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list