
    <e                    (   d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl Z 	 d dl!Z!n# e"$ r dZ!Y nw xY w	 d dl#Z#n# e"$ r dZ#Y nw xY w ej$        d	           ej%        Z%d
&                    d          Z'dZ( ej)                    dk    Z*	 d dl+Z+n# e"$ r dZ+Y nw xY wd Z,d Z-d Z.d Z/d Z0d Z1d Z2d Z3d Z4ej5        d             Z6 e-            Z7 e.            Z8 e/            Z9 e0            Z: e1            Z; e2            Z< e3            Z= e>e
d          Z? e4            Z@ ej        d          jA        ZB G d de jC                  ZD G d de jC                  ZE G d deE          ZF G d  d!          ZG G d" d#e jC                  ZH G d$ d%e jC                  ZI G d& d'          ZJ G d( d)eDeJ          ZK G d* d+eEeJ          ZL e jM        e?d,           G d- d.eFeJ                      ZN G d/ d0eHeJ          ZO G d1 d2eIeJ          ZP e jQ        e#du d3           e jM        e=d4           e jM         e,            d5k    d6           G d7 d8e jC        eJ                                              ZR G d9 d:eK          ZS G d; d<e jC        eJ          ZT G d= d>e jC                  ZU G d? d@eU          ZV G dA dBeGeUeJ          ZW G dC dDeVeW          ZX G dE dFeU          ZY G dG dHeY          ZZ G dI dJeU          Z[ G dK dLe[          Z\ G dM dNe[          Z] G dO dPe[          Z^ G dQ dRe[          Z_ G dS dTe[          Z` G dU dVe`          Za G dW dXe`          ZbdY ZcdZ Zdd[ Ze G d\ d]e jC                  Zf e jM        e7d^           G d_ d`e jC                              Zg e jM        e7d^           G da dbeO                      Zh e jM        e8dc           G dd dee jC                              Zi e jM        e9df           G dg dhe jC                              Zj e jM        e:di           G dj dke jC                              Zk e jM        e:di           G dl dmeP                      Zl e jM        e<dn           G do dpe jC                              Zm e jQ        e#du d3           e jM        e=d4           G dq dre jC                                          Zn e jM        e@ds           G dt due jC                              Zo G dv dweS          Zp G dx dyeL          Zq e jM        e?d,           G dz d{eN                      Zr G d| d}eG          Zs G d~ des          Zt G d des          Zu G d des          Zv G d des          Zw G d des          Zx G d des          Zy G d dey          Zz G d dez          Z{ G d dez          Z| G d des          Z} G d de}          Z~ G d de}          Z G d dete}          Z G d de jC                  Z G d dey          Z G d dey          Z G d deueweWe]          Z ede
j
        d           G d de|e                      Z ede
j
        d           G d dee                      Z ede
j
        d           G d dee                      Z G d deueweWea          Z ede
j
        d           e jM        ej        d           eedd           G d de|e                                              Z ede
j
        d           e jM        ej        d           eedd           G d dee                                              Z ede
j
        d           e jM        ej        d           eedd           G d dee                                              Z ede
j
        d           e jM        ej        d           ede
d           eedd           G d dee                                                          Z ede
j
        d           e jM        ej        d           ede
d           eedd           G d detee                                                          Z e jM        e?d,           G d deueweWe^                      Z e jM        e?d,           ede
j
        d           G d de|e                                  Z e jM        e?d,           ede
j
        d           G d dee                                  Z e jM        e?d,           ede
j
        d           G d dee                                  Z e jM        e?d,           G d deueweWeb                      Z ede
j
        d           e jM        ej        d           e jM        e?d,           eedd           G dÄ de|e                                                          Z ede
j
        d           e jM        ej        d           e jM        e?d,           eedd           G dń dee                                                          Z ede
j
        d           e jM        ej        d           e jM        e?d,           eedd           G dǄ dee                                                          Z ede
j
        d           e jM        ej        d           e jM        e?d,           ede
d           eedd           G dɄ dee                                                                      Z ede
j
        d           e jM        ej        d           e jM        e?d,           ede
d           eedd           G d˄ detee                                                                      Z G d̈́ dexeXe\          Z ede
j
        d           G dτ de{e                      Z ede
j
        d           G dф dee~e                      Z ede
j
        d           G dӄ dee~e                      Z G dՄ devexeXe_          Z ede
j
        d           e jQ        e*dצ           eedddڦ           G dۄ de{e                                              Z ede
j
        d           e jQ        e*dצ           eedddڦ           G d݄ dee~e                                              Z ede
j
        d           e jQ        e*dצ           eedddڦ           G d߄ dee~e                                              Z G d dexeXeZ          Z ede
j
        d           ede
d           G d de{e                                  Z ede
j
        d           ede
d           G d dee~e                                  Z ede
j
        d           ede
d           G d dee~e                                  Z ede
j
        dd           ede
ddd           G d dee                                  Z ede
j
        dd           ede
ddd           G d detee                                  Z G d d          Z eded           e jM         e>ed          p e>ed          d           G d dee]                                  Z eded           e jM         e>ed          p e>ed          d           G d deeGeVe\                                  Z G d deK          Z G d deT          Z G d deK          Z G d  deS          Z G d de          Z G d de          Z G d de          Z G d d	e          Z G d
 de          Z G d de          Z G d de          Z G d deep          Z G d de jC                  Z G d deDeJ          Z G d deDeJ          Z G d deD          Z G d deE          Z e jM        e?d,           G d deF                      Z G d de jC                  Z e jM        ej        d k    d!           G d" d#e jC                              Z e jM         e>e
d          d$           G d% d&e jC                              Z G d' d(eS          Zd)Zd*Zd+ZÐd, Z e jM         eĦ            d-           G d. d/e jC                              Z e jM         eĦ            d-           G d0 d1e jC        eJ                      Z G d2 d3eK          Z G d4 d5e jC                  Z e jM         e>e
d6          d7           G d8 d9e jC                              Z e jM        ej        d:k    d;           e jM        e!d<           G d= d>eD                                  Z G d? d@eK          Z e jM         e>edA          dB           G dC dDe̦                      Z e jM        e;dE           G dF dGe jC                              Z e jM        ej        dHk    dI           G dJ dKe jC                              Z e jM        ej                            dL          dM           G dN dOe jC                              Z G dP dQe jC                  Z G dR dSe jC                  Z ede
dT           ede
dU           ede
d           G dV dWe jC                                                      ZԐdX Ze֐dYk    r e j                     dS dS (Z      N)support)	os_helper)socket_helper)threading_helper)proxyFT)moduleu   Michael Gilfix was hereሴ
utf-8  AIXc                  ,   t           d S t          t          d          sd S 	 t          dd          5 } t          j        | t          j        d          }d d d            n# 1 swxY w Y   t          j        d|          d         S # t          $ r Y d S w xY w)NIOCTL_VM_SOCKETS_GET_LOCAL_CIDz
/dev/vsockrbz    Ir   )	fcntlhasattrsocketopenioctlr   structunpackOSError)frs     '/usr/lib/python3.11/test/test_socket.pyget_cidr   6   s    }t6;<< t(,%% 	NAvDfMMA	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N
 }S!$$Q''    tts4   B !AB A##B &A#'B 
BBc                      	 t          j         t           j        t           j        t           j                  } |                                  n# t
          t          f$ r Y dS w xY wdS )z5Check whether CAN sockets are supported on this host.FT)r   PF_CANSOCK_RAWCAN_RAWcloseAttributeErrorr   ss    r   _have_socket_canr$   C   sa    M&-&.II 	
				 G$   uu 4   4A A A c                      	 t          j         t           j        t           j        t           j                  } |                                  n# t
          t          f$ r Y dS w xY wdS )z;Check whether CAN ISOTP sockets are supported on this host.FT)r   r   
SOCK_DGRAM	CAN_ISOTPr    r!   r   r"   s    r   _have_socket_can_isotpr)   M   c    M&-):F<LMM 	
				 G$   uu 4r%   c                      	 t          j         t           j        t           j        t           j                  } |                                  n# t
          t          f$ r Y dS w xY wdS )z;Check whether CAN J1939 sockets are supported on this host.FT)r   r   r'   	CAN_J1939r    r!   r   r"   s    r   _have_socket_can_j1939r-   W   r*   r%   c                      	 t          j         t           j        t           j        d          } |                                  n# t          t
          f$ r Y dS w xY wdS )z5Check whether RDS sockets are supported on this host.r   FT)r   PF_RDSSOCK_SEQPACKETr    r!   r   r"   s    r   _have_socket_rdsr1   a   `    M&-)>BB 	
				 G$   uu 4   *A AAc                      	 t          j         t           j        t           j        d          } |                                  n# t          t
          f$ r Y dS w xY wdS )z8Check whether AF_ALG sockets are supported on this host.r   FT)r   AF_ALGr0   r    r!   r   r"   s    r   _have_socket_algr6   k   r2   r3   c                      	 t          j         t           j        t           j        d          } |                                  n# t          t
          f$ r Y dS w xY wdS )z<Check whether AF_QIPCRTR sockets are supported on this host.r   FT)r   
AF_QIPCRTRr'   r    r!   r   r"   s    r   _have_socket_qipcrtrr9   u   sa    M&+V->BB 	
				 G$   uu 4r3   c                  &    t                      du} | S )z:Check whether AF_VSOCK sockets are supported on this host.N)r   )rets    r   _have_socket_vsockr<      s    
))4
CJ    c                      	 t          j         t           j        t           j        t           j                  } |                                  n# t
          t          f$ r Y dS w xY wdS )z>Check whether AF_BLUETOOTH sockets are supported on this host.FT)r   AF_BLUETOOTHSOCK_STREAMBTPROTO_RFCOMMr    r!   r   r"   s    r   _have_socket_bluetoothrB      sf     M&-v/A6CXYY 	
				 G$   uu 4r%   c              #      K   t          j                    }	 t          j        |            d V  t          j        |           d S # t          j        |           w xY wN)r   getdefaulttimeoutsetdefaulttimeout)timeoutold_timeouts     r   socket_setdefaulttimeoutrI      sa      *,,K. ))) ----- ----s   A AIPPROTO_UDPLITEic                       e Zd Zd Zd ZdS )SocketTCPTestc                     t          j         t           j        t           j                  | _        t	          j        | j                  | _        | j                                         d S rD   )r   AF_INETr@   servr   	bind_portportlistenselfs    r   setUpzSocketTCPTest.setUp   sH    M&.&2DEE	!+DI66		r=   c                 F    | j                                          d | _         d S rD   rP   r    rT   s    r   tearDownzSocketTCPTest.tearDown       				r=   N__name__
__module____qualname__rV   rY    r=   r   rM   rM      s2          
    r=   rM   c                       e Zd Zd Zd ZdS )SocketUDPTestc                     t          j         t           j        t           j                  | _        t	          j        | j                  | _        d S rD   )r   rO   r'   rP   r   rQ   rR   rT   s    r   rV   zSocketUDPTest.setUp   s2    M&.&2CDD	!+DI66			r=   c                 F    | j                                          d | _         d S rD   rX   rT   s    r   rY   zSocketUDPTest.tearDown   rZ   r=   Nr[   r_   r=   r   ra   ra      s2        7 7 7    r=   ra   c                       e Zd Zd ZdS )SocketUDPLITETestc                     t          j         t           j        t           j        t           j                  | _        t          j        | j                  | _        d S rD   )r   rO   r'   rJ   rP   r   rQ   rR   rT   s    r   rV   zSocketUDPLITETest.setUp   s7    M&.&2CVE[\\	!+DI66			r=   N)r\   r]   r^   rV   r_   r=   r   re   re      s#        7 7 7 7 7r=   re   c                   6     e Zd ZdZ fdZ fdZ fdZ xZS )ThreadSafeCleanupTestCasezSubclass of unittest.TestCase with thread-safe cleanup methods.

    This subclass protects the addCleanup() and doCleanups() methods
    with a recursive lock.
    c                 j     t                      j        |i | t          j                    | _        d S rD   )super__init__	threadingRLock_cleanup_lockrU   argskwargs	__class__s      r   rk   z"ThreadSafeCleanupTestCase.__init__   s5    $)&)))&_..r=   c                 x    | j         5   t                      j        |i |cd d d            S # 1 swxY w Y   d S rD   )rn   rj   
addCleanupro   s      r   rt   z$ThreadSafeCleanupTestCase.addCleanup        	7 	7%577%t6v66	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7   /33c                 x    | j         5   t                      j        |i |cd d d            S # 1 swxY w Y   d S rD   )rn   rj   
doCleanupsro   s      r   rx   z$ThreadSafeCleanupTestCase.doCleanups   ru   rv   )r\   r]   r^   __doc__rk   rt   rx   __classcell__rr   s   @r   rh   rh      st         / / / / /7 7 7 7 77 7 7 7 7 7 7 7 7r=   rh   c                   ~    e Zd ZdZdZdZ	 dZ ej        e          Z		 dZ
e
d ej        e
          dz  z  z  Z
d Zd	S )
SocketCANTestzTo be able to run this test, a `vcan0` CAN interface can be created with
    the following commands:
    # modprobe vcan
    # ip link add dev vcan0 type vcan
    # ip link set up vcan0
    vcan0   z=IB3x8sz@3I4l2Ix   c                 T   t          j         t           j        t           j        t           j                  | _        |                     | j        j                   	 | j                            | j        f           d S # t          $ r! | 
                    d| j        z             Y d S w xY wN%network interface `%s` does not exist)r   r   r   r   r#   rt   r    bind	interfacer   skipTestrT   s    r   rV   zSocketCANTest.setUp  s    v}fov~NN%%%	+FKK)***** 	+ 	+ 	+MMA>* + + + + + +	+s    A< <'B'&B'N)r\   r]   r^   ry   r   bufsizecan_frame_fmtr   calcsizecan_frame_sizebcm_cmd_msg_fmtrV   r_   r=   r   r}   r}      s          IG M$V_]33N   Osofoo>>BCCO+ + + + +r=   r}   c                       e Zd ZdZdZd ZdS )SocketRDSTestz\To be able to run this test, the `rds` kernel module must be loaded:
    # modprobe rds
        c                 ,   t          j         t           j        t           j        d          | _        |                     | j        j                   	 t          j        | j                  | _        d S # t          $ r | 
                    d           Y d S w xY w)Nr   zunable to bind RDS socket)r   r/   r0   rP   rt   r    r   rQ   rR   r   r   rT   s    r   rV   zSocketRDSTest.setUp  s    M&-1FJJ		(((	7%/	::DIII 	7 	7 	7MM5666666	7s   A0 0BBN)r\   r]   r^   ry   r   rV   r_   r=   r   r   r     s4          G7 7 7 7 7r=   r   c                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	ThreadableTesta  Threadable Test class

    The ThreadableTest class makes it easy to create a threaded
    client/server pair from an existing unit test. To create a
    new threaded class from an existing unit test, use multiple
    inheritance:

        class NewClass (OldClass, ThreadableTest):
            pass

    This class defines two new fixture functions with obvious
    purposes for overriding:

        clientSetUp ()
        clientTearDown ()

    Any new test functions within the class must then define
    tests in pairs, where the test name is preceded with a
    '_' to indicate the client portion of the test. Ex:

        def testFoo(self):
            # Server portion

        def _testFoo(self):
            # Client portion

    Any exceptions raised by the clients during their tests
    are caught and transferred to the main thread to alert
    the testing framework.

    Note, the server setup function cannot call any blocking
    functions that rely on the client thread during setup,
    unless serverExplicitReady() is called just before
    the blocking call (such as in setting up a client/server
    connection and performing the accept() in setUp().
    c                 6    | j         | _        | j        | _         d S rD   )rV   _ThreadableTest__setUp_setUprT   s    r   rk   zThreadableTest.__init__H  s    z[


r=   c                 8    | j                                          dS )zThis method allows the server to explicitly indicate that
        it wants the client thread to proceed. This is useful if the
        server is about to execute a blocking routine that is
        dependent upon the client thread during its setup routine.N)server_readysetrT   s    r   serverExplicitReadyz"ThreadableTest.serverExplicitReadyM  s    
 	r=   c                 R                          t          j                               t          j                     _        t          j                     _        t          j                     _        t          j	        d           _        d _
         fd}                     |                                            }|                    d          }||dz   d          }t           d|z             }t          j         j        |f           _        	                                   n#  d _
         xY w	  j                                         n#  j                                         w xY w j                                                               j        j                   d S )N   Fc                  l     j                                         r j                                         d S rD   )queueqsizegetrT   s   r   raise_queued_exceptionz5ThreadableTest._setUp.<locals>.raise_queued_exception]  s5    z!! 'jnn&&&' 'r=   ._T)enterContextr   wait_threads_exitrl   Eventr   client_readydoner   Queueserver_crashedrt   idrfindgetattrthreadstart_new_thread	clientRunclient_threadr   r   wait)rU   r   
methodnamerK   test_methods   `    r   r   zThreadableTest._setUpT  s   *<>>???%O--%O--O%%	[^^
#	' 	' 	' 	' 	' 	./// WWYY
S!!!%
dC*$455#4N[N, ,	$LLNNNN	"&D 
 !!####D!!####   	'''''s   D) (E )
D33E E,c                    | j                                          	 |                                  n_# t          $ rR}| j                            |           |                                  Y d }~| j                                         d S d }~ww xY w	 | j                                         n# | j                                         w xY w| j	        r|                                  d S t          |d          st          d          	  |             n1# t          $ r$}| j                            |           Y d }~nd }~ww xY w|                                  d S # |                                  w xY w)N__call__z%test_func must be a callable function)r   r   clientSetUpBaseExceptionr   putclientTearDownr   r   r   r   	TypeError)rU   	test_funces      r   r   zThreadableTest.clientRunt  s      	$ 	 	 	JNN1!!!FFF!!#####	  !!####D!!#### 	!!!Fy*-- 	ECDDD	"IKKKK 	 	 	JNN1	 !!!!!D!!!!s[   0 B* 
B.B(B* BB* *C
D E 
D>D94E 9D>>E E-c                      t          d          )Nz clientSetUp must be implemented.)NotImplementedErrorrT   s    r   r   zThreadableTest.clientSetUp  s    !"DEEEr=   c                 ^    | j                                          t          j                     d S rD   )r   r   r   exitrT   s    r   r   zThreadableTest.clientTearDown  s     	r=   N)
r\   r]   r^   ry   rk   r   r   r   r   r   r_   r=   r   r   r   "  s}        # #J! ! !
     ( ( (@" " ",F F F    r=   r   c                   "    e Zd ZddZd Zd ZdS )ThreadedTCPSocketTestrunTestc                 r    t                               | |           t                              |            d S N)
methodNamerM   rk   r   rU   r   s     r   rk   zThreadedTCPSocketTest.__init__  5    t
;;;%%%%%r=   c                 b    t          j         t           j        t           j                  | _        d S rD   )r   rO   r@   clirT   s    r   r   z!ThreadedTCPSocketTest.clientSetUp  s    =1CDDr=   c                 z    | j                                          d | _         t                              |            d S rD   r   r    r   r   rT   s    r   r   z$ThreadedTCPSocketTest.clientTearDown  5    %%d+++++r=   Nr   r\   r]   r^   rk   r   r   r_   r=   r   r   r     sI        & & & &E E E, , , , ,r=   r   c                   "    e Zd ZddZd Zd ZdS )ThreadedUDPSocketTestr   c                 r    t                               | |           t                              |            d S r   )ra   rk   r   r   s     r   rk   zThreadedUDPSocketTest.__init__  r   r=   c                 b    t          j         t           j        t           j                  | _        d S rD   )r   rO   r'   r   rT   s    r   r   z!ThreadedUDPSocketTest.clientSetUp  s    =1BCCr=   c                 z    | j                                          d | _         t                              |            d S rD   r   rT   s    r   r   z$ThreadedUDPSocketTest.clientTearDown  r   r=   Nr   r   r_   r=   r   r   r     sI        & & & &D D D, , , , ,r=   r   z'UDPLITE sockets required for this test.c                   "    e Zd ZddZd Zd ZdS )ThreadedUDPLITESocketTestr   c                 r    t                               | |           t                              |            d S r   )re   rk   r   r   s     r   rk   z"ThreadedUDPLITESocketTest.__init__  s5    ""4J"???%%%%%r=   c                 x    t          j         t           j        t           j        t           j                  | _        d S rD   )r   rO   r'   rJ   r   rT   s    r   r   z%ThreadedUDPLITESocketTest.clientSetUp  s#    =1BFDZ[[r=   c                 z    | j                                          d | _         t                              |            d S rD   r   rT   s    r   r   z(ThreadedUDPLITESocketTest.clientTearDown  r   r=   Nr   r   r_   r=   r   r   r     sI        & & & &\ \ \, , , , ,r=   r   c                   "    e Zd ZddZd Zd ZdS )ThreadedCANSocketTestr   c                 r    t                               | |           t                              |            d S r   )r}   rk   r   r   s     r   rk   zThreadedCANSocketTest.__init__  r   r=   c                     t          j         t           j        t           j        t           j                  | _        	 | j                            | j        f           d S # t          $ r Y d S w xY wrD   )r   r   r   r   r   r   r   r   rT   s    r   r   z!ThreadedCANSocketTest.clientSetUp  se    =PP	HMM4>+,,,,, 	 	 	 DD	s    A 
A+*A+c                 z    | j                                          d | _         t                              |            d S rD   r   rT   s    r   r   z$ThreadedCANSocketTest.clientTearDown  r   r=   Nr   r   r_   r=   r   r   r     sF        & & & &  , , , , ,r=   r   c                   "    e Zd ZddZd Zd ZdS )ThreadedRDSSocketTestr   c                 r    t                               | |           t                              |            d S r   )r   rk   r   r   s     r   rk   zThreadedRDSSocketTest.__init__  r   r=   c                    t          j         t           j        t           j        d          | _        	 | j                            t
          df           | j                                        | _        d S # t          $ r Y d S w xY wNr   )	r   r/   r0   r   r   HOSTgetsocknamecli_addrr   rT   s    r   r   z!ThreadedRDSSocketTest.clientSetUp  sv    =0EqII	HMM4)$$$ H0022DMMM 	 	 	 DD	s   ?A2 2
B ?B c                 z    | j                                          d | _         t                              |            d S rD   r   rT   s    r   r   z$ThreadedRDSSocketTest.clientTearDown  r   r=   Nr   r   r_   r=   r   r   r     sF        & & & &	 	 	, , , , ,r=   r   
need fcntlz%VSOCK sockets required for this test.   z-This test can only be run on a virtual guest.c                   .    e Zd ZddZd Zd Zd Zd ZdS )	ThreadedVSOCKSocketStreamTestr   c                 |    t           j                            | |           t                              |            d S r   unittestTestCaserk   r   r   s     r   rk   z&ThreadedVSOCKSocketStreamTest.__init__  8    ""4J"???%%%%%r=   c                    t          j         t           j        t           j                  | _        |                     | j        j                   | j                            t           j        t          f           | j        	                                 | 
                                 | j                                        \  | _        | _        |                     | j        j                   d S rD   )r   AF_VSOCKr@   rP   rt   r    r   VMADDR_CID_ANY	VSOCKPORTrS   r   acceptconnconnaddrrT   s    r   rV   z#ThreadedVSOCKSocketStreamTest.setUp  s    M&/63EFF		(((	-y9:::	  """#'9#3#3#5#5 	4=	(((((r=   c                 &   t          j        d           t          j        t          j        t          j                  | _        |                     | j        j                   t                      }| j        	                    |t          f           d S )N皙?)timesleepr   r   r@   r   rt   r    r   connectr   )rU   cids     r   r   z)ThreadedVSOCKSocketStreamTest.clientSetUp  sg    
3=&2DEE'''ii#y)*****r=   c                 p    | j                             d          }|                     |t                     d S N   )r   recvassertEqualMSGrU   msgs     r   
testStreamz(ThreadedVSOCKSocketStreamTest.testStream  1    innT""c"""""r=   c                 v    | j                             t                     | j                                          d S rD   r   sendr  r    rT   s    r   _testStreamz)ThreadedVSOCKSocketStreamTest._testStream  .    cr=   Nr   r\   r]   r^   rk   rV   r   r  r  r_   r=   r   r   r     sd        & & & &) ) )+ + +# # #    r=   r   c                   2    e Zd ZdZd	dZd Zd Zd Zd ZdS )
SocketConnectedTestzSocket tests for client-server connection.

    self.cli_conn is a client socket connected to the server.  The
    setUp() method guarantees that it is connected to the server.
    r   c                 >    t                               | |           d S r   )r   rk   r   s     r   rk   zSocketConnectedTest.__init__  !    &&t
&CCCCCr=   c                     t                               |            |                                  | j                                        \  }}|| _        d S rD   )r   rV   r   rP   r   cli_connrU   r   addrs      r   rV   zSocketConnectedTest.setUp  sL    ##D))) 	  """Y%%''
dr=   c                 z    | j                                          d | _         t                              |            d S rD   )r  r    r   rY   rT   s    r   rY   zSocketConnectedTest.tearDown  s7    &&t,,,,,r=   c                     t                               |            | j                            t          | j        f           | j        | _        d S rD   )r   r   r   r   r   rR   	serv_connrT   s    r   r   zSocketConnectedTest.clientSetUp!  s@    ))$///$	*+++r=   c                 z    | j                                          d | _         t                              |            d S rD   )r  r    r   r   rT   s    r   r   z"SocketConnectedTest.clientTearDown&  s7    ,,T22222r=   Nr   )	r\   r]   r^   ry   rk   rV   rY   r   r   r_   r=   r   r  r  
  sr         D D D D  - - -
" " "
3 3 3 3 3r=   r  c                   .    e Zd ZddZd Zd Zd Zd ZdS )	SocketPairTestr   c                 |    t           j                            | |           t                              |            d S r   r   r   s     r   rk   zSocketPairTest.__init__-  r   r=   c                 F    t          j                    \  | _        | _        d S rD   )r   
socketpairrP   r   rT   s    r   rV   zSocketPairTest.setUp1  s    $/11	4888r=   c                 F    | j                                          d | _         d S rD   rX   rT   s    r   rY   zSocketPairTest.tearDown4  rZ   r=   c                     d S rD   r_   rT   s    r   r   zSocketPairTest.clientSetUp8      r=   c                 z    | j                                          d | _         t                              |            d S rD   r   rT   s    r   r   zSocketPairTest.clientTearDown;  r   r=   Nr   )r\   r]   r^   rk   rV   rY   r   r   r_   r=   r   r  r  +  sd        & & & &2 2 2    , , , , ,r=   r  c                   $    e Zd ZdZd Zd Zd ZdS )SocketTestBasezA base class for socket tests.

    Subclasses must provide methods newSocket() to return a new socket
    and bindSock(sock) to bind it to an unused address.

    Creates a socket self.serv and sets self.serv_addr to its address.
    c                 `    |                                  | _        |                                  d S rD   )	newSocketrP   
bindServerrT   s    r   rV   zSocketTestBase.setUpP  s)    NN$$	r=   c                 v    |                      | j                   | j                                        | _        dS )z9Bind server socket and set self.serv_addr to its address.N)bindSockrP   r   	serv_addrrT   s    r   r(  zSocketTestBase.bindServerT  s/    di   ..00r=   c                 F    | j                                          d | _         d S rD   rX   rT   s    r   rY   zSocketTestBase.tearDownY  rZ   r=   N)r\   r]   r^   ry   rV   r(  rY   r_   r=   r   r%  r%  G  sK           1 1 1
    r=   r%  c                   "     e Zd ZdZ fdZ xZS )SocketListeningTestMixinz%Mixin to listen on the server socket.c                 z    t                                                       | j                                         d S rD   )rj   rV   rP   rS   rU   rr   s    r   rV   zSocketListeningTestMixin.setUpa  s.    	r=   )r\   r]   r^   ry   rV   rz   r{   s   @r   r.  r.  ^  s>        //        r=   r.  c                   :     e Zd ZdZ fdZd Zd Zd Zd Z xZ	S )ThreadedSocketTestMixinzMixin to add client socket and allow client/server tests.

    Client socket is self.cli and its address is self.cli_addr.  See
    ThreadableTest for usage information.
    c                 n     t                      j        |i | t                              |            d S rD   )rj   rk   r   ro   s      r   rk   z ThreadedSocketTestMixin.__init__n  s9    $)&)))%%%%%r=   c                 `    |                                  | _        |                                  d S rD   )newClientSocketr   
bindClientrT   s    r   r   z#ThreadedSocketTestMixin.clientSetUpr  s+    ''))r=   c                 *    |                                  S )z&Return a new socket for use as client.)r'  rT   s    r   r5  z'ThreadedSocketTestMixin.newClientSocketv  s    ~~r=   c                 v    |                      | j                   | j                                        | _        dS )z8Bind client socket and set self.cli_addr to its address.N)r*  r   r   r   rT   s    r   r6  z"ThreadedSocketTestMixin.bindClientz  s/    dh,,..r=   c                 z    | j                                          d | _         t                              |            d S rD   r   rT   s    r   r   z&ThreadedSocketTestMixin.clientTearDown  r   r=   )
r\   r]   r^   ry   rk   r   r5  r6  r   rz   r{   s   @r   r2  r2  f  s~         & & & & &       / / /
, , , , , , ,r=   r2  c                   @     e Zd ZdZ fdZ fdZ fdZ fdZ xZS )ConnectedStreamTestMixinzMixin to allow client/server stream tests with connected client.

    Server's socket representing connection to client is self.cli_conn
    and client's connection to server is self.serv_conn.  (Based on
    SocketConnectedTest.)
    c                     t                                                       |                                  | j                                        \  }}|| _        d S rD   )rj   rV   r   rP   r   r  )rU   r   r  rr   s      r   rV   zConnectedStreamTestMixin.setUp  sJ     	  """Y%%''
dr=   c                     | j                                          d | _         t                                                       d S rD   )r  r    rj   rY   r0  s    r   rY   z!ConnectedStreamTestMixin.tearDown  s:    r=   c                     t                                                       | j                            | j                   | j        | _        d S rD   )rj   r   r   r   r+  r  r0  s    r   r   z$ConnectedStreamTestMixin.clientSetUp  s>    (((r=   c                     	 | j                                          d | _         n# t          $ r Y nw xY wt                                                       d S rD   )r  r    r!   rj   r   r0  s    r   r   z'ConnectedStreamTestMixin.clientTearDown  sa    	N  """!DNN 	 	 	D	     s    $ 
11)	r\   r]   r^   ry   rV   rY   r   r   rz   r{   s   @r   r;  r;    s                 
" " " " "
! ! ! ! ! ! ! ! !r=   r;  c                   (     e Zd ZdZ fdZd Z xZS )UnixSocketTestBasez(Base class for Unix-domain socket tests.c                     t          j                    | _        |                     t          j        | j                   t                                                       d S rD   )tempfilemkdtempdir_pathrt   osrmdirrj   rV   r0  s    r   rV   zUnixSocketTestBase.setUp  s@     (**$-000r=   c                     t          j        | j                  }t          j        ||           |                     t          j        |           d S )N)dir)rC  mktemprE  r   bind_unix_socketrt   r   unlink)rU   sockpaths      r   r*  zUnixSocketTestBase.bindSock  sF    4=111&tT222	($/////r=   )r\   r]   r^   ry   rV   r*  rz   r{   s   @r   rA  rA    sM        22    
0 0 0 0 0 0 0r=   rA  c                       e Zd ZdZd ZdS )UnixStreamBasez-Base class for Unix-domain SOCK_STREAM tests.c                 T    t          j         t           j        t           j                  S rD   )r   AF_UNIXr@   rT   s    r   r'  zUnixStreamBase.newSocket      }V^V-?@@@r=   Nr\   r]   r^   ry   r'  r_   r=   r   rP  rP    s.        77A A A A Ar=   rP  c                   ,     e Zd ZdZeZ fdZd Z xZS )InetTestBasez!Base class for IPv4 socket tests.c                 l    t                                                       | j        d         | _        d S Nr   )rj   rV   r+  rR   r0  s    r   rV   zInetTestBase.setUp  s&    N1%			r=   c                 <    t          j        || j                   d S )Nhost)r   rQ   r[  rU   rM  s     r   r*  zInetTestBase.bindSock  s     49555555r=   )	r\   r]   r^   ry   r   r[  rV   r*  rz   r{   s   @r   rV  rV    sR        ++D& & & & &6 6 6 6 6 6 6r=   rV  c                       e Zd ZdZd ZdS )TCPTestBasez#Base class for TCP-over-IPv4 tests.c                 T    t          j         t           j        t           j                  S rD   )r   rO   r@   rT   s    r   r'  zTCPTestBase.newSocket  rS  r=   NrT  r_   r=   r   r^  r^    .        --A A A A Ar=   r^  c                       e Zd ZdZd ZdS )UDPTestBasez#Base class for UDP-over-IPv4 tests.c                 T    t          j         t           j        t           j                  S rD   )r   rO   r'   rT   s    r   r'  zUDPTestBase.newSocket  s    }V^V->???r=   NrT  r_   r=   r   rb  rb    s.        --@ @ @ @ @r=   rb  c                       e Zd ZdZd ZdS )UDPLITETestBasez'Base class for UDPLITE-over-IPv4 tests.c                 j    t          j         t           j        t           j        t           j                  S rD   )r   rO   r'   rJ   rT   s    r   r'  zUDPLITETestBase.newSocket  s    }V^V->@VWWWr=   NrT  r_   r=   r   re  re    s.        11X X X X Xr=   re  c                       e Zd ZdZd ZdS )SCTPStreamBasez;Base class for SCTP tests in one-to-one (SOCK_STREAM) mode.c                 j    t          j         t           j        t           j        t           j                  S rD   )r   rO   r@   IPPROTO_SCTPrT   s    r   r'  zSCTPStreamBase.newSocket  s%    }V^V-?#02 2 	2r=   NrT  r_   r=   r   rh  rh    s)        EE2 2 2 2 2r=   rh  c                        e Zd ZdZej        ZdS )Inet6TestBasez!Base class for IPv6 socket tests.N)r\   r]   r^   ry   r   HOSTv6r[  r_   r=   r   rl  rl    s        ++DDDr=   rl  c                       e Zd ZdZd ZdS )UDP6TestBasez#Base class for UDP-over-IPv6 tests.c                 T    t          j         t           j        t           j                  S rD   )r   AF_INET6r'   rT   s    r   r'  zUDP6TestBase.newSocket  s    }V_f.?@@@r=   NrT  r_   r=   r   ro  ro    r`  r=   ro  c                       e Zd ZdZd ZdS )UDPLITE6TestBasez'Base class for UDPLITE-over-IPv6 tests.c                 j    t          j         t           j        t           j        t           j                  S rD   )r   rq  r'   rJ   rT   s    r   r'  zUDPLITE6TestBase.newSocket  s    }V_f.?AWXXXr=   NrT  r_   r=   r   rs  rs    s.        11Y Y Y Y Yr=   rs  c                 *    d fd}d }| r|n|S )a  Skip decorated test if condition is true, add client_skip decorator.

    If the decorated object is not a class, sets its attribute
    "client_skip" to a decorator which will return an empty function
    if the test is to be skipped, or the original function if it is
    not.  This can be used to avoid running the client part of a
    skipped test when using ThreadableTest.
    c                      d S rD   r_   )rp   rq   s     r   client_passz%skipWithClientIf.<locals>.client_pass  r"  r=   c                      t          j                  |           }t          | t                    s
fd|_        |S )Nc                     S rD   r_   )r   rw  s    r   <lambda>z3skipWithClientIf.<locals>.skipdec.<locals>.<lambda>
  s    ; r=   )r   skip
isinstancetypeclient_skip)objretvalrw  reasons     r   skipdecz!skipWithClientIf.<locals>.skipdec  sD    &v&&s++#t$$ 	7!6!6!6!6Fr=   c                 `    t          | t                    st          | d          sd | _        | S )Nr~  c                     | S rD   r_   )r   s    r   rz  z5skipWithClientIf.<locals>.noskipdec.<locals>.<lambda>  s     r=   )r|  r}  r   r~  )r  s    r   	noskipdecz#skipWithClientIf.<locals>.noskipdec  s3    3%% 	*m)D)D 	*)kCO
r=   r_   )	conditionr  r  r  rw  s    `  @r   skipWithClientIfr    sQ           
    .77Y.r=   c                       fd|D             }t          |dd                    d |D                       z             S )zSkip decorated test if obj is missing any of the given attributes.

    Sets client_skip attribute as skipWithClientIf() does.
    c                 4    g | ]}t          |          |S r_   )r   ).0namer  s     r   
<listcomp>z requireAttrs.<locals>.<listcomp>  s(    EEE'#t2D2DEtEEEr=   don't have , c              3      K   | ]}|V  d S rD   r_   r  r  s     r   	<genexpr>zrequireAttrs.<locals>.<genexpr>  s"      *D*DD4*D*D*D*D*D*Dr=   )r  join)r  
attributesmissings   `  r   requireAttrsr    sY    
 FEEE
EEEG*D*DG*D*D*D!D!DDF F Fr=   c            	         d}d | D             }|r#dd                     d |D                       z   }nVd | D             }	 t          j        | }|                                 n&# t          $ r}t	          |          }Y d}~nd}~ww xY wt          |dud                    d                     d | D                       |                    S )	a  Skip decorated test if a socket cannot be created with given arguments.

    When an argument is given as a string, will use the value of that
    attribute of the socket module, or skip the test if it doesn't
    exist.  Sets client_skip attribute as skipWithClientIf() does.
    Nc                 f    g | ].}t          |t                    t          t          |          ,|/S r_   )r|  strr   r   r  r  s     r   r  z!requireSocket.<locals>.<listcomp>%  sP     B B Bs#s##B,3FC,@,@Bs B B Br=   r  r  c              3      K   | ]}|V  d S rD   r_   r  s     r   r  z requireSocket.<locals>.<genexpr>(  s"      'A'A'A'A'A'A'A'Ar=   c                 f    g | ].}t          |t                    rt          t          |          n|/S r_   )r|  r  r   r   r  s     r   r  z!requireSocket.<locals>.<listcomp>*  sF     % % % -7sC,@,@IGFC(((c % % %r=   zcan't create socket({0}): {1}c              3   4   K   | ]}t          |          V  d S rD   )r  r  os     r   r  z requireSocket.<locals>.<genexpr>6  s(      ++c!ff++++++r=   )r  r   r    r   r  r  format)rp   errr  callargsr#   r   s         r   requireSocketr    s    CB Bd B B BG dii'A'A'A'A'AAAA% %#% % %	x(A
 GGIIII	  	 	 	a&&CCCCCC	
 4'..II++d+++++S	2 	23 3 3s   A$ $
B.BBc            	       
   e Zd Zd Zd Z ej        edud          d             Zd Z	d Z
