Ë
    oj,ˆ  ã                   ó  — d Z ddlmZ ddlmZmZmZmZmZ ddl	m
Z
 ddlmZmZmZmZ ddlmZ ddlmZ ddlmZmZ dd	lmZmZmZ dd
lmZ 	 ddlmZ eZddlmZm Z  ddl!m"Z"m#Z# ddl$m%Z% ddl&m'Z'm(Z(m)Z) ddl*m+Z+m,Z, ddl-m.Z.m/Z/m0Z0 ddl1m2Z2m3Z3m4Z4m5Z5 ddl6m7Z7m8Z8m9Z9 ddl:m;Z; ddl<m=Z=m>Z>m?Z?m@Z@mAZA ddlBmCZC ddlDmEZEmFZFmGZGmHZH ddlImJZJ ddlKmLZL ddlMmNZN ddlOmPZPmQZQmRZR ddlSmTZT ddlUmVZV  eTd«      ZWd ZX eTd«      �d!ZX G d"„ d#«      ZYd$„ ZZ G d%„ d&e?«      Z[ G d'„ d(e=«      Z\ e e2«       G d)„ d*e=«      «       Z] G d+„ d,eYeCe>«      Z^ G d-„ d.eYeC«      Z_ G d/„ d0«      Z` G d1„ d2«      Za G d3„ d4«      Zb G d5„ d6eaebeCeG«      Zc G d7„ d8e`ebeCeG«      Zd G d9„ d:eHeC«      Ze ef«       jÏ                  e^jÑ                  «       «        ef«       jÏ                  e_jÑ                  «       «        ef«       jÏ                  ecjÑ                  «       «        ef«       jÏ                  edjÑ                  «       «        ef«       jÏ                  eejÑ                  «       «        G d;„ d<eCe@«      Zi ef«       jÏ                  eijÑ                  «       «       y# e$ r dZY �Œ1w xY w)=z/
Tests for implementations of L{IReactorUNIX}.
é    )Úmd5)ÚcloseÚfstatÚstatÚunlinkÚurandom)Úpformat)ÚAF_INETÚSOCK_STREAMÚ
SOL_SOCKETÚsocket)ÚS_IMODE)Úpack)ÚmkstempÚmktemp)ÚOptionalÚSequenceÚType)ÚskipIf)ÚAF_UNIXN)Ú	InterfaceÚimplementer)ÚbaseÚ
interfaces)ÚUNIXAddress)ÚDeferredÚfailÚgatherResults)ÚUNIXClientEndpointÚUNIXServerEndpoint)ÚCannotListenErrorÚConnectionClosedÚFileDescriptorOverrun)ÚIFileDescriptorReceiverÚIReactorFDSetÚIReactorSocketÚIReactorUNIX)ÚClientFactoryÚDatagramProtocolÚServerFactory)ÚLoopingCall)ÚConnectableProtocolÚConnectionTestsMixinÚEndpointCreatorÚStreamClientTestsMixinÚrunProtocolsWithReactor)ÚReactorBuilder)ÚMyClientFactoryÚMyServerFactoryÚStreamTransportTestsMixinÚWriteSequenceTestsMixin)ÚnativeString)ÚFailure)Ú_coerceToFilesystemEncoding)ÚaddObserverÚerrÚremoveObserver)ÚrequireModule)Úplatformztwisted.python.sendmsgÚ z>sendmsg extension unavailable, extended UNIX features disabledc                   ó   — e Zd ZdZd„ Zy)ÚUNIXFamilyMixinzK
    Test-helper defining mixin for things related to AF_UNIX sockets.
    c                 óÎ   — d}| j                  «       } t        ||«      |||¬«      }|j                  «        | j                  t	        t        |«      j                  «      |«       y)z}
        Assert that the mode of the created unix socket is set to the mode
        specified to the reactor method.
        i€  )ÚmodeN)ÚbuildReactorÚgetattrÚstopListeningÚassertEqualr   r   Úst_mode)ÚselfÚ
methodNameÚpathÚfactoryrB   ÚreactorÚunixPorts          úA/usr/lib/python3/dist-packages/twisted/internet/test/test_unix.pyÚ	_modeTestzUNIXFamilyMixin._modeTestO   sY   € ð
 ˆØ×#Ñ#Ó%ˆØ/”7˜7 JÓ/°°gÀDÔIˆØ×ÑÔ Ø×Ñœ¤ d£×!3Ñ!3Ó4°dÕ;ó    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rO   © rP   rN   r@   r@   J   s   „ ñó	<rP   r@   c                 óF   — t        t        d«      «      j                  «       S )zI
    Return a new, unique abstract namespace path to be listened on.
    éd   )r   r   Ú	hexdigest)Úcases    rN   Ú_abstractPathrZ   [   s   € ô Œw�s‹|Ó×&Ñ&Ó(Ð(rP   c                   óT   — e Zd ZU dZej
                  fZeee	e
         ed<   d„ Zd„ Zy)ÚUNIXCreatorz(
    Create UNIX socket end points.
    ÚrequiredInterfacesc                 ó4   — t        dd¬«      }t        ||«      S )z3
        Construct a UNIX server endpoint.
        ú.sockú.©ÚsuffixÚdir)r   r    )rH   rL   rJ   s      rN   ÚserverzUNIXCreator.serveri   s   € ô
 ˜W¨#Ô.ˆÜ! '¨4Ó0Ð0rP   c                 ó.   — t        ||j                  «      S )z3
        Construct a UNIX client endpoint.
        )r   Úname)rH   rL   ÚserverAddresss      rN   ÚclientzUNIXCreator.clientq   s   € ô " '¨=×+=Ñ+=Ó>Ð>rP   N)rQ   rR   rS   rT   r   r'   r]   r   r   r   r   Ú__annotations__rd   rh   rU   rP   rN   r\   r\   b   s7   … ñð @J×?VÑ?VÐ>XÐ˜ ¨$¨y©/Ñ!:Ñ;ÓXò1ó?rP   r\   c                   ó&   — e Zd ZdZdZd„ Zd„ Zd„ Zy)ÚSendFileDescriptorzæ
    L{SendFileDescriptorAndBytes} sends a file descriptor and optionally some
    normal bytes and then closes its connection.

    @ivar reason: The reason the connection was lost, after C{connectionLost}
        is called.
    Nc                 ó    — || _         || _        y)zà
        @param fd: A C{int} giving a file descriptor to send over the
            connection.

        @param data: A C{str} giving data to send over the connection, or
            L{None} if no data is to be sent.
        N)ÚfdÚdata)rH   rm   rn   s      rN   Ú__init__zSendFileDescriptor.__init__ƒ   s   € ð ˆŒØˆ�	rP   c                 óä   — | j                   j                  | j                  «       | j                  r%| j                   j	                  | j                  «       | j                   j                  «        y)zn
        Send C{self.fd} and, if it is not L{None}, C{self.data}.  Then close the
        connection.
        N)Ú	transportÚsendFileDescriptorrm   rn   ÚwriteÚloseConnection©rH   s    rN   ÚconnectionMadez!SendFileDescriptor.connectionMadeŽ   sG   € ð
 	�‰×)Ñ)¨$¯'©'Ô2Ø�9Š9Ø�N‰N× Ñ  §¡Ô+Ø�‰×%Ñ%Õ'rP   c                 ó>   — t        j                  | |«       || _        y ©N)r,   ÚconnectionLostÚreason©rH   rz   s     rN   ry   z!SendFileDescriptor.connectionLost˜   s   € Ü×*Ñ*¨4°Ô8Øˆ�rP   )rQ   rR   rS   rT   rz   ro   rv   ry   rU   rP   rN   rk   rk   x   s   „ ñð €Fò	ò(órP   rk   c                   ó0   — e Zd ZdZdZdZd„ Zd„ Zd„ Zd„ Z	y)ÚReceiveFileDescriptora}  
    L{ReceiveFileDescriptor} provides an API for waiting for file descriptors to
    be received.

    @ivar reason: The reason the connection was lost, after C{connectionLost}
        is called.

    @ivar waiting: A L{Deferred} which fires with a file descriptor once one is
        received, or with a failure if the connection is lost with no descriptor
        arriving.
    Nc                 óz   — | j                   €t        «       | _        | j                  S t        | j                   «      S )z¯
        Return a L{Deferred} which will fire with the next file descriptor
        received, or with a failure if the connection is or has already been
        lost.
        )rz   r   Úwaitingr   ru   s    rN   ÚwaitForDescriptorz'ReceiveFileDescriptor.waitForDescriptor®   s0   € ð �;‰;ÐÜ#›:ˆDŒLØ—<‘<Ðä˜Ÿ™Ó$Ð$rP   c                 óH   — | j                   j                  |«       d| _         y)z�
        Fire the waiting Deferred, initialized by C{waitForDescriptor}, with the
        file descriptor just received.
        N)r   Úcallback)rH   Ú
