diff options
author | Christian Heimes <christian@python.org> | 2016-09-05 22:37:46 (GMT) |
---|---|---|
committer | Christian Heimes <christian@python.org> | 2016-09-05 22:37:46 (GMT) |
commit | 4837141def956b2079248e1ef638a1e0234e9eae (patch) | |
tree | acbcd5296bc4711c38980e846c78837c5d48b092 | |
parent | 3cebf9387279d8b21369f55e205392199ad9b1a2 (diff) | |
download | cpython-4837141def956b2079248e1ef638a1e0234e9eae.zip cpython-4837141def956b2079248e1ef638a1e0234e9eae.tar.gz cpython-4837141def956b2079248e1ef638a1e0234e9eae.tar.bz2 |
Issue 27744: Check for AF_ALG support in Kernel
-rw-r--r-- | 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 index 6fc6e27..1ee6237 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -65,10 +65,22 @@ def _have_socket_rds(): 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 @@ class SendfileUsingSendfileTest(SendfileUsingSendTest): def meth_from_sock(self, sock): return getattr(sock, "_sendfile_use_sendfile") -@unittest.skipUnless(hasattr(socket, "AF_ALG"), 'AF_ALG required') + +@unittest.skipUnless(HAVE_SOCKET_ALG, 'AF_ALG required') class LinuxKernelCryptoAPI(unittest.TestCase): # tests for AF_ALG def create_alg(self, typ, name): |