d Zd	 Zd
 Z ej        ej        dk    d          d             Z ej        ej        d          d             Z ej        ej        dk    d           ej        ej        d          d                         Zd Zd Zd Z ej         eed          d           ej         eed          d          d                         Z ej         eed          d          d             Z  ej         eed          d           d!             Z! ej         eed"          d#          d$             Z" ej         eed%          d&          d'             Z#d( Z$d) Z%ej&        d*             Z'd+ Z(d, Z) ej         eed-          d.          d/             Z* ej         eed0          d1          d2             Z+ ej         eed0          d1          d3             Z, ej         eed4          d5          d6             Z- ej         eed4          d5          d7             Z.d8 Z/d9 Z0d: Z1d; Z2d< Z3d= Z4d> Z5 ej        ej        dk    d          d?             Z6 ej        ej        dk    d           ej         eed@          dA          dB                         Z7dC Z8dD Z9 ej         ej:        dE          dF          dG             Z;dH Z<dI Z=dJ Z>dK Z?dL Z@dM ZAdN ZBdO ZCdP ZDdQ ZEdR ZFej&        dS             ZG ej        ej        dT          dU             ZH ej        ej        dT          dV             ZIdW ZJ ej        ej        dT           ej        ej        dXk    dY           ej        eKdZ           ej         eed          d[          d\                                                 ZL ej        ej        dT           ej        ej        dXk    d]          d^                         ZM ej        ej        dT           ej        ej        dXk    dY           ej        eKdZ           ej         eed          d[          d_                                                 ZN ej        ej        dT           ej        ej        dXk    d]          d`                         ZOda ZPdb ZQdc ZR ej         eedd          de          df             ZSdg ZTdh ZUdi ZVdj ZWdk ZX ej        ej        dk    dl          dm             ZYdn ZZdo Z[dp Z\dq Z]dr Z^ds Z_dS )tGeneralModuleTestsc                     dd l }|                     t          j        |j        u            t          j                    }|                     |t          j                   |                                 d S r   )_socket
assertTruer   
SocketTypeassertIsInstancer    )rU   r  r#   s      r   test_SocketType_is_socketobjectz2GeneralModuleTests.test_SocketType_is_socketobject>  s\    )W^;<<<MOOa!2333						r=   c                    t          j         t           j        t           j                  }|5  |                     d|                                z  t          |                     |                     dt           j        z  t          |                     |                     dt           j        z  t          |                     |                     dt          |                     |                     dt          |                     |                    d           |                     dt          |                     |                     t          |	                                          t          |                     d d d            n# 1 swxY w Y   |                     dt          |                     |                     dt          |                     d S )	Nzfd=%iz	family=%sztype=%szproto=0raddr	127.0.0.1r   laddrz[closed])
r   rO   r@   assertInfilenoreprassertNotInr   r  r   rU   r#   s     r   	test_reprzGeneralModuleTests.test_reprE  s   M&.&*<== 	9 	9MM'AHHJJ.Q888MM+6Q@@@MM)f&88$q''BBBMM)T!WW---Wd1gg...FF#$$$MM'477+++MM#ammoo..Q888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	j$q''***$q''*****s   EFFFNzneed _socket modulec           	         t          j        t           j        t           j                  }d|                                d|j        d|j        d|j        d	}|                     t          |          |           |
                                 n# |
                                 w xY wd|j        d|j        d|j        d}|                     t          |          |           d S )Nz<socket object, fd=z	, family=z, type=z, proto=>z<socket object, fd=-1, family=)r  r   rO   r@   r  familyr}  protor  r  r    )rU   r#   expecteds      r   test_csocket_reprz$GeneralModuleTests.test_csocket_reprS  s    N7?G,?@@	88::::qxxxBHT!WWh///GGIIIIAGGIIIIIxxx2a(+++++s   AB B(c                    t          j         t           j        t           j                  5 }t          |          }|                     |                                |                                           d d d            n# 1 swxY w Y   d }t          j                     	 |                                 |                     d           d S # t          $ r Y d S w xY w)NzSocket proxy still exists)
r   rO   r@   r   r  r  r   
gc_collectfailReferenceError)rU   r#   ps      r   test_weakrefzGeneralModuleTests.test_weakref`  s   ]6>6+=>> 	5!aAQXXZZ444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	3HHJJJ II122222  	 	 	DD	s$   A
B  BB!C 
CCc                 J   d}|                      t          |dz            5  t          # 1 swxY w Y   |                      t          |dz            5  t          j        # 1 swxY w Y   |                      t          |dz            5  t          j        # 1 swxY w Y   d S )Nz$Error raising socket exception (%s).r   r  zsocket.herrorzsocket.gaierror)assertRaisesr   r   herrorgaierrorr  s     r   testSocketErrorz"GeneralModuleTests.testSocketErrorm  s   4wC)O<< 	 	M	 	 	 	 	 	 	 	wC/,ABB 	  	 -	  	  	  	  	  	  	  	 wC2C,CDD 	" 	"/!	" 	" 	" 	" 	" 	" 	" 	" 	" 	"s0   *..A!!A%(A%BBBc                 
	   t          j         t           j        t           j                  }|                     |j                   |                    d           |                                }|                     t                    5 }|	                    d|           d d d            n# 1 swxY w Y   | 
                    t          |j                  d           |                     t                    5 }|	                    d|           d d d            n# 1 swxY w Y   | 
                    t          |j                  d           |                     t                    5 }|	                    dd            d d d            n# 1 swxY w Y   |                     dt          |j                             |                     t                    5 }|	                    dd|           d d d            n# 1 swxY w Y   | 
                    t          |j                  d           |                     t                    5 }|	                    dd|           d d d            n# 1 swxY w Y   | 
                    t          |j                  d           |                     t                    5 }|	                    ddd            d d d            n# 1 swxY w Y   |                     dt          |j                             |                     t                    5 }|	                    dd	|           d d d            n# 1 swxY w Y   |                     t                    5 }|	                    dd d            d d d            n# 1 swxY w Y   |                     t                    5 }|	                    d           d d d            n# 1 swxY w Y   |                     d
t          |j                             |                     t                    5 }|	                    dd|d           d d d            n# 1 swxY w Y   |                     dt          |j                             d S )N) r   u   ☠z*a bytes-like object is required, not 'str'y              @z.a bytes-like object is required, not 'complex'   fooznot NoneTyper   barz	(1 given)   z	(4 given))r   rO   r'   rt   r    r   r   r  r   sendtor  r  	exceptionr  )rU   r#   socknamecms       r   testSendtoErrorsz#GeneralModuleTests.testSendtoErrorsw  s@   M&.&*;<<   	w==??y)) 	)RHHXx(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)R\**E	G 	G 	Gy)) 	#RHHR"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#R\**I	K 	K 	Ky)) 	#RHHVT"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#nS%6%6777y)) 	,RHHXq(+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,R\**E	G 	G 	Gy)) 	&RHHRH%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&R\**I	K 	K 	Ky)) 	&RHHVQ%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&nc",&7&7888y)) 	.RHHVUH---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.y)) 	)RHHVT4(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) y)) 	RHHV	 	 	 	 	 	 	 	 	 	 	 	 	 	 	k3r|#4#4555y)) 	-RHHVQ!,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-k3r|#4#455555s   B**B.1B.7DD!D'F

FFG;;G?G?I,,I03I09KK!$K!*MMM3NNN<OO"%O"+QQQc                     t           j         t           j        rt           j         t           j         t           j         t           j         t           j         t           j         t           j	         t           j
         d S rD   )r   rO   has_ipv6rq  r@   r'   r   SOCK_RDMr0   
SOL_SOCKETSO_REUSEADDRrT   s    r   testCrucialConstantsz'GeneralModuleTests.testCrucialConstants  s[    ? 	OOr=   c                 j    t           j         t           j         t           j        rt           j         d S d S rD   )r   IPPROTO_TCPIPPROTO_UDPr  IPPROTO_IPV6rT   s    r   testCrucialIpProtoConstantsz.GeneralModuleTests.testCrucialIpProtoConstants  s7    ? 	 	  	 r=   ntWindows specificc                     t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         d S rD   )	r   IPPROTO_ICLFXBM
IPPROTO_STIPPROTO_CBTIPPROTO_IGPIPPROTO_RDPIPPROTO_PGMIPPROTO_L2TPrj  rT   s    r   testWindowsSpecificConstantsz/GeneralModuleTests.testWindowsSpecificConstants  sP    r=   zWASI is missing these methodsc                 ~    g d}|D ]5}t          t          j        |          s|                     d| d           6d S )N)_acceptr   r   
connect_exgetpeernamer   rS   recvfromrecvfrom_intor  
setsockoptshutdownzsocket method z is missing)r   r   r  )rU   namesr  s      r   test_socket_methodsz&GeneralModuleTests.test_socket_methods  sa    
 
 

  	> 	>D6=$// >		<4<<<===	> 	>r=   darwinmacOS specific testIPv6 required for this testc                 r    h d}|D ]/}|                      t          t          |          d| d           0d S )N>   
IPV6_RTHDRIPV6_TCLASSIPV6_DSTOPTSIPV6_HOPOPTSIPV6_NEXTHOPIPV6_PATHMTUIPV6_PKTINFOIPV6_CHECKSUMIPV6_DONTFRAGIPV6_HOPLIMITIPV6_RECVRTHDRIPV6_RECVTCLASSIPV6_RECVDSTOPTSIPV6_RECVHOPOPTSIPV6_RECVPATHMTUIPV6_RECVPKTINFOIPV6_USE_MIN_MTUIPV6_RECVHOPLIMITIPV6_RTHDRDSTOPTSIPV6_RTHDR_TYPE_0zMissing RFC3542 socket option '')r  r   r   )rU   optsopts      r   test3542SocketOptionsz(GeneralModuleTests.test3542SocketOptions  sd    
 
 
,  	 	COO$$&N&N&N&N   	 	r=   c                    t          j                    }	 t          j        |          }n%# t          $ r |                     d           Y nw xY w|                     |                    d          dk    d           	 t          j        |          \  }}}n%# t          $ r |                     d           Y nw xY w||g|z   }t          j        |          }||vr+| 	                    d|dt          |          d           d S d S )Nname lookup failurer   r   zError resolving host to ip.z1Error testing host resolution mechanisms. (fqdn: z, all: ))r   gethostnamegethostbynamer   r   r  findgethostbyaddrgetfqdnr  r  )rU   hostnameiphnamealiasesipaddrsall_host_namesfqhns           r   testHostnameResz"GeneralModuleTests.testHostnameRes  s<   %''	1%h//BB 	1 	1 	1MM/00000	1 	)+HIII	1&,&:2&>&>#E7GG 	1 	1 	1MM/00000	1 #E*W4~b!!~%%IIIY]Y]Y]_cdr_s_s_s_stuuuuu &%s!   * AA=B B87B8c                     t           j        ddfD ]*}|                     t          j        |          |           +t           j        fD ]0}|                     |t          j        |          d                    1d S )Nz10.0.0.1255.255.255.255r   )r   HOSTv4r  r   r  r  r  )rU   r  r[  s      r   test_host_resolutionz'GeneralModuleTests.test_host_resolution  s    "):7HI 	? 	?DV1$77>>>> #)* 	? 	?DMM$ 4T : :1 =>>>>	? 	?r=   c                 4   d}dD ]}|                      t          |          5  t          j        |           d d d            n# 1 swxY w Y   |                      t          |          5  t          j        |           d d d            n# 1 swxY w Y   d S )Nz[resolving an invalid IP address did not raise OSError; can be caused by a broken DNS server)z0.1.1.~1z1+.1.1.1z::1qz::1::2z1:1:1:1:1:1:1:1:1r  )r  r   r   r  r  )rU   explanationr  s      r    test_host_resolution_bad_addressz3GeneralModuleTests.test_host_resolution_bad_address  s&   3 	* 	+ 	+D""7"55 + +$T***+ + + + + + + + + + + + + + +""7"<< + +$T***+ + + + + + + + + + + + + + +		+ 	+s#   AA	A	+BB	B	sethostnameztest needs socket.sethostname()r  ztest needs socket.gethostname()c                    t          j                    }	 t          j        d           nC# t          $ r6}|j        t          j        k    r|                     d           n Y d }~nd }~ww xY w	 |                     t          j                    d           t          j        d           |                     t          j                    d           t          j        |           d S # t          j        |           w xY w)Nnewztest should be run as roots   barr  )r   r  r%  r   errnoEPERMr   r  )rU   oldhnr   s      r   test_sethostnamez#GeneralModuleTests.test_sethostname  s    "$$	u%%%% 	 	 	w%+%%:;;;; <;;;;	
	&V/115999v&&&V/115999u%%%%%Fu%%%%s!   * 
A*,A%%A*.A"C& &C<if_nameindexz$socket.if_nameindex() not available.c                    t          j                    }|D ]\  }}|                     |t                     |                     |t                     |                     |d           t          j        |          }|                     |t                     |                     ||           t          j        |          }|                     |t                     |                     ||           d S r   )	r   r,  r  intr  assertGreaterif_nametoindexr  if_indextoname)rU   
interfacesindexr  _index_names         r   testInterfaceNameIndexz)GeneralModuleTests.testInterfaceNameIndex,  s     (**
% 
	* 
	*KE4!!%---!!$,,,ua(((*400F!!&#...UF+++)%00E!!%---T5))))
	* 
	*r=   r1  z&socket.if_indextoname() not available.c                     |                      t          t          j        d           |                      t          t          j        d           d S Nr   	_DEADBEEF)r  r   r   r1  r   rT   s    r   testInvalidInterfaceIndexToNamez2GeneralModuleTests.testInvalidInterfaceIndexToName<  s@     	'6#8!<<<)V%:KHHHHHr=   r0  z&socket.if_nametoindex() not available.c                     |                      t          t          j        d           |                      t          t          j        d           d S r8  )r  r   r   r0  r   rT   s    r   testInvalidInterfaceNameToIndexz2GeneralModuleTests.testInvalidInterfaceNameToIndexB  s@     	)V%:A>>>'6#8+FFFFFr=   getrefcountztest needs sys.getrefcount()c                     	 t          j        t                    }t          j        t          d           d S # t
          $ r9 t          j        t                    |k    r|                     d           Y d S Y d S w xY w)Nr   z$socket.getnameinfo loses a reference)sysr=  r\   r   getnameinfor   r  )rU   origs     r   testRefCountGetNameInfoz*GeneralModuleTests.testRefCountGetNameInfoH  s    	B?8,,Dx***** 	B 	B 	Bx((D00		@AAAAAA 100	Bs   37 <A:9A:c                 T    	 t          j        dd           d S # t          $ r Y d S w xY w)N)r   r   r   r   r   )r   r@  r   rT   s    r   testInterpreterCrashz'GeneralModuleTests.testInterpreterCrashT  sB    	~q11111 	 	 	DD	s    
''c                    t           j        dt           j        dt           j        dt           j        di}|                                D ]\  }}d|z  dz
  }dD ]3}|                     ||z   | |||z                      |z             4 ||          }|                     ||z  |           |                     t          |d           d S )N       r   )r   r     i  r   igE#i2Tvl        )	r   htonlntohlhtonsntohsitemsr  r  OverflowError)rU   sizesfuncsizemaskrK   swappeds          r   testNtoHzGeneralModuleTests.testNtoH\  s     r6<r6<5++-- 	: 	:JD$tGq=DG F F  T44QtV+=+=+DEEEEd4jjGWt^T222mT59999	: 	:r=   c                 n   dd l }g d}|dgz   }dddddz  g}||j        dz
  |j        dz   gz   d	|j        gz   }|D ]*}t          j        |           t          j        |           +|D ]*}t          j        |           t          j        |           +|D ]N}|                     t          t          j        |           |                     t          t          j        |           O|D ]N}|                     t          t          j        |           |                     t          t          j        |           Od S )
Nr   )r   r   r   rH      l        r        )
	_testcapiINT_MININT_MAXr   rL  rK  rJ  rI  r  rN  )rU   r[  s_good_valuesl_good_valuesl_bad_valuess_bad_valuesks          r   testNtoHErrorsz!GeneralModuleTests.testNtoHErrorsj  sZ   )))%4Bq$w/q )"3A"567i'() 	
  	 	ALOOOLOOOO 	 	ALOOOLOOOO 	> 	>AmV\1===mV\1==== 	> 	>AmV\1===mV\1====	> 	>r=   c                 L   | j         }t          j                            d          st          j        dv rd}nd}|D ])}	 t	          j        |d          } n# t          $ r Y &w xY wt          t          t          d          rt          j                    dk    r t	          j        |          } |||           	 t	          j        |d          } |||           n# t          $ r d }Y nw xY wt          j
        s |t	          j        |          |            |t	          j        |d          |           | |t	          j        |d          |           |                     t          t          j        d	           |                     t          t          j        d
           d S )N)freebsdnetbsdgnukfreebsd)linuxr  )daytimeqotddomain)echori  rk  tcpgetandroidapilevel   udprW  rZ  )r  r?  platform
startswithr   getservbynamer   r   rn  r   
is_androidgetservbyportr  rN  )rU   eqservicesservicerR   port2udpports          r   testGetServByz GeneralModuleTests.testGetServBy  s    L##$HII 	5|222 5HH4H 	 	G+GU;;    M 122 	&((B..(11EBtUOOO	*7E::G Bw  	 	 	GGG	 ! 	5Bv#E**G444
6e,,g666Bv#GU33W===-)=rBBB-)=uEEEEEs#   A
A#"A#:C C+*C+c                    |                      t          j                    d            t          j                    5 }|                      |                                d            d d d            n# 1 swxY w Y   t	          d          5  |                      t          j                    d           t          j                    5 }|                      |                                d           d d d            n# 1 swxY w Y   t          j        d            |                      t          j                    d            t          j                    5 }|                      |                                d            d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                     t          t          j        d           |                     t          t          j        d           d S )N
   rW  spam)	r  r   rE   
gettimeoutrI   rF   r  
ValueErrorr   )rU   r#   rM  s      r   testDefaultTimeoutz%GeneralModuleTests.testDefaultTimeout  s    	133T:::]__ 	3Q\\^^T222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 &b)) 		: 		:V577<<< 8D  !2!2B7778 8 8 8 8 8 8 8 8 8 8 8 8 8 8 $T***V577>>> :D  !2!2D999: : : : : : : : : : : : : : :		: 		: 		: 		: 		: 		: 		: 		: 		: 		: 		: 		: 		: 		: 		: 	*f&>CCC 	)V%=vFFFFFsl   )A00A47A4
;F)C:.F:C>	>FC>	AF)F<FF	FF	FF#&F#	inet_atonztest needs socket.inet_aton()c                     |                      dt          j        d                     |                      dt          j        d                     d S )N       0.0.0.0   r  )r  r   r  rT   s    r   testIPv4_inet_aton_fourbytesz/GeneralModuleTests.testIPv4_inet_aton_fourbytes  sM    
 	F$4Y$?$?@@@F$45F$G$GHHHHHr=   	inet_ptonztest needs socket.inet_pton()c                 b    ddl m}mm fd} fd}                     d |d                                          d |d                                          d	 |d
                                          d |d                                          d |d                     t
          s ||d            ||d            ||d            ||d            ||d                                d |d                                          d |d                                          d	 |d
                                          d |d                      ||d            ||d            ||d            ||d            ||d           d S )Nr   )r  r  rO   c                      |           S rD   r_   )arO   r  s    r   rz  z5GeneralModuleTests.testIPv4toString.<locals>.<lambda>      ii++ r=   c                 J                         t          t          f| |          S rD   r  r   r  rP  r  rU   s     r   rz  z5GeneralModuleTests.testIPv4toString.<locals>.<lambda>  #    t'8'8j!4(
 (
 r=   r  r  s     z255.0.255.0s   z170.170.170.170   1.2.3.4r  r  z0.0.0.z	300.0.0.0za.0.0.0z	1.2.3.4.5::1)r   r  r  rO   r  r   )rU   r   gassertInvalidrO   r  s   `   @@r   testIPv4toStringz#GeneralModuleTests.testIPv4toString  s7    	>=========+++++
 
 
 
 	,aa	ll;;;,aa.>.>???,aa0A.B.BCCC,aa	ll;;;,aa0A.B.BCCC 	'M!X&&&a%%%a###a%%%a,aa	ll;;;,aa.>.>???,aa0A.B.BCCC,aa0A.B.BCCCa"""a%%%a###a%%%ar=   c                     	 ddl mmm} |s                     d           n%# t
          $ r                      d           Y nw xY wt          j        dk    rE	  d           n7# t          $ r*}|j	        dk    r                     d           Y d }~nd }~ww xY wfd	 fd
} 
                    d d                      
                    d d                      
                    d d                      
                    d d                      
                    d d                      
                    d d                      |d            |d            |d            |d            |d            |d            |d            |d           t          s |d            
                    d d                      
                    d  d!                      
                    d" d#                      |d$            |d%            |d&            |d'            |d(            |d)           d S )*Nr   )r  rq  r  IPv6 not available+could not import needed symbols from socketwin32::&'  IPv6 might not be supportedc                      |           S rD   r_   )r  rq  r  s    r   rz  z5GeneralModuleTests.testIPv6toString.<locals>.<lambda>      ii!,, r=   c                 J                         t          t          f|           S rD   r  r  r   rU   s    r   rz  z5GeneralModuleTests.testIPv6toString.<locals>.<lambda>  #    $"3"3j!1a#
 #
 r=                      z0::0s                  z1::s   Ev V$z$45ef:76cb:1a:56ef:afeb:bac:1924:aeaes   B
    '  T zad42:abc::127:0:254:2s     
            z12:a::z0x20::z:::z::0::z1::abc::z1::abc::defz1:2:3:4:5:6z1:2:3:4:5:6:z1:2:3:4:5:6:7:8:0z1:2:3:4:5:6:7:8:s               *@z::254.42.23.64s    B        *@z42::a29b:254.42.23.64s    B   *@z"42:a8b9:0:2:ffff:a29b:254.42.23.64z255.254.253.252z1::260.2.3.0z1::0.be.e.0z1:2:3:4:5:6:7:1.2.3.4z::1.2.3.4:0z0.100.200.0:3:4:5:6:7:8)r   r  rq  r  r   ImportErrorr?  rq  r   winerrorr  r   )rU   r  r   r  rq  r   r  s   `   @@@r   testIPv6toStringz#GeneralModuleTests.testIPv6toString  st   	I<<<<<<<<<< 42333 	I 	I 	IMMGHHHHH	I <7""A	(D)))) A A A:&&MM"?@@@A -,,,,
 
 
 
 
 	qqww///qqyy1113QQuXX>>>OA455	
 	
 	
 	SA%&&	
 	
 	
 	;QQx[[IIIhegj!!!m$$$m$$$n%%%)*** 	.M,---;A	
 	
 	
 	CA%&&	
 	
 	
 	OA233	
 	
 	
 	'(((n%%%m$$$-...m$$$/00000'   !( A
	A
A+ +
B5 BB	inet_ntopztest needs socket.inet_ntop()c                 (    ddl m}mm fd} fd}                     d |d                                          d |d                                          d	 |d
                                          d |d                      ||d            ||d            ||d                                d |t          d                                                    d |d                                          d |d                                          d	 |d
                      ||d            ||d            ||d                                d |t          d                               d S )Nr   )	inet_ntoar  rO   c                      |           S rD   r_   )r  rO   r  s    r   rz  z5GeneralModuleTests.testStringToIPv4.<locals>.<lambda>4  r  r=   c                 J                         t          t          f| |          S rD   r  r  s     r   rz  z5GeneralModuleTests.testStringToIPv4.<locals>.<lambda>5  r  r=   z1.0.1.0s     z170.85.170.85s   UUr  r  r  r  s      s        r  )r   r  r  rO   r  	bytearray)rU   r   r  r  rO   r  s   `   @@r   testStringToIPv4z#GeneralModuleTests.testStringToIPv40  s    	>=========+++++
 
 
 
 	AA&9$:$:;;;!!,?*@*@AAA*AA.A,B,BCCCAA&9$:$:;;;a%%%a%%%a&&&!!I6I,J,J*K*KLLLAA&9$:$:;;;!!,?*@*@AAA*AA.A,B,BCCCa%%%a%%%a&&&!!I6I,J,J*K*KLLLLLr=   c                     	 ddl mmm} |s                     d           n%# t
          $ r                      d           Y nw xY wt          j        dk    rE	  d           n7# t          $ r*}|j	        dk    r                     d           Y d }~nd }~ww xY wfd	 fd
} 
                    d d                      
                    d d                      
                    d d                      
                    d t          d                                |d            |d            |d           d S )Nr   )r  rq  r  r  r  r  r  r  r  c                      |           S rD   r_   )r  rq  r  s    r   rz  z5GeneralModuleTests.testStringToIPv6.<locals>.<lambda>[  r  r=   c                 J                         t          t          f|           S rD   r  r  s    r   rz  z5GeneralModuleTests.testStringToIPv6.<locals>.<lambda>\  r  r=   r  r  s                  z!aef:b01:506:1001:ffff:9997:55:170s   
 Ups   s   s   )r   r  rq  r  r   r  r?  rq  r   r  r  r  )rU   r  r   r  rq  r   r  s   `   @@@r   testStringToIPv6z#GeneralModuleTests.testStringToIPv6J  s   	I<<<<<<<<<< 42333 	I 	I 	IMMGHHHHH	I <7""A	(L1111 A A A:&&MM"?@@@A -,,,,
 
 
 
 
 	qq///"8 9 9:::/AQRR	
 	
 	
 	),B"C"C D DEEEl###l###k"""""r  c                    t          j         t           j        t           j                  }|                     |j                   t          j                    D ]a}t          j                    }	 |	                    d|f            n3# t          $ r&}|j        t          j        k    s|dk    r Y d }~Zd }~ww xY w|                                }	 t          j        t          j                              }n%# t          $ r |                     d           Y nw xY w|                     |d         d|fd|d         z             |                     |d         |           d S )Nr     r  r   z
%s invalidr   )r   rO   r@   rt   r    	itertoolscountr   find_unused_portr   r   r(  
EADDRINUSEr   r  r  r   r  r  )rU   rM  rK   rR   r   r  
my_ip_addrs          r   testSockNamezGeneralModuleTests.testSockNamen  sp   }V^V-?@@
### "" 	 	A 133D		9d+,,,
 	    7e...!q&& 39&&&& !!	1-f.@.B.BCCJJ 	1 	1 	1MM/00000	1 	d1g	:6tAw8NOOOa$'''''s*   -B
B6B11B6%C4 4DDc                    t          j         t           j        t           j                  }|                     |j                   |                    t           j        t           j                  }|                     |dk    d           d S )Nr   zinitial mode is reuse)	r   rO   r@   rt   r    
getsockoptr  r  assertFalserU   rM  reuses      r   testGetSockOptz!GeneralModuleTests.testGetSockOpt  sh     }V^V-?@@
### 163FGG!%<=====r=   c                 j   t          j         t           j        t           j                  }|                     |j                   |                    t           j        t           j        d           |                    t           j        t           j                  }| 	                    |dk    d           d S )Nr   r   zfailed to set reuse mode)
r   rO   r@   rt   r    r  r  r  r  r  r  s      r   testSetSockOptz!GeneralModuleTests.testSetSockOpt  s    }V^V-?@@
###)6+>BBB 163FGG!%?@@@@@r=   c                     t          j         t           j        t           j                  5 }|                    d           d d d            n# 1 swxY w Y   |                     t
          |j        d           d S )Nr      spam)r   rO   r@   
settimeoutr  r   r  r\  s     r   testSendAfterClosez%GeneralModuleTests.testSendAfterClose  s    ]6>6+=>> 	$OOA	 	 	 	 	 	 	 	 	 	 	 	 	 	 	'49g66666s   AAAc                    t          j                     }|                    t           j        df           t          j         |                                                                           	 |                                 |                     d           d S # t          $ r<}|                     |j        t          j	        t          j
        f           Y d }~d S d }~ww xY w)Nr   r  z#close() should raise EBADF/ENOTSOCK)r   r   
_LOCALHOSTr  r    r  r   r  r(  EBADFENOTSOCK)rU   rM  r  s      r   testCloseExceptionz%GeneralModuleTests.testCloseException  s    }		6$a()))T[[]]+++11333	=JJLLL
 II;<<<<<	  	D 	D 	DMM#)ek5>%BCCCCCCCCC	Ds   /B 
C $1CC c                    t          j         t           j        t           j                  5 }|                     |j        t           j                   t          t           d          r?|                     |j        t           j        t           j        z  t           j        f           n%|                     |j        t           j                   |                     |j	        d           d d d            d S # 1 swxY w Y   d S )NSOCK_CLOEXECr   )
r   rO   r@   r  r  r   r  r}  r  r  r\  s     r   testNewAttributesz$GeneralModuleTests.testNewAttributes  s    ]6>6+=>> 	,$T[&.999v~.. @di%1F4GG%134 4 4 4   F,>???TZ+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s   B:C11C58C5c                 0   t          j                     }|                     |j                   t          j                    }|dz   }|dz
  }|                     t          |j        t          |f           |                     t          |j        t          |f           t          j
                    D ]g}t          j                    }	 |                    t          |f            d S # t          $ r&}|j        t          j        k    s|dk    r Y d }~`d }~ww xY wd S )NrZ  r  )r   rt   r    r   r  r  rN  r   r   r  r  r   r(  r  )rU   rM  rR   big_portneg_portrK   r   s          r   test_getsockaddrargz&GeneralModuleTests.test_getsockaddrarg  s   }
###-//%<%<-T84DEEE-T84DEEE "" 	 	A 133D		4,'''
 	    7e...!q&& 39&&&&		 	s   C##
D-DDc                 ~   |                      t          t          j        d                     |                      t          t          d                     |                      t          t          d                     |                      t          t          d                     |                      t          t          d                     t          j                    }|                     |j                   |                     t          |j        dd            |                    t          j        d           d S )Nr   
SIO_RCVALL	RCVALL_ON
RCVALL_OFFSIO_KEEPALIVE_VALSrW  )r   d   r  )	r  r   r   rt   r    r  r  r   r  r  s     r   test_sock_ioctlz"GeneralModuleTests.test_sock_ioctl  s    w77888556664455555666(<==>>>MOO   *agr4888	)=99999r=   SIO_LOOPBACK_FAST_PATHz1Loopback fast path support required for this testc                 f   t          j                     }|                     |j                   	 |                    t           j        d           n5# t
          $ r(}d}|j        |k    r|                     d            d }~ww xY w|                     t          |j        t           j        d            d S )NTi='  zQSIO_LOOPBACK_FAST_PATH is defined but doesn't implemented in this Windows version)
r   rt   r    r   r  r   r  r   r  r   )rU   r#   excWSAEOPNOTSUPPs       r   test_sio_loopback_fast_pathz.GeneralModuleTests.test_sio_loopback_fast_path  s     MOO   	GGF148888 	 	 	!M|},, L M M M	 	)QWf.KTRRRRRs    A 
B#A==Bc                    	 t          j        dd           nB# t           j        $ r0}|j        t           j        k    r|                     d            d }~ww xY wt          j        t          d           D ]%}|                     t          |          d           &t          j        dd           t          j        dd           t          j        d d           t          j
        rt          j        dd           t          t          d          rt          j                    dk    rt          j        t          d	           t          j        t          d           t          j        t          d            t          j        t          dt           j        t           j                  }|D ]	\  }}}}}|                     |t           j                   |                     t!          |          d
|j        z             |                     t%          |          t%          |j                             |                     |t           j                   |                     t!          |          d|j        z             |                     t%          |          t%          |j                             t          j        t          d dt           j                  }|D ](\  }}}}}|                     |t           j                   )t          j        t          d ddt           j                   t          j        t          d dddt           j                   t          j        d dt           j        t           j        dt           j                   t          j        t          d           }t          j        t          d           }	|                     ||	           t          j        t          d t           j                  }t          j        t          d t           j                  }	|                     ||	           t          j        t          d dt           j                  }t          j        t          d t           j                  }	|                     ||	           t          j        t          d ddt           j                  }t          j        t          d t           j                  }	|                     ||	           t          j        t          d dddt           j                  }t          j        t          d t           j                  }	|                     ||	           t          j        d dt           j        t           j        dt           j                  }t          j        d dt           j        t           j        dt           j                  }	|                     ||	           |                     t.          t           j        dd           t          t           d          r<	 t          j        dd dddt           j                   d S # t           j        $ r Y d S w xY wd S )N	localhostP   zbuggy libc versionr  r  r  rn  ro  http<AddressFamily.AF_INET: %r><SocketKind.SOCK_STREAM: %r>r   )r[  rR   r  r}  )r  )flags)r[  rR   r  r}  r  r  u   AI_NUMERICSERV)r   getaddrinfor  r(  EAI_SERVICEr   r   r  lenr   IPV6_ENABLEDr   r?  rn  rO   r@   r  valuer  SOL_TCP
AI_PASSIVE	AF_UNSPECr  UnicodeEncodeErrorr  )
rU   r  infoinfosr  r}  r   socktyper  bs
             r   testGetaddrinfoz"GeneralModuleTests.testGetaddrinfo  st   	{B//// 	 	 	yF...2333		 &tT22 	+ 	+DSYY**** 	;+++;+++4$$$% 	*ub))) 122 	-&((B..tV,,,4$$$4&&&"4V^V=OPP%* 	9 	9!FD!QVV^444T&\\+H6<+WXXXS[[#fl*;*;<<<T6#5666T$ZZ)G$*)TUUUSYYDJ8888"4q&2DEE$) 	; 	; AxAqXv'9::::4q!V^<<<4q!Q0ABBB 	4F$4f6H!!,	. 	. 	. tT**Dt444AtT6>::tT&.AAAAtT1f.@AAtT0BCCCAtT1a@@tT@@@AtT1aF4EFFtT1BCCCAtQ(8&:La%02 2Dq9I$*$6a%+%68 8 8 	A,f.@+xXXX 6+,, 	 ";aA#)#8: : : : :?   	 	s&    A+AA#Y YYc                 T    |                      t          t          j        dd           d S )N)zmail.python.orgr   r   )r  r   r   r@  rT   s    r   test_getnameinfoz#GeneralModuleTests.test_getnameinfo:  s&    '6#57LaPPPPPr=   networkznetwork is not enabledc                 0   t          j        d          5  t          j        d           d d d            n# 1 swxY w Y   d}t          j        |           t          j        |           t          j        |dt          j        t          j                   d S )Nz
python.orgu!   испытание.pythontest.netr   )r   transient_internetr   r  gethostbyname_exr  r  r@   )rU   rk  s     r   	test_idnazGeneralModuleTests.test_idna>  s    
 -l;; 	/ 	/ ...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 5V$$$'''6!F$4V5GHHHHHs   6::c                 @    t          t          d          rt          t          d          s                     d            fd} fd}t          j                    \  }}t          j        t          j        |          }	 |r|                    d                                t                    5  t          j	        d           |
                    dt          j        z             d d d            n# 1 swxY w Y   |rat          j        t          j        |           t          j	        d                                t          |j
        dt          j        z             t          j	        d	           t          j        t          j        |           |                                 |                                 d S # t          j	        d	           t          j        t          j        |           |                                 |                                 w xY w)
Nalarmr  z9signal.alarm and socket.socketpair required for this testc                  T                         t          t          j        d           d S r   r  r  mathacoshrp   rU   s    r   
ok_handlerz@GeneralModuleTests.check_sendall_interrupted.<locals>.ok_handlerU  s#    j$*a88888r=   c                  ^                         t          t          j        d           ddz   d S Nr   r   r  r  s    r   raising_handlerzEGeneralModuleTests.check_sendall_interrupted.<locals>.raising_handlerW  s*    j$*a888FFFFr=   g      ?r      xr   )r   signalr   r   r  SIGALRMr  r  ZeroDivisionErrorr   sendallr   SOCK_MAX_SIZETimeoutErrorr    )rU   with_timeoutr  r	  cr#   	old_alarms   `      r   check_sendall_interruptedz,GeneralModuleTests.check_sendall_interruptedO  s    vw'' 	Wwv|/L/L 	WMMUVVV	9 	9 	9 	9 	9	 	 	 	 	  ""1M&./BB		 "S!!!""#455 8 8Q		$!667778 8 8 8 8 8 8 8 8 8 8 8 8 8 8  @fnj999Q!!,	"&)>">@ @ @ LOOOM&.)444GGIIIGGIIIII LOOOM&.)444GGIIIGGIIIIs2   1G  27C5)G  5C99G  <C9=A&G   AHc                 0    |                      d           d S NFr  rT   s    r   test_sendall_interruptedz+GeneralModuleTests.test_sendall_interruptedn  s    &&u-----r=   c                 0    |                      d           d S )NTr  rT   s    r   %test_sendall_interrupted_with_timeoutz8GeneralModuleTests.test_sendall_interrupted_with_timeoutq  s    &&t,,,,,r=   c                    t          j         t           j        t           j                  }t          |          }|                     t
                    5 }d }t          j                     d d d            n# 1 swxY w Y   |                     |t          |j
        j        d                              t          j         t           j        t           j                  }|                    d          }t          |          }d }t          j                     |                     t
                    5  d }t          j                     d d d            d S # 1 swxY w Y   d S )Nr   r   )r   rO   r@   r  assertWarnsResourceWarningr   r  r  r  warningrp   makefile)rU   rM  r   r  r   s        r   test_dealloc_warnz$GeneralModuleTests.test_dealloc_warnt  s   }V^V-?@@JJo.. 	!"D   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	aRZ_Q/00111}V^V-?@@MM$JJo.. 	! 	!A   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!s$   A55A9<A9/EEEc                 "   t          j         t           j        t           j                  5 }|                    d          }|                                 |                     t          |          d           d d d            d S # 1 swxY w Y   d S )Nr   z<_io.BufferedReader name=-1>)r   rO   r@   r  r    r  r  rU   rM  fps      r   test_name_closed_socketioz,GeneralModuleTests.test_name_closed_socketio  s    ]6>6+=>> 	G$t$$BHHJJJT"XX'EFFF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	Gs   ABBBc                 ^   t          j                     5 }|                    dd          }|                     |                                           |                     |                                           |                     |                                           |                                 |                     t          |j                   |                     t          |j                   |                     t          |j                   d d d            d S # 1 swxY w Y   d S )Nr   r   )	buffering)
r   r  r  readabler  writableseekabler    r  r  r"  s      r   test_unusable_closed_socketioz0GeneralModuleTests.test_unusable_closed_socketio  s+   ]__ 	7tq11BOOBKKMM***R[[]]+++R[[]]+++HHJJJj"+666j"+666j"+666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s   DD""D&)D&c                 ~   t          j                     }	 |                    t          df           t          j        |                                           |                     t                    5  |                    d           d d d            n# 1 swxY w Y   |                     t                    5  |                                 d d d            n# 1 swxY w Y   nK# |                     t                    5  |                                 d d d            w # 1 swxY w Y   w xY w|                     t                    5  t          j        d            d d d            n# 1 swxY w Y   |                     t                    5  t          j        d           d d d            d S # 1 swxY w Y   d S )Nr   r   rW  )	r   r   r   r    r  r  r   rS   r   r\  s     r   test_socket_closez$GeneralModuleTests.test_socket_close  s   }	IItQi   L'''""7++  A               ""7++  

              ""7++  

                y)) 	 	L	 	 	 	 	 	 	 	 	 	 	 	 	 	 	w'' 	 	L	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   AC% 1BC% BC% BC% 8CC C%D- D!D-!D%%D-(D%)D-