descriptors     rN   ÚfileDescriptorReceivedz,ReceiveFileDescriptor.fileDescriptorReceivedº   s   € ð
 	�‰×Ñ˜jÔ)Øˆ�rP   c           	      óŽ   — | j                   �9| j                   j                  t        t        d|›d�«      «      «       d| _         yy)a_  
        Fail the waiting Deferred, if it has not already been fired by
        C{fileDescriptorReceived}.  The bytes sent along with a file descriptor
        are guaranteed to be delivered to the protocol's C{dataReceived} method
        only after the file descriptor has been delivered to the protocol's
        C{fileDescriptorReceived}.
        NzReceived bytes (z) before descriptor.)r   Úerrbackr7   Ú	Exception©rH   rn   s     rN   ÚdataReceivedz"ReceiveFileDescriptor.dataReceivedÂ   sF   € ð �<‰<Ð#Ø�L‰L× Ñ Üœ	Ð$4°T°HÐ<PÐ"QÓRÓSôð  ˆD�Lð	 $rP   c                 óš   — t        j                  | |«       | j                  �"| j                  j                  |«       d| _        || _        y)zj
        Fail the waiting Deferred, initialized by C{waitForDescriptor}, if there
        is one.
        N)r,   ry   r   r†   rz   r{   s     rN   ry   z$ReceiveFileDescriptor.connectionLostÐ   s>   € ô
 	×*Ñ*¨4°Ô8Ø�<‰<Ð#Ø�L‰L× Ñ  Ô(ØˆDŒLØˆ�rP   )
rQ   rR   rS   rT   rz   r   r€   r„   r‰   ry   rU   rP   rN   r}   r}   �   s'   „ ñ
ð €FØ€Gò
%òò ó	rP   r}   c                   óì  — e Zd ZdZefZ e«       Zd„ Z e	 e
j                  «        d«      d„ «       Zd„ Z e	 e
j                  «        d«      d„ «       Zd„ Z e	e e«      d„ «       Z e	d	d
«      d„ «       Z e	e e«      d„ «       Zd„ Z e	e e«      d„ «       Z e	 e
j.                  «       d«       e	e e«      d„ «       «       Z e	e e«      d„ «       Z e	e e«      d„ «       Z e	e e«      d„ «       Zy)ÚUNIXTestsBuilderz=
    Builder defining tests relating to L{IReactorUNIX}.
    c                 óV   — | j                  d| j                  «       t        «       «       y)zs
        The UNIX socket created by L{IReactorUNIX.listenUNIX} is created with
        the mode specified.
        Ú
listenUNIXN)rO   r   r*   ru   s    rN   Ú	test_modezUNIXTestsBuilder.test_modeå   s   € ð
 	�‰�| T§[¡[£]´M³OÕDrP   ú8Abstract namespace UNIX sockets only supported on Linux.c                 óÌ   — t        | «      }| j                  «       }|j                  d|z   t        «       «      }| j	                  |j                  «       t        d|z   «      «       y)zµ
        On Linux, a UNIX socket path may begin with C{' '} to indicate
        a socket in the abstract namespace.  L{IReactorUNIX.listenUNIX}
        accepts such a path.
        ú N)rZ   rC   rŽ   r*   rF   ÚgetHostr   ©rH   rJ   rL   Úports       rN   Ú#test_listenOnLinuxAbstractNamespacez4UNIXTestsBuilder.test_listenOnLinuxAbstractNamespaceì   sS   € ô ˜TÓ"ˆØ×#Ñ#Ó%ˆØ×!Ñ! $¨¡+¬}«Ó?ˆØ×Ñ˜Ÿ™›¬°T¸D±[Ó)AÕBrP   c                 óô   — d„ }| j                  t        j                  d|«       | j                  «       }| j	                  t
        «      5  |j                  dt        «       «       ddd«       y# 1 sw Y   yxY w)z•
        L{IReactorUNIX.listenUNIX} raises L{CannotListenError} if the
        underlying port's createInternetSocket raises a socket error.
        c                 ó   — t        d«      ‚)Nz FakeBasePort forced socket.error)ÚOSErrorru   s    rN   ÚraiseSocketErrorz=UNIXTestsBuilder.test_listenFailure.<locals>.raiseSocketError  s   € ÜÐ<Ó=Ð=rP   ÚcreateInternetSocketznot-usedN)Úpatchr   ÚBasePortrC   ÚassertRaisesr!   rŽ   r*   )rH   rš   rL   s      rN   Útest_listenFailurez#UNIXTestsBuilder.test_listenFailureü   sc   € ò	>ð 	�
‰
”4—=‘=Ð"8Ð:JÔKØ×#Ñ#Ó%ˆØ×ÑÔ0Ó1ñ 	<Ø×Ñ˜z¬=«?Ô;÷	<÷ 	<ñ 	<ús   Á
A.Á.A7c                 óÌ   — t        | «      }| j                  «       }|j                  d|z   t        «       «      }| j	                  |j                  «       t        d|z   «      «       y)zc
        L{IReactorUNIX.connectUNIX} also accepts a Linux abstract namespace
        path.
        r’   N)rZ   rC   ÚconnectUNIXr(   rF   ÚgetDestinationr   )rH   rJ   rL   Ú	connectors       rN   Ú$test_connectToLinuxAbstractNamespacez5UNIXTestsBuilder.test_connectToLinuxAbstractNamespace
  sV   € ô ˜TÓ"ˆØ×#Ñ#Ó%ˆØ×'Ñ'¨¨t©´]³_ÓEˆ	Ø×Ñ˜×1Ñ1Ó3´[ÀÈÁÓ5MÕNrP   c                 ó  —  G d„ dt         «      } |«       } |«       }t        | ||| j                  «       | j                  |j                  d   |j                  d   «       | j                  |j                  d   |j                  d   «       y)z¾
        A client's transport's C{getHost} and C{getPeer} return L{UNIXAddress}
        instances which have the filesystem path of the host and peer ends of
        the connection.
        c                   ó   — e Zd Zd„ Zy)ú4UNIXTestsBuilder.test_addresses.<locals>.SaveAddressc                 ó€   — t        |j                  «       |j                  «       ¬«      | _        |j	                  «        y )N)ÚhostÚpeer)Údictr“   ÚgetPeerÚ	addressesrt   )rH   rq   s     rN   ÚmakeConnectionzCUNIXTestsBuilder.test_addresses.<locals>.SaveAddress.makeConnection   s3   € Ü!%Ø"×*Ñ*Ó,°9×3DÑ3DÓ3Fô"�”ð ×(Ñ(Õ*rP   N)rQ   rR   rS   r®   rU   rP   rN   ÚSaveAddressr§     s   „ ó+rP   r¯   r©   rª   N)r,   r0   Ú	endpointsrF   r­   )rH   r¯   rd   rh   s       rN   Útest_addresseszUNIXTestsBuilder.test_addresses  s}   € ô	+Ô-ô 	+ñ “ˆÙ“ˆä  f¨f°d·n±nÔEà×Ñ˜×)Ñ)¨&Ñ1°6×3CÑ3CÀFÑ3KÔLØ×Ñ˜×)Ñ)¨&Ñ1°6×3CÑ3CÀFÑ3KÕLrP   c                 ój  ‡ ‡‡‡— ddl mŠ t        «       Š‰j                  d«       t        ‰j	                  «       d«      Št        «       }|j                  «       }ˆˆˆ fd„}|j                  |«       |j                  t        d«       |j                  ˆfd„«       t        ‰ ‰|‰ j                  «       y)	z¤
        L{IUNIXTransport.sendFileDescriptor} accepts an integer file descriptor
        and sends a copy of it to the process reading from the connection.
        r   )Úfromfd)r>   r   ó   junkc                 óø   •—  ‰| t         t        «      }t        | «       ‰j                  ‰j	                  «       |j	                  «       «       ‰j                  ‰j                  «       |j                  «       «       y rx   )r
   r   r   rF   ÚgetsocknameÚassertNotEqualÚfileno)rƒ   Úreceivedr³   ÚsrH   s     €€€rN   ÚcheckDescriptorzAUNIXTestsBuilder.test_sendFileDescriptor.<locals>.checkDescriptor=  sY   ø€ Ù˜j¬'´;Ó?ˆHä�*Ôð ×Ñ˜QŸ]™]›_¨h×.BÑ.BÓ.DÔEð
 ×Ñ §¡£