E++E/2E/F22F69F6c           	      f   dD ]}|                      |          5  t          j                    5 }d|v rd nd}|                    ||          5 }|                     |j        |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d S )N)r   r   rwwwbmoder  r	   encoding)subTestr   r  r  r2  )rU   r2  rM  r4  r#  s        r   test_makefile_modez%GeneralModuleTests.test_makefile_mode  st   . 	8 	8D4(( 8 8]__ 8'*d{{ttHth?? 82(($7778 8 8 8 8 8 8 8 8 8 8 8 8 8 88 8 8 8 8 8 8 8 8 8 8 8 8 8 88 8 8 8 8 8 8 8 8 8 8 8 8 8 8	8 	8sX   B% BA7	+B7A;;B>A;?BB%BB%BB%%B)	,B)	c           	      R   dD ]}|                      |          5  t          j                    5 }|                     t          d          5  |                    |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d S )N)rtr   +r  r1  zinvalid mode)r5  r   assertRaisesRegexr  r  )rU   r2  rM  s      r   test_makefile_invalid_modez-GeneralModuleTests.test_makefile_invalid_mode  s`   ' 	, 	,D4(( , ,]__ ,//
NKK , ,d+++, , , , , , , , , , , , , , ,, , , , , , , , , , , , , , ,, , , , , , , , , , , , , , ,	, 	,sX   BBA-	!B-A11B4A15B8BBBBBB	"B	c                 p   t          j                     }|5  t          t          j        dz             D ])}|                     t
          t          j        ||           *	 d d d            n# 1 swxY w Y   t          t          j        dz             D ]}t          j        t          j        t           j        |                    }| 	                    |t           j                   t          j        t          j        t           j
        |                    }| 	                    |t           j
                   d S rX  )r   rangepickleHIGHEST_PROTOCOLr  r   dumpsloadsrO   r  r@   )rU   rM  protocolr  r}  s        r   test_picklezGeneralModuleTests.test_pickle  sY   } 	K 	K!&"9A"=>> K K!!)V\4JJJJK	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K f59:: 	7 	7H\&,v~x"H"HIIFVV^444<V-? J JKKDT6#56666		7 	7s   AA**A.1A.c                    dD ]t}t          j         t           j        t           j                  5 }|                    t          df           |                    |           d d d            n# 1 swxY w Y   ut          j         t           j        t           j                  5 }|                    t          df           |                                 d d d            d S # 1 swxY w Y   d S )N)r   rW  r   )r   rO   r@   r   r   rS   )rU   backlogsrvs      r   test_listen_backlogz&GeneralModuleTests.test_listen_backlog  s@    	$ 	$Gv~v/ABB $c$###

7###$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ ]6>6+=>> 	#HHdAYJJLLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s#   2A,,A0	3A0	!1CC#&C#c                    dd l }t          j        t          j        t          j                  5 }|                    t
          df           |                     t          |j        |j	        dz              d d d            d S # 1 swxY w Y   d S r  )
r[  r   rO   r@   r   r   r  rN  rS   r]  )rU   r[  rF  s      r   test_listen_backlog_overflowz/GeneralModuleTests.test_listen_backlog_overflow  s     	]6>6+=>> 	P#HHdAYmSZ9JQ9NOOO	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	Ps   ABBBIPv6 required for this test.c                 N   |                      t          t          j        t          j        ddfd           t          j        t          j        t          j                  5 }|                      t          |j        t          j        ddf           d d d            d S # 1 swxY w Y   d S )Nr   rV  i)	r  rN  r   r@  r   rm  rq  r@   r   r  s     r   test_flowinfoz GeneralModuleTests.test_flowinfo  s    -);(/J?	D 	D 	D]6?F,>?? 	U1mQVm6JAs5STTT	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	Us   /BB!Bc                     t          j        ddt           j        t           j        t           j                  \  ^ }}|                     |d           d S )Nff02::1de:c0:face:8Dr
   )ff02::1de:c0:face:8dr
   r   r   )r   r  rq  r'   r  r  )rU   r   sockaddrs      r   test_getaddrinfo_ipv6_basicz.GeneralModuleTests.test_getaddrinfo_ipv6_basic  sP    "."&/	
 
1h 	#GHHHHHr=   c                     |                      t          j                    t          j        d                     |                      t          j                    t          j        d                     d S )Nr  r  )r  r   r  rT   s    r   test_getfqdn_filter_localhostz0GeneralModuleTests.test_getfqdn_filter_localhost  sX    ))6>)+D+DEEE))6>$+?+?@@@@@r=   r  zdoes not work on WindowszSymbolic scope id does not workz test needs socket.if_nameindex()c                     t          j                    d         \  }}t          j        d|z   dt           j        t           j        t           j                  \  ^ }}|                     |ddd|f           d S )Nr   ff02::1de:c0:face:8D%r
   rO  )r   r,  r  rq  r'   r  r  )rU   ifindextest_interfacer   rP  s        r   &test_getaddrinfo_ipv6_scopeid_symbolicz9GeneralModuleTests.test_getaddrinfo_ipv6_scopeid_symbolic  sx     %+$7$9$9!$<!.".#n4&/	
 
1h 	$:D!W#MNNNNNr=   z.Numeric scope id does not work or undocumentedc                     d}t          j        dt          |          z   dt           j        t           j        t           j                  \  ^ }}|                     |ddd|f           d S )N*   rU  r
   rO  r   )r   r  r  rq  r'   r  r  )rU   rV  r   rP  s       r   %test_getaddrinfo_ipv6_scopeid_numericz8GeneralModuleTests.test_getaddrinfo_ipv6_scopeid_numeric  sk     ".#c'll2&/	
 
1h 	$:D!W#MNNNNNr=   c                     t          j                    d         \  }}ddd|f}t          j        |t           j        t           j        z            }|                     |d|z   df           d S )Nr   rN  r
   ff02::1de:c0:face:8d%1234)r   r,  r@  NI_NUMERICHOSTNI_NUMERICSERVr  )rU   rV  rW  rP  nameinfos        r   &test_getnameinfo_ipv6_scopeid_symbolicz9GeneralModuleTests.test_getnameinfo_ipv6_scopeid_symbolic  sn     %+$7$9$9!$<!.*D!W=%h0EH]0]^^$;n$Lf#UVVVVVr=   c                     d}ddd|f}t          j        |t           j        t           j        z            }|                     |dt          |          z   df           d S )NrZ  rN  r
   r   r]  r^  )r   r@  r_  r`  r  r  )rU   rV  rP  ra  s       r   %test_getnameinfo_ipv6_scopeid_numericz8GeneralModuleTests.test_getnameinfo_ipv6_scopeid_numeric  sa     *D!W=%h0EH]0]^^$;c'll$JF#STTTTTr=   c                 Z   t          j         t           j        t           j                  5 }|                     t	          |j                  d|j        j        z             |                     t	          |j                  d|j        j        z             |                     t          |j                  t          |j        j                             |                     t          |j                  t          |j        j                             d d d            d S # 1 swxY w Y   d S )Nr  r  )	r   rO   r@   r  r  r  r  r}  r  r  s     r   test_str_for_enumsz%GeneralModuleTests.test_str_for_enums  s     ]6>6+=>> 	=!T!(^^-JQX^-[\\\T!&\\+IAFL+XYYYS]]C,?,?@@@S[[#afl*;*;<<<		= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=s   C)D  D$'D$c                    t          t          dd          }t          t          dd          }t          j        |z  |z  }t          j        t          j        |          5 }|                     |j        t          j                   |                    d           |                     |j        t          j                   |                    d           |                     |j        t          j                   |                    d           |                     |j        t          j                   |                    d           |                     |j        t          j                   d d d            d S # 1 swxY w Y   d S )NSOCK_NONBLOCKr   r  r   TF)r   r   r@   rO   r  r}  r  setblocking)rU   rh  r  	sock_typer#   s        r    test_socket_consistent_sock_typez3GeneralModuleTests.test_socket_consistent_sock_type'  st   ;;v~q99&6E	]6>955 		9QVV%7888LLOOOQVV%7888LLOOOQVV%7888MM$QVV%7888MM%   QVV%7888		9 		9 		9 		9 		9 		9 		9 		9 		9 		9 		9 		9 		9 		9 		9 		9 		9 		9s   DE99E= E=c                 h   t          j         t           j        t           j                  }|                                }t	          t           j        j                                                  dz   }t	          d t           j        j        	                                D                       dz   }t          j         ||d|          5 }| 
                    |j        |           | 
                    |j        |           |                     |j        ddh           d d d            d S # 1 swxY w Y   d S )Nr   c              3   (   K   | ]\  }}|d v	|V  dS )>   r  rh  Nr_   )r  r  kinds      r   r  zEGeneralModuleTests.test_unknown_socket_family_repr.<locals>.<genexpr>B  s>       
 
d<<< <<<<
 
r=   ro  )r  r}  r  r  r   )r   rO   r@   detachmaxAddressFamily__members__values
SocketKindrM  r  r  r}  r  r  )rU   rM  fdunknown_familyunknown_typer#   s         r   test_unknown_socket_family_reprz2GeneralModuleTests.test_unknown_socket_family_repr7  sa    }V^V-?@@[[]]V1=DDFFGG!K 
 
$/;AACC
 
 
 
 
 	 ]%L   	,QX~666QV\222MM!'Ar7+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s   AD''D+.D+sendfileztest needs os.sendfile()c                     G d d          }t          j                     5 }t          j        t          j        t          j                  }t          j        |           |                     t           j                  5  |                     ||                     d d d            n# 1 swxY w Y   |                     t                    5  |                     |ddz                       d d d            n# 1 swxY w Y   |                     t                    5  |                     |d                      d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nc                       e Zd Zd Zd ZdS )<GeneralModuleTests.test__sendfile_use_sendfile.<locals>.Filec                     || _         d S rD   ru  )rU   ru  s     r   rk   zEGeneralModuleTests.test__sendfile_use_sendfile.<locals>.File.__init__S  s    r=   c                     | j         S rD   r~  rT   s    r   r  zCGeneralModuleTests.test__sendfile_use_sendfile.<locals>.File.filenoV  s	    wr=   N)r\   r]   r^   rk   r  r_   r=   r   Filer|  R  s2              r=   r  r   rY  )r   rF  r   curdirO_RDONLYr    r  _GiveupOnSendfile_sendfile_use_sendfilerN  r   )rU   r  rM  ru  s       r   test__sendfile_use_sendfilez.GeneralModuleTests.test__sendfile_use_sendfileP  sQ   	 	 	 	 	 	 	 	 ]__ 	8BK00BHRLLL""6#;<< 6 6++DDHH5556 6 6 6 6 6 6 6 6 6 6 6 6 6 6""=11 ; ;++DDDMM:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ;""9-- 8 8++DDJJ7778 8 8 8 8 8 8 8 8 8 8 8 8 8 8	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s~   AE$>B)E$)B-	-E$0B-	1E$"C<0E$<D 	 E$D 	E$!E E$E	E$E	E$$E(+E(c                    |                      |j        |           |                      |j        |           |                                }t	          j        |          }|                     |j                   |                                 |                      |j        |           |                      |j        |           |                      |                                |           d S Nr  )r  r  r}  r  r   rt   r    ro  )rU   r#   r  styperu  s2s         r   _test_socket_filenoz&GeneralModuleTests._test_socket_filenob  s    6***'''XXZZ]"%%%!!!	


F+++%(((b)))))r=   c                    t          j         t           j        t           j                  }|                     |j                   |                    t          j        df           |                     |t           j        t           j                   t          t           d          rt          j         t           j        t           j
                  }|                     |j                   |                    t          j        df           |                     |t           j        t           j
                   t          j        rt          j         t           j        t           j                  }|                     |j                   |                    t          j        dddf           |                     |t           j        t           j                   t          t           d          rt          j                    }|                     t           j        |           t          j         t           j        t           j                  }|                     |j                   	 |                    t&          j                            |d                     |                     |t           j        t           j                   d S # t,          $ r Y d S w xY wd S )Nr   r'   rR  r   )r   rO   r@   rt   r    r   r   r   r  r   r'   r  rq  rm  rC  rD  shutilrmtreerR  rF  rN  r  PermissionError)rU   r#   tmpdirs      r   test_socket_filenoz%GeneralModuleTests.test_socket_filenoo  s-   M&.&*<==   	"A&'''  FNF4FGGG6<(( 	Kfnf.?@@AOOAG$$$FFM&*+++$$Q8IJJJ% 	Mfov/ABBAOOAG$$$FFM(!Q2333$$Q9KLLL69%% 	=%''FOOFM6222fnf.@AAAOOAG$$$=rw||FH55666 ((FN)/);= = = = = #   	= 	=s   3J= =
K
Kc                     |                      t                    5  t          j        t          j        t          j        d           d d d            d S # 1 swxY w Y   d S )Ng     @E@r  r  r   r   rO   r@   rT   s    r    test_socket_fileno_rejects_floatz3GeneralModuleTests.test_socket_fileno_rejects_float  s    y)) 	K 	KM&.&*<TJJJJ	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K   ,AAAc                     |                      t                    5  t          j        t          j        t          j        d           d d d            d S # 1 swxY w Y   d S )Nfoor  r  rT   s    r   &test_socket_fileno_rejects_other_typesz9GeneralModuleTests.test_socket_fileno_rejects_other_types  s    y)) 	L 	LM&.&*<UKKKK	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	Lr  c                     |                      t          d          5  t          j        t          j        t          j        d           d d d            d S # 1 swxY w Y   d S )Nnegative file descriptorrW  r  r:  r  r   rO   r@   rT   s    r   )test_socket_fileno_rejects_invalid_socketz<GeneralModuleTests.test_socket_fileno_rejects_invalid_socket  s    ##J0JKK 	I 	IM&.&*<RHHHH	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I   ,AAAzWindows disallows -1 onlyc                     |                      t          d          5  t          j        t          j        t          j        d           d d d            d S # 1 swxY w Y   d S )Nr  ir  r  rT   s    r   #test_socket_fileno_rejects_negativez6GeneralModuleTests.test_socket_fileno_rejects_negative  s    ##J0JKK 	J 	JM&.&*<SIIII	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	Jr  c                 F   d}|                      t                    5 }t          j        t          j                               d d d            n# 1 swxY w Y   |                     |j        j        t          j        |f           |                      t                    5 }t          j        t          j	        t          j
        t          j                               d d d            n# 1 swxY w Y   |                     |j        j        t          j        |f           d S )Ni6'  r  )r  r   r   r   make_bad_fdr  r  r(  r  rO   r@   )rU   WSAENOTSOCKr  s      r   $test_socket_fileno_requires_valid_fdz7GeneralModuleTests.test_socket_fileno_requires_valid_fd  sg   w'' 	:2M!6!8!89999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:bl(5;*DEEEw'' 	02M" ,..0 0 0 0	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0
 	bl(5;*DEEEEEs#   'AAA!=C**C.1C.c                 B   t          j                    5 }|                     t                    5  t	          j        |                                           d d d            n# 1 swxY w Y   |                     t                    5 }t	          j        t          j        t          j        |                                           d d d            n# 1 swxY w Y   |                     |j	        j
        t          j                   d d d            d S # 1 swxY w Y   d S r  )rC  NamedTemporaryFiler  r   r   r  rO   r@   r  r  r(  r  )rU   afiler  s      r   %test_socket_fileno_requires_socket_fdz8GeneralModuleTests.test_socket_fileno_requires_socket_fd  s   (** 		Ae""7++ 5 5U\\^^44445 5 5 5 5 5 5 5 5 5 5 5 5 5 5 ""7++ +rN& <<>>+ + + ++ + + + + + + + + + + + + + +
 R\/@@@		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		AsX   D(A#D#A'	'D*A'	+D>CDC	DC	-DDDc                     dd l }dd l}|                    |j        ddd |          }|                    |t
          j                   d S )Nr   rq  r   c                 T    |                                  o|                     d          S )NAF_isupperrr  Cs    r   rz  z<GeneralModuleTests.test_addressfamily_enum.<locals>.<lambda>      !))++=!,,u*=*= r=   source)r  enum_old_convert_IntEnum_test_simple_enumr   rq  )rU   r  r  CheckedAddressFamilys       r   test_addressfamily_enumz*GeneralModuleTests.test_addressfamily_enum  si    #11ox==  2    
 	3V5IJJJJJr=   c                     dd l }dd l}|                    |j        ddd |          }|                    |t
          j                   d S )Nr   rt  r   c                 T    |                                  o|                     d          S )NSOCK_r  r  s    r   rz  z9GeneralModuleTests.test_socketkind_enum.<locals>.<lambda>  s    !))++?!,,w*?*? r=   r  )r  r  r  r  r  r   rt  )rU   r  r  CheckedSocketKinds       r   test_socketkind_enumz'GeneralModuleTests.test_socketkind_enum  si     ..lH?? /  
 	0&2CDDDDDr=   c                     dd l }dd l}|                    |j        ddd |          }|                    |t
          j                   d S )Nr   MsgFlagr   c                 T    |                                  o|                     d          S )NMSG_r  r  s    r   rz  z6GeneralModuleTests.test_msgflag_enum.<locals>.<lambda>  s    !))++>!,,v*>*> r=   r  )r  r  r  IntFlagr  r   r  )rU   r  r  CheckedMsgFlags       r   test_msgflag_enumz$GeneralModuleTests.test_msgflag_enum  sf    ++i>> ,  
 	~v~>>>>>r=   c                     dd l }dd l}|                    |j        ddd |          }|                    |t
          j                   d S )Nr   AddressInfor   c                 T    |                                  o|                     d          S )NAI_r  r  s    r   rz  z:GeneralModuleTests.test_addressinfo_enum.<locals>.<lambda>  r  r=   r  )r  r  r  r  r  r   r  )rU   r  r  CheckedAddressInfos       r   test_addressinfo_enumz(GeneralModuleTests.test_addressinfo_enum  si    !//mX== 0     	163EFFFFFr=   )`r\   r]   r^   r  r  r   
skipUnlessr  r  r  r  r  r  r  rF  r  r  skipIfr   is_wasir  r?  rq  r   r  r  r  r!  r$  r   r   r+  r6  r:  r<  rB  rD  rT  cpython_onlyrc  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  is_resource_enabledr  r  r  r  r   r$  r*  r,  r6  r;  rC  rG  rI  rL  rQ  rS  r   rX  r[  rb  rd  rf  rk  rx  r  r  r  r  r  r  r  r  r  r  r  r  r  r_   r=   r   r  r  <  s
         + + + X,.CDD
, 
, ED
,3 3 3" " "(6 (6 (6T        XD*<==  >= X_W_&EFF
> 
> GF
> X13HIIX35RSS  TS JI:v v v&? ? ?+ + +" X779Z[[X779Z[[& & \[ \[&$ X88?A A* *A A* X)9::AC CI IC CI X)9::AC CG GC CG Xm4479 9B B9 9B  : : : > > >.*F *F *FXG G G2 X558: :I I: :I X558: :   : : > X558: :<1 <1: :<1| X558: :M M: :M0 X558: :# #: :#D( ( (:> > >A A A7 7 7
= 
= 
=, , ,  ( XD*<==	: 	: >=	: XD*<==X)ABBLN NS SN N >=SN N N`Q Q Q X44Y??13 3
I 
I3 3
I  >. . .- - -! ! !"G G G	7 	7 	7   8 8 8, , ,	7 	7 	7   P P P X35STTU U UTU X35STTI I UTIA A A X35STTX_S\W,.HIIX_S;<<X88:\]]
O 
O ^] =< JI UT
O X35STTX8: :O O: : UTO X35STTX_S\W,.HIIX_S;<<X88:\]]W W ^] =< JI UTW X35STTX#,'18: :U U: : UTU= = =9 9 9 , , ,2 XZ002LMM8 8 NM8"* * *= = =>K K KL L LI I I X_RW_&ABBJ J CBJF F F
A 
A 
AK K KE E E? ? ?G G G G Gr=   r  z!SocketCan required for this test.c                   F   e Zd Zd Z ej         eed          d          d             Zd Z	 ej         eed          d          d             Z
d Zd Z ej         eed	          d
          d             Z ej         eed          d          d             ZdS )BasicCANTestc                 N    t           j         t           j         t           j         d S rD   )r   AF_CANr   r   rT   s    r   r  z!BasicCANTest.testCrucialConstants  s    r=   CAN_BCM&socket.CAN_BCM required for this test.c                 F   t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j	         t           j
         t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         d S rD   )r   r  CAN_BCM_TX_SETUPCAN_BCM_TX_DELETECAN_BCM_TX_READCAN_BCM_TX_SENDCAN_BCM_RX_SETUPCAN_BCM_RX_DELETECAN_BCM_RX_READCAN_BCM_TX_STATUSCAN_BCM_TX_EXPIREDCAN_BCM_RX_STATUSCAN_BCM_RX_TIMEOUTCAN_BCM_RX_CHANGEDCAN_BCM_SETTIMERCAN_BCM_STARTTIMERCAN_BCM_TX_COUNTEVTCAN_BCM_TX_ANNOUNCECAN_BCM_TX_CP_CAN_IDCAN_BCM_RX_FILTER_IDCAN_BCM_RX_CHECK_DLCCAN_BCM_RX_NO_AUTOTIMERCAN_BCM_RX_ANNOUNCE_RESUMECAN_BCM_TX_RESET_MULTI_IDXCAN_BCM_RX_RTR_FRAMErT   s    r   testBCMConstantszBasicCANTest.testBCMConstants  s     	 	      !!  !!!! 	!!""""######&&))))####r=   c                     t          j         t           j        t           j        t           j                  5 }	 d d d            d S # 1 swxY w Y   d S rD   r   r   r   r   r  s     r   testCreateSocketzBasicCANTest.testCreateSocket      ]6=&/6>JJ 	a	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   AAAc                     t          j         t           j        t           j        t           j                  5 }	 d d d            d S # 1 swxY w Y   d S rD   )r   r   r'   r  r  s     r   testCreateBCMSocketz BasicCANTest.testCreateBCMSocket  s     ]6=&*;V^LL 	PQ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r  c                    t          j         t           j        t           j        t           j                  5 }d}|                    |           |                     |                                |           d d d            d S # 1 swxY w Y   d S )N)r  )r   r   r   r   r   r  r   )rU   r#   addresss      r   testBindAnyzBasicCANTest.testBindAny  s    ]6=&/6>JJ 	7aGFF7OOOQ]]__g666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s   A BB	Bc                     t          j         t           j        t           j        t           j                  5 }|                     t
          d|j        d           d d d            d S # 1 swxY w Y   d S )Ninterface name too long)   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)r   r   r   r   r:  r   r   r  s     r   testTooLongInterfaceNamez%BasicCANTest.testTooLongInterfaceName  s    ]6=&/6>JJ 	:a""7,E#$6=: : :	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:s   #A%%A),A)CAN_RAW_LOOPBACKz/socket.CAN_RAW_LOOPBACK required for this test.c           	      ~   t          j         t           j        t           j        t           j                  5 }dD ]k}|                    t           j        t           j        |           |                     ||                    t           j        t           j                             l	 d d d            d S # 1 swxY w Y   d S )N)r   r   )	r   r   r   r   r  SOL_CAN_RAWr  r  r  )rU   r#   loopbacks      r   testLoopbackzBasicCANTest.testLoopback  s    ]6=&/6>JJ 	Oa" O OV/1H%' ' '  LL!3V5LMMO O O OO	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	Os   A/B22B69B6CAN_RAW_FILTERz-socket.CAN_RAW_FILTER required for this test.c           	         d\  }}t          j        d||          }t          j        t          j        t          j        t          j                  5 }|                    t          j        t          j        |           | 	                    ||
                    t          j        t          j        d                     |                    t          j        t          j        t          |                     d d d            d S # 1 swxY w Y   d S )N)   i   z=IIr   )r   packr   r   r   r   r  r  r   r  r  r  )rU   can_idcan_mask
can_filterr#   s        r   
testFilterzBasicCANTest.testFilter$  s%    ([99
]6=&/6>JJ 	[aLL+V-BJOOOZLL!3V5JANNP P PLL+V-BIjDYDYZZZ		[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[s   B#D  DDN)r\   r]   r^   r  r   r  r   r   r  r  r  r  r  r  r  r_   r=   r   r  r    sb         
 X33AC C$ $C C$<   X33AC C C C7 7 7: : : X);<<JL LO OL LO X)9::HJ J[ [J J[ [ [r=   r  c                       e Zd ZddZed             Zed             Zd Zd Zd Z	d Z
d	 Zd
 Z ej         eed          d          d             Z ej         eed          d          d             ZdS )CANTestr   c                 >    t                               | |           d S r   )r   rk   r   s     r   rk   zCANTest.__init__3  r  r=   c                     t          |          }|                    dd          }t          j        | j        |||          S )zBuild a CAN frame.r       )r  ljustr   r  r   )clsr  datacan_dlcs       r   build_can_framezCANTest.build_can_frame6  s;     d))zz!W%%{3,fgtDDDr=   c                 X    t          j        | j        |          \  }}}|||d|         fS )zDissect a CAN frame.N)r   r   r   )r  framer  r  r  s        r   dissect_can_framezCANTest.dissect_can_frame=  s4     !'c.? G Ghwh00r=   c                     | j                             | j                  \  }}|                     | j        |           |                     |d         | j                   d S r   )r#   r  r   r  cfr   rU   r  r  s      r   testSendFramezCANTest.testSendFrameC  sU    6??4<00D"%%%a$.11111r=   c                 z    |                      dd          | _        | j                            | j                   d S )Nr   s   r  r  r   r  rT   s    r   _testSendFramezCANTest._testSendFrameH  s6    &&t-DEEdgr=   c                     | j                             | j                  \  }}|                     | j        |           d S rD   )r#   r  r   r  r  r  s      r   testSendMaxFramezCANTest.testSendMaxFrameL  s9    6??4<00D"%%%%%r=   c                 z    |                      dd          | _        | j                            | j                   d S )Nr   s   r  rT   s    r   _testSendMaxFramezCANTest._testSendMaxFrameP  s5    &&t[99dgr=   c                     | j                             | j                  \  }}|                     | j        |           | j                             | j                  \  }}|                     | j        |           d S rD   )r#   r  r   r  cf1cf2r  s      r   testSendMultiFrameszCANTest.testSendMultiFramesT  sj    6??4<00D2&&&6??4<00D2&&&&&r=   c                     |                      dd          | _        | j                            | j                   |                      dd          | _        | j                            | j                   d S )N   s   D3"   s   "3)r  r!  r   r  r"  rT   s    r   _testSendMultiFrameszCANTest._testSendMultiFrames[  sc    ''.ABBdh''o>>dhr=   r  r  c                    | j                             | j                  \  }}|                     | j        |           |                     |          \  }}}|                     | j        |           |                     | j        |           d S rD   )r   r  r   r  r  r  r  r  )rU   r  r  r  r  r  s         r   _testBCMzCANTest._testBCMb  s     8$$T\22D"%%% $ 6 6r : :f---D)))))r=   c                 \   t          j         t           j        t           j        t           j                  }|                     |j                   |                    | j        f           d| _        t          g d          | _
        |                     | j        | j
                  | _        t           j        }d}d}dx}x}x}}d}	d}
t          j        | j        ||||||||	|

  
        }|| j        z   }|                    |          }|                     |t'          |                     d S )N#  )         r   i"  r   )r   r   r'   r  rt   r    r   r   r  bytesr  r  r  r  r   r  r   r  r  r  )rU   bcmopcoder  r  ival1_seconds
ival1_usecival2_seconds
ival2_usec
bcm_can_idnframesheaderheader_plus_frame
bytes_sents                 r   testBCMzCANTest.testBCMk  s(    mFM6+<fnMM	"""T^%&&&,,,--	&&t{DI>>'BCCC
C]Z
T1!!
 
 #TW,XX/00
S):%;%;<<<<<r=   Nr   )r\   r]   r^   rk   classmethodr  r  r  r  r  r  r#  r'  r   r  r   r   r)  r;  r_   r=   r   r	  r	  0  sC       D D D D E E [E 1 1 [1
2 2 2
  & & &  ' ' '      X33AC C* *C C* X33AC C= =C C= = =r=   r	  z!CAN ISOTP required for this test.c                   ~     e Zd Z fdZd Zd Z ej         ee	d          d          d             Z
d Zd Z xZS )		ISOTPTestc                 H     t                      j        |i | d| _        d S Nr~   rj   rk   r   ro   s      r   rk   zISOTPTest.__init__  *    $)&))) r=   c                 f    t           j         t           j         t           j         t           j         d S rD   )r   r  r   r(   r'   rT   s    r   r  zISOTPTest.testCrucialConstants  s(    r=   c                     t          j         t           j        t           j        t           j                  5 }	 d d d            d S # 1 swxY w Y   d S rD   r  r  s     r   r  zISOTPTest.testCreateSocket  r  r  r(   z(socket.CAN_ISOTP required for this test.c                     t          j         t           j        t           j        t           j                  5 }	 d d d            d S # 1 swxY w Y   d S rD   )r   r   r'   r(   r  s     r   testCreateISOTPSocketzISOTPTest.testCreateISOTPSocket       ]6=&*;V=MNN 	RS	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r  c                 0   t          j         t           j        t           j        t           j                  5 }|                     t
          d          5  |                    d           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr  )r  r   r   )r   r   r'   r(   r:  r   r   r  s     r   r  z"ISOTPTest.testTooLongInterfaceName  s    ]6=&*;V=MNN 	+RS''1JKK + +)***+ + + + + + + + + + + + + + +	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+s5   BA3'B3A7	7B:A7	;BBBc                    	 t          j         t           j        t           j        t           j                  5 }| j        ddf}|                    |           |                     |                                |           d d d            d S # 1 swxY w Y   d S # t          $ r?}|j	        t          j
        k    r|                     d| j        z             n Y d }~d S d }~ww xY w)Nr+  iV  r   )r   r   r'   r(   r   r   r  r   r   r(  ENODEVr   rU   r#   r  r   s       r   testBindzISOTPTest.testBind  s;   
	v}f.?AQRR 8VW~ue3t  $7778 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8  	 	 	w%,&&E>* + + + + + + + + + +	s;   4B AB>B BB BB 
C!"4CC!)r\   r]   r^   rk   r  r  r   r  r   r   rF  r  rL  rz   r{   s   @r   r>  r>    s        ! ! ! ! !     X55CE E E E+ + +      r=   r>  z!CAN J1939 required for this test.c                        e Zd Z fdZ ej         eed          d          d             Z ej         eed          d          d             Z	d Z
 xZS )	J1939Testc                 H     t                      j        |i | d| _        d S r@  rA  ro   s      r   rk   zJ1939Test.__init__  rB  r=   r,   z(socket.CAN_J1939 required for this test.c                 F   t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j	         t           j
         t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         d S rD   )r   r,   J1939_MAX_UNICAST_ADDRJ1939_IDLE_ADDRJ1939_NO_ADDRJ1939_NO_NAMEJ1939_PGN_REQUESTJ1939_PGN_ADDRESS_CLAIMEDJ1939_PGN_ADDRESS_COMMANDEDJ1939_PGN_PDU1_MAXJ1939_PGN_MAXJ1939_NO_PGNSO_J1939_FILTERSO_J1939_PROMISCSO_J1939_SEND_PRIOSO_J1939_ERRQUEUESCM_J1939_DEST_ADDRSCM_J1939_DEST_NAMESCM_J1939_PRIOSCM_J1939_ERRQUEUEJ1939_NLA_PADJ1939_NLA_BYTES_ACKEDJ1939_EE_INFO_NONEJ1939_EE_INFO_TX_ABORTJ1939_FILTER_MAXrT   s    r   testJ1939ConstantszJ1939Test.testJ1939Constants  s     	%%  ((**!! 	!!  """"!!$$!!%%r=   c                     t          j         t           j        t           j        t           j                  5 }	 d d d            d S # 1 swxY w Y   d S rD   )r   r   r'   r,   r  s     r   testCreateJ1939SocketzJ1939Test.testCreateJ1939Socket  rG  r  c                    	 t          j         t           j        t           j        t           j                  5 }| j        t           j        t           j        t           j        f}|                    |           | 	                    |
                                |           d d d            d S # 1 swxY w Y   d S # t          $ r?}|j        t          j        k    r|                     d| j        z             n Y d }~d S d }~ww xY wr   )r   r   r'   r,   r   rT  rZ  rS  r   r  r   r   r(  rJ  r   rK  s       r   rL  zJ1939Test.testBind  sG   
	v}f.?AQRR 8VW~v';V=PRXRfft  $7778 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8  	 	 	w%,&&E>* + + + + + + + + + +	s;   4B7 A'B*B7 *B..B7 1B.2B7 7
D 4C;;D )r\   r]   r^   rk   r   r  r   r   rh  rj  rL  rz   r{   s   @r   rN  rN    s        ! ! ! ! ! X55CE E   E E B X55CE E E E      r=   rN  z#RDS sockets required for this test.c                        e Zd Zd Zd Zd ZdS )BasicRDSTestc                 6    t           j         t           j         d S rD   )r   AF_RDSr/   rT   s    r   r  z!BasicRDSTest.testCrucialConstants  s    r=   c                     t          j         t           j        t           j        d          5 }	 d d d            d S # 1 swxY w Y   d S r   )r   r/   r0   r  s     r   r  zBasicRDSTest.testCreateSocket  s    ]6=&*?CC 	q	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   :>>c                 <   d}t          j         t           j        t           j        d          5 }|                    t           j        t           j        |           |                    t           j        t           j        |           d d d            d S # 1 swxY w Y   d S )Ni @  r   )r   r/   r0   r  r  	SO_RCVBUF	SO_SNDBUF)rU   r   r#   s      r   testSocketBufferSizez!BasicRDSTest.testSocketBufferSize  s    ]6=&*?CC 	GqLL*F,<gFFFLL*F,<gFFF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	Gs   ABBBN)r\   r]   r^   r  r  rt  r_   r=   r   rm  rm    sF            G G G G Gr=   rm  c                        e Zd ZddZ fdZd Zd Zd Zd Z e	e
j
        d          d	             Z e	e
j
        d
          d             Zd Zd Zd Zd Z xZS )RDSTestr   c                 >    t                               | |           d S r   )r   rk   r   s     r   rk   zRDSTest.__init__		  r  r=   c                 x    t                                                       t          j                    | _        d S rD   )rj   rV   rl   r   evtr0  s    r   rV   zRDSTest.setUp	  s'    ?$$r=   c                     | j                             | j                  \  }}|                     | j        |           |                     | j        |           d S rD   )rP   r  r   r  r  r   rU   r  r  s      r   testSendAndRecvzRDSTest.testSendAndRecv	  sS    Y''55
dD)))-----r=   c                 n    d| _         | j                            | j         dt          | j        f           d S Nr  r   r  r   r  r   rR   rT   s    r   _testSendAndRecvzRDSTest._testSendAndRecv	  0    		1tTY&788888r=   c                    | j                             | j        t          j                  \  }}|                     | j        |           | j                             | j                  \  }}|                     | j        |           d S rD   )rP   r  r   r   MSG_PEEKr  r  r{  s      r   testPeekzRDSTest.testPeek	  sr    Y''foFF
dD)))Y''55
dD)))))r=   c                 n    d| _         | j                            | j         dt          | j        f           d S r~  r  rT   s    r   	_testPeekzRDSTest._testPeek	  r  r=   recvmsgc                     | j                             | j                  \  }}}}|                     | j        |           d S rD   )rP   r  r   r  r  )rU   r  ancdata	msg_flagsr  s        r   testSendAndRecvMsgzRDSTest.testSendAndRecvMsg#	  s@    )-):):4<)H)H&gy$D)))))r=   sendmsgc                 r    d| _         | j                            | j         gddt          | j        f           d S )Ns<   hello hello hello hello hello hello hello hello hello hello r_   r   )r  r   r  r   rR   rT   s    r   _testSendAndRecvMsgzRDSTest._testSendAndRecvMsg(	  s6    "	$)b!dDI->?????r=   c                     | j                             | j                  \  }}|                     | j        |           | j                             | j                  \  }}|                     | j        |           d S rD   )rP   r  r   r  data1data2r{  s      r   testSendAndRecvMultizRDSTest.testSendAndRecvMulti-	  sn    Y''55
dT***Y''55
dT*****r=   c                     d| _         | j                            | j         dt          | j        f           d| _        | j                            | j        dt          | j        f           d S )Ns   baconr   s   egg)r  r   r  r   rR   r  rT   s    r   _testSendAndRecvMultizRDSTest._testSendAndRecvMulti4	  sX    

Adi'8999

Adi'899999r=   c                     t          j         | j        gg g d          \  }}}|                     | j        |           | j                            | j                  \  }}|                     | j        |           d S )Ng      @)selectrP   r  r  r   r  r  )rU   r   r/  r   r  r  s         r   
testSelectzRDSTest.testSelect;	  sp    -RS991adi###Y''55
dD)))))r=   c                 n    d| _         | j                            | j         dt          | j        f           d S )Ns   selectr   r  rT   s    r   _testSelectzRDSTest._testSelectA	  s0    		1tTY&788888r=   r   )r\   r]   r^   rk   rV   r|  r  r  r  r  r   r  r  r  r  r  r  rz   r{   s   @r   rv  rv  	  s       D D D D% % % % %. . .
9 9 9* * *9 9 9 \&-++* * ,+* \&-++@ @ ,+@+ + +: : :* * *9 9 9 9 9 9 9r=   rv  z'QIPCRTR sockets required for this test.c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )BasicQIPCRTRTestc                     t           j         d S rD   )r   r8   rT   s    r   r  z%BasicQIPCRTRTest.testCrucialConstantsI	  s    r=   c                     t          j         t           j        t           j                  5 }	 d d d            d S # 1 swxY w Y   d S rD   )r   r8   r'   r  s     r   r  z!BasicQIPCRTRTest.testCreateSocketL	  s~    ]6,f.?@@ 	A	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   9= =c                     t          j         t           j        t           j                  5 }|                     |                                d         d           d d d            d S # 1 swxY w Y   d S Nr   r   )r   r8   r'   r  r   r  s     r   testUnboundzBasicQIPCRTRTest.testUnboundP	  s    ]6,f.?@@ 	4AQ]]__Q/333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4s   /A&&A*-A*c                 B   t          j         t           j        t           j                  5 }t          j        ||                                d                    |                     |                                d         d           d d d            d S # 1 swxY w Y   d S )Nr   rZ  r   )r   r8   r'   r   rQ   r   assertNotEqualr  s     r   testBindSockzBasicQIPCRTRTest.testBindSockT	  s    ]6,f.?@@ 	7A#AAMMOOA,>???? 2A666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s   ABBBc                     t          j         t           j        t           j                  5 }|                     t          t
          j        |d           d d d            d S # 1 swxY w Y   d S )NrX  rZ  )r   r8   r'   r  r   r   rQ   r  s     r   testInvalidBindSockz$BasicQIPCRTRTest.testInvalidBindSockY	  s    ]6,f.?@@ 	LAg}'>KKK	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	Ls   )A  A$'A$c                    t          j         t           j        t           j                  5 }|                    d           |                     |                                d         d           d d d            d S # 1 swxY w Y   d S )N){   r  r   r   )r   r8   r'   r   r  r   r  s     r   testAutoBindSockz!BasicQIPCRTRTest.testAutoBindSock]	  s    ]6,f.?@@ 	7AIIj!!! 2A666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s   AA;;A?A?N)	r\   r]   r^   r  r  r  r  r  r  r_   r=   r   r  r  E	  sq            4 4 47 7 7
L L L7 7 7 7 7r=   r  c                   &    e Zd Zd Zd Zd Zd ZdS )BasicVSOCKTestc                     t           j         d S rD   )r   r   rT   s    r   r  z#BasicVSOCKTest.testCrucialConstantsg	  s    r=   c                     t           j         t           j         t           j         t           j         t           j         t           j         t           j         t           j         d S rD   )	r   SO_VM_SOCKETS_BUFFER_SIZESO_VM_SOCKETS_BUFFER_MIN_SIZESO_VM_SOCKETS_BUFFER_MAX_SIZEr   VMADDR_PORT_ANYVMADDR_CID_HOSTVM_SOCKETS_INVALID_VERSIONr   rT   s    r   testVSOCKConstantsz!BasicVSOCKTest.testVSOCKConstantsj	  sP    ((,,,,))----r=   c                     t          j         t           j        t           j                  5 }	 d d d            d S # 1 swxY w Y   d S rD   )r   r   r@   r  s     r   r  zBasicVSOCKTest.testCreateSockett	  s}    ]6?F,>?? 	1	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r  c                     t          j         t           j        t           j                  5 }|                    t           j        t           j                  }|                    t           j        t           j                  }|                    t           j        t           j                  }|                    t           j        t           j        |dz             |                    t           j        t           j        |dz             |                    t           j        t           j        |dz             |                     |dz  |                    t           j        t           j                             |                     |dz  |                    t           j        t           j                             |                     |dz  |                    t           j        t           j                             d d d            d S # 1 swxY w Y   d S Nr   )	r   r   r@   r  r  r  r  r  r  )rU   r#   orig_maxrA  orig_mins        r   rt  z#BasicVSOCKTest.testSocketBufferSizex	  s%   ]6?F,>?? 	D1||FO$*$HJ JH<< & @B BD||FO$*$HJ JH LL=x!|M M MLL94!8E E ELL=x!|M M M X\\\&/#AC CD D D TAX\\&/#=? ?@ @ @ X\\\&/#AC CD D D+	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	Ds   GHH
HN)r\   r]   r^   r  r  r  rt  r_   r=   r   r  r  b	  sU        
  . . .  D D D D Dr=   r  z)Bluetooth sockets required for this test.c                       e Zd Zd Zd Z ej        ej        dk    d          d             Z	 ej        ej        dk    d          d             Z
 ej        ej        dk    pej                            d          d	          d
             ZdS )BasicBluetoothTestc                 ,   t           j         t           j         t           j         t           j         t
          j        dk    rQt           j         t           j         t           j	         t
          j        
                    d          st           j         d S d S d S )Nr  re  )r   
BDADDR_ANYBDADDR_LOCALr?   rA   r?  rq  BTPROTO_HCISOL_HCIBTPROTO_L2CAPrr  BTPROTO_SCOrT   s    r   testBluetoothConstantsz)BasicBluetoothTest.testBluetoothConstants	  s    <7""NN  <**955 #"""" #"
# #r=   c                     t          j         t           j        t           j        t           j                  5 }	 d d d            d S # 1 swxY w Y   d S rD   )r   r?   r@   rA   r  s     r   testCreateRfcommSocketz)BasicBluetoothTest.testCreateRfcommSocket	  s    ]6.0BFDYZZ 	^_	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r  r  z&windows does not support L2CAP socketsc                     t          j         t           j        t           j        t           j                  5 }	 d d d            d S # 1 swxY w Y   d S rD   )r   r?   r0   r  r  s     r   testCreateL2capSocketz(BasicBluetoothTest.testCreateL2capSocket	  s    ]6.0EvG[\\ 	`a	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r  z$windows does not support HCI socketsc                     t          j         t           j        t           j        t           j                  5 }	 d d d            d S # 1 swxY w Y   d S rD   )r   r?   r   r  r  s     r   testCreateHciSocketz&BasicBluetoothTest.testCreateHciSocket	  s    ]6.ASTT 	XY	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r  re  z.windows and freebsd do not support SCO socketsc                     t          j         t           j        t           j        t           j                  5 }	 d d d            d S # 1 swxY w Y   d S rD   )r   r?   r0   r  r  s     r   testCreateScoSocketz&BasicBluetoothTest.testCreateScoSocket	  s     ]6.0EvGYZZ 	^_	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r  N)r\   r]   r^   r  r  r   r  r?  rq  r  r  rr  r  r_   r=   r   r  r  	  s        # # #   X_S\W,.VWW  XW X_S\W,.TUU  VU X_S\W,R0G0G	0R0REG G G G  r=   r  c                       e Zd ZddZd Zd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zd Zd Zd Zd Z ej        e          Zej        d             Zd Zd ZdS )BasicTCPTestr   c                 >    t                               | |           d S r   r  rk   r   s     r   rk   zBasicTCPTest.__init__	  !    $$Tj$AAAAAr=   c                 p    | j                             d          }|                     |t                     d S r   )r  r  r  r  r  s     r   testRecvzBasicTCPTest.testRecv	  s3    m  &&c"""""r=   c                 D    | j                             t                     d S rD   r  r  r  rT   s    r   	_testRecvzBasicTCPTest._testRecv	      C     r=   c                     | j                             t          t                    dz
            }| j                             d          }||z   }|                     |t                     d S N   r  )r  r  r  r  r  )rU   seg1seg2r  s       r   testOverFlowRecvzBasicTCPTest.testOverFlowRecv	  s[    }!!#c((Q,//}!!$''Tkc"""""r=   c                 D    | j                             t                     d S rD   r  rT   s    r   _testOverFlowRecvzBasicTCPTest._testOverFlowRecv	  r  r=   c                 v    | j                             d          \  }}|                     |t                     d S r   )r  r  r  r  rU   r  r  s      r   testRecvFromzBasicTCPTest.testRecvFrom	  s7    M**400	Tc"""""r=   c                 D    | j                             t                     d S rD   r  rT   s    r   _testRecvFromzBasicTCPTest._testRecvFrom	  r  r=   c                     | j                             t          t                    dz
            \  }}| j                             d          \  }}||z   }|                     |t                     d S r  )r  r  r  r  r  )rU   r  r  r  r  s        r   testOverFlowRecvFromz!BasicTCPTest.testOverFlowRecvFrom	  sc    ]++CHHQJ77
d]++D11
dTkc"""""r=   c                 D    | j                             t                     d S rD   r  rT   s    r   _testOverFlowRecvFromz"BasicTCPTest._testOverFlowRecvFrom	  r  r=   c                 ~    d}	 | j                             d          }|sn||z  }#|                     |d           d S )Nr=   r   r     ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)r  r  r  )rU   r  reads      r   testSendAllzBasicTCPTest.testSendAll	  sX    	=%%d++D 4KC		
 	k*****r=   c                 >    d}| j                             |           d S )Nr  )r  r  )rU   	big_chunks     r   _testSendAllzBasicTCPTest._testSendAll	  s#    	y)))))r=   c                 `   | j                                         }t          j        |t          j        t          j                  }|                     |j                   |                     |t          j                   |	                    d          }| 
                    |t                     d S r   )r  r  r   fromfdrO   r@   rt   r    r  r  r  r  )rU   ru  rM  r  s       r   
testFromFdzBasicTCPTest.testFromFd	  s    ]!!##}R1CDD
###dFM222iiooc"""""r=   c                 D    | j                             t                     d S rD   r  rT   s    r   _testFromFdzBasicTCPTest._testFromFd	  r  r=   c                     | j                                         }|                     |j                   |                    d          }|                     |t                     d S r   )r  duprt   r    r  r  r  )rU   rM  r  s      r   testDupzBasicTCPTest.testDup	  sT    }  ""
###iiooc"""""r=   c                 D    | j                             t                     d S rD   r  rT   s    r   _testDupzBasicTCPTest._testDup
  r  r=   c                     | j                             d          }|                     |t                     | j                                         d S r   )r  r  r  r  r   r   r  s     r   testShutdownzBasicTCPTest.testShutdown
  sG    m  &&c""" 		r=   c                 x    | j                             t                     | j                             d           d S r  )r  r  r  r  rT   s    r   _testShutdownzBasicTCPTest._testShutdown
  s4    C   """""r=   c                 >   dd l }| j                            t                     |                     t
          | j        j        |j        dz              |                     t
          | j        j        d|j        dz   z              | j                            d           d S )Nr   r   r   )	r[  r  r  r  r  rN  r  r]  UINT_MAXrU   r[  s     r   _testShutdown_overflowz#BasicTCPTest._testShutdown_overflow
  s    C   -)@#+a/	1 	1 	1-)@y1A56	8 	8 	8"""""r=   c                 <   | j                                         }| j                                         }|                     ||           |                     | j         j                   |                     t          | j         j        d           | j         	                                 t          j
        t          j        t          j        |          }|                     |j	                   |                    d          }|                     |t                     d S )Nr  r  )r  r  ro  r  r  _closedr  r   r  r    r   rO   r@   rt   r  )rU   r  r   rM  r  s        r   
testDetachzBasicTCPTest.testDetach!
  s    %%''M  ""F###-...'4=#5t<<< }V^V-?JJJ
###iiooc"""""r=   c                 D    | j                             t                     d S rD   r  rT   s    r   _testDetachzBasicTCPTest._testDetach1
  r  r=   Nr   )r\   r]   r^   rk   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  testShutdown_overflowr   r  r  r_   r=   r   r  r  	  sl       B B B B# # #
! ! !# # #! ! !# # #
! ! !# # #! ! !+ + +* * *# # #! ! !# # #! ! !  # # # 1G0>># # ## # # ! ! ! ! !r=   r  c                   :    e Zd Zd
dZd Zd Zd Zd Zd Zd Z	d	S )BasicUDPTestr   c                 >    t                               | |           d S r   )r   rk   r   s     r   rk   zBasicUDPTest.__init__7
  r  r=   c                     | j                             t          t                              }|                     |t                     d S rD   rP   r  r  r  r  r  s     r   testSendtoAndRecvzBasicUDPTest.testSendtoAndRecv:
  7    innSXX&&c"""""r=   c                 `    | j                             t          dt          | j        f           d S r   r   r  r  r   rR   rT   s    r   _testSendtoAndRecvzBasicUDPTest._testSendtoAndRecv?
  '    Qty 122222r=   c                     | j                             t          t                              \  }}|                     |t                     d S rD   rP   r  r  r  r  r  s      r   r  zBasicUDPTest.testRecvFromB
  =    I&&s3xx00	Tc"""""r=   c                 `    | j                             t          dt          | j        f           d S r   r  rT   s    r   r  zBasicUDPTest._testRecvFromG
  r  r=   c                 R    |                      t          | j        j        d           d S NrW  r  r  rP   r  rT   s    r   testRecvFromNegativez!BasicUDPTest.testRecvFromNegativeJ
  %    *di&8"=====r=   c                 `    | j                             t          dt          | j        f           d S r   r  rT   s    r   _testRecvFromNegativez"BasicUDPTest._testRecvFromNegativeN
  r  r=   Nr   
r\   r]   r^   rk   r  r  r  r  r  r  r_   r=   r   r  r  5
  s        D D D D# # #
3 3 3# # #
3 3 3> > >3 3 3 3 3r=   r  c                   :    e Zd Zd
dZd Zd Zd Zd Zd Zd Z	d	S )BasicUDPLITETestr   c                 >    t                               | |           d S r   )r   rk   r   s     r   rk   zBasicUDPLITETest.__init__V
  s!    !**4J*GGGGGr=   c                     | j                             t          t                              }|                     |t                     d S rD   r  r  s     r   r  z"BasicUDPLITETest.testSendtoAndRecvY
  r  r=   c                 `    | j                             t          dt          | j        f           d S r   r  rT   s    r   r  z#BasicUDPLITETest._testSendtoAndRecv^
  r  r=   c                     | j                             t          t                              \  }}|                     |t                     d S rD   r  r  s      r   r  zBasicUDPLITETest.testRecvFroma
  r  r=   c                 `    | j                             t          dt          | j        f           d S r   r  rT   s    r   r  zBasicUDPLITETest._testRecvFromf
  r  r=   c                 R    |                      t          | j        j        d           d S r  r  rT   s    r   r  z%BasicUDPLITETest.testRecvFromNegativei
  r  r=   c                 `    | j                             t          dt          | j        f           d S r   r  rT   s    r   r  z&BasicUDPLITETest._testRecvFromNegativem
  r  r=   Nr   r  r_   r=   r   r  r  R
  s        H H H H# # #
3 3 3# # #
3 3 3> > >3 3 3 3 3r=   r  c                        e Zd Zej        Z fdZd ZdZd Z	d Z
d Zd ZdZd	D ]Ze eeed          z  ZdZdZdZddZ xZS )SendrecvmsgBasec                 x    t          j                    | _        t                                                       d S rD   )rl   r   
misc_eventrj   rV   r0  s    r   rV   zSendrecvmsgBase.setUp
  s'    #/++r=   c                 6    | j                             |          S rD   )cli_sockr  r  s     r   sendToServerzSendrecvmsgBase.sendToServer
  s    }!!#&&&r=   r_   c                 Z     | j         j        || j        t          |          d          z    S rD   )r,  r  sendmsg_to_server_defaultsr  rU   rp   s     r   sendmsgToServerzSendrecvmsgBase.sendmsgToServer
  s4    
 %t}$T4SYYZZ@@C 	Cr=   c                 L     |j         |g|R  }|                     |           |S rD   )r  registerRecvmsgResult)rU   rM  r   rp   results        r   	doRecvmsgzSendrecvmsgBase.doRecvmsg
  s6     g----""6***r=   c                     d S rD   r_   rU   r4  s     r   r3  z%SendrecvmsgBase.registerRecvmsgResult
  s	     	r=   c                 2    |                      ||           d S rD   r  rU   addr1addr2s      r   checkRecvmsgAddressz#SendrecvmsgBase.checkRecvmsgAddress
  s      	&&&&&r=   r   )
MSG_CTRUNCMSG_OOBNc                 L   | j         }| j        }|r|| j        z  }|| j        z  }n||| j        z  }|| j        z  }|| z  }|| z  }||z  }||z  }||z  | z  }|r"t	          d                    |                    ||z  | z  }	|                     ||	z  ||	z             d S )Nz6contradictory set, unset requirements for flags {0:#x})msg_flags_common_setmsg_flags_common_unsetmsg_flags_eor_indicatormsg_flags_non_eor_indicator	Exceptionr  r  )
rU   r  eorcheckset
checkunsetignore
defaultsetdefaultunsetinbothrR  s
             r   
checkFlagszSendrecvmsgBase.checkFlags
  s    8 .
2 	9$66JD<<LL_$::JD88L 	zk!
	! 	Jl"
J&&0 	5 %%+VF^^5 5 5 :%&0x$77777r=   )Nr   r   r   )r\   r]   r^   r   LOOPBACK_TIMEOUTfail_timeoutrV   r-  r/  r1  r5  r3  r=  rB  r  r   r   rA  rC  rD  rM  rz   r{   s   @r   r(  r(  
  s        
 +L    ' ' ' "$C C C    ' ' ' ) ; ;''&$":"::    #$48 48 48 48 48 48 48 48r=   r(  c                       e Zd Zd ZdS )RecvmsgIntoMixinc                 *   t          |          } |j        |gg|R  }|                     |           |                     |d         d           |                     |d         |           t          |d |d                            f|dd          z   S r  )r  recvmsg_intor3  assertGreaterEqualassertLessEqualr/  )rU   rM  r   rp   bufr4  s         r   r5  zRecvmsgIntoMixin.doRecvmsg  s      ""C504000""6***q	1---VAY000c*6!9*o&&(6!"":55r=   N)r\   r]   r^   r5  r_   r=   r   rQ  rQ    s#        6 6 6 6 6r=   rQ  c                   .     e Zd Ze fd            Z xZS )SendrecvmsgDgramFlagsBasec                 D    t                      j        t          j        z  S rD   )rj   rD  r   	MSG_TRUNCr0  s    r   rD  z5SendrecvmsgDgramFlagsBase.msg_flags_non_eor_indicator  s    ww2V5EEEr=   )r\   r]   r^   propertyrD  rz   r{   s   @r   rX  rX    sM         F F F F XF F F F Fr=   rX  c                   .     e Zd Ze fd            Z xZS )SendrecvmsgSCTPFlagsBasec                 D    t                      j        t          j        z  S rD   )rj   rC  r   MSG_EORr0  s    r   rC  z0SendrecvmsgSCTPFlagsBase.msg_flags_eor_indicator  s    ww.??r=   )r\   r]   r^   r[  rC  rz   r{   s   @r   r]  r]    sM         @ @ @ @ X@ @ @ @ @r=   r]  c                   V    e Zd Zed             Zed             Zed             Zd ZdS )SendrecvmsgConnectionlessBasec                     | j         S rD   )rP   rT   s    r   	serv_sockz'SendrecvmsgConnectionlessBase.serv_sock#  s
    yr=   c                     | j         S rD   )r   rT   s    r   r,  z&SendrecvmsgConnectionlessBase.cli_sock'  s	    xr=   c                     g g d| j         fS r   )r+  rT   s    r   r/  z8SendrecvmsgConnectionlessBase.sendmsg_to_server_defaults+  s    B4>**r=   c                 B    | j                             || j                  S rD   )r,  r  r+  r  s     r   r-  z*SendrecvmsgConnectionlessBase.sendToServer/  s    }##C888r=   N)r\   r]   r^   r[  rc  r,  r/  r-  r_   r=   r   ra  ra    st        
   X   X + + X+9 9 9 9 9r=   ra  c                   @    e Zd Zed             Zed             Zd ZdS )SendrecvmsgConnectedBasec                     | j         S rD   )r  rT   s    r   rc  z"SendrecvmsgConnectedBase.serv_sock9  s
    }r=   c                     | j         S rD   )r  rT   s    r   r,  z!SendrecvmsgConnectedBase.cli_sock=  s
    ~r=   c                     d S rD   r_   r:  s      r   r=  z,SendrecvmsgConnectedBase.checkRecvmsgAddressA  	     	r=   N)r\   r]   r^   r[  rc  r,  r=  r_   r=   r   rh  rh  3  sY           X   X    r=   rh  c                        e Zd Z fdZ xZS )SendrecvmsgServerTimeoutBasec                     t                                                       | j                            | j                   d S rD   )rj   rV   rc  r  rO  r0  s    r   rV   z"SendrecvmsgServerTimeoutBase.setUpJ  s3    !!$"344444r=   )r\   r]   r^   rV   rz   r{   s   @r   rn  rn  G  s8        5 5 5 5 5 5 5 5 5r=   rn  c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Z eed          d             Zej        d             Zd Zd Zd Zd ZdS )SendmsgTestsc                     |                      | j                            t          t                              t                     d S rD   r  rc  r  r  r  rT   s    r   testSendmsgzSendmsgTests.testSendmsgS  4    ,,SXX66<<<<<r=   c                     |                      |                     t          g          t          t                               d S rD   r  r1  r  r  rT   s    r   _testSendmsgzSendmsgTests._testSendmsgW  s4    --se44c#hh?????r=   c                     |                      | j                            t          t                              t                     d S rD   rs  rT   s    r   testSendmsgDataGeneratorz%SendmsgTests.testSendmsgDataGeneratorZ  ru  r=   c                     |                      |                     d t          fD                       t          t                               d S )Nc              3      K   | ]}|V  d S rD   r_   r  s     r   r  z9SendmsgTests._testSendmsgDataGenerator.<locals>.<genexpr>_  s"      .@.@Qq.@.@.@.@.@.@r=   rw  rT   s    r   _testSendmsgDataGeneratorz&SendmsgTests._testSendmsgDataGenerator^  sN    --.@.@3%.@.@.@AAS	# 	# 	# 	# 	#r=   c                     |                      | j                            t          t                              t                     d S rD   rs  rT   s    r   testSendmsgAncillaryGeneratorz*SendmsgTests.testSendmsgAncillaryGeneratorb  ru  r=   c                     |                      |                     t          gd dD                       t          t                               d S )Nc              3      K   | ]}|V  d S rD   r_   r  s     r   r  z>SendmsgTests._testSendmsgAncillaryGenerator.<locals>.<genexpr>g  s      __Aa______r=   r_   rw  rT   s    r   _testSendmsgAncillaryGeneratorz+SendmsgTests._testSendmsgAncillaryGeneratorf  sK    --se_____EES	# 	# 	# 	# 	#r=   c                     |                      | j                            t          t                              t                     d S rD   rs  rT   s    r   testSendmsgArrayzSendmsgTests.testSendmsgArrayj  ru  r=   c                     |                      |                     t          j        dt                    g          t	          t                               d S )NB)r  r1  arrayr  r  rT   s    r   _testSendmsgArrayzSendmsgTests._testSendmsgArrayn  sL    --u{3/D/D.EFFS	# 	# 	# 	# 	#r=   c                     |                      | j                            t          t                              t                     d S rD   rs  rT   s    r   testSendmsgGatherzSendmsgTests.testSendmsgGatherr  ru  r=   c                     |                      |                     t          d d         t          dd          g          t          t                               d S Nr  rw  rT   s    r   _testSendmsgGatherzSendmsgTests._testSendmsgGatherv  sG    --s2A2wABB.@AA3s88LLLLLr=   c                 b    |                      | j                            d          d           d S NrY     doner  rc  r  rT   s    r   testSendmsgBadArgszSendmsgTests.testSendmsgBadArgsy  .    ,,T22G<<<<<r=   c           	         |                      t          | j        j                   |                      t          | j        d           |                      t          | j        t                                 |                      t          | j        t                      g           |                      t          | j        t          t                      g           |                      t          | j        t          gt                                 |                      t          | j        t          gg t                                 |                      t          | j        t          gg dt                                 |                     d           d S )Ns   not in an iterabler   r  )r  r   r,  r  r1  objectr  r-  rT   s    r   _testSendmsgBadArgsz SendmsgTests._testSendmsgBadArgs}  sU   )T]%:;;;)T%9/	1 	1 	1)T%9 ((	$ 	$ 	$)T%9!88*	& 	& 	&)T%9/	+ 	+ 	+)T%9%	+ 	+ 	+)T%9%VXX	/ 	/ 	/)T%9%Q	2 	2 	2'"""""r=   c                 b    |                      | j                            d          d           d S r  r  rT   s    r   testSendmsgBadCmsgzSendmsgTests.testSendmsgBadCmsg  r  r=   c           	         |                      t          | j        t          gt	                      g           |                      t          | j        t          gt	                      ddfg           |                      t          | j        t          gdt	                      dfg           |                      t          | j        t          gddt	                      fg           |                      t          | j        t          gdg           |                      t          | j        t          gdg           |                     d           d S )Nr      data)r   r   )r   r   r  rZ  r  r  r   r1  r  r  r-  rT   s    r   _testSendmsgBadCmsgz SendmsgTests._testSendmsgBadCmsg  s6   )T%9%&((	- 	- 	-)T%9%688Q"8!9	; 	; 	;)T%9%1fhh"8!9	; 	; 	;)T%9%1a"2!3	5 	5 	5)T%9%&	+ 	+ 	+)T%9%"5!6	8 	8 	8'"""""r=   
CMSG_SPACEc                 b    |                      | j                            d          d           d S r  r  rT   s    r   testSendmsgBadMultiCmsgz$SendmsgTests.testSendmsgBadMultiCmsg  s0     	,,T22G<<<<<r=   c                     |                      t          | j        t          gg d           |                      t          | j        t          gdt	                      g           |                     d           d S )Nr   r   r=   r  r  rT   s    r   _testSendmsgBadMultiCmsgz%SendmsgTests._testSendmsgBadMultiCmsg  su    )T%9%	. 	. 	.)T%9%+vxx!8	: 	: 	:'"""""r=   c                 b    |                      | j                            d          d           d S r  r  rT   s    r   testSendmsgExcessCmsgRejectz(SendmsgTests.testSendmsgExcessCmsgReject  s0     	,,T22G<<<<<r=   c                 8   t          t          d          so|                     t                    5 }|                     t
          gddg           d d d            n# 1 swxY w Y   |                     |j        j                   | 	                    d           d S )Nr  r  r  )
r   r   r  r   r1  r  assertIsNoner  r(  r-  rU   r  s     r   _testSendmsgExcessCmsgRejectz)SendmsgTests._testSendmsgExcessCmsgReject  s    v|,, 	2""7++ Hr$$cU[+,FGGGH H H H H H H H H H H H H H Hbl0111'"""""s   AA"Ac                     d S rD   r_   rT   s    r   testSendmsgAfterClosez"SendmsgTests.testSendmsgAfterClose  s    r=   c                     | j                                          |                     t          | j        t
          g           d S rD   )r,  r    r  r   r1  r  rT   s    r   _testSendmsgAfterClosez#SendmsgTests._testSendmsgAfterClose  s9    '4#7#?????r=   N)r\   r]   r^   rt  rx  rz  r}  r  r  r  r  r  r  r  r  r  r  r  r   r  r~  r  r  r  r  r  r_   r=   r   rq  rq  O  st       = = =@ @ @= = =# # #= = =# # #= = =# # #= = =M M M= = =# # #$= = =# # # \&,''= = ('=
 (# # )(#= = =
# # #  @ @ @ @ @r=   rq  c                   ~    e Zd Zd Zd Zd Zd Z eej	        dvd          d             Z
e
j        d             Zd	S )
SendmsgStreamTestsc                     |                      | j                            t          t                              t                     d S rD   rs  rT   s    r   testSendmsgExplicitNoneAddrz.SendmsgStreamTests.testSendmsgExplicitNoneAddr  ru  r=   c                     |                      |                     t          gg dd           t          t                               d S r   rw  rT   s    r   _testSendmsgExplicitNoneAddrz/SendmsgStreamTests._testSendmsgExplicitNoneAddr  s:    --seRDAA3s88LLLLLr=   c                     |                      | j                            d          d           |                     | j                            | j                             d S Nr     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaarG   r  rc  r  r  r*  r   rO  rT   s    r   testSendmsgTimeoutz%SendmsgStreamTests.testSendmsgTimeout  sV    ,,S118<<<,,T5F,GGHHHHHr=   c                 L   	 | j                             d           	 	 |                     dg           # t          $ r Y n,t
          $ r }|j        t          j        k    r Y d }~nd }~ww xY w| j        	                                 d S # | j        	                                 w xY w)NQ?Tr  )
r,  r  r1  r  r  r   r(  ENOMEMr*  r   rU   r  s     r   _testSendmsgTimeoutz&SendmsgStreamTests._testSendmsgTimeout  s    	"M$$T***55(((4445      9,, -,,,, O!!!!!DO!!!!s7   B 5 
A*B 	A*
A% B %A**B B#>   rh  z<MSG_DONTWAIT not known to work on this platform when sendingc                     |                      | j                            d          d           |                     | j                            | j                             d S r  r  rT   s    r   testSendmsgDontWaitz&SendmsgStreamTests.testSendmsgDontWait  sX    
 	,,S118<<<,,T5F,GGHHHHHr=   c                    	 |                      t                    5 }	 |                     dgg t          j                   ## 1 swxY w Y   |                     |j        j        t          j        t          j	        t          j
        f           | j                                         d S # | j                                         w xY w)NTr  )r  r   r1  r   MSG_DONTWAITr  r  r(  EAGAINEWOULDBLOCKr  r*  r   r  s     r   _testSendmsgDontWaitz'SendmsgStreamTests._testSendmsgDontWait  s    		"""7++ NrN(((R9LMMMNN N N N N N N N
 MM",, <):ELIK K K O!!!!!DO!!!!s)   B( %AAB( A	AB( (CN)r\   r]   r^   r  r  r  r  r  r?  rq  r  r~  r  r_   r=   r   r  r    s        = = =M M MI I I
" " ". cl)3 ! !I I! !I
 $
" 
" %$
" 
" 
"r=   r  c                       e Zd Zd Zd ZdS )SendmsgConnectionlessTestsc                     d S rD   r_   rT   s    r   testSendmsgNoDestAddrz0SendmsgConnectionlessTests.testSendmsgNoDestAddr  rl  r=   c                     |                      t          | j        j        t          g           |                      t          | j        j        t          gg dd            d S r   )r  r   r,  r  r  rT   s    r   _testSendmsgNoDestAddrz1SendmsgConnectionlessTests._testSendmsgNoDestAddr  s^    '4=#8%	! 	! 	!'4=#8%Q	. 	. 	. 	. 	.r=   N)r\   r]   r^   r  r  r_   r=   r   r  r    s2        
  
. . . . .r=   r  c                      e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Z eed          d             Zej        d             Z eej        d          d             Zej        d             ZdS )RecvmsgGenericTestsc                 0   |                      | j        t          t                              \  }}}}|                     |t                     |                     || j                   |                     |g            |                     |d           d S NTrF  r5  rc  r  r  r  r=  r   rM  rU   r  r  r  r  s        r   testRecvmsgzRecvmsgGenericTests.testRecvmsg  s    $(NN4>3s88$L$L!WeTc"""  t}555"%%%4(((((r=   c                 :    |                      t                     d S rD   r-  r  rT   s    r   _testRecvmsgz RecvmsgGenericTests._testRecvmsg       #r=   c                 4   |                      | j        t          t                    dd          \  }}}}|                     |t                     |                     || j                   |                     |g            |                     |d           d S )Nr   Tr  r  r  s        r   testRecvmsgExplicitDefaultsz/RecvmsgGenericTests.testRecvmsgExplicitDefaults#  s    $(NN4>36s88Q%C %C!WeTc"""  t}555"%%%4(((((r=   c                 :    |                      t                     d S rD   r  rT   s    r   _testRecvmsgExplicitDefaultsz0RecvmsgGenericTests._testRecvmsgExplicitDefaults,  r  r=   c                 6   |                      | j        t          t                    dz             \  }}}}|                     |t                     |                     || j                   |                     |g            |                     |d           d S )NrZ  Tr  r  r  s        r   testRecvmsgShorterz&RecvmsgGenericTests.testRecvmsgShorter/  s    $(NN4>36s88b=%B %B!WeTc"""  t}555"%%%4(((((r=   c                 :    |                      t                     d S rD   r  rT   s    r   _testRecvmsgShorterz'RecvmsgGenericTests._testRecvmsgShorter8  r  r=   c                 F   |                      | j        t          t                    dz
            \  }}}}|                     |t          d d                    |                     || j                   |                     |g            |                     |d           d S )Nr  Fr  r  r  s        r   testRecvmsgTruncz$RecvmsgGenericTests.testRecvmsgTrunc;  s    $(NN4>36s88a<%A %A!WeTc#2#h'''  t}555"%%%5)))))r=   c                 :    |                      t                     d S rD   r  rT   s    r   _testRecvmsgTruncz%RecvmsgGenericTests._testRecvmsgTruncD  r  r=   c                 2   |                      | j        t          t                    d          \  }}}}|                     |t                     |                     || j                   |                     |g            |                     |d           d S )Nr   Tr  r  r  s        r   testRecvmsgShortAncillaryBufz0RecvmsgGenericTests.testRecvmsgShortAncillaryBufG  s    $(NN4>36s88Q%@ %@!WeTc"""  t}555"%%%4(((((r=   c                 :    |                      t                     d S rD   r  rT   s    r   _testRecvmsgShortAncillaryBufz1RecvmsgGenericTests._testRecvmsgShortAncillaryBufP  r  r=   c                 2   |                      | j        t          t                    d          \  }}}}|                     |t                     |                     || j                   |                     |g            |                     |d           d S )N (  Tr  r  r  s        r   testRecvmsgLongAncillaryBufz/RecvmsgGenericTests.testRecvmsgLongAncillaryBufS  s    $(NN4>36s88U%D %D!WeTc"""  t}555"%%%4(((((r=   c                 :    |                      t                     d S rD   r  rT   s    r   _testRecvmsgLongAncillaryBufz0RecvmsgGenericTests._testRecvmsgLongAncillaryBuf\  r  r=   c                     | j                                          |                     t          | j        | j         d           d S r   )rc  r    r  r   r5  rT   s    r   testRecvmsgAfterClosez)RecvmsgGenericTests.testRecvmsgAfterClose_  s:    '4>4>4HHHHHr=   c                     d S rD   r_   rT   s    r   _testRecvmsgAfterClosez*RecvmsgGenericTests._testRecvmsgAfterClosed  r"  r=   c                    	 | j                             d           |                     t          | j        | j         t          t                               | j                                         d S # | j                                         w xY w)Nr  )	rc  r  r  r  r5  r  r  r*  r   rT   s    r   testRecvmsgTimeoutz&RecvmsgGenericTests.testRecvmsgTimeoutg  s    	"N%%d+++l"ndnc#hhH H H O!!!!!DO!!!!s   AA0 0Bc                 l    |                      | j                            | j                             d S Nr  )r  r*  r   rO  rT   s    r   _testRecvmsgTimeoutz'RecvmsgGenericTests._testRecvmsgTimeoutp  s0    ,,T5F,GGHHHHHr=   r  c           	         |                      | j        t          t                    dz
  dt          j                  \  }}}}|                     |t          d d                    |                     || j                   |                     |g            | 	                    |dt          t          dd                     |                      | j        t          t                    dt          j                  \  }}}}|                     |t                     |                     || j                   |                     |g            | 	                    |d           |                      | j        t          t                              \  }}}}|                     |t                     |                     || j                   |                     |g            | 	                    |d           d S )	Nr  r   r  FrZ  rF  rI  Tr  )r5  rc  r  r  r   r  r  r=  r   rM  r   r  s        r   testRecvmsgPeekz#RecvmsgGenericTests.testRecvmsgPeeks  s    %)NN4>36s88a<39?%D %D!WeT 	c#2#h'''  t}555"%%%
 	5&v{A>> 	 	@ 	@ 	@ %)NN4>36s88Q39?%D %D!WeT 	c"""  t}555"%%%4((( %)NN4>3s88$L$L!WeTc"""  t}555"%%%4(((((r=   c                 :    |                      t                     d S rD   r  rT   s    r   _testRecvmsgPeekz$RecvmsgGenericTests._testRecvmsgPeek  s    #r=   r  c                 n   | j                             | j                   |                     | j         t	          t
                              \  }}}}|                     |t
                     |                     || j                   |                     |g            | 	                    |d           d S r  )
rc  r  rO  r5  r  r  r  r=  r   rM  r  s        r   testRecvmsgFromSendmsgz*RecvmsgGenericTests.testRecvmsgFromSendmsg  s     	!!$"3444$(NN4>3s88$L$L!WeTc"""  t}555"%%%4(((((r=   c                     |                      |                     t          d d         t          dd          g          t          t                               d S r  rw  rT   s    r   _testRecvmsgFromSendmsgz+RecvmsgGenericTests._testRecvmsgFromSendmsg  sG    --s2A2wABB.@AA3s88LLLLLr=   N)r\   r]   r^   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r~  r  r  r  r_   r=   r   r  r    s       ) ) )  ) ) )  ) ) )  * * *  ) ) )  ) ) )  I I I
  " " "I I I \&*%% )  ) &% )D    !  \&-++) ) ,+) 'M M ('M M Mr=   r  c                   &    e Zd Zd Zd Zd Zd ZdS )RecvmsgGenericStreamTestsc                    |                      | j        d          \  }}}}|                     |d           |                     || j                   |                     |g            |                     |d            d S )Nr  r=   r  )r5  rc  r  r=  r   rM  r  s        r   testRecvmsgEOFz(RecvmsgGenericStreamTests.testRecvmsgEOF  s    $(NN4>4$H$H!WeTc"""  t}555"%%%4(((((r=   c                 8    | j                                          d S rD   )r,  r    rT   s    r   _testRecvmsgEOFz)RecvmsgGenericStreamTests._testRecvmsgEOF  s    r=   c                    |                      | j        t          t                    dz
            \  }}}}|                     || j                   |                     |g            |                     |d           |                      | j        d          \  }}}}|                     || j                   |                     |g            |                     |d           ||z   }|                     |t                     d S )Nr  Fr  r  T)r5  rc  r  r  r=  r   r  rM  )rU   r  r  r  r  r  r  s          r   testRecvmsgOverflowz-RecvmsgGenericStreamTests.testRecvmsgOverflow  s    %)^^DN47HHqL&B &B"gud  t}555"%%%5)))%)^^DND%I%I"gud  t}555"%%%4(((Tkc"""""r=   c                 :    |                      t                     d S rD   r  rT   s    r   _testRecvmsgOverflowz.RecvmsgGenericStreamTests._testRecvmsgOverflow  r  r=   N)r\   r]   r^   r  r  r  r  r_   r=   r   r   r     sP        ) ) )  # # #     r=   r   c                       e Zd Zd Zd ZdS )RecvmsgTestsc                 ,   |                      t          | j        j                   |                      t          | j        j        ddd           |                      t          | j        j        t          t                    dd           |                      t          | j        j        t          d          gdd           |                      t          | j        j        t                      dd           |                      t          | j        j        t          t                    t                      d           |                      t          | j        j        t          t                    dt                                 | j                            t          t                    dd          \  }}}}| 	                    |t                     | 
                    || j                   | 	                    |g            |                     |d           d S )NrW  r   r}  Tr  )r  r   rc  r  r  r  r  r  r  r  r=  r   rM  r  s        r   testRecvmsgBadArgszRecvmsgTests.testRecvmsgBadArgs  s   )T^%;<<<*dn&<a	$ 	$ 	$*dn&<c((B	+ 	+ 	+)T^%;$R==/1a	1 	1 	1)T^%; ((Aq	* 	* 	*)T^%;c((FHHa	1 	1 	1)T^%;c((Avxx	1 	1 	1 %)N$:$:3s88Q$J$J!WeTc"""  t}555"%%%4(((((r=   c                 :    |                      t                     d S rD   r  rT   s    r   _testRecvmsgBadArgsz RecvmsgTests._testRecvmsgBadArgs  r  r=   N)r\   r]   r^   r  r  r_   r=   r   r
  r
    s2        ) ) ),    r=   r
  c                   >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
RecvmsgIntoTestsc                    t          t          t                              }|                     t          | j        j                   |                     t          | j        j        t          t                    dd           |                     t          | j        j        |dd           |                     t          | j        j        t                      gdd           |                     t          | j        j        dgdd           |                     t          | j        j        |t                      gdd           |                     t          | j        j        |gdd           |                     t          | j        j        |gt                      d           |                     t          | j        j        |gdt                                 | j                            |gdd          \  }}}}| 	                    |t          t                               | 	                    |t          t                               | 
                    || j                   | 	                    |g            |                     |d           d S )Nr   s   I'm not writablerW  Tr  )r  r  r  r  r   rc  rS  r  r  r  r=  r   rM  rU   rV  nbytesr  r  r  s         r   testRecvmsgIntoBadArgsz'RecvmsgIntoTests.testRecvmsgIntoBadArgs  s=   C!!)T^%@AAA)T^%@c((Aq	* 	* 	*)T^%@q!	% 	% 	%)T^%@!88*a	, 	, 	,)T^%@./A	7 	7 	7)T^%@/1a	1 	1 	1*dn&A%Q	( 	( 	()T^%@%1	. 	. 	.)T^%@%FHH	. 	. 	. (,~'B'BC5!Q'O'O$S***inn---  t}555"%%%4(((((r=   c                 :    |                      t                     d S rD   r  rT   s    r   _testRecvmsgIntoBadArgsz(RecvmsgIntoTests._testRecvmsgIntoBadArgs	  r  r=   c                    t          t          t                              }| j                            d |fD                       \  }}}}|                     |t          t                               |                     |t          t                               |                     || j                   |                     |g            |                     |d           d S )Nc              3      K   | ]}|V  d S rD   r_   r  s     r   r  z<RecvmsgIntoTests.testRecvmsgIntoGenerator.<locals>.<genexpr>  s"      1Qr=   Tr  )	r  r  r  rc  rS  r  r=  r   rM  r  s         r   testRecvmsgIntoGeneratorz)RecvmsgIntoTests.testRecvmsgIntoGenerator  s    C!!'+~'B'B(  ( $S***inn---  t}555"%%%4(((((r=   c                 :    |                      t                     d S rD   r  rT   s    r   _testRecvmsgIntoGeneratorz*RecvmsgIntoTests._testRecvmsgIntoGenerator  r  r=   c                    t          j         ddgt          t                    z            }| j                            |g          \  }}}}|                     |t          t                               |                     |                                t                     |                     || j                   |                     |g            | 	                    |d           d S )Nr  r   Tr  )
r  r  r  rc  rS  r  tobytesr=  r   rM  r  s         r   testRecvmsgIntoArrayz%RecvmsgIntoTests.testRecvmsgIntoArray  s    k#sSXX~..'+~'B'BC5'I'I$S***,,,  t}555"%%%4(((((r=   c                 :    |                      t                     d S rD   r  rT   s    r   _testRecvmsgIntoArrayz&RecvmsgIntoTests._testRecvmsgIntoArray$  r  r=   c                 v   t          d          }t          d          }t          d          }| j                            |t          |          dd         |g          \  }}}}|                     |t          d                     |                     |t          d                     |                     |t          d                     |                     |t          d	                     |                     || j                   |                     |g            |                     |d
           d S )Ns   ----s
   0123456789s   --------------r   	      Mary had a little lambs   Marys
   01 had a 9s   little lamb---Tr  )	r  rc  rS  
memoryviewr  r  r=  r   rM  )rU   b1b2b3r  r  r  r  s           r   testRecvmsgIntoScatterz'RecvmsgIntoTests.testRecvmsgIntoScatter'  s'   w}%%())'+~'B'BB!$b)(+ (+$%>!?!?@@@Yw//000Y}55666Y'899:::  t}555"%%%4(((((r=   c                 0    |                      d           d S )Nr#  )r-  rT   s    r   _testRecvmsgIntoScatterz(RecvmsgIntoTests._testRecvmsgIntoScatter6  s    344444r=   N)r\   r]   r^   r  r  r  r  r  r   r(  r*  r_   r=   r   r  r    s        ) ) )8  	) 	) 	)  ) ) )  ) ) )5 5 5 5 5r=   r  c                       e Zd Z	 ddlZ edej                  Zn# e$ r dZY nw xY w ee	d          d             Z
 ee	d          d             ZdS )CmsgMacroTestsr   NiCMSG_LENc                    | j         t          j        d          z
  dz   }t          t	          d                    t          t	          |dz
  |                    z   }|                     t          j        d          t          j        d          j        dz             |D ]\}t          j        |          }|                     |t          j        d          z
  |           | 	                    || j                    ]| 
                    t          t          j        d           | 
                    t          t          j        |           | 
                    t          t          j        t          j                   d S )Nr   r     rK   r   rW  )socklen_t_limitr   r-  listr=  r/  r  itemsizer  rU  r  rN  r?  maxsize)rU   toobigrs  nr;   s        r   testCMSG_LENzCmsgMacroTests.testCMSG_LENG  s9    %(:(::Q>eCjj!!Dv|V)D)D$E$EE 	6?1--u{3/?/?/H1/LMMM 	< 	<A/!$$CS6?1#5#55q999  d&:;;;;-"=== 	-&AAA-#+FFFFFr=   r  c                 |   | j         t          j        d          z
  dz   }t          t	          d                    t          t	          |dz
  |                    z   }t          j        d          }|                     |t          j        d          j        dz             |D ]}t          j        |          }|                     ||           |                     |t          j	        |                     |                     ||t          j	        d          z              | 
                    || j                    |}|                     t          t          j        d           |                     t          t          j        |           |                     t          t          j        t          j                   d S )Nr   r/  r   rK   r   rW  )r0  r   r  r1  r=  r/  r  r2  rT  r-  rU  r  rN  r?  r3  )rU   r4  rs  lastr5  r;   s         r   testCMSG_SPACEzCmsgMacroTests.testCMSG_SPACE\  s|    %(9!(<(<<q@eCjj!!Dv|V)D)D$E$EE ##4S!1!1!:Q!>??? 	 	A#A&&C##C...##C););<<<##CV_Q-?-?)?@@@  d&:;;;DD-):B??? 	-):FCCC-):CKHHHHHr=   )r\   r]   r^   r[  minr]  r0  r  r  r   r6  r9  r_   r=   r   r,  r,  :  s        = #j)*;<<  % % %$%
 \&*%%G G &%G( \&,''I I ('I I Is    &&r,  c                      e Zd ZdZd Zd Zd Zd Zd Zd7d	Z	d
 Z
d Zd Zd Z eed          d             Zej        d             Zd Zd Z ej        ej        dk    d           ej        ed           eed          d                                     Zej         ej        ej        dk    d           ej        ed          d                                     Z ej        ej        dk    d           ej        ed           eed          d                                     Zej         ej        ej        dk    d           ej        ed          d                                     Zd Z ej        ej        dk    d          d             Zd Z d Z!d Z" eed          d              Z#e#j        d!             Z$d8d"Z%d# Z&d$ Z'd% Z(d& Z)d' Z*d( Z+d) Z,d* Z-d+ Z.d, Z/d8d-Z0d. Z1d/ Z2d0 Z3d1 Z4d2 Z5d3 Z6d4 Z7d5 Z8d6S )9SCMRightsTestic                 l   g }t          |          D ]}t          j                    \  }}|                     t          j        |           |                     t          j        |           t	          j        |t          |          	                                           |
                    |           |S rD   )r=  rC  mkstemprt   rF  rL  r    writer  encodeappend)rU   r5  fdsrK   ru  rN  s         r   newFDszSCMRightsTest.newFDs}  s     q 	 	A'))HBOOBIt,,,OOBHb)))HRQ)))JJrNNNN
r=   c                     t          |          D ]m\  }}t          j        |dt          j                   |                     t          j        |d          t          |                                                     nd S )Nr   r  )	enumeraterF  lseekSEEK_SETr  r  r  r@  )rU   rB  r5  ru  s       r   checkFDszSCMRightsTest.checkFDs  st     s^^ 	A 	AEArHRBK(((RWR..A@@@@	A 	Ar=   c                 <    |                      | j        |           d S rD   )rt   closeRecvmsgFDsr7  s     r   r3  z#SCMRightsTest.registerRecvmsgResult  s    ,f55555r=   c           	      B   |d         D ]\  }}}|t           j        k    r|t           j        k    rot          j        d          }|                    |d t          |          t          |          |j        z  z
                      |D ]}t          j        |           d S )Nr   rK   )	r   r  
SCM_RIGHTSr  	frombytesr  r2  rF  r    )rU   recvmsg_result
cmsg_level	cmsg_type	cmsg_datarB  ru  s          r   rJ  zSCMRightsTest.closeRecvmsgFDs  s     1?q0A 	! 	!,J	9f///!222k#&&i )II#i..3<*GH)I J K K K ! !BHRLLLL	! 	!r=   c                    |                      |                     t          gt          j        t          j        t          j        d|                     |                    fg          t          t                               d S )NrK   )	r  r1  r  r   r  rL  r  rC  r  )rU   r5  s     r   createAndSendFDszSCMRightsTest.createAndSendFDs  s{     	  ##)#4#)#4#(;sDKKNN#C#C#E "FG G HH	 	 	 	 	r=   r   r   c                 \   |\  }}}}|                      |t                     |                     || j                   |                     |dt
          j        |           |                     |t                     | 	                    t          |          |           t          j        d          }	|D ]}
|                     |
t                     |
\  }}}|                      |t
          j                   |                      |t
          j                   |                     |t                     |                      t          |          t           z  d           |	                    |           |                      t          |	          |           |                     |	           d S )NTrF  rH  rI  rK   r   )r  r  r=  r   rM  r   r>  r  r1  rU  r  r  tupler  rL  r/  
SIZEOF_INTrM  rH  )rU   numfdsr4  maxcmsgsignoreflagsr  r  r  r  rB  itemrO  rP  rQ  s                 r   checkRecvmsgFDszSCMRightsTest.checkRecvmsgFDs  s    %+!WeTc"""  t}5554F4E* 	 	, 	, 	, 	gt,,,S\\8444k# 	% 	%D!!$.../3,J	9Z):;;;Y(9:::!!)U333S^^j8!<<<MM)$$$$S6***cr=   c           	          |                      d|                     | j        t          t                    d                     d S )Nr   r  r\  r5  rc  r  r  rT   s    r   testFDPassSimplezSCMRightsTest.testFDPassSimple  L    Qt~/23xx!@ !@ 	A 	A 	A 	A 	Ar=   c                 *   |                      |                     t          gt          j        t          j        t          j        d|                     d                                                    fg          t          t                               d S )NrK   r   )
r  r1  r  r   r  rL  r  rC  r  r  rT   s    r   _testFDPassSimplezSCMRightsTest._testFDPassSimple  s      ##+c4;;q>>22::<<> ?@ @
 HH	 	 	 	 	r=   c           	          |                      d|                     | j        t          t                    d                     d S )Nr  r  r^  rT   s    r   testMultipleFDPassz SCMRightsTest.testMultipleFDPass  r`  r=   c                 0    |                      d           d S Nr  rS  rT   s    r   _testMultipleFDPassz!SCMRightsTest._testMultipleFDPass      a     r=   r  c                     |                      d|                     | j        t          t                    t          j        dt          z                                 d S rf  )r\  r5  rc  r  r  r   r  rW  rT   s    r   testFDPassCMSG_SPACEz"SCMRightsTest.testFDPassCMSG_SPACE  s^     	t~~dnc#hh$/J??A A	B 	B 	B 	B 	Br=   c                 0    |                      d           d S rf  rg  rT   s    r   _testFDPassCMSG_SPACEz#SCMRightsTest._testFDPassCMSG_SPACE  s    a     r=   c                     |                      d|                     | j        t          t                    t          j        dt          z                      t
          j                   d S )Nr   r  rZ  )	r\  r5  rc  r  r  r   r-  rW  r>  rT   s    r   testFDPassCMSG_LENz SCMRightsTest.testFDPassCMSG_LEN  sc    Q!^^DNCHH,2OA