¨H¯O©OÓ,=Õ>rP   z-Sending file descriptor encountered a problemc                 ó8   •— ‰j                   j                  «       S rx   ©rq   rt   ©Úignoredrd   s    €rN   ú<lambda>z:UNIXTestsBuilder.test_sendFileDescriptor.<locals>.<lambda>M  ó   ø€  &×"2Ñ"2×"AÑ"AÓ"C€ rP   N)r   r³   Úbindrk   r¸   r}   r€   ÚaddCallbackÚ
addErrbackr:   ÚaddBothr0   r°   )rH   rh   Údr»   r³   rº   rd   s   `   @@@rN   Útest_sendFileDescriptorz(UNIXTestsBuilder.test_sendFileDescriptor.  sƒ   û€ õ 	"ä‹HˆØ	�‰ˆwŒÜ# A§H¡H£J°Ó8ˆä&Ó(ˆØ×$Ñ$Ó&ˆö	?ð 	
�‰�oÔ&Ø	�‰”SÐIÔJØ	�	‰	ÓCÔDä  f¨f°d·n±nÕErP   Tzfails under LXC in Debian CIc                 óÒ   —  G d„ dt         «      } G d„ dt         «      } |«       } |«       }||_        t        | ||| j                  «       | j	                  |j
                  d«       y)z…
        If a L{IUNIXTransport.sendFileDescriptor} call fills up
        the send buffer, any registered producer is paused.
        c                   ó   — e Zd Zd„ Zy)úSUNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.DoesNotReadc                 ó8   — | j                   j                  «        y rx   )rq   ÚpauseProducingru   s    rN   rv   zbUNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.DoesNotRead.connectionMadeY  s   € Ø—‘×-Ñ-Õ/rP   N©rQ   rR   rS   rv   rU   rP   rN   ÚDoesNotReadrÊ   X  s   „ ó0rP   rÎ   c                   ó.   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zy)ú`UNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.SendsManyFileDescriptorsFc                 ó.  ‡ — t        «       ‰ _         ‰ j                  j                  ‰ d«       ˆ fd„}t        |«      ‰ _        ‰ j                  j
                  ‰ j                  _        ‰ j                  j                  d«      j                  t        d«       y )NTc                  ó¢   •— ‰ j                   j                  ‰ j                  j                  «       «       ‰ j                   j	                  d«       y )Nó   x)rq   rr   r   r¸   rs   ru   s   €rN   ÚsenderzUNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.SendsManyFileDescriptors.connectionMade.<locals>.senderc  s4   ø€ Ø—N‘N×5Ñ5°d·k±k×6HÑ6HÓ6JÔKØ—N‘N×(Ñ(¨Õ.rP   r   zSend loop failure)
r   rq   ÚregisterProducerr+   ÚtaskrL   ÚclockÚstartrÄ   r:   )rH   rÔ   s   ` rN   rv   zoUNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.SendsManyFileDescriptors.connectionMade_  sf   ø€ Ü$›h�”Ø—‘×/Ñ/°°dÔ;ô/ô (¨Ó/�”	Ø"&§.¡.×"8Ñ"8�—	‘	”Ø—	‘	—‘ Ó"×-Ñ-¬cÐ3FÕGrP   c                 ó$   — | j                  «        y rx   ©Ú_disconnectru   s    rN   ÚstopProducingznUNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.SendsManyFileDescriptors.stopProducingk  ó   € Ø× Ñ Õ"rP   c                 ó$   — | j                  «        y rx   rÚ   ru   s    rN   ÚresumeProducingzpUNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.SendsManyFileDescriptors.resumeProducingn  rÝ   rP   c                 óf   — d| _         | j                  j                  «        | j                  «        y )NT)Úpausedrq   ÚunregisterProducerrÛ   ru   s    rN   rÌ   zoUNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.SendsManyFileDescriptors.pauseProducingq  s%   € Ø"�”Ø—‘×1Ñ1Ô3Ø× Ñ Õ"rP   c                 ó´   — | j                   j                  «        | j                  j                  «        | j                  j                  j                  «        y rx   )rÖ   Ústoprq   ÚabortConnectionÚotherru   s    rN   rÛ   zlUNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.SendsManyFileDescriptors._disconnectv  s6   € Ø—	‘	—‘Ô Ø—‘×.Ñ.Ô0Ø—
‘
×$Ñ$×4Ñ4Õ6rP   N)	rQ   rR   rS   rá   rv   rÜ   rß   rÌ   rÛ   rU   rP   rN   ÚSendsManyFileDescriptorsrÐ   \  s!   „ ØˆFò
Hò#ò#ò#ó
7rP   rç   z*sendFileDescriptor producer was not pausedN)r,   ræ   r0   r°   Ú
assertTruerá   )rH   rÎ   rç   rd   rh   s        rN   Ú-test_sendFileDescriptorTriggersPauseProducingz>UNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducingQ  sY   € ô	0Ô-ô 	0ô	7Ô':ô 	7ñ> *Ó+ˆÙ“ˆØˆŒÜ  f¨f°d·n±nÔEà�‰˜Ÿ™Ð'SÕTrP   c                 óÊ  ‡— t        «       }t        |j                  «       d«      Št        «       }g }|j	                  «       }|j                  |j                  «       |j                  ˆfd„«       t        | ‰|| j                  «       | j                  |d   t        «       |d   j                  t        «       | j                  ‰j                  j                  t        «       y)ag  
        If L{IUNIXTransport.sendFileDescriptor} is used to queue a greater
        number of file descriptors than the number of bytes sent using
        L{ITransport.write}, the connection is closed and the protocol connected
        to the transport has its C{connectionLost} method called with a failure
        wrapping L{FileDescriptorOverrun}.
        Nc                 ó8   •— ‰j                   j                  «       S rx   r½   r¾   s    €rN   rÀ   z=UNIXTestsBuilder.test_fileDescriptorOverrun.<locals>.<lambda>’  rÁ   rP   r   )r   rk   r¸   r}   r€   rÅ   Úappendr0   r°   ÚassertIsInstancer7   Útrapr"   rz   Úvaluer#   )rH   Úcargorh   ÚresultrÆ   rd   s        @rN   Útest_fileDescriptorOverrunz+UNIXTestsBuilder.test_fileDescriptorOverrun‚  s¨   ø€ ô “ˆÜ# E§L¡L£N°DÓ9ˆä&Ó(ˆØˆØ×$Ñ$Ó&ˆØ	�	‰	�&—-‘-Ô Ø	�	‰	ÓCÔDä  f¨f°d·n±nÔEà×Ñ˜f Q™i¬Ô1Øˆq‰	�‰Ô'Ô(Ø×Ñ˜fŸm™m×1Ñ1Ô3HÕIrP   c                 ój  ‡— ddl m} ddlm} ddlm} d„ Št        t        «       G ˆfd„dt        «      «       } G d„ d	|«      } |t        t        «      \  }}| j                  |j                  «       | j                  |j                  «        |«       }	 |||	«      }
t        «       \  }}t        «       \  }}| j                  t        |«       | j                  t        |«       d
}||g} ||«      \  }} ||||«       |
j                  «        | j!                  t#        |	j$                  «      |«       | j'                  t)        |«      j+                  t)        |	j$                  «      «      «       |	j$                  r2|D �cg c]
  } ‰|«      ‘Œ }}| j!                  ||	j,                  «       yyc c}w )a‰  
        Drive _SendmsgMixin via sendmsg socket calls to check that
        L{IFileDescriptorReceiver.fileDescriptorReceived} is called once
        for each file descriptor received in the ancillary messages.

        @param ancillaryPacker: A callable that will be given a list of
            two file descriptors and should return a two-tuple where:
            The first item is an iterable of zero or more (cmsg_level,
            cmsg_type, cmsg_data) tuples in the same order as the given
            list for actual sending via sendmsg; the second item is an
            integer indicating the expected number of FDs to be received.
        r   ©Ú
socketpair)Ú_SendmsgMixin©Úsendmsgc                 óH   — t        | «      }|j                  |j                  fS rx   )r   Úst_devÚst_ino)rm   Úfss     rN   ÚdeviceInodeTuplezTUNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.deviceInodeTuple¼  s   € Ü�r“ˆBØ—I‘I˜rŸy™yÐ)Ð)rP   c                   ó   •— e Zd Zd„ Zˆ fd„Zy)úPUNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeProtocolc                 ó    — g | _         g | _        y rx   )ÚfdsÚdeviceInodesReceivedru   s    rN   ro   zYUNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeProtocol.__init__Â  s   € Ø�”Ø,.�Õ)rP   c                 ó”   •— | j                   j                  |«       | j                  j                   ‰|«      «       t        |«       y rx   )r  rì   r  r   )rH   rm   rý   s     €rN   r„   zgUNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeProtocol.fileDescriptorReceivedÆ  s4   ø€ Ø—‘—‘ Ô#Ø×)Ñ)×0Ñ0Ñ1AÀ"Ó1EÔFÜ�b•	rP   N)rQ   rR   rS   ro   r„   )rý   s   €rN   ÚFakeProtocolrÿ   À  s   ø„ ò/õrP   r  c                   ó.   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zy)úPUNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeReceiveré   c                 ó    — || _         || _        y rx   )r   Úprotocol)rH   ÚsktÚprotos      rN   ro   zYUNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeReceiver.__init__Î  s   € Ø!�”Ø %�•rP   c                  ó   — y rx   rU   rˆ   s     rN   Ú_dataReceivedz^UNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeReceiver._dataReceivedÒ  ó   € ØrP   c                  ó   — y rx   rU   ru   s    rN   r“   zXUNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeReceiver.getHostÕ  r  rP   c                  ó   — y rx   rU   ru   s    rN   r¬   zXUNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeReceiver.getPeerØ  r  rP   c                  ó   — y rx   rU   )rH   Úos     rN   Ú_getLogPrefixz^UNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeReceiver._getLogPrefixÛ  r  rP   N)	rQ   rR   rS   Ú
bufferSizero   r  r“   r¬   r  rU   rP   rN   ÚFakeReceiverr  Ë  s    „ ØˆJò&òòòórP   r  s   some data needs to be sentN)r   rõ   Útwisted.internet.unixrö   Útwisted.python.sendmsgrø   r   r$   r,   r   r   Ú
addCleanupr   r   r   ÚdoReadrF   Úlenr  ÚassertFalseÚsetÚintersectionr  )rH   ÚancillaryPackerrõ   rö   rø   r  r  Ú
sendSocketÚ
recvSocketr  ÚreceiverÚ	fileOneFDÚfileOneNameÚ	fileTwoFDÚfileTwoNameÚ
dataToSendÚ	fdsToSendÚ	ancillaryÚexpectedCountrm   ÚdeviceInodesSentrý   s                        @rN   Ú)_sendmsgMixinFileDescriptorReceivedDriverz:UNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriverš  sx  ø€ õ: 	&å7Ý2ò	*ô 
Ô,Ó	-ö	Ô.ó 	ó 
.ð	ô	˜=ô 	ñ& ",¬G´[Ó!AÑˆ
�JØ�‰˜
×(Ñ(Ô)Ø�‰˜
×(Ñ(Ô)á“ˆÙ 
¨EÓ2ˆô ")£Ñˆ	�;Ü!(£Ñˆ	�;Ø�‰œ Ô,Ø�‰œ Ô,à2ˆ
Ø 	Ð*ˆ	Ù#2°9Ó#=Ñ ˆ	�=Ù�
˜J¨	Ô2à�‰Ôð 	×Ñœ˜UŸY™Y›¨Ô7ð 	×Ñœ˜Y›×4Ñ4´S¸¿¹³^ÓDÔEð �9Š9Ø?HÖI¸Ñ 0°Õ 4ÐIÐÐIØ×ÑÐ-¨u×/IÑ/IÕJð ùÚIs   ÆF0c                 ó>   ‡— ddl mŠ ˆfd„}| j                  |«       y)zß
        _SendmsgMixin handles multiple file descriptors per recvmsg, calling
        L{IFileDescriptorReceiver.fileDescriptorReceived} once per received
        file descriptor. Scenario: single CMSG with two FDs.
        r   ©Ú
SCM_RIGHTSc                 ó8   •— t         ‰t        dg| ¢­Ž fg}d}||fS )NÚiié   ©r   r   )r'  r(  r)  r.  s      €rN   r  z[UNIXTestsBuilder.test_multiFileDescriptorReceivedPerRecvmsgOneCMSG.<locals>.ancillaryPacker  s,   ø€ Ü$ j´$°tÐ2H¸iÒ2HÐIÐJˆIØˆMØ˜mÐ+Ð+rP   N©r  r.  r+  ©rH   r  r.  s     @rN   Ú1test_multiFileDescriptorReceivedPerRecvmsgOneCMSGzBUNIXTestsBuilder.test_multiFileDescriptorReceivedPerRecvmsgOneCMSGý  s   ø€ õ 	6ô	,ð
 	×6Ñ6°ÕGrP   z=Multi control message ancillary sendmsg not supported on Mac.c                 ó>   ‡— ddl mŠ ˆfd„}| j                  |«       y)zá
        _SendmsgMixin handles multiple file descriptors per recvmsg, calling
        L{IFileDescriptorReceiver.fileDescriptorReceived} once per received
        file descriptor. Scenario: two CMSGs with one FD each.
        r   r-  c           	      óZ   •— | D �cg c]  }t         ‰t        d|«      f‘Œ }}d}||fS c c}w )NÚir1  r2  )r'  rm   r(  r)  r.  s       €rN   r  z\UNIXTestsBuilder.test_multiFileDescriptorReceivedPerRecvmsgTwoCMSGs.<locals>.ancillaryPacker  s9   ø€ ØKTÖUÀRœ* j´$°s¸B³-Ò@ÐUˆIÐUØˆMØ˜mÐ+Ð+ùò Vs   †(Nr3  r4  s     @rN   Ú2test_multiFileDescriptorReceivedPerRecvmsgTwoCMSGszCUNIXTestsBuilder.test_multiFileDescriptorReceivedPerRecvmsgTwoCMSGs  s   ø€ õ 	6ô	,ð
 	×6Ñ6°ÕGrP   c                 ó*  ‡‡— ddl mŠ d„ }ˆfd„}g }t        |j                  «       | j	                  t
        |j                  «       | j                  ‰d|«       | j                  |«       dŠt        ˆfd„|D «       «      }| j                  |d«       y	)
zØ
        _SendmsgMixin handles multiple file descriptors per recvmsg, calling
        L{IFileDescriptorReceiver.fileDescriptorReceived} once per received
        file descriptor. Scenario: unsupported CMSGs.
        r   r÷   c                 ó   — g }d}||fS )Nr   rU   )r'  r(  r)  s      rN   r  z[UNIXTestsBuilder.test_multiFileDescriptorReceivedPerRecvmsgBadCMSG.<locals>.ancillaryPacker0  s   € ØˆIØˆMØ˜mÐ+Ð+rP   c                 ó8   •— d}dg}d}‰j                  |||«      S )Ns	   some data)NNrP   r   )ÚReceivedMessage)r
  ÚargsÚkwargsrn   r(  Úflagsrø   s         €rN   ÚfakeRecvmsgUnsupportedAncillaryzkUNIXTestsBuilder.test_multiFileDescriptorReceivedPerRecvmsgBadCMSG.<locals>.fakeRecvmsgUnsupportedAncillary5  s*   ø€ ØˆDØ*Ð+ˆIØˆEØ×*Ñ*¨4°¸EÓBÐBrP   Úrecvmsgz#received unsupported ancillary datac              3   ó,   •K  — | ]  }‰|d    v –— Œ y­w)ÚformatNrU   )Ú.0ÚeÚexpectedMessages     €rN   ú	<genexpr>zUUNIXTestsBuilder.test_multiFileDescriptorReceivedPerRecvmsgBadCMSG.<locals>.<genexpr>D  s   øè ø€ ÒC°q�O q¨¡{Ô2ÑCùs   ƒz+Expected message not found in logged eventsN)
Útwisted.pythonrø   r9   rì   r  r;   rœ   r+  Úanyrè   )rH   r  rA  ÚeventsÚfoundrG  rø   s        @@rN   Ú1test_multiFileDescriptorReceivedPerRecvmsgBadCMSGzBUNIXTestsBuilder.test_multiFileDescriptorReceivedPerRecvmsgBadCMSG!  s~   ù€ õ 	+ò	,ô
	Cð ˆÜ�F—M‘MÔ"Ø�‰œ¨¯©Ô6à�
‰
�7˜IÐ'FÔGØ×6Ñ6°ÔGð @ˆÜÓC¸FÔCÓCˆØ�‰˜ÐLÕMrP   c                 ó¢  — ddl m}  |«       \  }}g }t        |j                  «       | j	                  t
        |j                  «        G d„ dt        «      } ||j                  «       d«      }t        «       }t        | ||| j                  «       |j                  «        |j                  d«       | j                  d|j                  d«      «       d	}d
}	t        |j                   |j"                  |	|¬«      }
|D ]1  }|
j%                  «       D ]  \  }}||j'                  |«      k7  sŒ Œ0  y | j)                  d|
›dt+        |«      ›d�«       y)zÙ
        If associated with a protocol which does not provide
        L{IFileDescriptorReceiver}, file descriptors received by the
        L{IUNIXTransport} implementation are closed and a warning is emitted.
        r   rô   c                   ó   — e Zd Zd„ Zy)úRUNIXTestsBuilder.test_avoidLeakingFileDescriptors.<locals>.RecordEndpointAddressesc                 óª   — | j                   j                  «       | _        | j                   j                  «       | _        t
        j                  | «       y rx   )rq   r“   ÚhostAddressr¬   ÚpeerAddressrk   rv   ru   s    rN   rv   zaUNIXTestsBuilder.test_avoidLeakingFileDescriptors.<locals>.RecordEndpointAddresses.connectionMade\  s:   € Ø#'§>¡>×#9Ñ#9Ó#;�Ô Ø#'§>¡>×#9Ñ#9Ó#;�Ô Ü"×1Ñ1°$Õ7rP   NrÍ   rU   rP   rN   ÚRecordEndpointAddressesrP  [  s   „ ó8rP   rT  r´   FrP   r  zˆ%(protocolName)s (on %(hostAddress)r) does not provide IFileDescriptorReceiver; closing file descriptor received (from %(peerAddress)r).r,   )rR  rS  ÚprotocolNamerD  zExpected event (z) not found in logged events (ú)N)r   rõ   r9   rì   r  r;   rk   r¸   r,   r0   r°   r   ÚsetblockingrF   Úrecvr«   rS  rR  ÚitemsÚgetr   r	   )rH   rõ   ÚprobeClientÚprobeServerrK  rT  rd   rh   rD  ÚclsNameÚexpectedEventÚlogEventÚkÚvs                 rN   Ú test_avoidLeakingFileDescriptorsz1UNIXTestsBuilder.test_avoidLeakingFileDescriptorsG  sJ  € õ 	&á#-£<Ñ ˆ�[àˆÜ�F—M‘MÔ"Ø�‰œ¨¯©Ô6ô	8Ô&8ô 	8ñ )¨×);Ñ);Ó)=¸wÓGˆÜ$Ó&ˆä  f¨f°d·n±nÔEð 	×ÑÔð 	×Ñ Ô&Ø×Ñ˜˜k×.Ñ.¨tÓ4Ô5ð:ð 	ð
 (ˆô Ø×*Ñ*Ø×*Ñ*Ø Øô	
ˆð ò 	ˆHØ%×+Ñ+Ó-ò ‘��1Ø˜Ÿ™ Q›Ó'Ùðñ
 ð	ð �IŠIò "ÜØõðõrP   c                 óh  ‡ — t        t        «       G ˆ fd„dt        «      «       }t        «       }t	        |j                  «       d«      } |«       }t        ‰ ||‰ j                  «       ‰ j                  t        |j                  d   «       ‰ j                  dt        |j                  dd «      «       y)z„
        L{IUNIXTransport.sendFileDescriptor} sends file descriptors before
        L{ITransport.write} sends normal bytes.
        c                   ó$   •— e Zd Zd„ Zˆ fd„Zd„ Zy)úJUNIXTestsBuilder.test_descriptorDeliveredBeforeBytes.<locals>.RecordEventsc                 ó<   — t        j                  | «       g | _        y rx   )r,   rv   rK  ru   s    rN   rv   zYUNIXTestsBuilder.test_descriptorDeliveredBeforeBytes.<locals>.RecordEvents.connectionMade�  s   € Ü#×2Ñ2°4Ô8Ø �•rP   c                 óz   •— ‰j                  t        |«       | j                  j                  t	        |«      «       y rx   )r  r   rK  rì   Útype)Ú	innerSelfrƒ   rH   s     €rN   r„   zaUNIXTestsBuilder.test_descriptorDeliveredBeforeBytes.<locals>.RecordEvents.fileDescriptorReceived¡  s*   ø€ Ø—‘¤ zÔ2Ø× Ñ ×'Ñ'¬¨ZÓ(8Õ9rP   c                 ó:   — | j                   j                  |«       y rx   )rK  Úextendrˆ   s     rN   r‰   zWUNIXTestsBuilder.test_descriptorDeliveredBeforeBytes.<locals>.RecordEvents.dataReceived¥  s   € Ø—‘×"Ñ" 4Õ(rP   N)rQ   rR   rS   rv   r„   r‰   ru   s   €rN   ÚRecordEventsre  ›  s   ø„ ò!ô:ó)rP   rl  r´   r   é   N)r   r$   r,   r   rk   r¸   r0   r°   rF   ÚintrK  Úbytes)rH   rl  rð   rd   rh   s   `    rN   Ú#test_descriptorDeliveredBeforeBytesz4UNIXTestsBuilder.test_descriptorDeliveredBeforeBytes”  s’   ø€ ô 