N,K,KM M
 *0): 	 	< 	< 	< 	< 	<r=   c                 0    |                      d           d S rX  rg  rT   s    r   _testFDPassCMSG_LENz!SCMRightsTest._testFDPassCMSG_LEN  ri  r=   r  zskipping, see issue #12958zskipping, see issue #22397c           	          |                      d|                     | j        t          t                    d          d           d S )Nr   r  )rY  r^  rT   s    r   testFDPassSeparatez SCMRightsTest.testFDPassSeparate  sK     	Q!^^DNCHHeLL&' 	 	) 	) 	) 	) 	)r=   c                 j   |                      d          \  }}|                     |                     t          gt          j        t          j        t          j        d|g          ft          j        t          j        t          j        d|g          fg          t          t                               d S Nr   rK   	rC  r  r1  r  r   r  rL  r  r  rU   fd0fd1s      r   _testFDPassSeparatez!SCMRightsTest._testFDPassSeparate       ;;q>>S  #&*;*0*;*/+cC5*A*A*C +1*;*0*;*/+cC5*A*A*C)D E E HH	 	 	 	 	r=   c                    d}|                      ||                     | j        t          t                    t          j        t                    t          j        t          |z            z             dt
          j	                   d S )Nr   )rY  rZ  )
r\  r5  rc  r  r  r   r  rW  r-  r>  )rU   num_fdss     r   testFDPassSeparateMinSpacez(SCMRightsTest.testFDPassSeparateMinSpace
  s     W!^^DNCHH,2,=j,I,I,2OJ<P,Q,Q-RS S '(V5F	 	 	H 	H 	H 	H 	Hr=   c                 j   |                      d          \  }}|                     |                     t          gt          j        t          j        t          j        d|g          ft          j        t          j        t          j        d|g          fg          t          t                               d S rv  rw  rx  s      r   _testFDPassSeparateMinSpacez)SCMRightsTest._testFDPassSeparateMinSpace  r|  r=   c                    	 |                      |g|          }nM# t          $ r@}|                     |j        t                     |                      |g          }Y d }~nd }~ww xY w|                     |t          |                     d S rD   )r1  r   r  r(  r.  r  r  )rU   r  r  r  r   s        r   sendAncillaryIfPossiblez%SCMRightsTest.sendAncillaryIfPossible%  s    	1))3%99FF 	1 	1 	1!!!'3///))3%00FFFFFF	1 	S*****s    
A$6AA$zsee issue #24725c           	          |                      d|                     | j        t          t                    d          t
          j                   d S )Nr   r  ro  )r\  r5  rc  r  r  r   r>  rT   s    r   testFDPassEmptyzSCMRightsTest.testFDPassEmpty0  sT     	Qt~/23xx!@ !@)/): 	 	< 	< 	< 	< 	<r=   c                 l    |                      t          t          j        t          j        dfg           d S Nr=   )r  r  r   r  rL  rT   s    r   _testFDPassEmptyzSCMRightsTest._testFDPassEmpty8  s>    $$SF,=,2,=,/,1 +2 	3 	3 	3 	3 	3r=   c                 D   |                      | j        t          t                    d          \  }}}}|                     |t                     |                     || j                   |                     |dt          j	                   | 
                    t          |          d           |D ]n\  }}}|                     |t          j                   |                     |t          j                   |                     t          |          t                     od S )Nr  Tr  r   )r5  rc  r  r  r  r=  r   rM  r   r>  rU  r  rL  
assertLessrW  rU   r  r  r  r  rO  rP  rQ  s           r   testFDPassPartialIntz"SCMRightsTest.testFDPassPartialInt=  s   $(NN4>36s88U%D %D!WeTc"""  t}55540ABBBS\\1---07 	8 	8,J	9Z):;;;Y(9:::OOC	NNJ7777	8 	8r=   c           	          |                      t          t          j        t          j        t          j        d| j        g                                          d d         fg           d S )NrK   rW  )r  r  r   r  rL  r  badfdr  rT   s    r   _testFDPassPartialIntz#SCMRightsTest._testFDPassPartialIntJ  se    $$k#
|,,4466ss;= >	? 	? 	? 	? 	?r=   c           	         |                      | j        t          t                    d          \  }}}}|                     |t                     |                     || j                   |                     |dt          j	                   | 
                    t          |          d           t          j        d          }|D ]\  }}}|                     |t          j                   |                     |t          j                   |                    |d t          |          t          |          |j        z  z
                      | 
                    t          |          d           |                     |           d S )Nr  Tr  r   rK   )r5  rc  r  r  r  r=  r   rM  r   r>  rU  r  r  rL  rM  r2  rH  )	rU   r  r  r  r  rB  rO  rP  rQ  s	            r   testFDPassPartialIntInMiddlez*SCMRightsTest.testFDPassPartialIntInMiddleQ  sq    %)NN4>36s88U%D %D!WeTc"""  t}55540ABBBS\\1---k#07 	G 	G,J	9Z):;;;Y(9:::MM) %E	NNc)nns|&CD%E F G G G GSXXq)))cr=   c           
      \   |                      d          \  }}|                     t          t          j        t          j        t          j        d|| j        g                                          d d         ft          j        t          j        t          j        d|g          fg           d S )Nr   rK   rW  )	rC  r  r  r   r  rL  r  r  r  rx  s      r   _testFDPassPartialIntInMiddlez+SCMRightsTest._testFDPassPartialIntInMiddled  s    ;;q>>S$$k#TZ01199;;CRC@B k#u%%'(	) 	) 	) 	) 	)r=   c                     |\  }}}}|                      |t                     |                     || j                   |                      |g            |                     |dt
          j        |           d S )NTrF  rG  rI  )r  r  r=  r   rM  r   r>  )rU   r4  rZ  r  r  r  r  s          r   checkTruncatedHeaderz"SCMRightsTest.checkTruncatedHeaderp  s     %+!WeTc"""  t}555"%%%4&2C* 	 	, 	, 	, 	, 	,r=   c                     |                      |                     | j        t          t                              t
          j                   d S Nro  r  r5  rc  r  r  r   r>  rT   s    r   testCmsgTruncNoBufSizez$SCMRightsTest.testCmsgTruncNoBufSizez  sP     	!!$..S"J"J /5.?	 	" 	A 	A 	A 	A 	Ar=   c                 0    |                      d           d S rX  rg  rT   s    r   _testCmsgTruncNoBufSizez%SCMRightsTest._testCmsgTruncNoBufSize  ri  r=   c                     |                      |                     | j        t          t                    d          t
          j                   d S )Nr   ro  r  rT   s    r   testCmsgTrunc0zSCMRightsTest.testCmsgTrunc0  sN    !!$..S1"M"M.4.? 	" 	A 	A 	A 	A 	Ar=   c                 0    |                      d           d S rX  rg  rT   s    r   _testCmsgTrunc0zSCMRightsTest._testCmsgTrunc0  ri  r=   c                     |                      |                     | j        t          t                    d                     d S rX  )r  r5  rc  r  r  rT   s    r   testCmsgTrunc1zSCMRightsTest.testCmsgTrunc1  s4    !!$..S1"M"MNNNNNr=   c                 0    |                      d           d S rX  rg  rT   s    r   _testCmsgTrunc1zSCMRightsTest._testCmsgTrunc1  ri  r=   c                     |                      |                     | j        t          t                    t
          dz                       d S r  )r  r5  rc  r  r  rW  rT   s    r   testCmsgTrunc2IntzSCMRightsTest.testCmsgTrunc2Int  sP     	!!$..S1;a#A #A 	B 	B 	B 	B 	Br=   c                 0    |                      d           d S rX  rg  rT   s    r   _testCmsgTrunc2Intz SCMRightsTest._testCmsgTrunc2Int  ri  r=   c           	          |                      |                     | j        t          t                    t          j        d          dz
                       d S r  )r  r5  rc  r  r  r   r-  rT   s    r   testCmsgTruncLen0Minus1z%SCMRightsTest.testCmsgTruncLen0Minus1  sY    !!$..S171C1Ca1G#I #I 	J 	J 	J 	J 	Jr=   c                 0    |                      d           d S rX  rg  rT   s    r   _testCmsgTruncLen0Minus1z&SCMRightsTest._testCmsgTruncLen0Minus1  ri  r=   c                 x   |                      | j        t          t                    |          \  }}}}|                     |t                     |                     || j                   |                     |dt          j	                   |dk    r|g k    rd S |                     t          |          d           |d         \  }}	}
|                     |t          j
                   |                     |	t          j                   |                     t          |
          |           |                     t          |
          |           t          j        d          }|                    |
d t          |
          t          |
          |j        z  z
                      |                     |           d S )NTrF  rG  r   r   rK   )r5  rc  r  r  r  r=  r   rM  r   r>  r  rL  rT  rU  r  rM  r2  rH  )rU   ancbufmaxdatamindatar  r  r  r  rO  rP  rQ  rB  s               r   checkTruncatedArrayz!SCMRightsTest.checkTruncatedArray  s   
 %)NN4>36s88V%E %E!WeTc"""  t}5554&2CDDDa<<GrMMFWq)))+21:(
IyV%6777F$5666I888S^^W555k#i !AI#i..3<"?@!A B 	C 	C 	Ccr=   c                 X    |                      t          j        d          d           d S )Nr   r  r  r  r   r-  rT   s    r   testCmsgTruncLen0zSCMRightsTest.testCmsgTruncLen0  s+      (:(:A FFFFFr=   c                 0    |                      d           d S rX  rg  rT   s    r   _testCmsgTruncLen0z SCMRightsTest._testCmsgTruncLen0  ri  r=   c                 ^    |                      t          j        d          dz   d           d S )Nr   r   r  r  rT   s    r   testCmsgTruncLen0Plus1z$SCMRightsTest.testCmsgTruncLen0Plus1  s0      (:(:Q(> JJJJJr=   c                 0    |                      d           d S r  rg  rT   s    r   _testCmsgTruncLen0Plus1z%SCMRightsTest._testCmsgTruncLen0Plus1  ri  r=   c                 l    |                      t          j        t                    t                     d S )Nr  r  r   r-  rW  rT   s    r   testCmsgTruncLen1zSCMRightsTest.testCmsgTruncLen1  s8      
(C(C)3 	! 	5 	5 	5 	5 	5r=   c                 0    |                      d           d S r  rg  rT   s    r   _testCmsgTruncLen1z SCMRightsTest._testCmsgTruncLen1  ri  r=   c                     |                      t          j        dt          z            dz
  dt          z  dz
             d S )Nr   r   r  r  rT   s    r   testCmsgTruncLen2Minus1z%SCMRightsTest.testCmsgTruncLen2Minus1  sJ      J(G(G!(K*+j.A)= 	! 	? 	? 	? 	? 	?r=   c                 0    |                      d           d S r  rg  rT   s    r   _testCmsgTruncLen2Minus1z&SCMRightsTest._testCmsgTruncLen2Minus1  ri  r=   N)r   r   r   )9r\   r]   r^   r  rC  rH  r3  rJ  rS  r\  r_  rb  rd  rh  r  r   rk  r~  rm  rp  rr  r   r  r?  rq  r   rt  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r_   r=   r   r<  r<  u  s        E
 
 
A A A6 6 6
! 
! 
!     6A A A
  A A A
! ! ! \&,''B B ('B %! ! &%!< < <! ! ! X_S\X-/KLLX_S677\&,'') ) (' 87 ML) #X_S\X-/KLLX_S677	 	 87 ML $#	 X_S\X-/KLLX_S677\&,''H H (' 87 MLH  +X_S\X-/KLLX_S677	 	 87 ML ,+		+ 	+ 	+ X_S\X-/ABB< < CB<3 3 3
8 8 8? ? ? \&,''  ('$ "-	) 	) .-	), , , ,A A A! ! !A A A
! ! !O O O! ! !B B B! ! !J J J! ! !   0G G G! ! !K K K! ! !5 5 5! ! !? ? ?! ! ! ! !r=   r<  c            	       X   e Zd ZdZdZd Zd5dZ eedd          d	             Z	e	j
        d
             Z eeddd          d             Zej
        d             Z eej        d           eedd          d                         Zej
        d             Z	 	 d5dZ eedddd          d             Zej
        d             Z eeddddd          d             Zej
        d             Z eej        d           eeddddd          d                         Zej
        d             Z eej        d           eeddddd          d                         Zej
        d             Zd6dZ eedd          d             Zej
        d             Z eedd          d             Zej
        d              Z eedd          d!             Zej
        d"             Z eedd          d#             Z e j
        d$             Z! eedd          d%             Z"e"j
        d&             Z# eedd          d'             Z$e$j
        d(             Z%d6d)Z& eeddddd          d*             Z'e'j
        d+             Z( eeddddd          d,             Z)e)j
        d-             Z* eeddddd          d.             Z+e+j
        d/             Z, eeddddd          d0             Z-e-j
        d1             Z. eeddddd          d2             Z/e/j
        d3             Z0d4S )7RFC3542AncillaryTestr   rW  c                 Z    i }|D ]%\  }}}|                      ||f|           ||||f<   &|S rD   )r  )rU   r  drO  rP  rQ  s         r   ancillaryMappingz%RFC3542AncillaryTest.ancillaryMapping  sQ     07 	3 	3,J	9j)4a888)2Az9%&&r=   r-  r   c                    | j                             t          j        t          j        d           | j                                         |                     | j         t          t                    |          \  }}}}| 
                    |t                     |                     || j                   |                     |dt          j        |           | 
                    t          |          d           |                     |d         t                      |d         \  }}	}
| 
                    |t          j                   | 
                    |	t          j                   |                     |
t$                     | 
                    t          |
          t&                     t)          j        d          }|                    |
           |                     |d         d           |                     |d         |           d S )Nr   TrU  r   rK   )rc  r  r   r  r  r*  r   r5  r  r  r  r=  r   rM  r>  r  rV  r  r/  rW  r  rM  rT  rU  )rU   
ancbufsizemaxhoprZ  r  r  r  r  rO  rP  rQ  r  s               r   checkHopLimitz"RFC3542AncillaryTest.checkHopLimit  s   
 	!!&"5"(":A	? 	? 	?$(NN4>36s88Z%I %I!WeT 	c"""  t}5554F4E* 	 	, 	, 	, 	Wq)))gaj%000+21:(
IyV%8999F$8999i///Y444K	I!a(((QqT6*****r=   r  r  c                 2    |                      d           d S Nr  r  )r  rT   s    r   testRecvHopLimitz%RFC3542AncillaryTest.testRecvHopLimit  s!     	e,,,,,r=   c                     |                      | j                            | j                             |                     t
                     d S r  r  r*  r   rO  r-  r  rT   s    r   _testRecvHopLimitz&RFC3542AncillaryTest._testRecvHopLimit  sF    
 	,,T5F,GGHHH#r=   r  c                 `    |                      t          j        t                               d S )Nr  )r  r   r  rW  rT   s    r   testRecvHopLimitCMSG_SPACEz/RFC3542AncillaryTest.testRecvHopLimitCMSG_SPACE"  s,     	f&7
&C&CDDDDDr=   c                     |                      | j                            | j                             |                     t
                     d S r  r  rT   s    r   _testRecvHopLimitCMSG_SPACEz0RFC3542AncillaryTest._testRecvHopLimitCMSG_SPACE'  D    ,,T5F,GGHHH#r=   r  c                 >    |                      d| j                   d S Nr  )r  r  )r  	hop_limitrT   s    r   testSetHopLimitz$RFC3542AncillaryTest.testSetHopLimit1  s%    
 	eDNCCCCCr=   c                 R   |                      | j                            | j                             |                     |                     t          gt          j        t          j	        t          j
        d| j        g          fg          t          t                               d S Nr  rK   )r  r*  r   rO  r  r1  r  r   r  r  r  r  r  rT   s    r   _testSetHopLimitz%RFC3542AncillaryTest._testSetHopLimit8  s    ,,T5F,GGHHH  ##)#68L#(;sT^4D#E#E#G "HI I HH		 	 	 	 	r=   c                    | j                             t          j        t          j        d           | j                             t          j        t          j        d           | j                                         |                     | j         t          t                    |          \  }}}}|                     |t                     |                     || j                   |                     |dt          j        |           |                     t          |          d           |                     |          }|t          j        t          j        f         }	|                     t          |	          t$                     t'          j        d          }
|
                    |	           |                     |
d         d           |                     |
d         d           |t          j        t          j        f         }|                     t          |          t$                     t'          j        d          }
|
                    |           |                     |
d         d           |                     |
d         |           d S )Nr   TrU  r   rK   r   r-  )rc  r  r   r  r  r  r*  r   r5  r  r  r  r=  r   rM  r>  r  r  rW  r  rM  rT  rU  r  )rU   r  r  rZ  r  r  r  r  ancmaptcdatar  hldatas               r   checkTrafficClassAndHopLimitz1RFC3542AncillaryTest.checkTrafficClassAndHopLimitA  s+    	!!&"5"(":A	? 	? 	?!!&"5"("8!	= 	= 	=$(NN4>36s88Z%I %I!WeT 	c"""  t}5554F4E* 	 	, 	, 	,Wq)))&&w//,f.@ABVj111K	F!a(((QqT3''',f.BCDVj111K	F!a(((QqT6*****r=   r  r  c                 2    |                      d           d S r  )r  rT   s    r   testRecvTrafficClassAndHopLimitz4RFC3542AncillaryTest.testRecvTrafficClassAndHopLimite  s!     	))U);;;;;r=   c                     |                      | j                            | j                             |                     t
                     d S r  r  rT   s    r    _testRecvTrafficClassAndHopLimitz5RFC3542AncillaryTest._testRecvTrafficClassAndHopLimitk  r  r=   c                 f    |                      t          j        t                    dz             d S Nr   r  )r  r   r  rW  rT   s    r   )testRecvTrafficClassAndHopLimitCMSG_SPACEz>RFC3542AncillaryTest.testRecvTrafficClassAndHopLimitCMSG_SPACEp  s>    
 	))(44q8 	* 	: 	: 	: 	: 	:r=   c                     |                      | j                            | j                             |                     t
                     d S r  r  rT   s    r   *_testRecvTrafficClassAndHopLimitCMSG_SPACEz?RFC3542AncillaryTest._testRecvTrafficClassAndHopLimitCMSG_SPACEx  r  r=   c                 >    |                      d| j                   d S r  r  r  rT   s    r   testSetTrafficClassAndHopLimitz3RFC3542AncillaryTest.testSetTrafficClassAndHopLimit}  s7     	))U15 	* 	A 	A 	A 	A 	Ar=   c                    |                      | j                            | j                             |                     |                     t          gt          j        t          j	        t          j
        d| j        g          ft          j        t          j        t          j
        d| j        g          fg          t          t                               d S r  )r  r*  r   rO  r  r1  r  r   r  r  r  traffic_classr  r  r  rT   s    r   _testSetTrafficClassAndHopLimitz4RFC3542AncillaryTest._testSetTrafficClassAndHopLimit  s    ,,T5F,GGHHH  ##)#68J#(;sT5G4H#I#I#K#)#68L#(;sT^4D#E#E#G"HI I
 HH	 	 	 	 	r=   c                 >    |                      d| j                   d S r  r  rT   s    r   testOddCmsgSizez$RFC3542AncillaryTest.testOddCmsgSize  s7     	))U15 	* 	A 	A 	A 	A 	Ar=   c                 P   |                      | j                            | j                             	 |                     t
          gt          j        t          j        t          j	        d| j
        g                                          dz   ft          j        t          j        t          j	        d| j        g          fg          }d S # t          $ r}|                     |j        t"                     |                     t
          gt          j        t          j        t          j	        d| j
        g          ft          j        t          j        t          j	        d| j        g          fg          }|                     |t'          t
                               Y d }~d S d }~ww xY w)Nr  rK   r  )r  r*  r   rO  r1  r  r   r  r  r  r  r  r  r  r   r  r(  r.  r  r  )rU   r  r   s      r   _testOddCmsgSizez%RFC3542AncillaryTest._testOddCmsgSize  s~   ,,T5F,GGHHH	/))%v'9+cD$6#788@@BBWLN%v';+cDN#344678 8FFF  	/ 	/ 	/!!!'3///))%v'9+cD$6#788:%v';+cDN#344678 8F VSXX.........	/s   BC
 

F%CF  F%c                    | j                             t          j        t          j        d           | j                                         |dn|f} | j        | j         t          t                    g|R  \  }}}}| 
                    |t                     |                     || j                   | 
                    |g            |                     |dt          j        |           d S )Nr   r_   Tr  )rc  r  r   r  r  r*  r   r5  r  r  r  r=  r   rM  r>  )rU   r  rZ  rp   r  r  r  r  s           r   checkHopLimitTruncatedHeaderz1RFC3542AncillaryTest.checkHopLimitTruncatedHeader  s     	!!&"5"(":A	? 	? 	?'rrj]$2DN4>36s88%D>B%D %D %D!WeT 	c"""  t}555"%%%4&2C* 	 	, 	, 	, 	, 	,r=   c                 H    |                      d t          j                   d S )Nr  rZ  r  r   r>  rT   s    r   r  z+RFC3542AncillaryTest.testCmsgTruncNoBufSize  s:     	))T
 7=6G 	* 	I 	I 	I 	I 	Ir=   c                     |                      | j                            | j                             |                     t
                     d S r  r  rT   s    r   r  z,RFC3542AncillaryTest._testCmsgTruncNoBufSize  r  r=   c                 H    |                      dt          j                   d S )Nr   r  r  rT   s    r   testSingleCmsgTrunc0z)RFC3542AncillaryTest.testSingleCmsgTrunc0  s8     	))Q6<6G 	* 	I 	I 	I 	I 	Ir=   c                     |                      | j                            | j                             |                     t
                     d S r  r  rT   s    r   _testSingleCmsgTrunc0z*RFC3542AncillaryTest._testSingleCmsgTrunc0  r  r=   c                 2    |                      d           d S )Nr   r  )r  rT   s    r   testSingleCmsgTrunc1z)RFC3542AncillaryTest.testSingleCmsgTrunc1  s    ))Q)77777r=   c                     |                      | j                            | j                             |                     t
                     d S r  r  rT   s    r   _testSingleCmsgTrunc1z*RFC3542AncillaryTest._testSingleCmsgTrunc1  r  r=   c                 B    |                      dt          z             d S r  )r  rW  rT   s    r   testSingleCmsgTrunc2Intz,RFC3542AncillaryTest.testSingleCmsgTrunc2Int  s#    ))Q^)DDDDDr=   c                     |                      | j                            | j                             |                     t
                     d S r  r  rT   s    r   _testSingleCmsgTrunc2Intz-RFC3542AncillaryTest._testSingleCmsgTrunc2Int  r  r=   c                 \    |                      t          j        d          dz
             d S )Nr   r   r  )r  r   r-  rT   s    r   testSingleCmsgTruncLen0Minus1z2RFC3542AncillaryTest.testSingleCmsgTruncLen0Minus1  s.    ))V_Q5G5G!5K)LLLLLr=   c                     |                      | j                            | j                             |                     t
                     d S r  r  rT   s    r   _testSingleCmsgTruncLen0Minus1z3RFC3542AncillaryTest._testSingleCmsgTruncLen0Minus1  r  r=   c                    | j                             t          j        t          j        d           | j                                         |                     | j         t          t                    t          j
        t                    dz
            \  }}}}|                     |t                     |                     || j                   |                     |dt          j                   |                     t          |          d           |rv|d         \  }}}|                     |t          j                   |                     |t          j                   |                     t          |          t                     d S d S )Nr   Tr  r   )rc  r  r   r  r  r*  r   r5  r  r  r-  rW  r  r=  r   rM  r>  rU  r  r  r  s           r   testSingleCmsgTruncInDataz.RFC3542AncillaryTest.testSingleCmsgTruncInData  sV   
 	!!&"5"(":A	? 	? 	?$(NNNCHHfoj&A&AA&E%G %G!WeT 	c"""  t}5554&2CDDDS\\1--- 	8/6qz,J	9Z)<===Y(<===OOC	NNJ77777		8 	8r=   c                     |                      | j                            | j                             |                     t
                     d S r  r  rT   s    r   _testSingleCmsgTruncInDataz/RFC3542AncillaryTest._testSingleCmsgTruncInData  r  r=   c                    | j                             t          j        t          j        d           | j                             t          j        t          j        d           | j                                         |                     | j         t          t                    |          \  }}}}|                     |t                     |                     || j                   |                     |dt          j        |           |                     t          |          d           |d         \  }}}	|                     |t          j                   |                     |t          j        t          j        h           |                     t          |	          t&                     t)          j        d          }
|
                    |	           |                     |