Ô,Ó	-ö
	)Ô.ó 
	)ó 
.ð
	)ô “ˆÜ# E§L¡L£N°GÓ<ˆÙ“ˆä  f¨f°d·n±nÔEà×Ñœ˜fŸm™m¨AÑ.Ô/Ø×Ñ˜¤%¨¯©°a°bÐ(9Ó":Õ;rP   N)rQ   rR   rS   rT   r'   r]   r\   r°   r�   r   r=   ÚisLinuxr–   rŸ   r¤   r±   rø   ÚsendmsgSkipReasonrÇ   ré   rò   r+  r5  ÚisMacOSXr9  rM  rb  rp  rU   rP   rN   rŒ   rŒ   Ü   s¯  „ ñð '˜Ðá“€IòEñ ØˆH×ÑÓÐØEóñ
Có	ð
Cò<ñ ØˆH×ÑÓÐØEóñOó	ðOòMñ, �ˆKÐ*Ó+ñ Fó ,ð FñD ˆDÐ0Ó1ñ.Uó 2ð.Uñ` �ˆKÐ*Ó+ñJó ,ðJò.aKñF �ˆKÐ*Ó+ñHó ,ðHñ Øˆ×ÑÓØGóñ �ˆKÐ*Ó+ñHó ,ó	ð
Hñ �ˆKÐ*Ó+ñ#Nó ,ð#NñJ �ˆKÐ*Ó+ñJó ,ðJñX �ˆKÐ*Ó+ñ<ó ,ñ<rP   rŒ   c                   ón   — e Zd ZdZej
                  fZd„ Z e e	j                  «        d«      d„ «       Zy)ÚUNIXDatagramTestsBuilderzE
    Builder defining tests relating to L{IReactorUNIXDatagram}.
    c                 óV   — | j                  d| j                  «       t        «       «       y)zƒ
        The UNIX socket created by L{IReactorUNIXDatagram.listenUNIXDatagram}
        is created with the mode specified.
        ÚlistenUNIXDatagramN)rO   r   r)   ru   s    rN   Útest_listenModez(UNIXDatagramTestsBuilder.test_listenMode¼  s   € ð
 	�‰Ð+¨T¯[©[«]Ô<LÓ<NÕOrP   r�   c                 óÌ   — t        | «      }| j                  «       }|j                  d|z   t        «       «      }| j	                  |j                  «       t        d|z   «      «       y)z½
        On Linux, a UNIX socket path may begin with C{' '} to indicate a
        socket in the abstract namespace.  L{IReactorUNIX.listenUNIXDatagram}
        accepts such a path.
        r’   N)rZ   rC   rw  r)   rF   r“   r   r”   s       rN   r–   z<UNIXDatagramTestsBuilder.test_listenOnLinuxAbstractNamespaceÃ  sU   € ô ˜TÓ"ˆØ×#Ñ#Ó%ˆØ×)Ñ)¨$°©+Ô7GÓ7IÓJˆØ×Ñ˜Ÿ™›¬°T¸D±[Ó)AÕBrP   N)rQ   rR   rS   rT   r   ÚIReactorUNIXDatagramr]   rx  r   r=   rq  r–   rU   rP   rN   ru  ru  ²  sM   „ ñð %×9Ñ9Ð;Ðò
Pñ ØˆH×ÑÓÐØEóñ	Có	ñ	CrP   ru  c                   óB   — e Zd ZU dZeefZeee	e
         ed<   d„ Zd„ Zy)ÚSocketUNIXMixinzb
    Mixin which uses L{IReactorSocket.adoptStreamPort} to hand out listening
    UNIX ports.
    r]   c                 óB  — t        t        «      }t        dd¬«      }|j                  |«       |j	                  d«       |j                  d«       	 |j                  |j                  «       |j                  |«      |j                  «        S # |j                  «        w xY w)zj
        Get a UNIX port from a reactor, wrapping an already-initialized file
        descriptor.
        r_   r`   ra   é   F)
r   r   r   rÂ   ÚlistenrW  ÚadoptStreamPortr¸   Úfamilyr   )rH   rL   rK   ÚportSockrJ   s        rN   ÚgetListeningPortz SocketUNIXMixin.getListeningPortÞ  sv   € ô
 œ'“?ˆä˜W¨#Ô.ˆØ�‰�dÔØ�‰˜ÔØ×Ñ˜UÔ#ð	Ø×*Ñ*¨8¯?©?Ó+<¸h¿o¹oÈwÓWà�N‰NÕøˆH�N‰NÕús   Á*B ÂBc                 ó:   — |j                  |j                  |«      S ©aZ  
        Connect to a listening UNIX socket.

        @param reactor: The reactor under test.
        @type reactor: L{IReactorUNIX}

        @param address: The listening's address.
        @type address: L{UNIXAddress}

        @param factory: The client factory.
        @type factory: L{ClientFactory}

        @return: The connector
        ©r¡   rf   ©rH   rL   ÚaddressrK   s       rN   ÚconnectToListenerz!SocketUNIXMixin.connectToListenerî  ó   € ð ×"Ñ" 7§<¡<°Ó9Ð9rP   N)rQ   rR   rS   rT   r'   r&   r]   r   r   r   r   ri   rƒ  r‰  rU   rP   rN   r|  r|  Ó  s6   … ñð 	Øð?Ð˜ ¨$¨y©/Ñ!:Ñ;ó ò