d         d           |                     |
d         d           d S )Nr   Tr  r   rK   r-  )rc  r  r   r  r  r  r*  r   r5  r  r  r  r=  r   rM  r>  r  r  r  rW  r  rM  rT  rU  )rU   r  rZ  r  r  r  r  rO  rP  rQ  r  s              r   checkTruncatedSecondHeaderz/RFC3542AncillaryTest.checkTruncatedSecondHeader  s    	!!&"5"(":A	? 	? 	?!!&"5"("8!	= 	= 	=$(NN4>36s88Z%I %I!WeT 	c"""  t}5554&2C* 	 	, 	, 	, 	Wq)))+21:(
IyV%8999i&"4f6J!KLLLY444K	I!a(((QqT3'''''r=   c                 v    |                      t          j        t                    t          j                   d S r  )r  r   r  rW  r>  rT   s    r   testSecondCmsgTrunc0z)RFC3542AncillaryTest.testSecondCmsgTrunc0:  sC     	''(9*(E(E4:4E 	( 	G 	G 	G 	G 	Gr=   c                     |                      | j                            | j                             |                     t
                     d S r  r  rT   s    r   _testSecondCmsgTrunc0z*RFC3542AncillaryTest._testSecondCmsgTrunc0@  r  r=   c                 d    |                      t          j        t                    dz              d S rX  r  r   r  rW  rT   s    r   testSecondCmsgTrunc1z)RFC3542AncillaryTest.testSecondCmsgTrunc1E  s.     	''(9*(E(E(IJJJJJr=   c                     |                      | j                            | j                             |                     t
                     d S r  r  rT   s    r   _testSecondCmsgTrunc1z*RFC3542AncillaryTest._testSecondCmsgTrunc1J  r  r=   c                 t    |                      t          j        t                    dt          z  z              d S r  r  rT   s    r   testSecondCmsgTrunc2Intz,RFC3542AncillaryTest.testSecondCmsgTrunc2IntO  s?     	''(9*(E(E()J)7 	8 	8 	8 	8 	8r=   c                     |                      | j                            | j                             |                     t
                     d S r  r  rT   s    r   _testSecondCmsgTrunc2Intz-RFC3542AncillaryTest._testSecondCmsgTrunc2IntU  r  r=   c                     |                      t          j        t                    t          j        d          z   dz
             d S r  )r  r   r  rW  r-  rT   s    r   testSecondCmsgTruncLen0Minus1z2RFC3542AncillaryTest.testSecondCmsgTruncLen0Minus1Z  sR     	''(9*(E(E(.(:(:);=>)? 	@ 	@ 	@ 	@ 	@r=   c                     |                      | j                            | j                             |                     t
                     d S r  r  rT   s    r   _testSecondCmsgTruncLen0Minus1z3RFC3542AncillaryTest._testSecondCmsgTruncLen0Minus1`  r  r=   c                 p   | j                             t          j        t          j        d           | j                             t          j        t          j        d           | j                                         |                     | j         t          t                    t          j        t                    t          j        t                    z   dz
            \  }}}}|                     |t                     |                     || j                   |                     |dt          j                   t          j        t          j        h}|                    d          \  }}}|                     |t          j                   |                    |           |                     t          |          t                     t/          j        d          }	|	                    |           |                     |	d         d           |                     |	d         d           |rv|                    d          \  }}}|                     |t          j                   |                    |           |                     t          |          t                     |                     |g            d S )Nr   Tr  r   rK   r-  )rc  r  r   r  r  r  r*  r   r5  r  r  r  rW  r-  r  r=  r   rM  r>  r  r  popremover  rM  rT  rU  r  )
rU   r  r  r  r  
cmsg_typesrO  rP  rQ  r  s
             r   testSecondCmsgTruncInDataz.RFC3542AncillaryTest.testSecondCmsgTruncInDatae  sC   
 	!!&"5"(":A	? 	? 	?!!&"5"("8!	= 	= 	=$(NNNCHHj))FOJ,G,GG!K%M %M!WeT 	c"""  t}5554&2CDDD(&*>?
+2;;q>>(
IyV%8999)$$$Y444K	I!a(((QqT3''' 	8/6{{1~~,J	9Z)<===i(((OOC	NNJ777"%%%%%r=   c                     |                      | j                            | j                             |                     t
                     d S r  r  rT   s    r   _testSecondCmsgTruncInDataz/RFC3542AncillaryTest._testSecondCmsgTruncInData  r  r=   N)r-  r   r  )1r\   r]   r^   r  r  r  r  r  r   r  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  r  r  r  r  r  r  r  r  r  r  r!  r#  r%  r'  r,  r.  r_   r=   r   r  r    s        I M  + + + +8 \&-??- - @?- !  "! \&,(;_MME E NME  +  ,+ \&-++\&-??D D @? ,+D
    !  ?B12"+ "+ "+ "+H \&-#]4 4< <4 4< %0  10 \&,(;_#]4 4: :4 4: /:  ;: \&-++\&,(;_#]4 4A A4 4 ,+A $/  0/ \&-++\&,(;_#]4 4A A4 4 ,+A  / / ! /*, , , ,( \&-??I I @?I '  (' \&-??I I @?I %  &% \&-??8 8 @?8 %  &% \&-??E E @?E (  )( \&-??M M @?M #.  /. \&-??8 8 @?8* *  +*( ( ( (@ \&,(;_#]4 4G G4 4G %  &% \&,(;_#]4 4K K4 4K %  &% \&,(;_#]4 48 84 48 (  )( \&,(;_#]4 4@ @4 4@ #.  /. \&,(;_#]4 4!& !&4 4!&F *  +*  r=   r  c                       e Zd ZdS )SendrecvmsgUDPTestBaseNr\   r]   r^   r_   r=   r   r0  r0             	Dr=   r0  r  c                       e Zd ZdS )SendmsgUDPTestNr1  r_   r=   r   r4  r4            Dr=   r4  r  c                       e Zd ZdS )RecvmsgUDPTestNr1  r_   r=   r   r7  r7    r5  r=   r7  rS  c                       e Zd ZdS )RecvmsgIntoUDPTestNr1  r_   r=   r   r9  r9    r5  r=   r9  c                       e Zd Zd ZdS )SendrecvmsgUDP6TestBasec                 R    |                      |d d         |d d                    d S r  r9  r:  s      r   r=  z+SendrecvmsgUDP6TestBase.checkRecvmsgAddress  0     	ssU3B3Z00000r=   Nr\   r]   r^   r=  r_   r=   r   r;  r;    s#        1 1 1 1 1r=   r;  rJ  rq  r'   c                       e Zd ZdS )SendmsgUDP6TestNr1  r_   r=   r   r@  r@             	Dr=   r@  c                       e Zd ZdS )RecvmsgUDP6TestNr1  r_   r=   r   rC  rC    rA  r=   rC  c                       e Zd ZdS )RecvmsgIntoUDP6TestNr1  r_   r=   r   rE  rE    rA  r=   rE  r  c                       e Zd ZdS )RecvmsgRFC3542AncillaryUDP6TestNr1  r_   r=   r   rG  rG             	Dr=   rG  c                       e Zd ZdS )#RecvmsgIntoRFC3542AncillaryUDP6TestNr1  r_   r=   r   rJ  rJ    s         	Dr=   rJ  c                       e Zd ZdS )SendrecvmsgUDPLITETestBaseNr1  r_   r=   r   rL  rL    s        
 	Dr=   rL  c                       e Zd ZdS )SendmsgUDPLITETestNr1  r_   r=   r   rN  rN    rA  r=   rN  c                       e Zd ZdS )RecvmsgUDPLITETestNr1  r_   r=   r   rP  rP    rA  r=   rP  c                       e Zd ZdS )RecvmsgIntoUDPLITETestNr1  r_   r=   r   rR  rR    rA  r=   rR  c                       e Zd Zd ZdS )SendrecvmsgUDPLITE6TestBasec                 R    |                      |d d         |d d                    d S r  r9  r:  s      r   r=  z/SendrecvmsgUDPLITE6TestBase.checkRecvmsgAddress  r=  r=   Nr>  r_   r=   r   rT  rT    s#        1 1 1 1 1r=   rT  c                       e Zd ZdS )SendmsgUDPLITE6TestNr1  r_   r=   r   rW  rW    rH  r=   rW  c                       e Zd ZdS )RecvmsgUDPLITE6TestNr1  r_   r=   r   rY  rY    rH  r=   rY  c                       e Zd ZdS )RecvmsgIntoUDPLITE6TestNr1  r_   r=   r   r[  r[    rH  r=   r[  c                       e Zd ZdS )#RecvmsgRFC3542AncillaryUDPLITE6TestNr1  r_   r=   r   r]  r]    s         	Dr=   r]  c                       e Zd ZdS )'RecvmsgIntoRFC3542AncillaryUDPLITE6TestNr1  r_   r=   r   r_  r_    s         	Dr=   r_  c                       e Zd ZdS )SendrecvmsgTCPTestBaseNr1  r_   r=   r   ra  ra  $  r5  r=   ra  c                       e Zd ZdS )SendmsgTCPTestNr1  r_   r=   r   rc  rc  (  r5  r=   rc  c                       e Zd ZdS )RecvmsgTCPTestNr1  r_   r=   r   re  re  ,  r2  r=   re  c                       e Zd ZdS )RecvmsgIntoTCPTestNr1  r_   r=   r   rg  rg  1  r2  r=   rg  c                       e Zd ZdS )SendrecvmsgSCTPStreamTestBaseNr1  r_   r=   r   ri  ri  7  r2  r=   ri  z6IPPROTO_SCTP: [Errno 62] Protocol not supported on AIXrO   r@   rj  c                       e Zd ZdS )SendmsgSCTPStreamTestNr1  r_   r=   r   rk  rk  <  rA  r=   rk  c                        e Zd Z fdZ xZS )RecvmsgSCTPStreamTestc                     	 t          t          |                                            d S # t          $ r6}|j        t          j        k    r |                     d           Y d }~d S d }~ww xY wNz4sporadic ENOTCONN (kernel issue?) - see issue #13876)rj   rm  r  r   r(  ENOTCONNr   rU   r   rr   s     r   r  z$RecvmsgSCTPStreamTest.testRecvmsgEOFH  s    	R'..==????? 	R 	R 	Rw%.((MMPQQQQQQQQQ	R   ', 
A,+A''A,r\   r]   r^   r  rz   r{   s   @r   rm  rm  B  A        R R R R R R R R Rr=   rm  c                        e Zd Z fdZ xZS )RecvmsgIntoSCTPStreamTestc                     	 t          t          |                                            d S # t          $ r6}|j        t          j        k    r |                     d           Y d }~d S d }~ww xY wro  )rj   rv  r  r   r(  rp  r   rq  s     r   r  z(RecvmsgIntoSCTPStreamTest.testRecvmsgEOFV  s    	R+T22AACCCCC 	R 	R 	Rw%.((MMPQQQQQQQQQ	Rrr  rs  r{   s   @r   rv  rv  P  rt  r=   rv  c                       e Zd ZdS )SendrecvmsgUnixStreamTestBaseNr1  r_   r=   r   ry  ry  _  r5  r=   ry  rR  c                       e Zd ZdS )SendmsgUnixStreamTestNr1  r_   r=   r   r{  r{  c  r2  r=   r{  c                       e Zd ZdS )RecvmsgUnixStreamTestNr1  r_   r=   r   r}  r}  h  rA  r=   r}  c                       e Zd ZdS )RecvmsgIntoUnixStreamTestNr1  r_   r=   r   r  r  n  rA  r=   r  r  rL  c                       e Zd ZdS )RecvmsgSCMRightsStreamTestNr1  r_   r=   r   r  r  t  r2  r=   r  c                       e Zd ZdS )RecvmsgIntoSCMRightsStreamTestNr1  r_   r=   r   r  r  y  rA  r=   r  c                   `     e Zd Z fdZej        Z eed          r	dZ	d Z
 xZS dZ	d Z
 xZS )InterruptedTimeoutBasec                     t                                                       t          j        t          j        d           }|                     t          j        t          j        |           d S )Nc                     ddz  S r  r_   )signumr  s     r   rz  z.InterruptedTimeoutBase.setUp.<locals>.<lambda>  s
    A r=   )rj   rV   r  r  rt   )rU   orig_alrm_handlerrr   s     r   rV   zInterruptedTimeoutBase.setUp  sS    "M&.*E*EG Gv~7HIIIIIr=   	setitimerg?c                 D    t          j        t           j        |           d S rD   )r  r  ITIMER_REALrU   secondss     r   setAlarmzInterruptedTimeoutBase.setAlarm  s    V/99999r=   r   c                 .    t          j        |           d S rD   )r  r   r  s     r   r  zInterruptedTimeoutBase.setAlarm  s    L!!!!!r=   )r\   r]   r^   rV   r   rN  rG   r   r  
alarm_timer  rz   r{   s   @r   r  r    s        
J J J J J &G
 wv{## 
"
	: 	: 	: 	: 	: 	: 	: 
	" 	" 	" 	" 	" 	" 	"r=   r  siginterruptr   r  z+Don't have signal.alarm or signal.setitimerc                        e Zd Z fdZd Zd Zd Zd Zd Z e	e
j
        d          d             Z e	e
j
        d	          d
             Z xZS )InterruptedRecvTimeoutTestc                     t                                                       | j                            | j                   d S rD   )rj   rV   rP   r  rG   r0  s    r   rV   z InterruptedRecvTimeoutTest.setUp  s2    	T\*****r=   c                    	 |                      | j                   |                     t                    5 } ||i | d d d            n# 1 swxY w Y   |                      d           d S # |                      d           w xY wr   )r  r  r  r  rU   rP  rp   rq   r  s        r   checkInterruptedRecvz/InterruptedRecvTimeoutTest.checkInterruptedRecv  s    	MM$/***""#455 &d%f%%%& & & & & & & & & & & & & & & MM!DMM!s-   4A- 	AA- AA- AA- -Bc                 F    |                      | j        j        d           d S r   )r  rP   r  rT   s    r   testInterruptedRecvTimeoutz5InterruptedRecvTimeoutTest.testInterruptedRecvTimeout  s"    !!$).$77777r=   c                 `    |                      | j        j        t          d                     d S r   )r  rP   	recv_intor  rT   s    r   testInterruptedRecvIntoTimeoutz9InterruptedRecvTimeoutTest.testInterruptedRecvIntoTimeout  s)    !!$)"5yGGGGGr=   c                 F    |                      | j        j        d           d S r   )r  rP   r  rT   s    r   testInterruptedRecvfromTimeoutz9InterruptedRecvTimeoutTest.testInterruptedRecvfromTimeout  s#    !!$)"4d;;;;;r=   c                 `    |                      | j        j        t          d                     d S r   )r  rP   r  r  rT   s    r   "testInterruptedRecvfromIntoTimeoutz=InterruptedRecvTimeoutTest.testInterruptedRecvfromIntoTimeout  s)    !!$)"99T??KKKKKr=   r  c                 F    |                      | j        j        d           d S r   )r  rP   r  rT   s    r   testInterruptedRecvmsgTimeoutz8InterruptedRecvTimeoutTest.testInterruptedRecvmsgTimeout  s#    !!$)"3T:::::r=   rS  c                 b    |                      | j        j        t          d          g           d S r   )r  rP   rS  r  rT   s    r   !testInterruptedRecvmsgIntoTimeoutz<InterruptedRecvTimeoutTest.testInterruptedRecvmsgIntoTimeout  s,    !!$)"89T??:KLLLLLr=   )r\   r]   r^   rV   r  r  r  r  r  r  r   r  r  rz   r{   s   @r   r  r    s        + + + + +  8 8 8H H H< < <L L L \&-++; ; ,+; \&-00M M 10M M M M Mr=   r  c                        e Zd Z fdZd Zd Z ej        dd          d             Z ej        dd          d             Z	 ej        dd           e
ej        d          d	                         Z xZS )
InterruptedSendTimeoutTestc                    t                                                       |                                 | _        |                     | j        j                   t          j        | j                  }|	                                 | j
                                        \  | _        }|                     | j        j                   |                                 | j                            | j                   d S )N)target)rj   rV   r'  r  rt   r    rl   Thread	doConnectstartrP   r   r  r  r  rG   )rU   
cli_threadr  rr   s      r   rV   z InterruptedSendTimeoutTest.setUp  s    )),--- %T^<<<
"i..00t+,,,!!$,/////r=   c                 D    | j                             | j                   d S rD   )r  r   r+  rT   s    r   r  z$InterruptedSendTimeoutTest.doConnect  s     t~.....r=   c                     	 |                      t                    5 }	 |                     | j                    ||i | ## 1 swxY w Y   	 |                     d           d S # |                     d           w xY wNTr   )r  r  r  r  r  s        r   checkInterruptedSendz/InterruptedSendTimeoutTest.checkInterruptedSend  s    	""#455 **MM$/222D$)&)))** * * * * * * * *
 MM!DMM!s(   A$ %AAA$ A	A$ $A;r}  r%  c                 F    |                      | j        j        d           d S Nr  )r  r  r  rT   s    r   testInterruptedSendTimeoutz5InterruptedSendTimeoutTest.testInterruptedSendTimeout  s#    !!$."5x@@@@@r=   c                 R    |                      | j        j        d| j                   d S r  )r  r  r  r+  rT   s    r   testInterruptedSendtoTimeoutz7InterruptedSendTimeoutTest.testInterruptedSendtoTimeout  s4     	!!$."7"&.	2 	2 	2 	2 	2r=   r  c                 H    |                      | j        j        dg           d S r  )r  r  r  rT   s    r   testInterruptedSendmsgTimeoutz8InterruptedSendTimeoutTest.testInterruptedSendmsgTimeout  s'     	!!$."88*EEEEEr=   )r\   r]   r^   rV   r  r  r   requires_mac_verr  r  r  r   r  rz   r{   s   @r   r  r    s        0 0 0 0 0/ / /
 
 
 Wb!$$A A %$A Wb!$$2 2 %$2 Wb!$$\&-++F F ,+ %$F F F F Fr=   r  c                       e Zd Zd Zd ZdS )TCPCloserTestc                 |   | j                                         \  }}|                                 | j        }t	          j        |gg g d          \  }}}|                     ||g           |                     |                    d          d           |                                 |                                 d S )N      ?r   r=   )rP   r   r    r   r  r  r  )rU   r   r  sdr  r?  r  s          r   	testClosezTCPCloserTest.testClose  s    Y%%''
d

X!="r2s;;eSt$$$S))) 	



r=   c                 z    | j                             t          | j        f           t	          j        d           d S Nr  )r   r   r   rR   r   r   rT   s    r   
_testClosezTCPCloserTest._testClose  s0    $	*+++
3r=   N)r\   r]   r^   r  r  r_   r=   r   r  r    s2              r=   r  c                   @    e Zd ZddZd Zd Zd Zd Zd Zd Z	d	 Z
d
S )BasicSocketPairTestr   c                 >    t                               | |           d S r   )r  rk   r   s     r   rk   zBasicSocketPairTest.__init__!  s!    <<<<<r=   c                    |                      |t          j                   t          t          d          r&|                     |j        t          j                   n%|                     |j        t          j                   |                     |j        t          j                   |                     |j	        d           d S )NrR  r   )
r  r   r   r  r  rR  rO   r}  r@   r  r\  s     r   _check_defaultsz#BasicSocketPairTest._check_defaults$  s    dFM22269%% 	:T[&.9999T[&.999F$6777Q'''''r=   c                 :    |                      | j                   d S rD   )r  r   rT   s    r   _testDefaultsz!BasicSocketPairTest._testDefaults-  s    TX&&&&&r=   c                 :    |                      | j                   d S rD   )r  rP   rT   s    r   testDefaultsz BasicSocketPairTest.testDefaults0  s    TY'''''r=   c                 p    | j                             d          }|                     |t                     d S r   )rP   r  r  r  r  s     r   r  zBasicSocketPairTest.testRecv3  r  r=   c                 D    | j                             t                     d S rD   )r   r  r  rT   s    r   r  zBasicSocketPairTest._testRecv7  s    cr=   c                 D    | j                             t                     d S rD   )rP   r  r  rT   s    r   testSendzBasicSocketPairTest.testSend:  s    	sr=   c                 p    | j                             d          }|                     |t                     d S r   )r   r  r  r  r  s     r   	_testSendzBasicSocketPairTest._testSend=  s1    hmmD!!c"""""r=   Nr   )r\   r]   r^   rk   r  r  r  r  r  r  r  r_   r=   r   r  r    s        = = = =( ( (' ' '( ( (# # #    # # # # #r=   r  c                      e Zd ZddZd Zd Zd Zej        d             Z	 ej        e          Z
 ej         eed          d           ej        d	d
d          d                         Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )NonBlockingTCPTestsr   c                 n    t          j                    | _        t                              | |           d S r   )rl   r   eventr   rk   r   s     r   rk   zNonBlockingTCPTests.__init__D  s0    _&&
&&t
&CCCCCr=   c                    |                      | j                                        |           |dk    }|                      |                                |           t          a|d u }t	          j        |t          j        t          j                  }|                      t          |t          j        z             |           d S d S )N        )	r  rP   r  getblockingr   F_GETFLrF  
O_NONBLOCKbool)rU   rM  rG   blockingfd_blockingflags         r   assert_sock_timeoutz'NonBlockingTCPTests.assert_sock_timeoutH  s    --//999sN))++X666 #d?K;tU]BMBBDdR]&:!;!;;[IIIII r=   c                    | j                             d           |                     | j         d            | j                             d           |                     | j         d           | j                             d            |                     | j         d            | j                             d           |                     | j         d           | j                             d           |                     | j         d           | j                             d           |                     | j         d           d S )NTFr  r   r}  )rP   ri  r  r  rT   s    r   testSetBlockingz#NonBlockingTCPTests.testSetBlockingY  s   	d###  D111	e$$$  C000	T"""  D111	Q  A...	R     B///	Q  A.....r=   c                     d S rD   r_   rT   s    r   _testSetBlockingz$NonBlockingTCPTests._testSetBlockingm  r"  r=   c                    dd l }|j        |j        k    r|                     d           | j                            d           |                     | j                                        d           | j                            |j        dz              |                     | j                                                   d S )Nr   zneeds UINT_MAX < ULONG_MAXFr  r   )	r[  r  	ULONG_MAXr   rP   ri  r  r  r  r  s     r   testSetBlocking_overflowz,NonBlockingTCPTests.testSetBlocking_overflowp  s     	!444MM6777	e$$$--//555	i014555$)..0011111r=   rh  ztest needs socket.SOCK_NONBLOCKr         c                     | j                                          t          j        t          j        t          j        t          j        z            | _         |                     | j         d           d S r   )rP   r    r   rO   r@   rh  r  rT   s    r   testInitNonBlockingz'NonBlockingTCPTests.testInitNonBlocking  s[    
 		M&."("4v7K"KM M	  A.....r=   c                     d S rD   r_   rT   s    r   _testInitNonBlockingz(NonBlockingTCPTests._testInitNonBlocking  r"  r=   c                 D   t          d           5  | j                            d           | j                                        \  }}|                     |j                   |                     |                                           d d d            d S # 1 swxY w Y   d S )Nr}  )rI   rP   r  r   rt   r    r  r  r  s      r   testInheritFlagsBlockingz,NonBlockingTCPTests.testInheritFlagsBlocking  s     &d++ 	1 	1I  $$$))++JD$OODJ'''doo//000		1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   A8BBBc                 R    | j                             t          | j        f           d S rD   r   r   r   rR   rT   s    r   _testInheritFlagsBlockingz-NonBlockingTCPTests._testInheritFlagsBlocking  %    $	*+++++r=   c                 J   d}t          |          5  | j                            d           | j                                        \  }}|                     |j                   |                     |                                |           d d d            d S # 1 swxY w Y   d S )Ng      4@r}  )rI   rP   r  r   rt   r    r  r  )rU   default_timeoutr   r  s       r   testInheritFlagsTimeoutz+NonBlockingTCPTests.testInheritFlagsTimeout  s     %o66 	A 	AI  $$$))++JD$OODJ'''T__..@@@		A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	As   A9BBBc                 R    | j                             t          | j        f           d S rD   r  rT   s    r   _testInheritFlagsTimeoutz,NonBlockingTCPTests._testInheritFlagsTimeout  r  r=   c                    | j                             d           t          j                    }|                     t
                    5  | j                                         \  }}d d d            n# 1 swxY w Y   t          j                    |z
  }|                     |d           | j        	                                 t          j
        | j         gg g t          j                  \  }}}| j         |vr|                     d           | j                                         \  }}|                     |j                   |                     |                                           d S )NFr  z'Error trying to do accept after select.)rP   ri  r   	monotonicr  BlockingIOErrorr   r  r  r   r  r   LONG_TIMEOUTr  rt   r    r  r  )rU   
start_timer   r  dtr  r?  r  s           r   
testAcceptzNonBlockingTCPTests.testAccept  ss   	e$$$ ^%%
// 	, 	,))++JD$	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,^
*C   
!=$)b"g>RSSeS9D  II?@@@ Y%%''
d
###$//++,,,,,s   A11A58A5c                     | j                                          | j                            t          | j        f           d S rD   )r  r   r   r   r   rR   rT   s    r   _testAcceptzNonBlockingTCPTests._testAccept  s9     	
$	*+++++r=   c                    | j                                         \  }}|                     |j                   |                    d           |                     t                    5  |                    t          t                              }d d d            n# 1 swxY w Y   | j
                                         t          j        |gg g t          j                  \  }}}||vr|                     d           |                    t          t                              }|                     |t                     d S )NFz0Error during select call to non-blocking socket.)rP   r   rt   r    ri  r  r  r  r  r  r  r   r  r   r  r  r  )rU   r   r  r  r  r?  r  s          r   r  zNonBlockingTCPTests.testRecv  sK   Y%%''
d
### // 	& 	&))CHH%%C	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	
!=$R9MNNeStIIHIII iiC!!c"""""s   &(BB!Bc                     | j                             t          | j        f           | j                                         | j                             t                     d S rD   )r   r   r   rR   r  r   r  r  rT   s    r   r  zNonBlockingTCPTests._testRecv  sQ    $	*+++ 	
 	r=   Nr   )r\   r]   r^   rk   r  r  r  r   r  r  _testSetBlocking_overflowr   r  r   r   requires_linux_versionr  r  r  r  r  r  r  r   r  r  r_   r=   r   r  r  B  ss       D D D DJ J J"/ / /(   
2 
2 
2 !5 45E F FX99:< <#W#Aq"--/ / .-< </  1 1 1, , ,	A 	A 	A, , ,- - -,, , ,# # #(    r=   r  c                       e Zd ZdZdZdZdZdZdZe	Z
dZe	Zd"d	Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d  Z$d! Z%dS )#FileObjectClassTestCaseao  Unit tests for the object returned by socket.makefile()

    self.read_file is the io object returned by makefile() on
    the client connection.  You can read from this file to
    get output from the server.

    self.write_file is the io object returned by makefile() on the
    server connection.  You can write to this file to send output
    to the client.
    rW  r	   strictNr   r0  r   c                 >    t                               | |           d S r   r  r   s     r   rk   z FileObjectClassTestCase.__init__  r  r=   c                    d t          d          D             \  | _        | _        | _        | _        t
                              |            | j                            | j	        | j
        | j        | j        | j                  | _        d S )Nc                 4    g | ]}t          j                    S r_   )rl   r   r  rK   s     r   r  z1FileObjectClassTestCase.setUp.<locals>.<listcomp>  s3     G1 G1 G1"#IOG1 G1 G1r=   r  r4  errorsnewline)r=  evt1evt2serv_finishedcli_finishedr  rV   r  r  	read_moder   r4  r  r  	read_filerT   s    r   rV   zFileObjectClassTestCase.setUp  s    G1 G1',QxxG1 G1 G1C	49d0$2C!!$'''//NDL}[l	 0 $ $r=   c                     | j                                          | j                                         |                     | j        j                   d | _        t                              |            d S rD   )r  r   r  r    r  closedr  rY   rT   s    r   rY   z FileObjectClassTestCase.tearDown  sc       -...$$T*****r=   c                     t                               |            | j                            | j        | j        | j        | j        | j                  | _	        d S )Nr  )
r  r   r  r  
write_moder   r4  r  r  
write_filerT   s    r   r   z#FileObjectClassTestCase.clientSetUp  sP    ''---.11OT\}[l	 2 $ $r=   c                     | j                                          | j                                         |                     | j        j                   d | _        t                              |            d S rD   )r  r   r  r    r  r  r  r   rT   s    r   r   z&FileObjectClassTestCase.clientTearDown  sc    .///**400000r=   c                    | j                             d           | j                            d           |                     t
          | j        j        d           |                     t                    5 }| j                            d           d d d            n# 1 swxY w Y   |                     dt          |j	                             d S )Nr   r  z!cannot read from timed out object)
r  r  r  r  r  r  r   r  r  r  )rU   ctxs     r   testReadAfterTimeoutz,FileObjectClassTestCase.testReadAfterTimeout  s     	  ###A,(;Q???w'' 	#3N"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#93s};M;MNNNNNs   5BB #B c                     | j                             | j        dd                    | j                                          | j                                         d S )Nr   r  )r  r?  	write_msgflushr  r   rT   s    r   _testReadAfterTimeoutz-FileObjectClassTestCase._testReadAfterTimeout'  sR    dnQqS1222!!!!!r=   c                     | j                             t          | j                  dz
            }| j                             d          }||z   }|                     || j                   d S r  )r  r  r  read_msgr  )rU   	first_seg
second_segr  s       r   testSmallReadz%FileObjectClassTestCase.testSmallRead,  sc    N''DM(:(:1(<==	^((++
*$dm,,,,,r=   c                 v    | j                             | j                   | j                                          d S rD   r  r?  r  r   rT   s    r   _testSmallReadz&FileObjectClassTestCase._testSmallRead3  4    dn---r=   c                 n    | j                                         }|                     || j                   d S rD   )r  r  r  r#  r  s     r   testFullReadz$FileObjectClassTestCase.testFullRead7  s3    n!!##dm,,,,,r=   c                 v    | j                             | j                   | j                                          d S rD   )r  r?  r  r    rT   s    r   _testFullReadz%FileObjectClassTestCase._testFullRead<  r*  r=   c                      t          | j                              }	 | j                            d          }|sn||z  }#|                     || j                   d S rX  )r}  r#  r  r  r  )rU   rV  chars      r   testUnbufferedReadz*FileObjectClassTestCase.testUnbufferedRead@  sl    !d4=!!##	>&&q))D 4KC		
 	dm,,,,,r=   c                 v    | j                             | j                   | j                                          d S rD   r(  rT   s    r   _testUnbufferedReadz+FileObjectClassTestCase._testUnbufferedReadJ  r*  r=   c                 n    | j                                         }|                     || j                   d S rD   )r  readliner  r#  rU   lines     r   testReadlinez$FileObjectClassTestCase.testReadlineN  s3    ~&&((t}-----r=   c                 v    | j                             | j                   | j                                          d S rD   r(  rT   s    r   _testReadlinez%FileObjectClassTestCase._testReadlineS  r*  r=   c                     | j                                          | j                                        }|                     || j                   d S rD   )r  r    r  r  r  r#  r  s     r   testCloseAfterMakefilez.FileObjectClassTestCase.testCloseAfterMakefileW  sG    n!!##dm,,,,,r=   c                 v    | j                             | j                   | j                                          d S rD   r(  rT   s    r   _testCloseAfterMakefilez/FileObjectClassTestCase._testCloseAfterMakefile^  r*  r=   c                 "   | j                                          | j                            t	          t
                              }t          | j        t                    r|	                                }| 
                    || j                   d S rD   )r  r    r  r  r  r  r|  r#  r  decoder  r  s     r   testMakefileAfterMakefileClosez6FileObjectClassTestCase.testMakefileAfterMakefileCloseb  sp    m  S**dmS)) 	**,,Cdm,,,,,r=   c                 v    | j                             | j                   | j                                          d S rD   r(  rT   s    r   _testMakefileAfterMakefileClosez7FileObjectClassTestCase._testMakefileAfterMakefileClosei  r*  r=   c                 F    |                      | j        j                    d S rD   )r  r  r  rT   s    r   testClosedAttrz&FileObjectClassTestCase.testClosedAttrm  s"    DN1122222r=   c                 F    |                      | j        j                    d S rD   )r  r  r  rT   s    r   _testClosedAttrz'FileObjectClassTestCase._testClosedAttrp  s"    DO2233333r=   c                     |                      | j        j        | j                   |                      | j        j        | j                                                   d S rD   )r  r  r2  r  r  r  r  rT   s    r   testAttributesz&FileObjectClassTestCase.testAttributess  sN    ,dn===,dm.B.B.D.DEEEEEr=   c                     |                      | j        j        | j                   |                      | j        j        | j                                                   d S rD   )r  r  r2  r  r  r  r  rT   s    r   _testAttributesz'FileObjectClassTestCase._testAttributesw  sN    -t???-t~/D/D/F/FGGGGGr=   c                     | j                                          |                     t          | j         j                   | j                                         |                     t          | j        j                   d S rD   )r  r    r  r  r  r  r   r   rT   s    r   testRealClosez%FileObjectClassTestCase.testRealClose{  sf    *dn&;<<<'4=#<=====r=   c                     d S rD   r_   rT   s    r   _testRealClosez&FileObjectClassTestCase._testRealClose  r"  r=   r   )&r\   r]   r^   ry   r   r4  r  r  r  r  r#  r  r  rk   rV   rY   r   r   r  r!  r&  r)  r,  r.  r1  r3  r8  r:  r<  r>  rA  rC  rE  rG  rI  rK  rM  rO  r_   r=   r   r  r    s       	 	 GHFGIHJIB B B B$ $ $+ + +$ $ $1 1 1
O 
O 
O" " "
- - -     - - -
     - - -     . . .
     - - -     - - -     3 3 34 4 4F F FH H H> > >    r=   r  c                   R    e Zd ZdZdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd ZdS )!UnbufferedFileObjectClassTestCasea  Repeat the tests from FileObjectClassTestCase with bufsize==0.

    In this case (and in this case only), it should be possible to
    create a file object, read a line from it, create another file
    object, read another line from it, without loss of data in the
    first file object's buffer.  Note that http.client relies on this
    when reading multiple requests from the same socket.r   c                 "   | j                                         }|                     |d| j        z              | j                            dd          | _         | j                                         }|                     |d| j        z              d S )N   A. r   r      B. )r  r5  r  r  r  r  r6  s     r   testUnbufferedReadlinez8UnbufferedFileObjectClassTestCase.testUnbufferedReadline  s    ~&&((v6777//a88~&&((v677777r=   c                     | j                             d| j        z              | j                             d| j        z              | j                                          d S )NrS  rT  r(  rT   s    r   _testUnbufferedReadlinez9UnbufferedFileObjectClassTestCase._testUnbufferedReadline  sV    ft~5666ft~5666r=   c                     | j                                          | j                             d          }|                     || j                   | j                                         |                     t          | j         j        d           d S r   )r  r    r  r  r#  r  r  r   r  s     r   testMakefileClosez3UnbufferedFileObjectClassTestCase.testMakefileClose  sz    m  &&dm,,,'4=#5t<<<<<r=   c                 v    | j                             | j                   | j                                          d S rD   r(  rT   s    r   _testMakefileClosez4UnbufferedFileObjectClassTestCase._testMakefileClose  r*  r=   c                     t          j        | j                  }| j                                         t          j        | j                  }|                     |dz
  |           d S rX  )r?  r=  r  r  r    r  )rU   refcount_beforerefcount_afters      r   testMakefileCloseSocketDestroyz@UnbufferedFileObjectClassTestCase.testMakefileCloseSocketDestroy  sY    /$-88771,n=====r=   c                     d S rD   r_   rT   s    r   _testMakefileCloseSocketDestroyzAUnbufferedFileObjectClassTestCase._testMakefileCloseSocketDestroy  r"  r=   c                 $   | j                             d           |                     | j                            t          d                    d            |                     | j                            t          | j                  dz
            d            | j	        
                                 | j                            d           | j                            t          | j                  dz
            }|Ct          j        d           | j                            t          | j                  dz
            }t          d          }| j                            |          }|                     |d           ||d |         z   }|                     || j                   |                     | j                            t          d                    d            |                     | j                            d          d            d S )NFr}  r  r  g      ?rG  r   )r  ri  r  r  readintor  r  r  r#  r  r   r  r   r   r   )rU   r$  rV  r5  r  s        r   testSmallReadNonBlockingz:UnbufferedFileObjectClassTestCase.testSmallReadNonBlocking  s   !!%(((002??FFF,,S-?-?!-CDDdKKK		sN''DM(:(:Q(>??	JsOOO++C,>,>,BCCImmN##C((A#bqb'!dm,,,002??FFF,,Q//66666r=   c                    | j                             d           | j                            | j                   | j                                         | j                                         | j                            d           d S )Nr        @)	r  r   r  r?  r  r   r  r   r  rT   s    r   _testSmallReadNonBlockingz;UnbufferedFileObjectClassTestCase._testSmallReadNonBlocking  sp    	sdn---	 	$$$$$r=   c                     | j                             d           | j        r|                     | j                   d S d S )Nrf  )r  r   serv_skippedr   rT   s    r   testWriteNonBlockingz6UnbufferedFileObjectClassTestCase.testWriteNonBlocking  sK    s###  	-MM$+,,,,,	- 	-r=   c                 f   d | _         | j                            d           dt          j        z  }d}| j                            |          }|                     |d           t          |          D ]7}| j                            |          }| d S |                     |d           8d| _         d S )NFr
  r}  r   z$failed to saturate the socket buffer)	ri  r  ri  r   r  r  r?  r/  r=  )rU   BIGLIMITr5  rK   s        r   _testWriteNonBlockingz7UnbufferedFileObjectClassTestCase._testWriteNonBlocking  s     ""5)))W**O!!#&&1a   u 
	G 
	GA%%c**Ayq!$$$$
 !GDr=   N)r\   r]   r^   ry   r   rU  rW  rY  r[  r_  ra  rd  rg  rj  rn  r_   r=   r   rQ  rQ    s        < < G8 8 8     
= = =     > > >  7 7 7&% % %- - -G G G G Gr=   rQ  c                       e Zd ZdZdS )#LineBufferedFileObjectClassTestCaser   Nr\   r]   r^   r   r_   r=   r   rp  rp            GGGr=   rp  c                       e Zd ZdZdS )$SmallBufferedFileObjectClassTestCaser   Nrq  r_   r=   r   rt  rt    rr  r=   rt  c                   L    e Zd ZdZdZe                    d          ZdZeZ	dZ
dS )"UnicodeReadFileObjectClassTestCase=Tests for socket.makefile() in text mode (rather than binary)r   r	   r0  r  Nr\   r]   r^   ry   r  r  r@  r#  r  r  r  r_   r=   r   rv  rv    s9        GGIzz'""HJIGGGr=   rv  c                   L    e Zd ZdZdZeZdZe                    d          Z	dZ
dS )#UnicodeWriteFileObjectClassTestCaserw  r   r/  r	   r  N)r\   r]   r^   ry   r  r  r#  r  r@  r  r  r_   r=   r   rz  rz    s9        GGIHJ

7##IGGGr=   rz  c                   r    e Zd ZdZdZe                    d          ZdZe                    d          Z	dZ
dS )'UnicodeReadWriteFileObjectClassTestCaserw  r   r	   r/  r  Nrx  r_   r=   r   r|  r|    sE        GGIzz'""HJ

7##IGGGr=   r|  c                       e Zd ZdZd ZdS )NetworkConnectionTestzProve network connection.c                 h    t          j        t          | j        f          | _        | j        | _        d S rD   )r   create_connectionr   rR   r   r  rT   s    r   r   z!NetworkConnectionTest.clientSetUp  s*     +T49,=>>r=   N)r\   r]   r^   ry   r   r_   r=   r   r~  r~    s)        ##" " " " "r=   r~  c                       e Zd ZdZdS )BasicTCPTest2zLTests that NetworkConnection does not break existing TCP functionality.
    N)r\   r]   r^   ry   r_   r=   r   r  r  "  s           r=   r  c                   l    e Zd Z G d dej                  Zej        d             Zd Zd Z	d Z
d ZdS )	NetworkConnectionNoServerc                       e Zd Zd ZdS )$NetworkConnectionNoServer.MockSocketc                      t          d          )Nz	timed out)r  r0  s     r   r   z,NetworkConnectionNoServer.MockSocket.connect)  s    {+++r=   N)r\   r]   r^   r   r_   r=   r   
MockSocketr  (  s#        	, 	, 	, 	, 	,r=   r  c              #      K   t           j         }| j        t           _         	 dV  |t           _         dS # |t           _         w xY w)z*Return a socket which times out on connectN)r   r  )rU   
old_sockets     r   mocked_socket_modulez.NetworkConnectionNoServer.mocked_socket_module,  sD       ]
	'EEE&FMMMJFM&&&&s	   3 Ac                    t          j                    }t          j        t          j        t          j                  }|                     |j                   |                     t                    5 }|	                    t          |f           d d d            n# 1 swxY w Y   |                     |j        j        t          j                   d S rD   )r   r  r   rO   r@   rt   r    r  r   r   r   r  r  r(  ECONNREFUSED)rU   rR   r   r  s       r   test_connectz&NetworkConnectionNoServer.test_connect6  s    -//mFNF,>??	"""w'' 	&2KKt%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&+U-?@@@@@s   1BB!Bc                 ,   t          j                    }|                     t                    5 }t	          j        t          |f           d d d            n# 1 swxY w Y   t          j                    }|                     |j	        j
        |           d S rD   )r   r  r  r   r   r  r   get_socket_conn_refused_errsr  r  r(  )rU   rR   r  expected_errnoss       r   test_create_connectionz0NetworkConnectionNoServer.test_create_connection>  s     -//w'' 	32$dD\222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3" (DFFbl(/:::::s   AAAc                    t          j                    }	 t          j        t          |fd           |                     d           n# t          $ r}|}Y d }~nd }~ww xY w|                     |t                     |j        D ]}|                     |t                     t          j
        d|dt          j                  }|                     t          |          t          |j                             d S )NT)
all_errorszexpected connection to failr  r   )r   r  r   r  r   r  ExceptionGroupr  
exceptionsr   r  r@   r  r  )rU   rR   r   eg	addressess        r   !test_create_connection_all_errorsz;NetworkConnectionNoServer.test_create_connection_all_errorsV  s   -//	5$dD\dCCCC II34444  	 	 	BBBBBB	
 	b.111 	. 	.A!!!W----&q&"46 6	 	YR]););<<<<<s   A 
AAAc                 L   |                                  5  	 t          j        t          df           |                     d           nD# t
          $ r Y n8t          $ r,}t          j        s|j	        t          j
        k    r Y d }~nd }~ww xY wd d d            d S # 1 swxY w Y   d S )Nr
   zTimeoutError not raised)r  r   r  r   r  r  r   r   r  r(  EAFNOSUPPORTr  s     r   test_create_connection_timeoutz8NetworkConnectionNoServer.test_create_connection_timeouth  s    &&(( 		5 		55($666 		34444         - e>P1P1P 2Q1P1P1P1P		5 		5 		5 		5 		5 		5 		5 		5 		5 		5 		5 		5 		5 		5 		5 		5 		5 		5sE   BAB
B	B	B	"B?BB		BB BN)r\   r]   r^   r   r  
contextlibcontextmanagerr  r  r  r  r  r_   r=   r   r  r  &  s        , , , , ,V] , , , ' ' 'A A A; ; ;0= = =$5 5 5 5 5r=   r  c                   d    e Zd ZddZd Zd Zd ZeZd ZeZ	d Z
eZd ZeZd	 ZeZd
 ZeZd ZdS )NetworkConnectionAttributesTestr   c                 r    t                               | |           t                              |            d S r   r   r   s     r   rk   z(NetworkConnectionAttributesTest.__init__y  r   r=   c                 6    t          j                    | _        d S rD   )r   r  source_portrT   s    r   r   z+NetworkConnectionAttributesTest.clientSetUp}  s    (9;;r=   c                 z    | j                                          d | _         t                              |            d S rD   r   rT   s    r   r   z.NetworkConnectionAttributesTest.clientTearDown  r   r=   c                 f    | j                                         \  }}|                                 d S rD   )rP   r   r    r  s      r   _justAcceptz+NetworkConnectionAttributesTest._justAccept  s*    Y%%''
d