ó :rP   r|  c                   ó   — e Zd ZdZd„ Zd„ Zy)ÚListenUNIXMixinzZ
    Mixin which uses L{IReactorTCP.listenUNIX} to hand out listening UNIX
    ports.
    c                 ó@   — t        dd¬«      }|j                  ||«      S )z0
        Get a UNIX port from a reactor
        r_   r`   ra   )r   rŽ   )rH   rL   rK   rJ   s       rN   rƒ  z ListenUNIXMixin.getListeningPort  s#   € ô
 ˜W¨#Ô.ˆØ×!Ñ! $¨Ó0Ð0rP   c                 ó:   — |j                  |j                  |«      S r…  r†  r‡  s       rN   r‰  z!ListenUNIXMixin.connectToListener  rŠ  rP   N)rQ   rR   rS   rT   rƒ  r‰  rU   rP   rN   rŒ  rŒ     s   „ ñò
1ó:rP   rŒ  c                   ó<   — e Zd ZU efZeeee         e	d<   d„ Z
d„ Zy)ÚUNIXPortTestsMixinr]   c                 óR   — |› dt        |j                  «       j                  «      ›�S )zZ
        Get the message expected to be logged when a UNIX port starts listening.
        z starting on ©r6   r“   rf   )rH   r•   rK   s      rN   Ú#getExpectedStartListeningLogMessagez6UNIXPortTestsMixin.getExpectedStartListeningLogMessage#  s'   € ð �˜-¬°T·\±\³^×5HÑ5HÓ(IÐ'LÐMÐMrP   c                 óP   — dt        |j                  «       j                  «      › d�S )zJ
        Get the expected connection lost message for a UNIX port
        z(UNIX Port z Closed)r’  )rH   r•   s     rN   ÚgetExpectedConnectionLostLogMsgz2UNIXPortTestsMixin.getExpectedConnectionLostLogMsg)  s%   € ð œ\¨$¯,©,«.×*=Ñ*=Ó>Ð?¸xÐHÐHrP   N)rQ   rR   rS   r'   r]   r   r   r   r   ri   r“  r•  rU   rP   rN   r�  r�     s)   … Ø?K¸oÐ˜ ¨$¨y©/Ñ!:Ñ;ÓMòNóIrP   r�  c                   ó   — e Zd ZdZy)ÚUNIXPortTestsBuilderz.
    Tests for L{IReactorUNIX.listenUnix}
    N©rQ   rR   rS   rT   rU   rP   rN   r—  r—  0  ó   „ òrP   r—  c                   ó   — e Zd ZdZy)ÚUNIXFDPortTestsBuilderz3
    Tests for L{IReactorUNIX.adoptStreamPort}
    Nr˜  rU   rP   rN   r›  r›  ;  r™  rP   r›  c                   ó(   — e Zd ZeeefZd„ Zd„ Zd„ Z	y)Ú%UNIXAdoptStreamConnectionTestsBuilderc                 ó‚  — | j                  «       }ddlm}  G d„ dt        «      } |t        t
        «      \  }}|j                  d«       | j                  |j                  «       | j                  |j                  «       |j                  «       } |«       }|j                  |t        |«      }| j                  |«       y)z€
        {IReactorSocket.adoptStreamConnection} returns None if the given
        factory's buildProtocol returns None.
        r   rô   c                   ó   — e Zd Zd„ Zy)úXUNIXAdoptStreamConnectionTestsBuilder.test_buildProtocolReturnsNone.<locals>.NoneFactoryc                  ó   — y rx   rU   )rH   rˆ  s     rN   ÚbuildProtocolzfUNIXAdoptStreamConnectionTestsBuilder.test_buildProtocolReturnsNone.<locals>.NoneFactory.buildProtocol\  s   € ØrP   N)rQ   rR   rS   r¢  rU   rP   rN   ÚNoneFactoryr   [  s   „ órP   r£  FN)rC   r   rõ   r*   r   r   rW  r  r   r¸   ÚadoptStreamConnectionÚassertIsNone)	rH   rL   rõ   r£  Ús1Ús2Ús1FDrK   rñ   s	            rN   Útest_buildProtocolReturnsNonezCUNIXAdoptStreamConnectionTestsBuilder.test_buildProtocolReturnsNoneM  s“   € ð ×#Ñ#Ó%ˆå%ô	œ-ô 	ñ œG¤[Ó1‰ˆˆBØ
�‰�uÔØ�‰˜Ÿ™Ô!Ø�‰˜Ÿ™Ô!à�y‰y‹{ˆÙ“-ˆØ×.Ñ.¨t´W¸gÓFˆØ×Ñ˜&Õ!rP   c                 óœ   ‡ — ˆ fd„}‰ j                  «       }‰ j                  |dd¬«      }|j                  |«       ‰ j                  |«       y)z>
        Helper method to test UNIX server addresses.
        c                 ó,  •— | \  }}}	 t        d|j                  «       j                  «      }‰j                  d|j                  j
                  ›d|›d�t        |j                  «      «       ‰j                  d|j                  j
                  ›d|›�|j                  j                  «       |j                  j                  d   }‰j                  |t        «       |j                  j                  «        y # |j                  j                  «        w xY w)Nr>   z<AccumulatingProtocol #z on ú>zAccumulatingProtocol,ú,r   )r8   r“   rf   rF   rq   Ú	sessionnoÚstrÚlogstrrK   ÚpeerAddressesrí   r   rt   )Ú	protocolsrh   rd   r•   ÚportPathrS  rH   s         €rN   Ú	connectedzOUNIXAdoptStreamConnectionTestsBuilder.test_ServerAddressUNIX.<locals>.connectedn  sà   ø€ Ø#,Ñ ˆF�F˜Dð2Ü6°r¸4¿<¹<»>×;NÑ;NÓO�Ø× Ò à×'Ñ'×1Ó1²8ð=ä˜×(Ñ(Ó)ôð × Ò à×'Ñ'×1Ó1±8ð=à×$Ñ$×+Ñ+ôð %Ÿn™n×:Ñ:¸1Ñ=�Ø×%Ñ% k´;Ô?ð × Ñ ×/Ñ/Õ1ø�× Ñ ×/Ñ/Õ1ús   ‰CC7 Ã7DN)Ú	interfaceÚaddressFamily)rC   ÚgetConnectedClientAndServerrÃ   Ú
runReactor)rH   r´  rL   rÆ   s   `   rN   Útest_ServerAddressUNIXz<UNIXAdoptStreamConnectionTestsBuilder.test_ServerAddressUNIXi  sN   ø€ ô
	2ð, ×#Ñ#Ó%ˆØ×,Ñ,Ø˜t°4ð -ó 
ˆð 	
�‰�iÔ Ø�‰˜Õ rP   c                 óÈ  ‡‡‡‡— t        «       }t        «       |_        t        «       Št        «       ‰_        t        «       ‰_        t	        «       }t        «       |_        t        «       |_        t        dd¬«      }‰j                  ||«      Šˆˆfd„}|j                  j                  |«       t        |j                  ‰j                  g«      }ˆfd„}	|j                  |	«       t        «       Š‰j                  |	«       t        |j                  ‰j                  g«      }
ˆˆfd„}|
j                  |«       ‰j                  ‰j                  «       j                  |«       ‰S )a0  
        Return a L{Deferred} firing with a L{MyClientFactory} and
        L{MyServerFactory} connected pair, and the listening C{Port}. The
        particularity is that the server protocol has been obtained after doing
        a C{adoptStreamConnection} against the original server connection.
        r_   r`   ra   c                 óÐ   •— ‰j                  | j                  «       ‰j                  | j                  «       ‰j                  | j                  j	                  «       t
        ‰«       y rx   )ÚremoveReaderrq   ÚremoveWriterr¤  r¸   r   )r  rL   rd   s    €€rN   ÚfirstServerConnectedz_UNIXAdoptStreamConnectionTestsBuilder.getConnectedClientAndServer.<locals>.firstServerConnected¡  sF   ø€ Ø× Ñ  §¡Ô1Ø× Ñ  §¡Ô1Ø×)Ñ)¨%¯/©/×*@Ñ*@Ó*BÄGÈVÕTrP   c                 ó@   •— ‰j                   r‰j                  «        | S rx   )Úrunningrä   )rñ   rL   s    €rN   rä   zOUNIXAdoptStreamConnectionTestsBuilder.getConnectedClientAndServer.<locals>.stop¬  s   ø€ Ø�ŠØ—‘”ØˆMrP   c                 ó8   •— | \  }}‰j                  ||‰f«       y rx   )r‚   )r²  rh   rd   Údeferredr•   s      €€rN   rØ   zPUNIXAdoptStreamConnectionTestsBuilder.getConnectedClientAndServer.<locals>.startº  s!   ø€ Ø&‰NˆF�FØ×Ñ˜v v¨tÐ4Õ5rP   )r3   r   ÚprotocolConnectionMadeÚprotocolConnectionLostr2   r   rŽ   rÃ   r   rÅ   rÄ   r¡   r“   rf   )rH   rL   rµ  r¶  ÚfirstServerrh   rJ   r¾  ÚlostDeferredrä   ÚstartDeferredrØ   rÂ  r•   rd   s    `          @@@rN   r·  zAUNIXAdoptStreamConnectionTestsBuilder.getConnectedClientAndServer‹  s(  û€ ô &Ó'ˆÜ-5«ZˆÔ*ä Ó"ˆÜ(0«
ˆÔ%Ü(0«
ˆÔ%ä Ó"ˆÜ(0«
ˆÔ%Ü(0«
ˆÔ%ô ˜W¨#Ô.ˆØ×!Ñ! $¨Ó4ˆõ	Uð
 	×*Ñ*×6Ñ6Ð7KÔLä$Ø×*Ñ*¨F×,IÑ,IÐJó
ˆô	ð
 	×Ñ˜TÔ"ä“:ˆØ×Ñ˜DÔ!ä%Ø×*Ñ*¨F×,IÑ,IÐJó
ˆõ	6ð 	×!Ñ! %Ô(à×Ñ˜DŸL™L›N×/Ñ/°Ô8ØˆrP   N)
rQ   rR   rS   r%   r&   r'   r]   r©  r¹  r·  rU   rP   rN   r�  r�  F  s#   „ àØØðÐò"ò8 !óD6rP   r�  c                   ó6   — e Zd ZdZefZdZed„ «       Zd„ Z	d„ Z
y)ÚUnixClientTestsBuilderz7
    Define tests for L{IReactorUNIX.connectUNIX}.
    Nc                 óR   — | j                   €t        | «      | _         | j                   S )z‹
        Return a path usable by C{connectUNIX} and C{listenUNIX}.

        @return: A path instance, built with C{_abstractPath}.
        )Ú_pathrZ   ru   s    rN   rJ   zUnixClientTestsBuilder.pathÔ  s$   € ð �:‰:ÐÜ& tÓ,ˆDŒJØ�z‰zÐrP   c                 ó:   — |j                  | j                  |«      S )z×
        Start an UNIX server with the given C{factory}.

        @param reactor: The reactor to create the UNIX port in.

        @param factory: The server factory.

        @return: A UNIX port instance.
        )rŽ   rJ   ©rH   rL   rK   s      rN   r  zUnixClientTestsBuilder.listenß  s   € ð ×!Ñ! $§)¡)¨WÓ5Ð5rP   c                 ó:   — |j                  | j                  |«      S )zÝ
        Start an UNIX client with the given C{factory}.

        @param reactor: The reactor to create the connection in.

        @param factory: The client factory.

        @return: A UNIX connector instance.
        )r¡   rJ   rÍ  s      rN   ÚconnectzUnixClientTestsBuilder.connectë  s   € ð ×"Ñ" 4§9¡9¨gÓ6Ð6rP   )rQ   rR   rS   rT   r'   r]   rË  ÚpropertyrJ   r  rÏ  rU   rP   rN   rÉ  rÉ  Ë  s2   „ ñð '˜Ðà€Eàñó ðò
6ó
7rP   rÉ  )jrT   Úhashlibr   Úosr   r   r   r   r   Úpprintr	   r   r
   r   r   r   Ústructr   Útempfiler   r   Útypingr   r   r   Úunittestr   r   Ú_AF_UNIXÚImportErrorÚzope.interfacer   r   Útwisted.internetr   r   Útwisted.internet.addressr   Útwisted.internet.deferr   r   r   Útwisted.internet.endpointsr   r    Útwisted.internet.errorr!   r"   r#   Útwisted.internet.interfacesr$   r%   r&   r'   Útwisted.internet.protocolr(   r)   r*   Útwisted.internet.taskr+   Ú&twisted.internet.test.connectionmixinsr,   r-   r.   r/   r0   Ú#twisted.internet.test.reactormixinsr1   Útwisted.internet.test.test_tcpr2   r3   r4   r5   Útwisted.python.compatr6   Útwisted.python.failurer7   Útwisted.python.filepathr8   Útwisted.python.logr9   r:   r;   Útwisted.python.reflectr<   Útwisted.python.runtimer=   rø   rr  r@   rZ   r\   rk   r}   rŒ   ru  r|  rŒ  r�  r—  r›  r�  ÚglobalsÚupdateÚmakeTestCaseClassesrÉ  rU   rP   rN   ú<module>rï     s^  ðñõ
 ß 2Õ 2Ý ß ;Ó ;Ý Ý ß $ß +Ñ +Ý ðÝ*ð €Gç 1ç -Ý 0ß @Ñ @ß M÷ñ ÷
ó ÷ UÑ TÝ -÷õ õ ?÷ó õ /Ý *Ý ?ß ?Ñ ?Ý 0Ý +á
Ð0Ó
1€ØÐ ÙÐ)Ó*Ð6àKð ÷
<ñ <ò")ô?�/ô ?ô,"Ð,ô "ñJ Ð$Ó%ô;Ð/ó ;ó &ð;ô|S<�¨Ð8Lô S<ôlC˜°ô C÷B*:ñ *:÷Z:ñ :÷@Iñ Iô ØØØØô	ôØØØØô	ô{Ð,CÀ^ô {ñ| ƒ	× Ñ Ð!×5Ñ5Ó7Ô 8Ù ƒ	× Ñ Ð)×=Ñ=Ó?Ô @Ù ƒ	× Ñ Ð%×9Ñ9Ó;Ô <Ù ƒ	× Ñ Ð'×;Ñ;Ó=Ô >Ù ƒ	× Ñ Ð6×JÑJÓLÔ Mô*7˜^Ð-Cô *7ñZ ƒ	× Ñ Ð'×;Ñ;Ó=Õ >øðG ò ØƒGðús   ÁI= É=JÊJ