r=   c                     t          j        t          | j        ft          j                  | _        |                     | j        j                   | 	                    | j        j
        d           d S )Nr  r   )r   r  r   rR   r   rN  r   rt   r    r  r  rT   s    r   _testFamilyz+NetworkConnectionAttributesTest._testFamily  s`    +T49,=$+$<> > >'''!,,,,,r=   c                 &   t          j        t          | j        ft          j        d| j        f          | _        |                     | j        j	                   | 
                    | j                                        d         | j                   d S )Nr  )rG   source_addressr   )r   r  r   rR   r   rN  r  r   rt   r    r  r   rT   s    r   _testSourceAddressz2NetworkConnectionAttributesTest._testSourceAddress  s    +T49,=$+$<,.0@+AC C C 	'''--//2D4DEEEEEr=   c                    |                      t          j                    d u            t          j        d           	 t          j        t
          | j        f          | _        |                     | j        j	                   t          j        d            n# t          j        d            w xY w| 
                    | j                                        d           d S )NrZ  r  r   rE   rF   r  r   rR   r   rt   r    r  r  rT   s    r   _testTimeoutDefaultz3NetworkConnectionAttributesTest._testTimeoutDefault  s    022d:;;; $$$	+/ty0ABBDHOODHN+++$T****F$T****,,..33333s   AB B-c                    |                      t          j                    d u            t          j        d           	 t          j        t
          | j        fd           | _        |                     | j        j	                   t          j        d            n# t          j        d            w xY w| 
                    | j                                        d            d S N   r  r  rT   s    r   _testTimeoutNonez0NetworkConnectionAttributesTest._testTimeoutNone  s    022d:;;; $$$	+/ty0A4PPPDHOODHN+++$T****F$T****,,..55555s   AB B/c                     t          j        t          | j        fd          | _        |                     | j                                        d           d S r  )r   r  r   rR   r   r  r  rT   s    r   _testTimeoutValueNamedz6NetworkConnectionAttributesTest._testTimeoutValueNamed  sJ    +T49,=rJJJ,,..33333r=   c                     t          j        t          | j        fd          | _        |                     | j        j                   |                     | j                                        d           d S )Nr  )	r   r  r   rR   r   rt   r    r  r  rT   s    r   _testTimeoutValueNonamedz8NetworkConnectionAttributesTest._testTimeoutValueNonamed  s]    +T49,=rBB''',,..33333r=   Nr   )r\   r]   r^   rk   r   r   r  
testFamilyr  testSourceAddressr  testTimeoutDefaultr  testTimeoutNoner  testTimeoutValueNamedr  testTimeoutValueNonamedr  r_   r=   r   r  r  w  s        & & & &< < <, , ,
   J- - - $F F F %	4 	4 	4 "O	6 	6 	6 (4 4 4 *4 4 4 4 4r=   r  c                   8    e Zd Zd	dZd Zd Zd ZeZd Zd Z	dS )
NetworkConnectionBehaviourTestr   c                 r    t                               | |           t                              |            d S r   r   r   s     r   rk   z'NetworkConnectionBehaviourTest.__init__  r   r=   c                     d S rD   r_   rT   s    r   r   z*NetworkConnectionBehaviourTest.clientSetUp  r"  r=   c                 z    | j                                          d | _         t                              |            d S rD   r   rT   s    r   r   z-NetworkConnectionBehaviourTest.clientTearDown  r   r=   c                     | j                                         \  }}|                     |j                   t	          j        d           |                    d           d S )Nr     done!)rP   r   rt   r    r   r   r  r  s      r   testInsideTimeoutz0NetworkConnectionBehaviourTest.testInsideTimeout  sR    Y%%''
d
###
1		(r=   c                     t          j        t          | j        f          x| _        }|                    d          }|                     |d           d S )Nr  r  )r   r  r   rR   r   r  r  )rU   rM  r  s      r   _testInsideTimeoutz1NetworkConnectionBehaviourTest._testInsideTimeout  sK     2D$)3DEEE4yy||x(((((r=   c                     t          j        t          | j        fd          x| _        |                     t          fd           d S )Nr   r  c                  .                          d          S )Nr  )r  )rM  s   r   rz  zDNetworkConnectionBehaviourTest._testOutsideTimeout.<locals>.<lambda>  s    		! r=   )r   r  r   rR   r   r  r  r\  s    @r   _testOutsideTimeoutz2NetworkConnectionBehaviourTest._testOutsideTimeout  sL     2D$)3DaPPPP4,(<(<(<(<=====r=   Nr   )
r\   r]   r^   rk   r   r   r  testOutsideTimeoutr  r  r_   r=   r   r  r    s{        & & & &  , , ,
  
 +) ) )
> > > > >r=   r  c                   b    e Zd Zd Zd Z ej         eed          d          d             Z	dS )TCPTimeoutTestc                 J      fd}                      t          |d           d S )Nc                  n    j                             d           j                                          d S r  )rP   r  r   rp   rq   rU   s     r   raise_timeoutz4TCPTimeoutTest.testTCPTimeout.<locals>.raise_timeout  s3    I  %%%Ir=   z*Error generating a timeout exception (TCP)r  r  rU   r  s   ` r   testTCPTimeoutzTCPTimeoutTest.testTCPTimeout  sL    	 	 	 	 	 	,J	L 	L 	L 	L 	Lr=   c                 8   d}	 | j                             d           | j                                         }nI# t          $ r |                     d           Y n(t
          $ r d}Y n |                     d           Y nxY w|s|                     d           d S d S )NFr  z%caught timeout instead of error (TCP)Tz!caught unexpected exception (TCP)z3accept() returned success when we did not expect it)rP   r  r   r  r  r   rU   okr  s      r   testTimeoutZerozTCPTimeoutTest.testTimeoutZero  s    	;I  %%%)""$$CC 	? 	? 	?II=>>>>> 	 	 	BBB	;II9::::: 	MIIKLLLLL	M 	Ms   38 A>A>&A>r   ztest needs signal.alarm()c                 >   | j                             d            G d dt                    fd}t          j        t          j        |          }	 	 t          j        d           | j                                         }|                     d           ns# t          $ r |                     d           Y nR$ r Y nL |                     dt          j
                    d d         t          j                    fz   z             Y nxY wt          j        d	           n# t          j        d	           w xY wn # $ r |                     d
           Y nw xY wt          j        t          j        |           d S # t          j        t          j        |           w xY w)Nrf  c                       e Zd ZdS )4TCPTimeoutTest.testInterruptedTimeout.<locals>.AlarmNr1  r_   r=   r   Alarmr    s        Dr=   r  c                     rD   r_   )r  r  r  s     r   alarm_handlerz<TCPTimeoutTest.testInterruptedTimeout.<locals>.alarm_handler  s    Kr=   r   znothing caughtzcaught timeout instead of Alarmz3caught other exception instead of Alarm: %s(%s):
%sr   zgot Alarm in wrong place)rP   r  rE  r  r  r   r   r  r  r?  exc_info	traceback
format_exc)rU   r  r  r  r  s       @r   testInterruptedTimeoutz%TCPTimeoutTest.testInterruptedTimeout  s    		S!!!	 	 	 	 	I 	 	 		 	 	 	 	M&.-@@		5 Qi&&(( 		*++++   = = =		;<<<<<   L		 )<>>"1"-1E1G1G0IIK L L L L L QQ 	2 	2 	2II011111	2 M&.)44444FM&.)4444sg   -B D  D7D  9D=D  ?ADD  D:  D66D: 9E; :EE; EE; ;!FN)
r\   r]   r^   r  r  r   r  r   r  r  r_   r=   r   r  r    sv        L L LM M M X1146 65 56 65 5 5r=   r  c                       e Zd Zd Zd ZdS )UDPTimeoutTestc                 J      fd}                      t          |d           d S )Nc                  p    j                             d           j                             d           d S Nr  r  rP   r  r  r  s     r   r  z4UDPTimeoutTest.testUDPTimeout.<locals>.raise_timeout  3    I  %%%INN4     r=   z*Error generating a timeout exception (UDP)r  r  s   ` r   testUDPTimeoutzUDPTimeoutTest.testUDPTimeout  sL    	! 	! 	! 	! 	! 	,J	L 	L 	L 	L 	Lr=   c                 :   d}	 | j                             d           | j                             d          }nI# t          $ r |                     d           Y n(t
          $ r d}Y n |                     d           Y nxY w|s|                     d           d S d S )NFr  r  z%caught timeout instead of error (UDP)Tz!caught unexpected exception (UDP)1recv() returned success when we did not expect itrP   r  r  r  r  r   r  s      r   r  zUDPTimeoutTest.testTimeoutZero  s    	;I  %%%)..&&CC 	? 	? 	?II=>>>>> 	 	 	BBB	;II9::::: 	KIIIJJJJJ	K 	K   49 A?A?'A?N)r\   r]   r^   r  r  r_   r=   r   r  r    s:        L L LK K K K Kr=   r  c                       e Zd Zd Zd ZdS )UDPLITETimeoutTestc                 J      fd}                      t          |d           d S )Nc                  p    j                             d           j                             d           d S r  r  r  s     r   r  z<UDPLITETimeoutTest.testUDPLITETimeout.<locals>.raise_timeout2  r  r=   z.Error generating a timeout exception (UDPLITE)r  r  s   ` r   testUDPLITETimeoutz%UDPLITETimeoutTest.testUDPLITETimeout1  sL    	! 	! 	! 	! 	! 	,N	P 	P 	P 	P 	Pr=   c                 :   d}	 | j                             d           | j                             d          }nI# t          $ r |                     d           Y n(t
          $ r d}Y n |                     d           Y nxY w|s|                     d           d S d S )NFr  r  z)caught timeout instead of error (UDPLITE)Tz%caught unexpected exception (UDPLITE)r  r  r  s      r   r  z"UDPLITETimeoutTest.testTimeoutZero8  s    	?I  %%%)..&&CC 	C 	C 	CIIABBBBB 	 	 	BBB	?II=>>>>> 	KIIIJJJJJ	K 	Kr  N)r\   r]   r^   r  r  r_   r=   r   r  r  -  s:        P P PK K K K Kr=   r  c                       e Zd Zd Zd ZdS )TestExceptionsc                     |                      t          t          t                               |                      t          t          j        t                               |                      t          t          j        t                               |                      t          t          j        t                               |                     t          j	        t                     |                     t          j        t                     d S rD   )r  
issubclassr   rE  r   r  r  rG   assertIserrorr  rT   s    r   testExceptionTreez TestExceptions.testExceptionTreeH  s    
7I66777
6='::;;;
6?G<<===
6>7;;<<<flG,,,fnl33333r=   c                    t          j         t           j        t           j        d          }t          j         t           j        t           j        d|                                          }|                                 |                     |j                   |                     t                    5  |	                    d           d d d            d S # 1 swxY w Y   d S )Nr   F)
r   rO   r@   r  r    rt   ro  r  r   ri  )rU   sock0rM  s      r   test_setblocking_invalidfdz)TestExceptions.test_setblocking_invalidfdP  s     fnf.@!DD}NF.5<<>>C C$$$w'' 	$ 	$U###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$s   0CCCN)r\   r]   r^   r  r  r_   r=   r   r  r  F  s2        4 4 4
$ 
$ 
$ 
$ 
$r=   r  rh  Linux specific testc                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	TestLinuxAbstractNamespacel   c                    d}t          j         t           j        t           j                  5 }|                    |           |                                 t          j         t           j        t           j                  5 }|                    |                                           |                                d         5 }|                     |                                |           |                     |	                                |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Ns    python-test-hello r   )
r   rR  r@   r   rS   r   r   r   r  r  )rU   r  s1r  s3s        r   testLinuxAbstractNamespacez5TestLinuxAbstractNamespace.testLinuxAbstractNamespaceb  s   2]6>6+=>> 	@"GGGIIKKKv~v/ABB @b

2>>++,,,YY[[^ @r$$R^^%5%5w???$$R^^%5%5w???@ @ @ @ @ @ @ @ @ @ @ @ @ @ @@ @ @ @ @ @ @ @ @ @ @ @ @ @ @	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@s\   AE?AD5ADD5D""D5%D"&D5)E5D9	9E<D9	=EEEc                 $   dd| j         dz
  z  z   }t          j        t          j        t          j                  5 }|                    |           |                     |                                |           d d d            d S # 1 swxY w Y   d S )Nr     hr   )UNIX_PATH_MAXr   rR  r@   r   r  r   rU   r  r#   s      r   testMaxNamez&TestLinuxAbstractNamespace.testMaxNamem  s    DD$6$:;;]6>6+=>> 	7!FF7OOOQ]]__g666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s   >BB	B	c                     dd| j         z  z   }t          j        t          j        t          j                  5 }|                     t
          |j        |           d d d            d S # 1 swxY w Y   d S )N h)r	  r   rR  r@   r  r   r   r		  s      r   testNameOverflowz+TestLinuxAbstractNamespace.testNameOverflows  s    3!333]6>6+=>> 	8!gqvw777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s   "A&&A*-A*c                 .   t          j         t           j        t           j                  }	 |                    d           |                     |                                d           |                                 d S # |                                 w xY w)Nz python test     python test )r   rR  r@   r   r  r   r    r  s     r   testStrNamez&TestLinuxAbstractNamespace.testStrNamex  sr    M&.&*<==	FF+,,,Q]]__.GHHHGGIIIIIAGGIIIIs   =A> >Bc                    t          j         t           j        t           j                  5 }|                    t	          d                     |                     |                                d           d d d            d S # 1 swxY w Y   d S )Nr	  )r   rR  r@   r   r  r  r   r  s     r   testBytearrayNamez,TestLinuxAbstractNamespace.testBytearrayName  s    ]6>6+=>> 	I!FF9677888Q]]__.GHHH	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	Is   ABB	Bc                 x   d}t          j         t           j        t           j                  5 }|                    d           |                     |                                |           t          j         t           j        t           j                  5 }|                    d           |                     |                                |           |                     |                                |                                           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Ns   ^ [0-9a-f]{5}r  )r   rR  r@   r   assertRegexr   r  )rU   abstract_addressr	  r  s       r   testAutobindz'TestLinuxAbstractNamespace.testAutobind  s    -]6>6+=>> 	H"GGBKKKR^^--/?@@@v~v/ABB Hb  !1!13CDDD##BNN$4$4bnn6F6FGGGH H H H H H H H H H H H H H H		H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	Hs7   A'D/A8DD/D	D/D	D//D36D3N)
r\   r]   r^   r	  r	  r
	  r	  r	  r	  r	  r_   r=   r   r 	  r 	  ]  s         M	@ 	@ 	@7 7 78 8 8
  I I IH H H H Hr=   r 	  ztest needs socket.AF_UNIXc                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Z ej        ej        d
k    d          d             ZdS )TestUnixDomainc                 b    t          j         t           j        t           j                  | _        d S rD   )r   rR  r@   rM  rT   s    r   rV   zTestUnixDomain.setUp  s    M&.&2DEE			r=   c                 8    | j                                          d S rD   )rM  r    rT   s    r   rY   zTestUnixDomain.tearDown  s    	r=   c                     	 t          j        |          S # t          $ r> |                     d                    |t          j                                         Y d S w xY w)NzBPathname {0!a} cannot be represented in file system encoding {1!r})rF  fsencoder  r   r  r?  getfilesystemencodingrU   rN  s     r   encodedzTestUnixDomain.encoded  sy    	8;t$$$! 	8 	8 	8MM((.#355)7 )78 8 8 8 8 8	8s    AAAc                     	 t          j        ||           d S # t          $ rH}t          |          dk    r)|                     d                    |                     n Y d }~d S d }~ww xY w)NzAF_UNIX path too longz6Pathname {0!a} is too long to serve as an AF_UNIX path)r   rK  r   r  r   r  )rU   rM  rN  r   s       r   r   zTestUnixDomain.bind  s    	*466666 	 	 	1vv000LVD\\# # # # 	# # # # # #	s    
A+=A&&A+c                 `    |                      | j                                        d           d S )N)r  N)r  rM  r   rT   s    r   r  zTestUnixDomain.testUnbound  s*    di++--z:::::r=   c                 (   t           j                            t          j                  }|                     | j        |           |                     t          j        |           | 	                    | j        
                                |           d S rD   )rF  rN  abspathr   TESTFNr   rM  rt   rL  r  r   r	  s     r   testStrAddrzTestUnixDomain.testStrAddr  so    wy/00		$)T"""	($///..00$77777r=   c                 N   t           j                            t          j                  }|                     | j        |                     |                     |                     t          j	        |           | 
                    | j                                        |           d S rD   )rF  rN  r$	  r   r%	  r   rM  r 	  rt   rL  r  r   r	  s     r   testBytesAddrzTestUnixDomain.testBytesAddr  s{    wy/00		$)T\\$//000	($///..00$77777r=   c                 z   t           j                            t          j                  }|                     |          }|                     | j        |                    dd                     | 	                    t          j
        |           |                     | j                                        |           d S )Nasciisurrogateescape)rF  rN  r$	  r   TESTFN_UNICODEr 	  r   rM  r@  rt   rL  r  r   )rU   rN  r  s      r   testSurrogateescapeBindz&TestUnixDomain.testSurrogateescapeBind  s     wy788LL		$)QXXg/@AABBB	($///..00$77777r=   c                 j   t           j        |                     d           t          j                            t           j                  }|                     | j        |           |                     t           j	        |           | 
                    | j                                        |           d S )Nz!No unencodable filename available)r   TESTFN_UNENCODABLEr   rF  rN  r$	  r   rM  rt   rL  r  r   r	  s     r   testUnencodableAddrz"TestUnixDomain.testUnencodableAddr  s     '/MM=>>>wy;<<		$)T"""	($///..00$77777r=   rh  r  c                 R    |                      t          | j        j        d           d S )Nr  )r  r   rM  r   rT   s    r   testEmptyAddresszTestUnixDomain.testEmptyAddress  s&     	'49>266666r=   N)r\   r]   r^   rV   rY   r 	  r   r  r&	  r(	  r-	  r0	  r   r  r?  rq  r2	  r_   r=   r   r	  r	    s        F F F  	8 	8 	8
 
 
; ; ;8 8 88 8 88 8 88 8 8 X_S\W,.CDD7 7 ED7 7 7r=   r	  c                   p    e Zd ZdZddZd Zd Zd ZeZd Z	eZ
d Zd	 Zd
 ZeZd ZeZd Zd Zd ZeZdS )BufferIOTestzF
    Test the buffer versions of socket.recv() and socket.send().
    r   c                 >    t                               | |           d S r   r  r   s     r   rk   zBufferIOTest.__init__  r  r=   c                 v   t          j         ddgt          t                    z            }| j                            |          }|                     |t          t                               |                                }|d t          t                             }|                     |t                     d S Nr  r   )r  r  r  r  r  r  r  rU   rV  r  r  s       r   testRecvIntoArrayzBufferIOTest.testRecvIntoArray  s    k#sSXX~..((--S***kkmm)3s88)nc"""""r=   c                 b    t          t                    }| j                            |           d S rD   r/  r  r  r  rU   rV  s     r   _testRecvIntoArrayzBufferIOTest._testRecvIntoArray  )    CjjC     r=   c                    t          d          }| j                            |          }|                     |t	          t
                               |d t	          t
                             }|                     |t
                     d S r   )r  r  r  r  r  r  r8	  s       r   testRecvIntoBytearrayz"BufferIOTest.testRecvIntoBytearray  sm    oo((--S***)3s88)nc"""""r=   c                 0   t          d          }| j                            t          |                    }|                     |t          t                               |d t          t                             }|                     |t                     d S r   )r  r  r  r$  r  r  r  r8	  s       r   testRecvIntoMemoryviewz#BufferIOTest.testRecvIntoMemoryview  ss    oo((C99S***)3s88)nc"""""r=   c                 |   t          j         ddgt          t                    z            }| j                            |          \  }}|                     |t          t                               |                                }|d t          t                             }|                     |t                     d S r7	  )r  r  r  r  r  r  r  rU   rV  r  r  r  s        r   testRecvFromIntoArrayz"BufferIOTest.testRecvFromIntoArray  s    k#sSXX~..}22377S***kkmm)3s88)nc"""""r=   c                 b    t          t                    }| j                            |           d S rD   r;	  r<	  s     r   _testRecvFromIntoArrayz#BufferIOTest._testRecvFromIntoArray  r>	  r=   c                    t          d          }| j                            |          \  }}|                     |t	          t
                               |d t	          t
                             }|                     |t
                     d S r   )r  r  r  r  r  r  rD	  s        r   testRecvFromIntoBytearrayz&BufferIOTest.testRecvFromIntoBytearray  sq    oo}22377S***)3s88)nc"""""r=   c                 6   t          d          }| j                            t          |                    \  }}|                     |t          t                               |d t          t                             }|                     |t                     d S r   )r  r  r  r$  r  r  r  rD	  s        r   testRecvFromIntoMemoryviewz'BufferIOTest.testRecvFromIntoMemoryview  sw    oo}22:c??CCS***)3s88)nc"""""r=   c                 r    t          d          }|                     t          | j        j        |d           d S )Nr   r  )r  r  r  r  r  r<	  s     r   testRecvFromIntoSmallBufferz(BufferIOTest.testRecvFromIntoSmallBuffer#  s2    ll*dm&A3MMMMMr=   c                 D    | j                             t                     d S rD   r  rT   s    r   _testRecvFromIntoSmallBufferz)BufferIOTest._testRecvFromIntoSmallBuffer(  r  r=   c                     t                      }| j                            |           | j                            |d           d S r   )r  r  r  r<	  s     r   testRecvFromIntoEmptyBufferz(BufferIOTest.testRecvFromIntoEmptyBuffer+  s?    kk##C(((##C+++++r=   Nr   )r\   r]   r^   ry   rk   r9	  r=	  r@	  _testRecvIntoBytearrayrB	  _testRecvIntoMemoryviewrE	  rG	  rI	  _testRecvFromIntoBytearrayrK	  _testRecvFromIntoMemoryviewrM	  rO	  rQ	  _testRecvFromIntoEmptyBufferr_   r=   r   r4	  r4	    s        B B B B# # #! ! !# # # 0# # # 1# # #! ! !# # # "8# # # #9N N N
! ! !, , ,
 $:   r=   r4	  i        c                     t          t          d          sdS 	 t          dd          } n# t          t          t
          f$ r Y dS w xY w| 5  | D ]%}|                    d          r ddd           dS &	 ddd           n# 1 swxY w Y   dS )	zCheck if the TIPC module is loaded

    The TIPC module is not loaded automatically on Ubuntu and probably
    other Linux distros.
    AF_TIPCFz/proc/modulesr	   r3  ztipc NT)r   r   r   FileNotFoundErrorIsADirectoryErrorr  rr  )r   r7  s     r   isTipcAvailabler]	  7  s    69%% u73330/B    uu 
   	 	Dw''        	               5s'   + AAB3BBBz6TIPC module is not loaded, please 'sudo modprobe tipc'c                       e Zd Zd ZdS )TIPCTestc                 0   t          j         t           j        t           j                  }t          j         t           j        t           j                  }|                     |j                   |                     |j                   |                    t           j        t           j        d           t           j        t          t          t          f}|                    |           t           j        t          t          t          t          t          z
  dz            z   df}|                    t           |           |                    d          \  }}|                     |                                |           |                     |t                      d S )Nr   r   r   r  )r   rZ	  r  rt   r    r  r  r  TIPC_ADDR_NAMESEQ
TIPC_STYPE
TIPC_LOWER
TIPC_UPPERr   TIPC_ADDR_NAMEr.  r  r  r  r  r   )rU   rF  r   srvaddrsendaddrr  recvaddrs          r   testRDMzTIPCTest.testRDMN  s'   mFNFO<<mFNFO<<	"""	"""v(&*=qAAA+ZJ():S*z"9Q!>???D

3!!!T**X**H555c"""""r=   N)r\   r]   r^   ri	  r_   r=   r   r_	  r_	  K  s#        # # # # #r=   r_	  c                   .    e Zd ZddZd Zd Zd Zd ZdS )	TIPCThreadableTestr   c                 |    t           j                            | |           t                              |            d S r   r   r   s     r   rk   zTIPCThreadableTest.__init__f  s8    ""4j"AAA%%%%%r=   c                 V   t          j         t           j        t           j                  | _        |                     | j        j                   | j                            t           j        t           j        d           t           j	        t          t          t          f}| j                            |           | j                                         |                                  | j                                        \  | _        | _        |                     | j        j                   d S rX  )r   rZ	  r@   rF  rt   r    r  r  r  ra	  rb	  rc	  rd	  r   rS   r   r   r   r   )rU   rf	  s     r   rV   zTIPCThreadableTest.setUpj  s    =1CDD'''F-v/BAFFF+ZJ(g  """#'8??#4#4 	4=	(((((r=   c                    t          j        d           t          j        t          j        t          j                  | _        |                     | j        j                   t          j        t          t          t          t          t          z
  dz            z   df}| j                            |           | j                                        | _        d S )Nr   r   r   )r   r   r   rZ	  r@   r   rt   r    re	  rb	  rc	  r.  rd	  r   r   cliaddr)rU   r  s     r   r   zTIPCThreadableTest.clientSetUpv  s     	
3=1CDD'''%zS*z"9Q!>???Dx++--r=   c                     | j                             d          }|                     |t                     |                     | j        | j                   d S r   )r   r  r  r  ro	  r   r  s     r   r  zTIPCThreadableTest.testStream  sK    innT""c"""t}55555r=   c                 v    | j                             t                     | j                                          d S rD   r
  rT   s    r   r  zTIPCThreadableTest._testStream  r  r=   Nr   r  r_   r=   r   rk	  rk	  c  sd        & & & &
) 
) 
)
. 
. 
.6 6 6
    r=   rk	  c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )ContextManagersTestc                 B   t          j                     5 }|                     |j                   d d d            n# 1 swxY w Y   |                     |j                   t          j                     5 }|                                 d d d            n# 1 swxY w Y   |                     |j                   t          j                     5 }|                     t          |j        d           d d d            n# 1 swxY w Y   |                     |j                   d S Nr  )r   r  r  r  r    r  r   r  r\  s     r   _testSocketClassz$ContextManagersTest._testSocketClass  s   ]__ 	+T\***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+%%%]__ 	JJLLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	%%%]__ 	=gt|V<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=%%%%%s1   ;??3BBB"C::C>C>c                     | j                                         \  }}|                     |j                   |                    d          }|                    |           d S r   rP   r   rt   r    r  r  rU   r   r  r  s       r   testCreateConnectionBasez,ContextManagersTest.testCreateConnectionBase  T    Y%%''
d
###yyTr=   c                 t   | j                                         }t          j        |          5 }|                     |j                   |                    d           |                     |                    d          d           d d d            n# 1 swxY w Y   | 	                    |j                   d S )Nr  r  )
rP   r   r   r  r  r  r  r  r  r  rU   r  rM  s      r   _testCreateConnectionBasez-ContextManagersTest._testCreateConnectionBase  s    )''))%g.. 	6$T\***LL   TYYt__f555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	%%%%%s   ABBBc                     | j                                         \  }}|                     |j                   |                    d          }|                    |           d S r   rx	  ry	  s       r   testCreateConnectionClosez-ContextManagersTest.testCreateConnectionClose  r{	  r=   c                 .   | j                                         }t          j        |          5 }|                                 d d d            n# 1 swxY w Y   |                     |j                   |                     t          |j	        d           d S ru	  )
rP   r   r   r  r    r  r  r  r   r  r}	  s      r   _testCreateConnectionClosez.ContextManagersTest._testCreateConnectionClose  s    )''))%g.. 	$JJLLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	%%%'4<88888s   AAAN)r\   r]   r^   rv	  rz	  r~	  r	  r	  r_   r=   r   rs	  rs	    s_        & & &  & & &  9 9 9 9 9r=   rs	  c                      e Zd Z ej         eed          d           ej        ddd          d                         Z	d Z
d Zd	 Z ej        ed
u d          d             Z ej        ed
u d          d             Zd Zd
S )InheritanceTestr  zSOCK_CLOEXEC not definedr   r  r  c                 <   t          j         t           j        t           j        t           j        z            5 }|                     |j        t           j                   |                     |                                           d d d            d S # 1 swxY w Y   d S rD   )r   rO   r@   r  r  r}  r  get_inheritabler  s     r   test_SOCK_CLOEXECz!InheritanceTest.test_SOCK_CLOEXEC  s     ]6>!-0CCE E 	2HIQVV%7888Q..00111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s   ABBBc                     t          j                     }|5  |                     |                                d           d d d            d S # 1 swxY w Y   d S r  )r   r  r	  r\  s     r   test_default_inheritablez(InheritanceTest.test_default_inheritable  s    } 	< 	<T1133U;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<s   )AAAc                 6   t          j                     }|5  |                                }|                                 |5  |                     |                                d           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S r  )r   r  r    r  r	  )rU   rM  newsocks      r   test_dupzInheritanceTest.test_dup  s3   } 	C 	ChhjjGJJLLL C C  !8!8!:!:EBBBC C C C C C C C C C C C C C C	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	Cs5   +B)A6*B6A:	:B=A:	>BBBc                 V   t          j                     }|5  |                    d           |                     |                                d           |                    d           |                     |                                d           d d d            d S # 1 swxY w Y   d S )NTF)r   set_inheritabler  r	  r\  s     r   test_set_inheritablez$InheritanceTest.test_set_inheritable  s    } 	< 	<  &&&T1133T:::  '''T1133U;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<s   A;BB"%B"Nr   c                    t          j                     }|5  |                                }|                     |                                d           t	          j        |t          j                  }|t          j         z  }t	          j        |t          j        |           |                     |                                d           d d d            d S # 1 swxY w Y   d S )NFT)r   r  r  r	  r   F_GETFD
FD_CLOEXECF_SETFD)rU   rM  ru  r  s       r   test_get_inheritable_cloexecz,InheritanceTest.test_get_inheritable_cloexec  s   } 		; 		;BT1133U;;; KEM22Ee&&&EKEM5111T1133T:::		; 		; 		; 		; 		; 		; 		; 		; 		; 		; 		; 		; 		; 		; 		; 		; 		; 		;   B4CCCc                    t          j                     }|5  |                                }|                     t          j        |t          j                  t          j        z  t          j                   |                    d           |                     t          j        |t          j                  t          j        z  d           d d d            d S # 1 swxY w Y   d S r  )r   r  r  r   r	  r	  r	  )rU   rM  ru  s      r   test_set_inheritable_cloexecz,InheritanceTest.test_set_inheritable_cloexec  s   } 	  	 BU[U];;e>NN"-/ / /   &&&U[U];;e>NN     	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 r	  c                 :   t          j                    \  }}|                     |j                   |                     |j                   |                     |                                d           |                     |                                d           d S r  )r   r  rt   r    r  r	  )rU   r	  r  s      r   test_socketpairzInheritanceTest.test_socketpair  s    "$$B!!!!!!++--u555++--u55555r=   )r\   r]   r^   r   r  r   r   r   r  r	  r	  r	  r	  r  r   r	  r	  r	  r_   r=   r   r	  r	    s       X8835 5#W#Aq"--2 2 .-5 52< < <
C C C< < < X_Ud]L11; ; 21; X_Ud]L11	  	  21	 6 6 6 6 6r=   r	  rh  zSOCK_NONBLOCK not definedc                   L    e Zd Zd	dZ ej        ddd          d             ZdS )
NonblockConstantTestTr  c                 d   |r|                      |j        t          j                   |                      |                                |           |                     t          j        |t          j        t          j	                  t          j	        z             |dk    r)| 
                    |                                           d S |                     |                                           d S |                      |j        t          j                   |                      |                                d            | 
                    t          j        |t          j        t          j	                  t          j	        z             |                     |                                           d S r   )r  r}  r   r@   r  r  r   r  rF  r  r  r  )rU   r#   nonblockrG   s       r   checkNonblockz"NonblockConstantTest.checkNonblock  sU    	-QVV%7888Q\\^^W555OOAu}bm<<r}LN N N!||  11111 00000QVV%7888Q\\^^T222Au}bm<<r}LN N NOOAMMOO,,,,,r=   r   r  r  c                 v   t          j         t           j        t           j        t           j        z            5 }|                     |           |                    d           |                     |d           |                    d           |                     |           |                    d            |                     |d           |                    d           |                     |d           |                    d           |                     |d           d d d            n# 1 swxY w Y   t          j                    }t          j        d           t          j                     5 }|                     |           d d d            n# 1 swxY w Y   t          j        d            t          j                     5 }|                     |d           d d d            n# 1 swxY w Y   t          j        d           t          j                     5 }|                     |d           d d d            n# 1 swxY w Y   t          j        d            t          j                     5 }|                     |d           d d d            n# 1 swxY w Y   t          j        |           d S )NTF)r	  g       @r  r  )	r   rO   r@   rh  r	  ri  r  rE   rF   )rU   r#   ts      r   test_SOCK_NONBLOCKz'NonblockConstantTest.test_SOCK_NONBLOCK  s    ]6>!-0DDF F 	2IJq!!!MM$q5111MM%   q!!!LLq5111LLq#...MM$q5111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 $&& %%%]__ 	"q!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" &&&]__ 	)q%(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) %%%]__ 	/q#...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ &&&]__ 	)q%(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) #####sZ   C0D33D7:D78FF!FG//G36G3!II	I	7JJ!JN)Tr  )r\   r]   r^   r	  r   r  r	  r_   r=   r   r	  r	    sU        - - - -2 $W#Aq"--$ $ .-$ $ $r=   r	  r  r  zneed multiprocessingc                   B    e Zd Zed             Zd Zd Zd Zd Zd Z	dS )TestSocketSharingc                 &   |                                 }|                                 }t          j        |          }|                                \  }}|                    |           |                                 |                                 d S rD   )r   r   	fromsharer   r  r    )r  qsdatamessager#   r  r  s          r   remoteProcessServerz%TestSocketSharing.remoteProcessServer>  sq     %%''U##

A 	

7



						r=   c                    t          j                    }t          j        | j        |f          }|                                 | j                            |j                  }| j                                        }| j        	                                 |
                    |           d}|
                    |           t          j        |          }g }	 |                    d          }|sn|                    |           .|	                                 d                    |          }|                     ||           |                                 d S )Nr  rp   s
   slapmahfroTr  r=   )multiprocessingr   Processr	  r  rP   sharepidr   r    r   r   r  r  rA  r  r  )	rU   r	  r  r  r  r	  r#   mreceiveds	            r   	testSharezTestSocketSharing.testShareL  s+   
 !###4+C1$OOO				 yqu%% y$$&&		d  	g $T**	66#;;D HHTNNN		
 	
			88A;;7+++	r=   c                 
   | j                             t          j                              }|                     t
          t          j        |d d                    |                     t
          t          j        |dz              d S )NrW  r  )rP   r	  rF  getpidr  r  r   r	  )rU   r  s     r   testShareLengthz!TestSocketSharing.testShareLengtho  sc    yry{{++*f&6SbS	BBB*f&6VDDDDDr=   c                    |                      |                                d            |                      |                                |                                           |                      |j        |j                   |                      |j        |j                   |j        dk    r"|                      |j        |j                   d S d S r   )r  r  r  r}  r  )rU   orgothers      r   compareSocketsz TestSocketSharing.compareSocketst  s     	))4000))5+;+;+=+=>>>U\2225:... 9>>SY44444 >r=   c                    | j                             t          j                              }t	          j        |          }	 |                     | j         |           |                                 d S # |                                 w xY wrD   )rP   r	  rF  r	  r   r	  r	  r    )rU   r  r#   s      r   testShareLocalz TestSocketSharing.testShareLocal  sk    yry{{++T""		1---GGIIIIIAGGIIIIs   A2 2Bc                 $   t           j        t           j        g}t           j        t           j        g}|D ]}|D ]}	 t          j         ||          }n# t
          $ r Y %w xY w	 |                    t          j                              }t          j	        |          }	 | 
                    ||           |                                 n# |                                 w xY w	 |                                 # |                                 w xY wd S rD   )r   rO   rq  r@   r'   r   r	  rF  r	  r	  r	  r    )rU   familiestypesr   r	  r  r  shareds           r   	testTypeszTestSocketSharing.testTypes  s   NFO4#V%67 	# 	#A # ##]1a00FF   H#!<<	44D#-d33F'++FF;;;LLNNNNFLLNNNN#	# 	#s5   A
AA!:C6C2C6CC66DN)
r\   r]   r^   r<  r	  r	  r	  r	  r	  r	  r_   r=   r   r	  r	  9  s~        
   [! ! !FE E E
5 5 5   # # # # #r=   r	  c                       e Zd ZdZdZdZdZej        Z	e
d             Ze
d             Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d Z%d S )!SendfileUsingSendTestz>
    Test the send() implementation of socket.sendfile().
    i   r   r=   c                    d }d                     d t          | j                  D                       }t          t          j        d          5 } || j        | j                  D ]}|                    |           	 d d d            n# 1 swxY w Y   t          t          j        d          5 }|                                | _	        d d d            d S # 1 swxY w Y   d S )Nc              3   D   K   | |k    r|V  | |z  } | |k    | r| V  d S d S rD   r_   )totalsteps     r   chunksz0SendfileUsingSendTest.setUpClass.<locals>.chunks  sM      $,,


 $,,   r=   r=   c                 n    g | ]2}t          j        t          j                                                  3S r_   )randomchoicestringascii_lettersr@  r  s     r   r  z4SendfileUsingSendTest.setUpClass.<locals>.<listcomp>  sA     7 7 7 !-(<==DDFF 7 7 7r=   r0  r   )
r  r=  BUFSIZEr   r   r%	  FILESIZEr?  r  FILEDATA)r  r	  chunkr   csizes        r   
setUpClassz SendfileUsingSendTest.setUpClass  sk   	 	 	  7 7#(#5#57 7 7 8 8)"D)) 	Qck::  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 )"D)) 	5Q6688CL	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s$   /BBB0CCCc                 B    t          j        t           j                   d S rD   )r   rL  r%	  )r  s    r   tearDownClassz#SendfileUsingSendTest.tearDownClass  s    )*****r=   c                     | j                             t          j                   | j                                         \  }}|                    | j                   |                     |j                   |S rD   )rP   r  r   r  r   TIMEOUTrt   r    r  s      r   accept_connz!SendfileUsingSendTest.accept_conn  s_    	W1222Y%%''
d%%%
###r=   c                     g }	 |                     | j                  }|sn|                    |           3d                    |          S )NTr=   )r  r	  rA  r  )rU   r   r	  r	  s       r   	recv_datazSendfileUsingSendTest.recv_data  sU    	#IIdl++E OOE"""		#
 xx!!!r=   c                 "    t          |d          S )N_sendfile_use_sendr   r\  s     r   meth_from_sockz$SendfileUsingSendTest.meth_from_sock  s     t1222r=   c                    | j                                         }t          t          j        d          }t          j        |          5 }|5 }|                     |          } ||          }|                     || j	                   |                     |
                                | j	                   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr   rP   r   r   r   r%	  r   r  r	  r  r	  tellrU   r  filerM  methsents         r   _testRegularFilez&SendfileUsingSendTest._testRegularFile  sH   )''))I$d++%g.. 	9$ 	9&&t,,D4::DT4=111TYY[[$-888		9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9s7   CA)C 4C C	CC	CCCc                     |                                  }|                     |          }|                     t          |          | j                   |                     || j                   d S rD   r	  r	  r  r  r	  r	  rU   r   r  s      r   testRegularFilez%SendfileUsingSendTest.testRegularFile  `    !!~~d##TDM222t}-----r=   c                    | j                                         }t          j        | j                  }t          j        |          5 }|5 }|                    |          }|                     || j	                   |                     |
                                | j	                   |                     t
          j        |j        |           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S rD   )rP   r   ioBytesIOr	  r   r  ry  r  r	  r	  r  r  r  )rU   r  r	  rM  r	  s        r   _testNonRegularFilez)SendfileUsingSendTest._testNonRegularFile  s   )''))z$-((%g.. 	A$ 	A==&&DT4=111TYY[[$-888f6"94A A A		A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	As7   C2
BCC2C	C2!C	"C22C69C6c                     |                                  }|                     |          }|                     t          |          | j                   |                     || j                   d S rD   r	  r	  s      r   testNonRegularFilez(SendfileUsingSendTest.testNonRegularFile  r	  r=   c                 P   | j                                         }t          j        dz   }t	          |d          5  |                     t          j        |           d d d            n# 1 swxY w Y   t	          |d          }t          j        |          5 }|5 }| 	                    |          } ||          }| 
                    |d           | 
                    |                                d           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )N2r0  r   r   )rP   r   r   r%	  r   rt   rL  r   r  r	  r  r	  )rU   r  filenamer	  rM  r	  r	  s          r   _testEmptyFileSendz(SendfileUsingSendTest._testEmptyFileSend  s   )''))#c)(D!! 	8 	8OOI,h777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8Hd##%g.. 	-$ 	-&&t,,D4::DT1%%%TYY[[!,,,		- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-sH   !A&&A*-A*DAD7DD	D
D	DD"Dc                     |                                  }|                     |          }|                     |d           d S r  )r	  r	  r  r	  s      r   testEmptyFileSendz'SendfileUsingSendTest.testEmptyFileSend  s@    !!~~d##s#####r=   c                    | j                                         }t          t          j        d          }t          j        |          5 }|5 }|                     |          } ||d          }|                     || j	        dz
             |                     |
                                | j	                   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr     )offsetr	  r	  s         r   _testOffsetz!SendfileUsingSendTest._testOffset  sT   )''))I$d++%g.. 	9$ 	9&&t,,D4T***DT4=4#7888TYY[[$-888		9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9s7   CA.C9CC			CC		CC!$C!c                     |                                  }|                     |          }|                     t          |          | j        dz
             |                     || j        dd                     d S )Nr	  r	  r	  s      r   
testOffsetz SendfileUsingSendTest.testOffset  sn    !!~~d##TDMD$8999t}TUU344444r=   c                    | j                                         }t          t          j        d          }t          j        |t          j                  }|5  |5  d}| 	                    |          } |||          }| 
                    ||           | 
                    |                                |           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr   r  GKL r  rP   r   r   r   r%	  r   r  r   rN  r	  r  r	  rU   r  r	  rM  r  r	  r	  s          r   
_testCountz SendfileUsingSendTest._testCount  sm   )''))I$d++'070HJ J J 	1 	14 	1 	1E&&t,,D4E***DT5)))TYY[[%000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	17   C A#C<C C	C C	C  C$'C$c                     d}|                                  }|                     |          }|                     t          |          |           |                     || j        d |                    d S )Nr	  r	  r	  r  r  r	  rU   r  r   r  s       r   	testCountzSendfileUsingSendTest.testCount+  sl    !!~~d##TE***t}VeV455555r=   c                    | j                                         }t          t          j        d          }t          j        |t          j                  }|5  |5  d}| 	                    |          } |||          }| 
                    ||           | 
                    |                                |           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr   r  r   r	  r 
  r
  s          r   _testCountSmallz%SendfileUsingSendTest._testCountSmall4  sm   )''))I$d++'070HJ J J 	1 	14 	1 	1E&&t,,D4E***DT5)))TYY[[%000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1r
  c                     d}|                                  }|                     |          }|                     t          |          |           |                     || j        d |                    d S rX  r
  r
  s       r   testCountSmallz$SendfileUsingSendTest.testCountSmall@  sl    !!~~d##TE***t}VeV455555r=   c                    | j                                         }t          t          j        d          }t          j        |d          5 }|5 }d}|                     |          } ||d|          }|                     ||           |                     |	                                |dz              d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr   r   r  駆   )r	  r  )
rP   r   r   r   r%	  r   r  r	  r  r	  r
  s          r   _testCountWithOffsetz*SendfileUsingSendTest._testCountWithOffsetI  s[   )''))I$d++%gq999 	8T4 	84E&&t,,D4T777DT5)))TYY[[%$,777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s7   
CA'C 4C C	CC	CCCc                     d}|                                  }|                     |          }|                     t          |          |           |                     || j        d|dz                       d S )Nr
  r
  r
  r
  s       r   testCountWithOffsetz)SendfileUsingSendTest.testCountWithOffsetS  sp    !!~~d##TE***t}T%*_=>>>>>r=   c                    | j                                         }t          t          j        d          }t          j        |          5 }|5 }|                    d           |                     |          }| 	                    t          ||           | 	                    t          |j        |           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr   F)rP   r   r   r   r%	  r   r  ri  r	  r  r  ry  rU   r  r	  rM  r	  s        r   _testNonBlockingz&SendfileUsingSendTest._testNonBlocking\  sI   )''))I$d++%g.. 	?$ 	?U###&&t,,Dj$555j$->>>		? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?s7   CA(B?3C?C	CC	CCCc                     |                                  }|                    d          r|                     d           d S d S )Nr   z$was not supposed to receive any data)r	  r  r  rU   r   s     r   testNonBlockingz%SendfileUsingSendTest.testNonBlockinge  sH    !!99T?? 	>II<=====	> 	>r=   c                    | j                                         }t          t          j        d          }t          j        |t          j                  }|5  |5  | 	                    |          } ||          }| 
                    || j                   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr   r  )rP   r   r   r   r%	  r   r  r   rN  r	  r  r	  r	  s         r   _testWithTimeoutz&SendfileUsingSendTest._testWithTimeoutl  sE   )''))I$d++'070HJ J J 	2 	24 	2 	2&&t,,D4::DT4=111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s6   B9<B!B9!B%	%B9(B%	)B99B= B=c                     |                                  }|                     |          }|                     t          |          | j                   |                     || j                   d S rD   r	  r	  s      r   testWithTimeoutz%SendfileUsingSendTest.testWithTimeoutv  r	  r=   c                    | j                                         }t          t          j        d          5 }t          j        |          5 }|                    d           |                     |          }| 	                    t          ||           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr   g{Gz?)rP   r   r   r   r%	  r   r  r  r	  r  r  r
  s        r   _testWithTimeoutTriggeredSendz3SendfileUsingSendTest._testWithTimeoutTriggeredSend~  s)   )'')))"D)) 	<T)'22 <d%%%**400!!,d;;;< < < < < < < < < < < < < < <	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<s6   B4	ABB4B 	 B4#B 	$B44B8;B8c                     |                                  }|                    d           t          j        d           d S )NiX r   )r	  r  r   r   r
  s     r   testWithTimeoutTriggeredSendz2SendfileUsingSendTest.testWithTimeoutTriggeredSend  s6    !!		%
1r=   c                     d S rD   r_   rT   s    r   _test_errorsz"SendfileUsingSendTest._test_errors  r"  r=   c           	      :   t          t          j        d          5 }t          j        t          j                  5 }|                     |          }|                     t          d||           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          t          j        d          5 }t          j                    5 }|                     |          }|                     t          d||           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          t          j        d          5 }t          j                    5 }|                     |          }|                     t          d||d	           |                     t          d||d
	           |                     t          d||d	           |                     t          d||d	           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr   r  r@   r	   r3  zbinary modezpositive integerr	  r	  r   r   rW  )	r   r   r%	  r   r'   r	  r:  r  r   )rU   r	  r#   r	  s       r   test_errorsz!SendfileUsingSendTest.test_errors  s   )"D)) 	;TF$5666 ;!**1--&&tT; ; ;; ; ; ; ; ; ; ; ; ; ; ; ; ; ;	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;
 )"W555 	; ;A**1--&&tT; ; ;; ; ; ; ; ; ; ; ; ; ; ; ; ; ;	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;
 )"D)) 
	=T 	=A**1--&&y2D'+T ' > > >&&y2D'+T ' > > >&&z3E'+T ' < < <&&z3E'+T ' = = =	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=
	= 
	= 
	= 
	= 
	= 
	= 
	= 
	= 
	= 
	= 
	= 
	= 
	= 
	= 
	= 
	= 
	= 
	=s    B3A:.B:A>	>BA>	BBB7D!3D
>D!
D	D!D	D!!D%(D%HBG8,H8G<	<H?G<	 HHHN)&r\   r]   r^   ry   r	  r	  r	  r   rN  r	  r<  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r
  r
  r	
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r!
  r#
  r_   r=   r   r	  r	    s         !HGH&G5 5 [5$ + + [+  " " "3 3 39 9 9. . .A A A. . .
- 
- 
-$ $ $9 9 95 5 5
1 
1 
16 6 6
1 
1 
16 6 68 8 8? ? ?? ? ?> > >2 2 2. . .< < <    = = = = =r=   r	  ry  z%os.sendfile() required for this test.c                       e Zd ZdZd ZdS )SendfileUsingSendfileTestzB
    Test the sendfile() implementation of socket.sendfile().
    c                 "    t          |d          S )Nr  r	  r\  s     r   r	  z(SendfileUsingSendfileTest.meth_from_sock  s    t5666r=   N)r\   r]   r^   ry   r	  r_   r=   r   r%
  r%
    s-         7 7 7 7 7r=   r%
  zAF_ALG requiredc                       e Zd Zd Z ej        dd          d             Zd Z ej        dd          d             Z ej        dd          d	             Z	 ej        dd          d
             Z
d Zd ZdS )LinuxKernelCryptoAPIc                    t          j         t           j        t           j        d          }	 |                    ||f           |S # t          $ r<}|                                 t          j        t          |          ||          d }~ww xY wr   )	r   r5   r0   r   r[	  r    r   SkipTestr  )rU   typr  rM  r   s        r   
create_algzLinuxKernelCryptoAPI.create_alg  s    }V]F,A1EE	IIsDk""" K ! 	7 	7 	7JJLLL#CFFC666	7s   A 
B7BBr  r  c                    t                               d          }|                     dd          5 }|                                \  }}|5  |                    d           |                     |                    d          |           d d d            n# 1 swxY w Y   |                                \  }}|5  |                    dt          j	                   |                    dt          j	                   |                    dt          j	                   |                    d	           |                     |                    d          |           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )
N@ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015adhashsha256s   abcr     a   b   cr=   )
r/  fromhexr,
  r   r  r  r  r  r   MSG_MORErU   r  algoopr   s        r   test_sha256z LinuxKernelCryptoAPI.test_sha256  s   == ": ; ;__VX.. 	9$KKMMEB 9 9

6"""  x8889 9 9 9 9 9 9 9 9 9 9 9 9 9 9 KKMMEB 9 9fo...fo...fo...  x8889 9 9 9 9 9 9 9 9 9 9 9 9 9 9	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9sZ   E=?B
E=B	E=B	E=:BE%E=%E)	)E=,E)	-E==FFc                    t                               d          }|                     dd          5 }|                    t          j        t          j        d           |                                \  }}|5  |                    d           | 	                    |
                    d          |           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )N(effcdf6ae5eb2fa2d27416d5f184df9c259a7c79r/
  z
hmac(sha1)s   Jefes   what do ya want for nothing?r  )r/  r4
  r,
  r  r   SOL_ALGALG_SET_KEYr   r  r  r  r6
  s        r   test_hmac_sha1z#LinuxKernelCryptoAPI.test_hmac_sha1  sC   ==!KLL__V\22 	9dOOFNF,>HHHKKMMEB 9 9

:;;;  x8889 9 9 9 9 9 9 9 9 9 9 9 9 9 9	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9s6   AC6?C5CC	CC		CC Cr  c                 l   t                               d          }t                               d          }d}t                               d          }t          |          }|                     dd          5 }|                    t
          j        t
          j        |           |                                \  }}|5  |	                    t
          j
        |t
          j                   |                    |           |                     |                    |          |           d d d            n# 1 swxY w Y   |                                \  }}|5  |	                    |gt
          j        |           |                     |                    |          |           d d d            n# 1 swxY w Y   d	}	|g|	z  }
|                                \  }}|5  |	                    |
t
          j
        |           |                    ||	z            }d d d            n# 1 swxY w Y   |                     t          |          ||	z             |                     |d |         |           |                                \  }}|5  |	                    |gt
          j        |           |                    ||	z            }d d d            n# 1 swxY w Y   |                     t          |          ||	z             |                     |||	z             d d d            d S # 1 swxY w Y   d S )
N 06a9214036b8a15b512e03d534120006 3dafba429d9eb430b422da802c9fac41s   Single block msg e353779c1079aeb82708942dbe77181askcipherzcbc(aes))r8
  ivr  )r8
  rD
  r  )r/  r4
  r  r,
  r  r   r<
  r=
  r   sendmsg_afalgALG_OP_ENCRYPTr5
  r  r  r  ALG_OP_DECRYPT)rU   keyrD
  r  
ciphertextmsglenr7
  r8
  r   
multiplierlongmsgencdecs                r   test_aes_cbcz!LinuxKernelCryptoAPI.test_aes_cbc  sC   mm>??]]=>>!]]#EFF
S__Z44  	4OOFNF,>DDDKKMMEB > >  F$9b'- ! 8 8 8

3  *===	> > > > > > > > > > > > > > > KKMMEB 7 7  *$*$9b ! B B B  #6667 7 7 7 7 7 7 7 7 7 7 7 7 7 7 Jej(GKKMMEB 3 3  $*$9b ! B B Bggfz1223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 SXXv
':;;;S&\:666KKMMEB 3 3  #$*$9b ! B B Bggfz1223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 SXXv
':;;;S#
"2333A 	4  	4  	4  	4  	4  	4  	4  	4  	4  	4  	4  	4  	4  	4  	4  	4  	4  	4s   6AL);A+D2&L)2D6	6L)9D6	:L)AF/#L)/F3	3L)6F3	7$L);H"L)"H&	&L))H&	*A L)
<KL)K	L)K	AL))L-0L-r"  c                 	   t                               d          }t                               d          }t                               d          }t                               d          }t                               d          }t                               d          }t          |          }t          |          }|                     dd          5 }	|	                    t
          j        t
          j        |           |	                    t
          j        t
          j        d |           |		                                \  }
}|
5  |

                    t
          j        ||t
          j        	           |
                    |t
          j                   |
                    |           |
                    |t          |          z   |z             }|                     ||||                     |                     ||| d                     d d d            n# 1 swxY w Y   |		                                \  }
}|
5  ||z   }|

                    |gt
          j        ||
           |
                    |t          |          z   |z             }|                     ||||                     |                     ||| d                     d d d            n# 1 swxY w Y   t!          j        d          j        }|		                                \  }
}|
5  ||z   }|
                    |gt
          j        t
          j         |t
          j                  gt
          j        t
          j         |t          |                    |z   gt
          j        t
          j         ||          gf           |
                    t          |          |z             }|                     ||||                     |                     ||| d                     d d d            n# 1 swxY w Y   |		                                \  }
}|
5  ||z   |z   }|

                    |gt
          j        ||
           |
                    t          |          |z
            }|                     |||d                     d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )N c939cc13397c1d37de6ae0e1cb7c423cb3d8cc017cbb89b39e0f67e2 c3b3c41f113a31b73d9a5cd432103069 24825602bd12a984e0092d3e448eda5f 93fe7d9e9bfd10348a5606e5cafa7354 0032a1dc85f1c9786925a2e71d8272ddaeadzgcm(aes))r8
  rD
  assoclenr  )r8
  rD
  rX
  r   )r/  r4
  r  r,
  r  r   r<
  r=
  ALG_SET_AEAD_AUTHSIZEr   rE
  rF
  r5
  r  r  r  r   Structr  r  
ALG_SET_OP
ALG_SET_IVALG_SET_AEAD_ASSOCLENrG
  )rU   rH
  rD
  plainassocexpected_ctexpected_tagtaglenrX
  r7
  r8
  r   resr  pack_uint32s                  r   test_aead_aes_gcmz&LinuxKernelCryptoAPI.test_aead_aes_gcm	  s   mm>??]]566@AA@AAmm$FGG}}%GHH\""u::__VZ00 1	8DOOFNF,>DDDOOFNF,H &* * * KKMMEB > >  F$9b*2&/ ! K K K

5&/222

5!!!gghU3f<==  c(F72B.CDDD  sF788}===> > > > > > > > > > > > > > > KKMMEB > >em  #6+@R*2 ! 4 4 4gghU3f<==  c(F72B.CDDD  sF788}===> > > > > > > > > > > > > > > !-,,1KKKMMEB > >em

Enf&7VEZ9[9[\nf&7SWW9M9MPR9RSnf&BKKPXDYDYZ   ggc#hh/00  c(F72B.CDDD  sF788}===> > > > > > > > > > > > > > > KKMMEB 8 8k)L8  #6+@R*2 ! 4 4 4ggc#hh/00  HII7778 8 8 8 8 8 8 8 8 8 8 8 8 8 8Y1	8 1	8 1	8 1	8 1	8 1	8 1	8 1	8 1	8 1	8 1	8 1	8 1	8 1	8 1	8 1	8 1	8 1	8s   A1SC	HSH	SH	S;BKSK	SK	5SC=PSP!	!S$P!	%SA0R=1S=S	SS	SSSc                    |                      dd          5 }t          j        d          }|                    t          j        t          j        |           |                                \  }}|5  |                    d          }| 	                    t          |          d           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nrngdrbg_pr_sha256rF  )r,
  rF  urandomr  r   r<
  r=
  r   r  r  r  )rU   r7
  
extra_seedr8
  r   rns         r   test_drbg_pr_sha256z(LinuxKernelCryptoAPI.test_drbg_pr_sha256H  s9    __U$455 	.BJOOFNF,>
KKKKKMMEB . .WWR[[  R"---. . . . . . . . . . . . . . .		. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s6   AC09B5)C5B9	9C<B9	=CCCc                    t          j         t           j        t           j        d          }|5  |                     t                    5  |                                 d d d            n# 1 swxY w Y   |                     t                    5  |                    d            d d d            n# 1 swxY w Y   |                     t                    5  |                    d           d d d            n# 1 swxY w Y   |                     t                    5  |                    t           j        d            d d d            n# 1 swxY w Y   |                     t                    5  |                    t           j        d           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr   )r8
  r   )r8
  rX
  rW  )r   r5   r0   r  r   rE
  rF
  r\  s     r   test_sendmsg_afalg_argsz,LinuxKernelCryptoAPI.test_sendmsg_afalg_argsS  sD   }V]F,A1EE 	J 	J""9-- % %""$$$% % % % % % % % % % % % % % % ""9-- , ,""d"+++, , , , , , , , , , , , , , , ""9-- & &""1%%%& & & & & & & & & & & & & & & ""9-- L L""f&;d"KKKL L L L L L L L L L L L L L L ""9-- J J""f&;b"IIIJ J J J J J J J J J J J J J J	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	Js   F6A)F6)A-	-F60A-	1F6B1%F61B5	5F68B5	9F6C8,F68C<	<F6?C<	 F6"E?F6E	F6E	F60"FF6F"	"F6%F"	&F66F:=F:c                    t          j         t           j        t           j        d          }|                     |j                   |                     t                    5  |                    d           d d d            n# 1 swxY w Y   |                     t          d          5  |                    d           d d d            n# 1 swxY w Y   |                     t                    5  |                    d           d d d            n# 1 swxY w Y   |                     t          d          5  |                    d           d d d            d S # 1 swxY w Y   d S )Nr   )tttttttttttttr  ztype too long)ttttttttttttttr  )r}  ?nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnzname too long)r}  @nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn)
r   r5   r0   rt   r    r  r[	  r   r:  r  r\  s     r   test_length_restrictionz,LinuxKernelCryptoAPI.test_length_restrictione  s7   }V]F,A1EE
### 011 	* 	*II()))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*##J@@ 	* 	*II()))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 011 	* 	*II()))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*##J@@ 	* 	*II()))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*sH   BBB'C		CC.DDD6EE EN)r\   r]   r^   r,
  r   r  r9
  r>
  rO
  re
  rl
  rn
  rt
  r_   r=   r   r(
  r(
    s       	 	 	 $W#Aq))9 9 *)9"9 9 9 $W#Aq))&4 &4 *)&4P $W#Aq))<8 <8 *)<8| $W#Aq)). . *).J J J$* * * * *r=   r(
  r  r  c                       e Zd Zd ZdS )TestMacOSTCPFlagsc                 D    |                      t          j                   d S rD   )r  r   TCP_KEEPALIVErT   s    r   test_tcp_keepalivez$TestMacOSTCPFlags.test_tcp_keepalivey  s    ,-----r=   N)r\   r]   r^   ry
  r_   r=   r   rv
  rv
  w  s#        . . . . .r=   rv
  winzrequires Windowsc                       e Zd Zh dZd ZdS )TestMSWindowsTCPFlags>   
TCP_MAXSEGTCP_KEEPCNTTCP_NODELAYTCP_FASTOPENTCP_KEEPIDLETCP_KEEPINTVLc                      d t          t                    D             } fd|D             }                     g |d           d S )Nc                 <    g | ]}|                     d           |S )TCP)rr  )r  r#   s     r   r  z<TestMSWindowsTCPFlags.test_new_tcp_flags.<locals>.<listcomp>  s)    BBB!all5.A.ABABBBr=   c                 &    g | ]}|j         v|S r_   )knownTCPFlags)r  r#   rU   s     r   r  z<TestMSWindowsTCPFlags.test_new_tcp_flags.<locals>.<listcomp>  s&    FFF!43E*E*E1*E*E*Er=   zANew TCP flags were discovered. See bpo-32394 for more information)rI  r   r  )rU   providedunknowns   `  r   test_new_tcp_flagsz(TestMSWindowsTCPFlags.test_new_tcp_flags  sc    BBs6{{BBBFFFFhFFFWO	Q 	Q 	Q 	Q 	Qr=   N)r\   r]   r^   r
  r
  r_   r=   r   r|
  r|
  }  s9          MQ Q Q Q Qr=   r|
  c                   D   e Zd Zd Zd Zd Z ej         ee	d           p ee	d           d           ej
        ej        d          d                         Z ej         ej                     d	           ej
        ej        d          d
                         ZdS )CreateServerTestc                    t          j                    }t          j        d|f          5 }|                     |                                d         d           |                     |                                d         |           d d d            n# 1 swxY w Y   t           j        rt          j        d|ft          j                  5 }|                     |                                d         d           |                     |                                d         |           d d d            d S # 1 swxY w Y   d S d S )Nr  r   r   r  r  )r   r  r   create_serverr  r   r  rq  rU   rR   rM  s      r   test_addresszCreateServerTest.test_address  s   -//!;"566 	:$T--//2K@@@T--//2D999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: % 	>%udm-3_> > > >AE  !1!1!3!3A!6>>>  !1!1!3!3A!6===> > > > > > > > > > > > > > > > > >	> 	>s%   ABBBAD66D:=D:c                    t          j        d          5 }|                     |j        t           j                   |                     |j        t           j                   d d d            n# 1 swxY w Y   t          j        rt          j        dt           j	                  5 }|                     |j        t           j	                   |                     |j        t           j                   d d d            d S # 1 swxY w Y   d S d S )Nr  r  r   r  )
r   r
  r  r  rO   r}  r@   r   r  rq  )rU   rM  r#   s      r   test_family_and_typez%CreateServerTest.test_family_and_type  sv   !"233 	<tT[&.999TY(:;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< % 	@%jIII @Q  6?;;;  F,>???@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @	@ 	@s%   AA,,A03A0#AC;;C?C?c                 |   t          t          d          sK|                     t                    5  t          j        dd           d d d            d S # 1 swxY w Y   d S t          j        d          5 }|                    t          j        t          j                  }|                     |d           d d d            n# 1 swxY w Y   t          j        dd          5 }|                    t          j        t          j                  }| 	                    |d           d d d            d S # 1 swxY w Y   d S )NSO_REUSEPORT)r  r   T)
reuse_portr   )
r   r   r  r  r
  r  r  r
  r  r  )rU   rM  r  s      r   test_reuse_portz CreateServerTest.test_reuse_port  s   v~.. 		,"":.. H H$%5$GGGGH H H H H H H H H H H H H H H H H H %&677 )4oof&79LMM  a((() ) ) ) ) ) ) ) ) ) ) ) ) ) ) %&64HHH ,Doof&79LMM##C+++, , , , , , , , , , , , , , , , , ,s7   AAA5ACC	C#AD11D58D5r  IPV6_V6ONLYz IPV6_V6ONLY option not supportedr  c                 x    t          j        dt           j                  5 }d d d            d S # 1 swxY w Y   d S )Nr
  r  )r   r
  rq  r\  s     r   test_ipv6_only_defaultz'CreateServerTest.test_ipv6_only_default  s    
 !*V_EEE 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	Ls   /33dualstack_ipv6 not supportedc                     t          j        dt           j        d          5 }|                     |j        t           j                   d d d            d S # 1 swxY w Y   d S )Nr
  Tr  dualstack_ipv6)r   r
  rq  r  r  r\  s     r   test_dualstack_ipv6_familyz+CreateServerTest.test_dualstack_ipv6_family  s     !*V_157 7 7 	;:>T[&/:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s   &AAAN)r\   r]   r^   r
  r
  r
  r   r  r   r  r  r   r  r
  r   has_dualstack_ipv6r
  r_   r=   r   r
  r
    s       	> 	> 	>@ @ @
, 
, 
, X_.999 9 -88879 9 X35RSSL L TS9 9L X_2244435 5X35RSS; ; TS5 5; ; ;r=   r
  c                   |   e Zd Zej        Zd Zd Zd Z e	j
        ej        d          d             Z e	j         ej                     d           e	j
        ej        d          d                         Z e	j         ej                     d           e	j
        ej        d          d                         Zd	S )
CreateServerFunctionalTestc                 $     fd}t          j                    |                     j                   t          j        ||f          } |j                                          |j         j                                                    d S )Nc                 ^   | 5  |                                  \  }}|5                      j                   |                    d          }|s	 d d d            d d d            d S |                    |           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S r   )r   r   rG   r  r  )rM  r   r   r  r  rU   s       r   runz3CreateServerFunctionalTest.echo_server.<locals>.run  sa    & &++--a & &JJt|,,,))D//C 	& & & & & && & & & & & & & LL%%%& & & & & & & & & & & & & & && & & & & & & & & & & & & & & & & &s@   B"3B
B")B
>B"
B	B"B	B""B&)B&r	  )	rl   r   r  rG   r  r  rt   r  r   )rU   rM  r
  r   r  s   `   @r   echo_serverz&CreateServerFunctionalTest.echo_server  s    	& 	& 	& 	& 	& 	& !!%%%!D8<<<T\222		r=   c                 <   t          j         |          5 }|                    | j                   |                    |           |                    d           |                     |                    d          d           d d d            d S # 1 swxY w Y   d S )Nr  r  r  )r   r  rG   r   r  r  r  )rU   r  r  rM  s       r   echo_clientz&CreateServerFunctionalTest.echo_client  s    ]&))) 	6TOODL)))LLLL   TYYt__f555		6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6s   A.BBBc                     t          j                    }t          j        d|f          5 }|                     |           |                     d|ft          j                   d d d            d S # 1 swxY w Y   d S )Nr  r  )r   r  r   r
  r
  r
  rO   r
  s      r   	test_tcp4z$CreateServerFunctionalTest.test_tcp4  s    -//!2t*-- 	BT"""k40&.AAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	Bs   8A//A36A3r  c                    t          j                    }t          j        d|ft          j                  5 }|                     |           |                     d|ft          j                   d d d            d S # 1 swxY w Y   d S )Nr  r  r  r   r  r   r
  rq  r
  r
  r
  s      r   	test_tcp6z$CreateServerFunctionalTest.test_tcp6  s    -//!2t*)/: : : 	==AT"""eT]FO<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=s   8A;;A?A?r
  c                    t          j                    }t          j        d|ft          j        d          5 }|                     |           |                     d|ft          j                   d d d            d S # 1 swxY w Y   d S )Nr  Tr
  r  )r   r  r   r
  rq  r
  r
  rO   r
  s      r   test_dual_stack_client_v4z4CreateServerFunctionalTest.test_dual_stack_client_v4  s     -//!2t*V_157 7 7 	B:>T"""k40&.AAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B   8A<<B B c                    t          j                    }t          j        d|ft          j        d          5 }|                     |           |                     d|ft          j                   d d d            d S # 1 swxY w Y   d S )Nr  Tr
  r  r
  r
  s      r   test_dual_stack_client_v6z4CreateServerFunctionalTest.test_dual_stack_client_v6  s     -//!2t*V_157 7 7 	=:>T"""eT]FO<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=r
  N)r\   r]   r^   r   rN  rG   r
  r
  r
  r   r  r   r  r
  r  r   r
  r
  r
  r_   r=   r   r
  r
    s=       &G  $6 6 6B B B X35RSS= = TS= X_2244435 5X35RSSB B TS5 5B X_2244435 5X35RSS= = TS5 5= = =r=   r
  send_fdsrecv_fdsc                       e Zd Zd ZdS )SendRecvFdsTestsc           	      H   d }d }d t          d          D             }|                     ||           d |D             }t          j        t          j        t          j                  \  }}|5  |5  t          j        |t          g|           t          j        |t          t                    dz  t          |          dz            \  }}}	}
|                     ||           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   | 
                    |t                     | 
                    t          |          t          |                     | 
                    |	d           t          |          D ]>\  }}|\  }}t          j        |t          |                                                     ?t          |          D ]O\  }}t          j        |d          }| 
                    |t          |                                                     Pd S )	Nc                 f    | D ]-\  }}t          j        |           t          j        |           .d S rD   rF  r    )pipesrz  fd2s      r   close_pipesz8SendRecvFdsTests.testSendAndRecvFds.<locals>.close_pipes  s;    !  S r=   c                 8    | D ]}t          j        |           d S rD   r
  )rB  ru  s     r   	close_fdsz6SendRecvFdsTests.testSendAndRecvFds.<locals>.close_fds  s*       r=   c                 4    g | ]}t          j                    S r_   )rF  pipe)r  r   s     r   r  z7SendRecvFdsTests.testSendAndRecvFds.<locals>.<listcomp>  s    ...q...r=   r}  c                     g | ]\  }}|S r_   r_   )r  rfdwfds      r   r  z7SendRecvFdsTests.testSendAndRecvFds.<locals>.<listcomp>  s    )))xsCs)))r=   r   r   r  )r=  rt   r   r  rR  r@   r
  r  r
  r  r  rE  rF  r?  r  r@  r  )rU   r
  r
  r
  rB  sock1sock2r  fds2r  r  r3  r
  r
  r  s                  r   testSendAndRecvFdsz#SendRecvFdsTests.testSendAndRecvFds  s   	 	 	
	 	 	
 /.E"II...U+++))5))) (9KLLu 	- 	-E 	- 	-OEC5#...%+_UCHHqL#c((UV,%W%W"CudOOIt,,,		- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	c"""TCHH---""" $E** 	/ 	/JE3HCHS#e**++--....#D// 	9 	9JE373$$DTCJJ$5$5$7$78888	9 	9s7   0D	3A3C2&D	2C6	6D	9C6	:D		DDN)r\   r]   r^   r
  r_   r=   r   r
  r
    s#        #9 #9 #9 #9 #9r=   r
  c                  d    t          j                    } t          j        t           j        g| R   d S rD   )r   threading_setupr   addModuleCleanupthreading_cleanup)thread_infos    r   setUpModuler
  1  s3    "244K.@O;OOOOOOr=   __main__)r   testr   test.supportr   r   r   r(  r	  r  r   r  rC  r   r  r   r?  rF  rq  r  r  weakrefr   r  r  r>  r   r	  r  r	  _threadr   rl   r	  r  r   requires_working_socketr   r@  r  r   systemr   r  r   r$   r)   r-   r1   r6   r9   r<   rB   r  rI   HAVE_SOCKET_CANHAVE_SOCKET_CAN_ISOTPHAVE_SOCKET_CAN_J1939HAVE_SOCKET_RDSHAVE_SOCKET_ALGHAVE_SOCKET_QIPCRTRHAVE_SOCKET_VSOCKr   HAVE_SOCKET_UDPLITEHAVE_SOCKET_BLUETOOTHr2  rW  r   rM   ra   re   rh   r}   r   r   r   r   r  r   r   r   r  r   r  r  r%  r.  r2  r;  rA  rP  rV  r^  rb  re  rh  rl  ro  rs  r  r  r  r  r  r	  r>  rN  rm  rv  r  r  r  r  r  r  r(  rQ  rX  r]  ra  rh  rn  rq  r  r  r  r   r
  r  r,  r<  r  r0  r4  r7  r9  r;  r  r@  rC  rE  rG  rJ  rL  rN  rP  rR  rT  rW  rY  r[  r]  r_  ra  rc  re  rg  ri  rk  rm  rv  ry  r{  r}  r  r  r  r  r  r  r  r  r  r  rQ  rp  rt  rv  rz  r|  r  r~  r  r  r  r  r  r  r  r  r 	  r	  r4	  rb	  rc	  rd	  r]	  r_	  rk	  rs	  r	  r	  r  r	  r	  r%
  r(
  rv
  rr  r|
  r
  r
  r
  r
  r\   mainr_   r=   r   <module>r
     s4)          " " " " " " & & & & & & ) ) ) ) ) )  				              



 				                              OOOLLLL   EEE   t , , , ,)0099	ho5 NNNN   GGG( ( (              
 
 
 . . . #"$$..00 ..00 ""$$""$$**,, &&(( gf&788 ..00  U[&
	 	 	 	 	H% 	 	 	    H%   7 7 7 7 7 7 7 77 7 7 7 7 7 7 7&0+ 0+ 0+ 0+ 0+H% 0+ 0+ 0+f7 7 7 7 7H% 7 7 7 m m m m m m m m^, , , , ,M> , , ,, , , , ,M> , , , (
35 5, , , , , 1> , ,5 5,, , , , ,M> , , ,(, , , , ,M> , , ,, $--&
13 3WWYY!^
9; ;    H$5~  ; ;3 3 .-
<3 3 3 3 3/ 3 3 3B, , , , ,X& , , ,8    X&   .    ~   , , , , ,7,, , ,>!! !! !! !! !!76!! !! !!H0 0 0 0 0 0 0 0$A A A A A' A A A
6 
6 
6 
6 
6> 
6 
6 
6A A A A A, A A A@ @ @ @ @, @ @ @X X X X Xl X X X2 2 2 2 2\ 2 2 2         L      
A A A A A= A A AY Y Y Y Y} Y Y Y/ / /.F F F3 3 3>]G ]G ]G ]G ]G* ]G ]G ]G@% _&IJJP[ P[ P[ P[ P[8$ P[ P[ KJP[f _&IJJW= W= W= W= W=# W= W= KJW=t *,OPP' ' ' ' '! ' ' QP'T *,OPP: : : : :! : : QP:z _&KLLG G G G G8$ G G MLG" _&KLL<9 <9 <9 <9 <9# <9 <9 ML<9| (
35 57 7 7 7 7x( 7 75 576 $--&
13 3+D +D +D +D +DX& +D +D3 3 .-+D\ *@B B" " " " "* " "B B"Jx! x! x! x! x!& x! x! x!v3 3 3 3 3( 3 3 3: (
35 53 3 3 3 30 3 35 53nt8 t8 t8 t8 t8/ t8 t8 t8n	6 	6 	6 	6 	6 	6 	6 	6F F F F F F F F@ @ @ @ @ @ @ @9 9 9 9 9O 9 9 9*       (5 5 5 5 5? 5 5 5t@ t@ t@ t@ t@/ t@ t@ t@n:" :" :" :" :" :" :" :"z. . . . . . . ."SM SM SM SM SM/ SM SM SMl          3      F    &   :M5 M5 M5 M5 M5')< M5 M5 M5`8I 8I 8I 8I 8IX& 8I 8I 8Ivf! f! f! f! f!0 f! f! f!Ro o o o o7 o o oh	 	 	 	 	6:4k	 	 	
 fmY''	 	 	 	 	/1G 	 	 ('	 fmY''	 	 	 	 	\#9 	 	 ('	 fm^,,	 	 	 	 	)+A 	 	 -,	1 1 1 1 17;5|1 1 1 fmY'']/1OPPz<((	 	 	 	 	02I 	 	 )( QP ('	 fmY'']/1OPPz<((	 	 	 	 	l$; 	 	 )( QP ('	 fm^,,]/1OPPz<((	 	 	 	 	*,C 	 	 )( QP -,	 fmY'']/1OPPfn%%z<((	 	 	 	 	&:&=	 	 )( &% QP ('	 fm^,,]/1OPPfn%%z<((	 	 	 	 	*:*>*A	 	 )( &% QP -,	 (
35 5	 	 	 	 	!::4o	 	5 5	
 (
35 5fmY''	 	 	 	 	35O 	 	 ('5 5	 (
35 5fmY''	 	 	 	 	'A 	 	 ('5 5	 (
35 5fm^,,	 	 	 	 	-/I 	 	 -,5 5	 (
35 51 1 1 1 1";;57G1 15 51 fmY'']/1OPP(
35 5z<((	 	 	 	 	46Q 	 	 )(5 5 QP ('
	 fmY'']/1OPP(
35 5z<((	 	 	 	 	,(C 	 	 )(5 5 QP ('
	 fm^,,]/1OPP(
35 5z<((	 	 	 	 	.0K 	 	 )(5 5 QP -,
	 fmY'']/1OPP(
35 5fn%%z<((	 	 	 	 	*>&A	 	 )( &%5 5 QP ('	 fm^,,]/1OPP(
35 5fn%%z<((	 	 	 	 	.>*>*E	 	 )( &%5 5 QP -,		 	 	 	 	55{	 	 	 fmY''	 	 	 	 	')? 	 	 ('	 fmY''	 	 	 	 	\#<+	 	 ('	 fm^,,	 	 	 	 	)+D/	 	 -,	
	 	 	 	 	$<$<$<n	 	 	
 fmY''NOOy-88	 	 	 	 	.0M 	 	 98 PO ('	 fmY''NOOy-88	R 	R 	R 	R 	RL*C9	R 	R 98 PO ('	R fm^,,NOOy-88	R 	R 	R 	R 	R 02K =	R 	R 98 PO -,	R	 	 	 	 	$<$<n	 	 	 fmY''fi  	 	 	 	 	.0M 	 	 !  ('	 fmY''fi  	 	 	 	 	L*C9	 	 !  ('	 fm^,,fi  	 	 	 	 	 02K =	 	 !  -,	 fmY	22fi|<<	 	 	 	 	0M 	 	 =< 32	 fmY77fi|<<	 	 	 	 	%5}%B	 	 =< 87	" " " " " " " "@ fn%%WWVW--M1M1MBD D$M $M $M $M $M!7 $M $MD D &%$MR fn%%WWVW--M1M1MBD D4F 4F 4F 4F 4F!7!:!9;4F 4FD D &%4Fn    )   ( #  #  #  #  #.  #  #  #F] ] ] ] ]/ ] ] ]@` ` ` ` `1 ` ` `FiG iG iG iG iG(? iG iG iGX    *A   
    +B   
    )@       *A       .E   " " " " "F " " "    )<   N5 N5 N5 N5 N5 1 N5 N5 N5bD4 D4 D4 D4 D4m^ D4 D4 D4N> > > > >]N > > >>75 75 75 75 75] 75 75 75rK K K K K] K K K. (
35 5K K K K K* K K5 5K.$ $ $ $ $X& $ $ $. S\W,.CDD4H 4H 4H 4H 4H!2 4H 4H ED4Hn WWVY//1LMMG7 G7 G7 G7 G7X& G7 G7 NMG7TP: P: P: P: P:& P: P: P:f 


  ( __&&MO O# # # # #x  # #O O#, __&&MO O$ $ $ $ $*N $ $O O$N)9 )9 )9 )9 )9/ )9 )9 )9X@6 @6 @6 @6 @6h' @6 @6 @6F WWV_5502 29$ 9$ 9$ 9$ 9$8, 9$ 9$2 29$x RW_&899_&<==b# b# b# b# b# b# b# >= :9b#JF= F= F= F= F=1 F= F= F=R WWR,,<> >7 7 7 7 7 5 7 7> >7 _&788@* @* @* @* @*8, @* @* 98@*F S\X-/DEE. . . . .) . . FE.
 S\,,U335GHHQ Q Q Q QH- Q Q IHQ,0; 0; 0; 0; 0;x( 0; 0; 0;f>= >= >= >= >=!2 >= >= >=@ fj!!fj!!fi  $9 $9 $9 $9 $9x( $9 $9 !  "! "!$9NP P P
 zHMOOOOO s6    B BBB B"!B"(C- -C76C7