ó
    Ö›‘hî™  ã                   ó‚  • S r SSKJr  SSKJrJrJrJrJr  SSK	J
r
  SSKJrJrJrJr  SSKJr  SSKJr  SSKJrJr  SS	KJrJrJrJrJr  SS
KJr   SSKJr  \rSSK J!r!J"r"  SSK#J$r$J%r%J&r&J'r'J(r(  SSK)J*r*  SSK+J,r,J-r-J.r.  SSK/J0r0J1r1  SSK2J3r3J4r4J5r5  SSK6J7r7J8r8J9r9J:r:  SSK;J<r<J=r=J>r>  SSK?J@r@  SSKAJBrBJCrCJDrDJErEJFrF  SSKGJHrH  SSKIJJrJJKrKJLrLJMrMJNrN  SSKOJPrP  SSKQJRrR  SSKSJTrT  SSKUJVrVJWrWJXrX  SSKYJZrZ  SSK[J\r\J]r]  SSK^J_r_  SS K`Jara  \Z" S!5      rbS"rc\Z" S!5      b  S#rc " S$ S%5      rdS& re " S' S(\D5      rf " S) S*\B5      rg\"" \75       " S+ S,\B5      5       rh " S- S.\d\H\C5      ri " S/ S0\d\H5      rj " S1 S25      rk " S3 S45      rl " S5 S65      rm " S7 S8\l\m\H\M5      rn " S9 S:\k\m\H\M5      ro " S; S<\N\H5      rp\q" 5       Rå                  \iRç                  5       5        \q" 5       Rå                  \jRç                  5       5        \q" 5       Rå                  \nRç                  5       5        \q" 5       Rå                  \oRç                  5       5        \q" 5       Rå                  \pRç                  5       5         " S= S>\H\E5      rt\q" 5       Rå                  \tRç                  5       5        \" \]S?:g  S@5       " SA SB\a5      5       rug! \ a    Sr GNcf = f)Cz/
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)ÚAnyÚCallableÚOptionalÚSequenceÚType)ÚskipIf)ÚAF_UNIXN)Ú	InterfaceÚimplementer)ÚbaseÚerrorÚ
interfacesÚreactorÚtcp)ÚUNIXAddress)ÚDeferredÚfailÚgatherResults)ÚUNIXClientEndpointÚUNIXServerEndpoint)ÚCannotListenErrorÚConnectionClosedÚFileDescriptorOverrun)ÚIFileDescriptorReceiverÚIReactorFDSetÚIReactorSocketÚIReactorUNIX)ÚClientFactoryÚDatagramProtocolÚServerFactory)ÚLoopingCall)ÚConnectableProtocolÚConnectionTestsMixinÚEndpointCreatorÚStreamClientTestsMixinÚrunProtocolsWithReactor)ÚReactorBuilder)ÚClosingFactoryÚMyClientFactoryÚMyServerFactoryÚStreamTransportTestsMixinÚWriteSequenceTestsMixin)ÚnativeString)ÚFailure)Ú_coerceToFilesystemEncoding)ÚaddObserverÚerrÚremoveObserver)ÚrequireModule)ÚplatformÚplatformType)ÚAccumulatingProtocol)ÚTestCaseztwisted.python.sendmsgÚ z>sendmsg extension unavailable, extended UNIX features disabledc                   ó   • \ rS rSrSrS rSrg)ÚUNIXFamilyMixinéM   zC
Test-helper defining mixin for things related to AF_UNIX sockets.
c                 óÄ   • SnU R                  5       n[        XQ5      " X#US9nUR                  5         U R                  [	        [        U5      R                  5      U5        g)ze
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ÚfactoryrL   r   ÚunixPorts          ÚcC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/internet/test/test_unix.pyÚ	_modeTestÚUNIXFamilyMixin._modeTestR   sS   € ð
 ˆØ×#Ñ#Ó%ˆÜ˜7Ô/°ÀDÑIˆØ×ÑÔ Ø×Ñœ¤ d£×!3Ñ!3Ó4°dÕ;ó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rX   Ú__static_attributes__r[   rZ   rW   rI   rI   M   s   † ñõ	<rZ   rI   c                 óF   • [        [        S5      5      R                  5       $ )zA
Return a new, unique abstract namespace path to be listened on.
éd   )r   r   Ú	hexdigest)Úcases    rW   Ú_abstractPathrf   ^   s   € ô Œw�s‹|Ó×&Ñ&Ó(Ð(rZ   c                   ó\   • \ rS rSr% Sr\R                  4r\\	\
\         \S'   S rS rSrg)ÚUNIXCreatorée   z 
Create UNIX socket end points.
ÚrequiredInterfacesc                 ó,   • [        SSS9n[        X5      $ )z#
Construct a UNIX server endpoint.
ú.sockÚ.©ÚsuffixÚdir)r   r%   )rR   r   rT   s      rW   ÚserverÚUNIXCreator.serverl   s   € ô
 ˜W¨#Ñ.ˆÜ! 'Ó0Ð0rZ   c                 ó,   • [        XR                  5      $ )z#
Construct a UNIX client endpoint.
)r$   Úname)rR   r   ÚserverAddresss      rW   ÚclientÚUNIXCreator.clientt   s   € ô " '×+=Ñ+=Ó>Ð>rZ   r[   N)r\   r]   r^   r_   r`   r   r,   rj   r   r   r   r   Ú__annotations__rq   rv   ra   r[   rZ   rW   rh   rh   e   s7   ‡ ñð @J×?VÑ?VÐ>XÐ˜ ¨$¨y©/Ñ!:Ñ;ÓXò1õ?rZ   rh   c                   ó.   • \ rS rSrSrSrS rS rS rSr	g)ÚSendFileDescriptoré{   zÒ
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                 ó   • Xl         X l        g)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)rR   r}   r~   s      rW   Ú__init__ÚSendFileDescriptor.__init__†   s   € ð ŒØ�	rZ   c                 óî   • U R                   R                  U R                  5        U R                  (       a%  U R                   R	                  U R                  5        U R                   R                  5         g)zV
Send C{self.fd} and, if it is not L{None}, C{self.data}.  Then close the
connection.
N)Ú	transportÚsendFileDescriptorr}   r~   ÚwriteÚloseConnection©rR   s    rW   ÚconnectionMadeÚ!SendFileDescriptor.connectionMade‘   sG   € ð
 	�‰×)Ñ)¨$¯'©'Ô2Ø�9�9Ø�N‰N× Ñ  §¡Ô+Ø�‰×%Ñ%Õ'rZ   c                 ó<   • [         R                  " X5        Xl        g ©N)r1   ÚconnectionLostÚreason©rR   rŒ   s     rW   r‹   Ú!SendFileDescriptor.connectionLost›   s   € Ü×*Ò*¨4Ô8Ø�rZ   )r~   r}   rŒ   )
r\   r]   r^   r_   r`   rŒ   r   r‡   r‹   ra   r[   rZ   rW   rz   rz   {   s   † ñð €Fò	ò(õrZ   rz   c                   ó8   • \ rS rSrSrSrSrS rS rS r	S r
Srg)	ÚReceiveFileDescriptoré    a]  
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                 ó|   • U R                   c  [        5       U l        U R                  $ [        U R                   5      $ )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.
)rŒ   r!   Úwaitingr"   r†   s    rW   ÚwaitForDescriptorÚ'ReceiveFileDescriptor.waitForDescriptor±   s0   € ð �;‰;ÑÜ#›:ˆDŒLØ—<‘<Ðä˜Ÿ™Ó$Ð$rZ   c                 óH   • U R                   R                  U5        SU l         g)zi
Fire the waiting Deferred, initialized by C{waitForDescriptor}, with the
file descriptor just received.
N)r“   Úcallback)rR   Ú
descriptors     rW   ÚfileDescriptorReceivedÚ,ReceiveFileDescriptor.fileDescriptorReceived½   s   € ð
 	�‰×Ñ˜jÔ)Øˆ�rZ   c           	      ó’   • U R                   b:  U R                   R                  [        [        SU< S35      5      5        SU l         gg)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“   Úerrbackr=   Ú	Exception©rR   r~   s     rW   ÚdataReceivedÚ"ReceiveFileDescriptor.dataReceivedÅ   sF   € ð �<‰<Ñ#Ø�L‰L× Ñ Üœ	Ð$4°T±HÐ<PÐ"QÓRÓSôð  ˆD�Lð	 $rZ   c                 óš   • [         R                  " X5        U R                  b"  U R                  R                  U5        SU l        Xl        g)zR
Fail the waiting Deferred, initialized by C{waitForDescriptor}, if there
is one.
N)r1   r‹   r“   rœ   rŒ   r�   s     rW   r‹   Ú$ReceiveFileDescriptor.connectionLostÓ   s:   € ô
 	×*Ò*¨4Ô8Ø�<‰<Ñ#Ø�L‰L× Ñ  Ô(ØˆDŒLØ�rZ   )rŒ   r“   )r\   r]   r^   r_   r`   rŒ   r“   r”   r™   rŸ   r‹   ra   r[   rZ   rW   r�   r�       s'   † ñ
ð €FØ€Gò
%òò õ	rZ   r�   c                   óF  • \ rS rSrSr\4r\" 5       rS r	\
" \R                  " 5       (       + S5      S 5       rS r\
" \R                  " 5       (       + S5      S 5       rS r\
" \(       + \5      S	 5       r\
" \(       + \5      S
 5       r\
" \(       + \5      S 5       rS r\
" \(       + \5      S 5       r\
" \R0                  " 5       S5      \
" \(       + \5      S 5       5       r\
" \(       + \5      S 5       r\
" \(       + \5      S 5       r\
" \(       + \5      S 5       rSrg)ÚUNIXTestsBuilderéß   z5
Builder defining tests relating to L{IReactorUNIX}.
c                 óV   • U R                  SU R                  5       [        5       5        g)z[
The UNIX socket created by L{IReactorUNIX.listenUNIX} is created with
the mode specified.
Ú
listenUNIXN)rX   r   r/   r†   s    rW   Ú	test_modeÚUNIXTestsBuilder.test_modeè   s   € ð
 	�‰�| T§[¡[£]´M³OÕDrZ   ú8Abstract namespace UNIX sockets only supported on Linux.c                 óÎ   • [        U 5      nU R                  5       nUR                  " SU-   [        5       5      nU R	                  UR                  5       [        SU-   5      5        g)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)rf   rM   r§   r/   rP   ÚgetHostr    ©rR   rT   r   Úports       rW   Ú#test_listenOnLinuxAbstractNamespaceÚ4UNIXTestsBuilder.test_listenOnLinuxAbstractNamespaceï   sS   € ô ˜TÓ"ˆØ×#Ñ#Ó%ˆØ×!Ò! $¨¡+¬}«Ó?ˆØ×Ñ˜Ÿ™›¬°T¸D±[Ó)AÕBrZ   c                 ó   • S nU R                  [        R                  SU5        U R                  5       nU R	                  [
        5         UR                  " S[        5       5        SSS5        g! , (       d  f       g= f)z}
L{IReactorUNIX.listenUNIX} raises L{CannotListenError} if the
underlying port's createInternetSocket raises a socket error.
c                 ó   • [        S5      e)Nz FakeBasePort forced socket.error)ÚOSErrorr†   s    rW   ÚraiseSocketErrorÚ=UNIXTestsBuilder.test_listenFailure.<locals>.raiseSocketError  s   € ÜÐ<Ó=Ð=rZ   ÚcreateInternetSocketznot-usedN)Úpatchr   ÚBasePortrM   ÚassertRaisesr&   r§   r/   )rR   rµ   r   s      rW   Útest_listenFailureÚ#UNIXTestsBuilder.test_listenFailureÿ   sZ   € ò	>ð 	�
‰
”4—=‘=Ð"8Ð:JÔKØ×#Ñ#Ó%ˆØ×ÑÔ0Õ1Ø×Ò˜z¬=«?Ô;÷ 2×1Ö1ús   Á
A/Á/
A=c                 óÎ   • [        U 5      nU R                  5       nUR                  " SU-   [        5       5      nU R	                  UR                  5       [        SU-   5      5        g)zK
L{IReactorUNIX.connectUNIX} also accepts a Linux abstract namespace
path.
r¬   N)rf   rM   ÚconnectUNIXr-   rP   ÚgetDestinationr    )rR   rT   r   Ú	connectors       rW   Ú$test_connectToLinuxAbstractNamespaceÚ5UNIXTestsBuilder.test_connectToLinuxAbstractNamespace  sV   € ô ˜TÓ"ˆØ×#Ñ#Ó%ˆØ×'Ò'¨¨t©´]³_ÓEˆ	Ø×Ñ˜×1Ñ1Ó3´[ÀÈÁÓ5MÕNrZ   c                 ó  •  " S S[         5      nU" 5       nU" 5       n[        XX0R                  5        U R                  UR                  S   UR                  S   5        U R                  UR                  S   UR                  S   5        g)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                   ó   • \ rS rSrS rSrg)Ú4UNIXTestsBuilder.test_addresses.<locals>.SaveAddressi"  c                 óz   • [        UR                  5       UR                  5       S9U l        UR	                  5         g )N)ÚhostÚpeer)Údictr­   ÚgetPeerÚ	addressesr…   )rR   r‚   s     rW   ÚmakeConnectionÚCUNIXTestsBuilder.test_addresses.<locals>.SaveAddress.makeConnection#  s3   € Ü!%Ø"×*Ñ*Ó,°9×3DÑ3DÓ3Fñ"�”ð ×(Ñ(Õ*rZ   )rË   N)r\   r]   r^   r_   rÌ   ra   r[   rZ   rW   ÚSaveAddressrÅ   "  s   † õ+rZ   rÎ   rÇ   rÈ   N)r1   r5   Ú	endpointsrP   rË   )rR   rÎ   rq   rv   s       rW   Útest_addressesÚUNIXTestsBuilder.test_addresses  sy   € ô	+Ô-ô 	+ñ “ˆÙ“ˆä ¨f·n±nÔEà×Ñ˜×)Ñ)¨&Ñ1°6×3CÑ3CÀFÑ3KÔLØ×Ñ˜×)Ñ)¨&Ñ1°6×3CÑ3CÀFÑ3KÕLrZ   c                 ón  ^ ^^^• SSK Jm  [        5       mTR                  S5        [        TR	                  5       S5      m[        5       nUR                  5       nUUU 4S jnUR                  U5        UR                  [        S5        UR                  U4S j5        [        T TUT R                  5        g)	zŒ
L{IUNIXTransport.sendFileDescriptor} accepts an integer file descriptor
and sends a copy of it to the process reading from the connection.
r   )Úfromfd)rG   r   ó   junkc                 óø   >• T" U [         [        5      n[        U 5        TR                  TR	                  5       UR	                  5       5        TR                  TR                  5       UR                  5       5        g rŠ   )r
   r   r   rP   ÚgetsocknameÚassertNotEqualÚfileno)r˜   ÚreceivedrÓ   ÚsrR   s     €€€rW   ÚcheckDescriptorÚAUNIXTestsBuilder.test_sendFileDescriptor.<locals>.checkDescriptor@  sY   ø€ Ù˜j¬'´;Ó?ˆHä�*Ôð ×Ñ˜QŸ]™]›_¨h×.BÑ.BÓ.DÔEð
 ×Ñ §¡£
¨H¯O©OÓ,=Õ>rZ   z-Sending file descriptor encountered a problemc                 ó8   >• TR                   R                  5       $ rŠ   ©r‚   r…   ©Úignoredrq   s    €rW   Ú<lambda>Ú:UNIXTestsBuilder.test_sendFileDescriptor.<locals>.<lambda>P  ó   ø€  &×"2Ñ"2×"AÑ"AÔ"CrZ   N)r   rÓ   Úbindrz   rØ   r�   r”   ÚaddCallbackÚ
addErrbackr@   ÚaddBothr5   rÏ   )rR   rv   ÚdrÛ   rÓ   rÚ   rq   s   `   @@@rW   Útest_sendFileDescriptorÚ(UNIXTestsBuilder.test_sendFileDescriptor1  sƒ   û€ õ 	"ä‹HˆØ	�‰ˆwŒÜ# A§H¡H£J°Ó8ˆä&Ó(ˆØ×$Ñ$Ó&ˆ÷	?ð 	
�‰�oÔ&Ø	�‰”SÐIÔJØ	�	‰	ÔCÔDä  f¨f°d·n±nÕErZ   c                 óÌ   •  " S S[         5      n " S S[         5      nU" 5       nU" 5       nXCl        [        XX@R                  5        U R	                  UR
                  S5        g)zm
If a L{IUNIXTransport.sendFileDescriptor} call fills up
the send buffer, any registered producer is paused.
c                   ó   • \ rS rSrS rSrg)ÚSUNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.DoesNotReadi[  c                 ó8   • U R                   R                  5         g rŠ   )r‚   ÚpauseProducingr†   s    rW   r‡   ÚbUNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.DoesNotRead.connectionMade\  s   € Ø—‘×-Ñ-Õ/rZ   r[   N©r\   r]   r^   r_   r‡   ra   r[   rZ   rW   ÚDoesNotReadrí   [  s   † õ0rZ   rò   c                   ó6   • \ rS rSrSrS rS rS rS rS r	Sr
g	)
Ú`UNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.SendsManyFileDescriptorsi_  Fc                 ó0  ^ • [        5       T l         T R                  R                  T S5        U 4S jn[        U5      T l        T R                  R
                  T R                  l        T R                  R                  S5      R                  [        S5        g )NTc                  ó¢   >• T R                   R                  T R                  R                  5       5        T R                   R	                  S5        g )Nó   x)r‚   rƒ   r   rØ   r„   r†   s   €rW   ÚsenderÚUNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.SendsManyFileDescriptors.connectionMade.<locals>.senderf  s4   ø€ Ø—N‘N×5Ñ5°d·k±k×6HÑ6HÓ6JÔKØ—N‘N×(Ñ(¨Õ.rZ   r   zSend loop failure)
r   r‚   ÚregisterProducerr0   Útaskr   ÚclockÚstartræ   r@   )rR   rø   s   ` rW   r‡   ÚoUNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.SendsManyFileDescriptors.connectionMadeb  sf   ø€ Ü$›h�”Ø—‘×/Ñ/°°dÔ;õ/ô (¨Ó/�”	Ø"&§.¡.×"8Ñ"8�—	‘	”Ø—	‘	—‘ Ó"×-Ñ-¬cÐ3FÕGrZ   c                 ó$   • U R                  5         g rŠ   ©Ú_disconnectr†   s    rW   ÚstopProducingÚnUNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.SendsManyFileDescriptors.stopProducingn  ó   € Ø× Ñ Õ"rZ   c                 ó$   • U R                  5         g rŠ   r   r†   s    rW   ÚresumeProducingÚpUNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.SendsManyFileDescriptors.resumeProducingq  r  rZ   c                 óf   • SU l         U R                  R                  5         U R                  5         g )NT)Úpausedr‚   ÚunregisterProducerr  r†   s    rW   rï   ÚoUNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.SendsManyFileDescriptors.pauseProducingt  s%   € Ø"�”Ø—‘×1Ñ1Ô3Ø× Ñ Õ"rZ   c                 ó´   • U R                   R                  5         U R                  R                  5         U R                  R                  R                  5         g rŠ   )rû   Ústopr‚   ÚabortConnectionÚotherr†   s    rW   r  ÚlUNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducing.<locals>.SendsManyFileDescriptors._disconnecty  s6   € Ø—	‘	—‘Ô Ø—‘×.Ñ.Ô0Ø—
‘
×$Ñ$×4Ñ4Õ6rZ   )r	  r   rû   N)r\   r]   r^   r_   r	  r‡   r  r  rï   r  ra   r[   rZ   rW   ÚSendsManyFileDescriptorsrô   _  s!   † ØˆFò
Hò#ò#ò#õ
7rZ   r  z*sendFileDescriptor producer was not pausedN)r1   r  r5   rÏ   Ú
assertTruer	  )rR   rò   r  rq   rv   s        rW   Ú-test_sendFileDescriptorTriggersPauseProducingÚ>UNIXTestsBuilder.test_sendFileDescriptorTriggersPauseProducingT  sS   € ô	0Ô-ô 	0ô	7Ô':ô 	7ñ> *Ó+ˆÙ“ˆØŒÜ ¨f·n±nÔEà�‰˜Ÿ™Ð'SÕTrZ   c                 óÊ  ^• [        5       n[        UR                  5       S5      m[        5       n/ nUR	                  5       nUR                  UR                  5        UR                  U4S j5        [        U TX R                  5        U R                  US   [        5        US   R                  [        5        U R                  TR                  R                  [        5        g)a7  
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   >• TR                   R                  5       $ rŠ   rÞ   rß   s    €rW   rá   Ú=UNIXTestsBuilder.test_fileDescriptorOverrun.<locals>.<lambda>•  rã   rZ   r   )r   rz   rØ   r�   r”   rç   Úappendr5   rÏ   ÚassertIsInstancer=   Útrapr'   rŒ   Úvaluer(   )rR   Úcargorv   Úresultrè   rq   s        @rW   Útest_fileDescriptorOverrunÚ+UNIXTestsBuilder.test_fileDescriptorOverrun…  s¦   ø€ ô “ˆÜ# E§L¡L£N°DÓ9ˆä&Ó(ˆØˆØ×$Ñ$Ó&ˆØ	�	‰	�&—-‘-Ô Ø	�	‰	ÔCÔDä  f¨f·n±nÔEà×Ñ˜f Q™i¬Ô1Øˆq‰	�‰Ô'Ô(Ø×Ñ˜fŸm™m×1Ñ1Ô3HÕIrZ   c                 óp  ^• SSK Jn  SSKJn  SSKJn  S m[        [        5       " U4S jS[        5      5       n " S S	U5      nU" [        [        5      u  pxU R                  UR                  5        U R                  UR                  5        U" 5       n	U" X‰5      n
[        5       u  p¼[        5       u  pÞU R                  [        U5        U R                  [        U5        S
nX½/nU" U5      u  nnU" XU5        U
R                  5         U R!                  [#        U	R$                  5      U5        U R'                  [)        U5      R+                  [)        U	R$                  5      5      5        U	R$                  (       a5  U Vs/ s H  nT" U5      PM     nnU R!                  UU	R,                  5        ggs  snf )a9  
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   • [        U 5      nUR                  UR                  4$ rŠ   )r   Úst_devÚst_ino)r}   Úfss     rW   ÚdeviceInodeTupleÚTUNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.deviceInodeTuple¿  s   € Ü�r“ˆBØ—I‘I˜rŸy™yÐ)Ð)rZ   c                   ó(   >• \ rS rSrS rU 4S jrSrg)ÚPUNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeProtocoliÃ  c                 ó    • / U l         / U l        g rŠ   )ÚfdsÚdeviceInodesReceivedr†   s    rW   r   ÚYUNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeProtocol.__init__Å  s   € Ø�”Ø,.�Õ)rZ   c                 ó”   >• U R                   R                  U5        U R                  R                  T" U5      5        [        U5        g rŠ   )r/  r  r0  r   )rR   r}   r*  s     €rW   r™   ÚgUNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeProtocol.fileDescriptorReceivedÉ  s4   ø€ Ø—‘—‘ Ô#Ø×)Ñ)×0Ñ0Ñ1AÀ"Ó1EÔFÜ�b•	rZ   )r0  r/  N)r\   r]   r^   r_   r   r™   ra   )r*  s   €rW   ÚFakeProtocolr-  Ã  s   ø† ò/÷ð rZ   r4  c                   ó6   • \ rS rSrSrS rS rS rS rS r	Sr
g	)
ÚPUNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeReceiveriÎ  é   c                 ó   • Xl         X l        g rŠ   )r   Úprotocol)rR   ÚsktÚprotos      rW   r   ÚYUNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeReceiver.__init__Ñ  s   € Ø!”Ø %•rZ   c                 ó   • g rŠ   r[   rž   s     rW   Ú_dataReceivedÚ^UNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeReceiver._dataReceivedÕ  ó   € ØrZ   c                 ó   • g rŠ   r[   r†   s    rW   r­   ÚXUNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeReceiver.getHostØ  r@  rZ   c                 ó   • g rŠ   r[   r†   s    rW   rÊ   ÚXUNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeReceiver.getPeerÛ  r@  rZ   c                 ó   • g rŠ   r[   )rR   Úos     rW   Ú_getLogPrefixÚ^UNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver.<locals>.FakeReceiver._getLogPrefixÞ  r@  rZ   )r9  r   N)r\   r]   r^   r_   Ú
bufferSizer   r>  r­   rÊ   rG  ra   r[   rZ   rW   ÚFakeReceiverr6  Î  s    † ØˆJò&òòòõrZ   rJ  s   some data needs to be sentN)r   r"  Útwisted.internet.unixr#  Útwisted.python.sendmsgr%  r   r)   r1   r   r   Ú
addCleanupr   r   r   ÚdoReadrP   Úlenr/  ÚassertFalseÚsetÚintersectionr0  )rR   ÚancillaryPackerr"  r#  r%  r4  rJ  Ú
sendSocketÚ
recvSocketr;  ÚreceiverÚ	fileOneFDÚfileOneNameÚ	fileTwoFDÚfileTwoNameÚ
dataToSendÚ	fdsToSendÚ	ancillaryÚexpectedCountr}   ÚdeviceInodesSentr*  s                        @rW   Ú)_sendmsgMixinFileDescriptorReceivedDriverÚ:UNIXTestsBuilder._sendmsgMixinFileDescriptorReceivedDriver�  sm  ø€ õ: 	&å7Ý2ò	*ô 
Ô,Ó	-÷	Ô.ó 	ó 
.ð	ô	˜=ô 	ñ& ",¬G´[Ó!AÑˆ
Ø�‰˜
×(Ñ(Ô)Ø�‰˜
×(Ñ(Ô)á“ˆÙ 
Ó2ˆô ")£Ñˆ	Ü!(£Ñˆ	Ø�‰œ Ô,Ø�‰œ Ô,à2ˆ
ØÐ*ˆ	Ù#2°9Ó#=Ñ ˆ	�=Ù�
¨	Ô2à�‰Ôð 	×Ñœ˜UŸY™Y›¨Ô7ð 	×Ñœ˜Y›×4Ñ4´S¸¿¹³^ÓDÔEð �9�9Ù?HÓIºy¸Ñ 0°Ö 4¹yÐÐIØ×ÑÐ-¨u×/IÑ/IÕJð ùÚIs   ÆF3c                 ó@   ^• SSK Jm  U4S jnU R                  U5        g)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                 ó6   >• [         T[        S/U Q76 4/nSnX4$ )NÚiié   ©r   r   )r\  r]  r^  rd  s      €rW   rS  Ú[UNIXTestsBuilder.test_multiFileDescriptorReceivedPerRecvmsgOneCMSG.<locals>.ancillaryPacker	  s*   ø€ Ü$ j´$°tÐ2H¸iÒ2HÐIÐJˆIØˆMØÐ+Ð+rZ   N©rL  rd  r`  ©rR   rS  rd  s     @rW   Ú1test_multiFileDescriptorReceivedPerRecvmsgOneCMSGÚBUNIXTestsBuilder.test_multiFileDescriptorReceivedPerRecvmsgOneCMSG   s   ø€ õ 	6õ	,ð
 	×6Ñ6°ÕGrZ   z=Multi control message ancillary sendmsg not supported on Mac.c                 ó@   ^• SSK Jm  U4S jnU R                  U5        g)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   rc  c           	      ó^   >• U  Vs/ s H  n[         T[        SU5      4PM     nnSnX#4$ s  snf )NÚirg  rh  )r\  r}   r]  r^  rd  s       €rW   rS  Ú\UNIXTestsBuilder.test_multiFileDescriptorReceivedPerRecvmsgTwoCMSGs.<locals>.ancillaryPacker  s8   ø€ ÙKTÓUÊ9ÀRœ* j´$°s¸B³-Ó@É9ˆIÐUØˆMØÐ+Ð+ùò Vs   †*Nrj  rk  s     @rW   Ú2test_multiFileDescriptorReceivedPerRecvmsgTwoCMSGsÚCUNIXTestsBuilder.test_multiFileDescriptorReceivedPerRecvmsgTwoCMSGs  s   ø€ õ 	6õ	,ð
 	×6Ñ6°ÕGrZ   c                 ó.  ^^• SSK Jm  S nU4S jn/ n[        UR                  5        U R	                  [
        UR                  5        U R                  TSU5        U R                  U5        Sm[        U4S jU 5       5      nU R                  US5        g	)
z¸
_SendmsgMixin handles multiple file descriptors per recvmsg, calling
L{IFileDescriptorReceiver.fileDescriptorReceived} once per received
file descriptor. Scenario: unsupported CMSGs.
r   r$  c                 ó   • / nSnX4$ )Nr   r[   )r\  r]  r^  s      rW   rS  Ú[UNIXTestsBuilder.test_multiFileDescriptorReceivedPerRecvmsgBadCMSG.<locals>.ancillaryPacker3  s   € ØˆIØˆMØÐ+Ð+rZ   c                 ó6   >• SnS/nSnTR                  X4U5      $ )Ns	   some data)NNrZ   r   )ÚReceivedMessage)r:  ÚargsÚkwargsr~   r]  Úflagsr%  s         €rW   ÚfakeRecvmsgUnsupportedAncillaryÚkUNIXTestsBuilder.test_multiFileDescriptorReceivedPerRecvmsgBadCMSG.<locals>.fakeRecvmsgUnsupportedAncillary8  s(   ø€ ØˆDØ*Ð+ˆIØˆEØ×*Ñ*¨4¸EÓBÐBrZ   Úrecvmsgz#received unsupported ancillary datac              3   ó4   >#   • U  H  nTUS    ;   v •  M     g7f)ÚformatNr[   )Ú.0ÚeÚexpectedMessages     €rW   Ú	<genexpr>ÚUUNIXTestsBuilder.test_multiFileDescriptorReceivedPerRecvmsgBadCMSG.<locals>.<genexpr>G  s   øé € ÐCºF°q�O q¨¡{Ö2ºFùs   ƒz+Expected message not found in logged eventsN)
Útwisted.pythonr%  r?   r  rM  rA   r¸   r`  Úanyr  )rR   rS  r|  ÚeventsÚfoundrƒ  r%  s        @@rW   Ú1test_multiFileDescriptorReceivedPerRecvmsgBadCMSGÚBUNIXTestsBuilder.test_multiFileDescriptorReceivedPerRecvmsgBadCMSG$  s~   ù€ õ 	+ò	,õ
	Cð ˆÜ�F—M‘MÔ"Ø�‰œ¨¯©Ô6à�
‰
�7˜IÐ'FÔGØ×6Ñ6°ÔGð @ˆÜÔC¹FÓCÓCˆØ�‰˜ÐLÕMrZ   c                 ó   • SSK Jn  U" 5       u  p#/ n[        UR                  5        U R	                  [
        UR                  5         " S S[        5      nU" UR                  5       S5      n[        5       n[        XXpR                  5        UR                  5         UR                  S5        U R                  SUR                  S5      5        S	nS
n	[        UR                   UR"                  U	US9n
U H3  nU
R%                  5        H  u  pÍXÛR'                  U5      :w  d  M    M1       g   U R)                  SU
< S[+        U5      < S35        g)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                   ó   • \ rS rSrS rSrg)ÚRUNIXTestsBuilder.test_avoidLeakingFileDescriptors.<locals>.RecordEndpointAddressesi^  c                 óª   • U R                   R                  5       U l        U R                   R                  5       U l        [
        R                  U 5        g rŠ   )r‚   r­   ÚhostAddressrÊ   ÚpeerAddressrz   r‡   r†   s    rW   r‡   ÚaUNIXTestsBuilder.test_avoidLeakingFileDescriptors.<locals>.RecordEndpointAddresses.connectionMade_  s:   € Ø#'§>¡>×#9Ñ#9Ó#;�Ô Ø#'§>¡>×#9Ñ#9Ó#;�Ô Ü"×1Ñ1°$Õ7rZ   )r�  r‘  Nrñ   r[   rZ   rW   ÚRecordEndpointAddressesrŽ  ^  s   † õ8rZ   r“  rÔ   FrZ   r7  zˆ%(protocolName)s (on %(hostAddress)r) does not provide IFileDescriptorReceiver; closing file descriptor received (from %(peerAddress)r).r1   )r�  r‘  ÚprotocolNamer€  zExpected event (z) not found in logged events (Ú)N)r   r"  r?   r  rM  rA   rz   rØ   r1   r5   rÏ   r   ÚsetblockingrP   ÚrecvrÉ   r‘  r�  ÚitemsÚgetr"   r	   )rR   r"  ÚprobeClientÚprobeServerrˆ  r“  rq   rv   r€  ÚclsNameÚexpectedEventÚlogEventÚkÚvs                 rW   Ú test_avoidLeakingFileDescriptorsÚ1UNIXTestsBuilder.test_avoidLeakingFileDescriptorsJ  s6  € õ 	&á#-£<Ñ ˆàˆÜ�F—M‘MÔ"Ø�‰œ¨¯©Ô6ô	8Ô&8ô 	8ñ )¨×);Ñ);Ó)=¸wÓGˆÜ$Ó&ˆä ¨f·n±nÔEð 	×ÑÔð 	×Ñ Ô&Ø×Ñ˜˜k×.Ñ.¨tÓ4Ô5ð:ð 	ð
 (ˆô Ø×*Ñ*Ø×*Ñ*Ø Øñ	
ˆó ˆHØ%×+Ñ+Ö-‘�ØŸ™ Q›Õ'Úñ .ñ
 ñ ð �IŠIó "ÜØöðõrZ   c                 óh  ^ • [        [        5       " U 4S jS[        5      5       n[        5       n[	        UR                  5       S5      nU" 5       n[        T X4T R                  5        T R                  [        UR                  S   5        T R                  S[        UR                  SS 5      5        g)zl
L{IUNIXTransport.sendFileDescriptor} sends file descriptors before
L{ITransport.write} sends normal bytes.
c                   ó.   >• \ rS rSrS rU 4S jrS rSrg)ÚJUNIXTestsBuilder.test_descriptorDeliveredBeforeBytes.<locals>.RecordEventsiž  c                 ó>   • [         R                  " U 5        / U l        g rŠ   )r1   r‡   rˆ  r†   s    rW   r‡   ÚYUNIXTestsBuilder.test_descriptorDeliveredBeforeBytes.<locals>.RecordEvents.connectionMade   s   € Ü#×2Ò2°4Ô8Ø �•rZ   c                 óz   >• TR                  [        U5        U R                  R                  [	        U5      5        g rŠ   )rM  r   rˆ  r  Útype)Ú	innerSelfr˜   rR   s     €rW   r™   ÚaUNIXTestsBuilder.test_descriptorDeliveredBeforeBytes.<locals>.RecordEvents.fileDescriptorReceived¤  s*   ø€ Ø—‘¤ zÔ2Ø× Ñ ×'Ñ'¬¨ZÓ(8Õ9rZ   c                 ó:   • U R                   R                  U5        g rŠ   )rˆ  Úextendrž   s     rW   rŸ   ÚWUNIXTestsBuilder.test_descriptorDeliveredBeforeBytes.<locals>.RecordEvents.dataReceived¨  s   € Ø—‘×"Ñ" 4Õ(rZ   )rˆ  N)r\   r]   r^   r_   r‡   r™   rŸ   ra   r†   s   €rW   ÚRecordEventsr¥  ž  s   ø† ò!õ:õ)rZ   r¯  rÔ   r   é   N)r   r)   r1   r   rz   rØ   r5   rÏ   rP   Úintrˆ  Úbytes)rR   r¯  r  rq   rv   s   `    rW   Ú#test_descriptorDeliveredBeforeBytesÚ4UNIXTestsBuilder.test_descriptorDeliveredBeforeBytes—  s�   ø€ ô 
Ô,Ó	-÷
	)Ô.ó 
	)ó 
.ð
	)ô “ˆÜ# E§L¡L£N°GÓ<ˆÙ“ˆä  f°d·n±nÔEà×Ñœ˜fŸm™m¨AÑ.Ô/Ø×Ñ˜¤%¨¯©°a°bÐ(9Ó":Õ;rZ   r[   N)r\   r]   r^   r_   r`   r,   rj   rh   rÏ   r¨   r   rC   ÚisLinuxr°   r»   rÁ   rÐ   r%  ÚsendmsgSkipReasonré   r  r  r`  rl  ÚisMacOSXrr  rŠ  r¡  r³  ra   r[   rZ   rW   r¤   r¤   ß   s«  † ñð '˜Ðá“€IòEñ Ø×ÒÓÔØEóñ
Có	ð
Cò<ñ Ø×ÒÓÔØEóñOó	ðOòMñ, �ŒKÐ*Ó+ñ Fó ,ð FñD �ŒKÐ*Ó+ñ.Uó ,ð.Uñ` �ŒKÐ*Ó+ñJó ,ðJò.aKñF �ŒKÐ*Ó+ñHó ,ðHñ Ø×ÒÓØGóñ �ŒKÐ*Ó+ñHó ,ó	ð
Hñ �ŒKÐ*Ó+ñ#Nó ,ð#NñJ �ŒKÐ*Ó+ñJó ,ðJñX �ŒKÐ*Ó+ñ<ó ,ó<rZ   r¤   c                   ó~   • \ rS rSrSr\R                  4rS r\	" \
R                  " 5       (       + S5      S 5       rSrg)ÚUNIXDatagramTestsBuilderiµ  z=
Builder defining tests relating to L{IReactorUNIXDatagram}.
c                 óV   • U R                  SU R                  5       [        5       5        g)zk
The UNIX socket created by L{IReactorUNIXDatagram.listenUNIXDatagram}
is created with the mode specified.
ÚlistenUNIXDatagramN)rX   r   r.   r†   s    rW   Útest_listenModeÚ(UNIXDatagramTestsBuilder.test_listenMode¿  s   € ð
 	�‰Ð+¨T¯[©[«]Ô<LÓ<NÕOrZ   rª   c                 óÎ   • [        U 5      nU R                  5       nUR                  " SU-   [        5       5      nU R	                  UR                  5       [        SU-   5      5        g)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)rf   rM   r»  r.   rP   r­   r    r®   s       rW   r°   Ú<UNIXDatagramTestsBuilder.test_listenOnLinuxAbstractNamespaceÆ  sU   € ô ˜TÓ"ˆØ×#Ñ#Ó%ˆØ×)Ò)¨$°©+Ô7GÓ7IÓJˆØ×Ñ˜Ÿ™›¬°T¸D±[Ó)AÕBrZ   r[   N)r\   r]   r^   r_   r`   r   ÚIReactorUNIXDatagramrj   r¼  r   rC   rµ  r°   ra   r[   rZ   rW   r¹  r¹  µ  sK   † ñð %×9Ñ9Ð;Ðò
Pñ Ø×ÒÓÔØEóñ	Có	ó	CrZ   r¹  c                   óJ   • \ rS rSr% Sr\\4r\\	\
\         \S'   S rS rSrg)ÚSocketUNIXMixiniÖ  zV
Mixin which uses L{IReactorSocket.adoptStreamPort} to hand out listening
UNIX ports.
rj   c                 ó>  • [        [        5      n[        SSS9nUR                  U5        UR	                  S5        UR                  S5         UR                  " UR                  5       UR                  U5      UR                  5         $ ! UR                  5         f = f)zR
Get a UNIX port from a reactor, wrapping an already-initialized file
descriptor.
rl   rm   rn   é   F)
r   r   r   rä   Úlistenr–  ÚadoptStreamPortrØ   Úfamilyr   )rR   r   rU   ÚportSockrT   s        rW   ÚgetListeningPortÚ SocketUNIXMixin.getListeningPortá  sv   € ô
 œ'“?ˆä˜W¨#Ñ.ˆØ�‰�dÔØ�‰˜ÔØ×Ñ˜UÔ#ð	Ø×*Ò*¨8¯?©?Ó+<¸h¿o¹oÈwÓWà�N‰NÕøˆH�N‰NÕús   Á+B
 Â
Bc                 ó<   • UR                   " UR                  U5      $ ©a  
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¾   rt   ©rR   r   ÚaddressrU   s       rW   ÚconnectToListenerÚ!SocketUNIXMixin.connectToListenerñ  ó   € ð ×"Ò" 7§<¡<°Ó9Ð9rZ   r[   N)r\   r]   r^   r_   r`   r,   r+   rj   r   r   r   r   rx   rÉ  rÐ  ra   r[   rZ   rW   rÂ  rÂ  Ö  s6   ‡ ñð 	Øð?Ð˜ ¨$¨y©/Ñ!:Ñ;ó ò
õ :rZ   rÂ  c                   ó$   • \ rS rSrSrS rS rSrg)ÚListenUNIXMixini  zN
Mixin which uses L{IReactorTCP.listenUNIX} to hand out listening UNIX
ports.
c                 ó:   • [        SSS9nUR                  " X25      $ )z 
Get a UNIX port from a reactor
rl   rm   rn   )r   r§   )rR   r   rU   rT   s       rW   rÉ  Ú ListenUNIXMixin.getListeningPort	  s!   € ô
 ˜W¨#Ñ.ˆØ×!Ò! $Ó0Ð0rZ   c                 ó<   • UR                   " UR                  U5      $ rÌ  rÍ  rÎ  s       rW   rÐ  Ú!ListenUNIXMixin.connectToListener  rÒ  rZ   r[   N)r\   r]   r^   r_   r`   rÉ  rÐ  ra   r[   rZ   rW   rÔ  rÔ    s   † ñò
1õ:rZ   rÔ  c                   óD   • \ rS rSr% \4r\\\\	         \
S'   S rS rSrg)ÚUNIXPortTestsMixini#  rj   c                 óT   • U S[        UR                  5       R                  5      < 3$ )zJ
Get the message expected to be logged when a UNIX port starts listening.
z starting on ©r<   r­   rt   )rR   r¯   rU   s      rW   Ú#getExpectedStartListeningLogMessageÚ6UNIXPortTestsMixin.getExpectedStartListeningLogMessage&  s'   € ð �˜-¬°T·\±\³^×5HÑ5HÓ(IÑ'LÐMÐMrZ   c                 óP   • S[        UR                  5       R                  5       S3$ )z:
Get the expected connection lost message for a UNIX port
z(UNIX Port z Closed)rÜ  )rR   r¯   s     rW   ÚgetExpectedConnectionLostLogMsgÚ2UNIXPortTestsMixin.getExpectedConnectionLostLogMsg,  s%   € ð œ\¨$¯,©,«.×*=Ñ*=Ó>Ð?¸xÐHÐHrZ   r[   N)r\   r]   r^   r_   r,   rj   r   r   r   r   rx   rÝ  rà  ra   r[   rZ   rW   rÚ  rÚ  #  s)   ‡ Ø?K¸oÐ˜ ¨$¨y©/Ñ!:Ñ;ÓMòNõIrZ   rÚ  c                   ó   • \ rS rSrSrSrg)ÚUNIXPortTestsBuilderi3  z&
Tests for L{IReactorUNIX.listenUnix}
r[   N©r\   r]   r^   r_   r`   ra   r[   rZ   rW   rã  rã  3  ó   † ôrZ   rã  c                   ó   • \ rS rSrSrSrg)ÚUNIXFDPortTestsBuilderi>  z+
Tests for L{IReactorUNIX.adoptStreamPort}
r[   Nrä  r[   rZ   rW   rç  rç  >  rå  rZ   rç  c                   ó0   • \ rS rSr\\\4rS rS r	S r
Srg)Ú%UNIXAdoptStreamConnectionTestsBuilderiI  c                 ó‚  • U R                  5       nSSKJn   " S S[        5      nU" [        [
        5      u  pEUR                  S5        U R                  UR                  5        U R                  UR                  5        UR                  5       nU" 5       nUR                  " U[        U5      nU R                  U5        g)zh
{IReactorSocket.adoptStreamConnection} returns None if the given
factory's buildProtocol returns None.
r   r!  c                   ó   • \ rS rSrS rSrg)ÚXUNIXAdoptStreamConnectionTestsBuilder.test_buildProtocolReturnsNone.<locals>.NoneFactoryi^  c                 ó   • g rŠ   r[   )rR   rÏ  s     rW   ÚbuildProtocolÚfUNIXAdoptStreamConnectionTestsBuilder.test_buildProtocolReturnsNone.<locals>.NoneFactory.buildProtocol_  s   € ØrZ   r[   N)r\   r]   r^   r_   rî  ra   r[   rZ   rW   ÚNoneFactoryrì  ^  s   † õrZ   rð  FN)rM   r   r"  r/   r   r   r–  rM  r   rØ   ÚadoptStreamConnectionÚassertIsNone)	rR   r   r"  rð  Ús1Ús2Ús1FDrU   r  s	            rW   Útest_buildProtocolReturnsNoneÚCUNIXAdoptStreamConnectionTestsBuilder.test_buildProtocolReturnsNoneP  s‘   € ð ×#Ñ#Ó%ˆå%ô	œ-ô 	ñ œG¤[Ó1‰ˆØ
�‰�uÔØ�‰˜Ÿ™Ô!Ø�‰˜Ÿ™Ô!à�y‰y‹{ˆÙ“-ˆØ×.Ò.¨t´W¸gÓFˆØ×Ñ˜&Õ!rZ   c                 ó˜   ^ • U 4S jnT R                  5       nT R                  USSS9nUR                  U5        T R                  U5        g)z.
Helper method to test UNIX server addresses.
c                 ó2  >• U u  pn [        SUR                  5       R                  5      nTR                  SUR                  R
                  < SU< S3[        UR                  5      5        TR                  SUR                  R
                  < SU< 3UR                  R                  5        UR                  R                  S   nTR                  U[        5        UR                  R                  5         g ! UR                  R                  5         f = f)NrG   z<AccumulatingProtocol #z on Ú>zAccumulatingProtocol,Ú,r   )r>   r­   rt   rP   r‚   Ú	sessionnoÚstrÚlogstrrU   ÚpeerAddressesr  r    r…   )Ú	protocolsrv   rq   r¯   ÚportPathr‘  rR   s         €rW   Ú	connectedÚOUNIXAdoptStreamConnectionTestsBuilder.test_ServerAddressUNIX.<locals>.connectedq  sÞ   ø€ Ø#,Ñ ˆF˜Dð2Ü6°r¸4¿<¹<»>×;NÑ;NÓO�Ø× Ò à×'Ñ'×1Ô1³8ð=ä˜×(Ñ(Ó)ôð × Ò à×'Ñ'×1Ô1²8ð=à×$Ñ$×+Ñ+ôð %Ÿn™n×:Ñ:¸1Ñ=�Ø×%Ñ% k´;Ô?ð × Ñ ×/Ñ/Õ1ø�× Ñ ×/Ñ/Õ1ús   ˆCC: Ã:DN)Ú	interfaceÚaddressFamily)rM   ÚgetConnectedClientAndServerrå   Ú
runReactor)rR   r  r   rè   s   `   rW   Útest_ServerAddressUNIXÚ<UNIXAdoptStreamConnectionTestsBuilder.test_ServerAddressUNIXl  sN   ø€ õ
	2ð, ×#Ñ#Ó%ˆØ×,Ñ,Ø˜t°4ð -ð 
ˆð 	
�‰�iÔ Ø�‰˜Õ rZ   c                 óÊ  ^^^^• [        5       n[        5       Ul        [        5       m[        5       Tl        [        5       Tl        [	        5       n[        5       Ul        [        5       Ul        [        SSS9nTR                  " Xd5      mUU4S jnUR                  R                  U5        [        UR                  TR                  /5      nU4S jn	UR                  U	5        [        5       mTR                  U	5        [        UR                  TR                  /5      n
UU4S jnU
R                  U5        TR                  " TR                  5       R                  U5        T$ )a  
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.
rl   rm   rn   c                 óÖ   >• TR                   " U R                  5        TR                  " U R                  5        TR                  " U R                  R	                  5       [
        T5        g rŠ   )ÚremoveReaderr‚   ÚremoveWriterrñ  rØ   r   )r;  r   rq   s    €€rW   ÚfirstServerConnectedÚ_UNIXAdoptStreamConnectionTestsBuilder.getConnectedClientAndServer.<locals>.firstServerConnected¤  sF   ø€ Ø× Ò  §¡Ô1Ø× Ò  §¡Ô1Ø×)Ò)¨%¯/©/×*@Ñ*@Ó*BÄGÈVÕTrZ   c                 óL   >• TR                   (       a  TR                  " 5         U $ rŠ   )Úrunningr  )r  r   s    €rW   r  ÚOUNIXAdoptStreamConnectionTestsBuilder.getConnectedClientAndServer.<locals>.stop¯  s   ø€ Ø��Ø—’”ØˆMrZ   c                 ó4   >• U u  pTR                  XT45        g rŠ   )r—   )r   rv   rq   Údeferredr¯   s      €€rW   rý   ÚPUNIXAdoptStreamConnectionTestsBuilder.getConnectedClientAndServer.<locals>.start½  s   ø€ Ø&‰NˆFØ×Ñ˜v¨tÐ4Õ5rZ   )r9   r!   ÚprotocolConnectionMadeÚprotocolConnectionLostr8   r   r§   rå   r#   rç   ræ   r¾   r­   rt   )rR   r   r  r  ÚfirstServerrv   rT   r  ÚlostDeferredr  ÚstartDeferredrý   r  r¯   rq   s    `          @@@rW   r  ÚAUNIXAdoptStreamConnectionTestsBuilder.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ØˆrZ   r[   N)r\   r]   r^   r_   r*   r+   r,   rj   rö  r  r  ra   r[   rZ   rW   ré  ré  I  s#   † àØØðÐò"ò8 !õD6rZ   ré  c                   ó>   • \ rS rSrSr\4rSr\S 5       r	S r
S rSrg)ÚUnixClientTestsBuilderiÎ  z/
Define tests for L{IReactorUNIX.connectUNIX}.
Nc                 óT   • U R                   c  [        U 5      U l         U R                   $ )zs
Return a path usable by C{connectUNIX} and C{listenUNIX}.

@return: A path instance, built with C{_abstractPath}.
)Ú_pathrf   r†   s    rW   rT   ÚUnixClientTestsBuilder.path×  s$   € ð �:‰:ÑÜ& tÓ,ˆDŒJØ�z‰zÐrZ   c                 ó<   • UR                   " U R                  U5      $ )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§   rT   ©rR   r   rU   s      rW   rÅ  ÚUnixClientTestsBuilder.listenâ  s   € ð ×!Ò! $§)¡)¨WÓ5Ð5rZ   c                 ó<   • UR                   " U R                  U5      $ )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¾   rT   r"  s      rW   ÚconnectÚUnixClientTestsBuilder.connectî  s   € ð ×"Ò" 4§9¡9¨gÓ6Ð6rZ   )r  )r\   r]   r^   r_   r`   r,   rj   r  ÚpropertyrT   rÅ  r%  ra   r[   rZ   rW   r  r  Î  s2   † ñð '˜Ðà€Eàñó ðò
6õ
7rZ   r  Úposixz%UNIX sockets only supported on POSIX.c                   óT   • \ rS rSrSrSrS rS\\\/S4   SS4S jr	S	 r
S
 rS rSrg)ÚRealSocketTestsiþ  z$
Test real UNIX socket connections.
Úunixpathc              ƒ   ó´  #   • [         R                  R                  [        5      (       d   e[	        5       n[        R
                  " U R                  U5      n[        U[        R                  5      (       d   eX!l
        U R                  UR                  5        [        5       n[        R                  " U R                  U5        UR                  I Sh  v•N   UR                   (       d   eU R#                  UR                   R$                  5        U R#                  UR&                  5        UR(                  R+                  [,        R.                  5        g N�7f)zd
A port created with L{IReactorTCP.listenUNIX} can be connected to with
L{IReactorTCP.connectUNIX}.
N)r   r,   Ú
providedByr   r7   r§   rT   Ú
isinstancer   ÚPortr¯   rM  ÚcleanUpr8   r¾   r  ÚlastProtocolr  ÚmadeÚdisconnectedÚ
lostReasonr  r   ÚConnectionDone)rR   Úfr¯   ÚclientFs       rW   Útest_closePortInProtocolFactoryÚ/RealSocketTests.test_closePortInProtocolFactory  sñ   é € ô
 ×&Ñ&×1Ñ1´'×:Ñ:Ð:Ð:äÓˆÜ×!Ò! $§)¡)¨QÓ/ˆÜ˜$¤§¡×)Ñ)Ð)Ð)ØŒØ�‰˜Ÿ	™	Ô"Ü!Ó#ˆÜ×Ò˜DŸI™I wÔ/à×Ñ×Ðà×#×#Ð#Ð#Ø�‰˜×,Ñ,×1Ñ1Ô2Ø�‰˜×)Ñ)Ô*Ø×Ñ×Ñ¤× 4Ñ 4Õ5ñ 	ùs   ‚CEÃEÃBEr—   NÚreturnc              ƒ   óv  #   • [         R                  R                  [        5      (       d   e[	        5       n[        5       nX2l        [        R                  " U R                  U5      nU R                  UR                  5        [        5       n[        5       nXel        [        R                  " U R                  U5        [        X6/5      I Sh  v•N u  pxU" Xx5        UR                  (       d   eUR                  (       d   eUR                  R                  5         UR                  R                  5         g Ni7f)zq
Invoke the given callback with a client protocol and a server protocol
which have been connected to each other.
N)r   r,   r-  r   r9   r!   r  r§   rT   rM  rO   r8   r¾   r#   r‚   r…   )	rR   r—   ÚserverFactoryÚserverConnMader¯   r7  ÚclientConnMadeÚserverProtocolÚclientProtocols	            rW   Ú_connectedClientAndServerTestÚ-RealSocketTests._connectedClientAndServerTest  só   é € ô ×&Ñ&×1Ñ1´'×:Ñ:Ð:Ð:ä'Ó)ˆÜ9A»ˆØ/=Ô,Ü×!Ò! $§)¡)¨]Ó;ˆØ�‰˜×*Ñ*Ô+ä!Ó#ˆÜ(0«
ˆØ)7Ô&Ü×Ò˜DŸI™I wÔ/ä/<ØÐ,ó0
÷ *
Ñ&ˆñ 	�Ô0Ø×'×'Ð'Ð'Ø×'×'Ð'Ð'Ø× Ñ ×/Ñ/Ô1Ø× Ñ ×/Ñ/Õ1ñ*
ùs   ‚CD9ÃD7ÃA*D9c              ƒ   óp   ^ #   • S[         S[         SS4U 4S jjnT R                  U5      I Sh  v•N   g N7f)zÅ
The transport of a protocol connected with L{IReactorTCP.connectUNIX} or
L{IReactor.TCP.listenUNIX} can have L{ITCPTransport.getTcpNoDelay} or
L{ITCPTransport.setTcpNoDelay} called without error.
r?  r@  r:  Nc                 ó–  >• X4 HÁ  n[         R                  R                  UR                  5      (       d   eUR                  nTR	                  UR                  5       S5        UR                  S5        TR	                  UR                  5       S5        UR                  S5        TR	                  UR                  5       S5        MÃ     g )Nr   TF)r   ÚITCPTransportr-  r‚   rP   ÚgetTcpNoDelayÚsetTcpNoDelay©r?  r@  Úpr‚   rR   s       €rW   ÚcheckÚ.RealSocketTests.test_tcpNoDelay.<locals>.checkA  s£   ø€ ð %Ó5�Ü!×/Ñ/×:Ñ:¸1¿;¹;×GÑGÐGÐGØŸK™K�	Ø× Ñ  ×!8Ñ!8Ó!:¸AÔ>Ø×'Ñ'¨Ô-Ø× Ñ  ×!8Ñ!8Ó!:¸AÔ>Ø×'Ñ'¨Ô.Ø× Ñ  ×!8Ñ!8Ó!:¸AÖ>ò 6rZ   ©rE   rA  ©rR   rJ  s   ` rW   Útest_tcpNoDelayÚRealSocketTests.test_tcpNoDelay:  s9   øé € ð
	?Ü0ð
	?ÜBVð
	?à÷
	?ð ×0Ñ0°Ó7×7Ó7ùó   ƒ+6®4¯6c              ƒ   óp   ^ #   • S[         S[         SS4U 4S jjnT R                  U5      I Sh  v•N   g N7f)zî
The transport of a protocol connected with L{IReactorTCP.connectUNIX} or
L{IReactor.TCP.listenUNIX} can have its I{SO_KEEPALIVE} state inspected
and manipulated with L{ITCPTransport.getTcpKeepAlive} and
L{ITCPTransport.setTcpKeepAlive}.
r?  r@  r:  Nc                 ó–  >• X4 HÁ  n[         R                  R                  UR                  5      (       d   eUR                  nTR	                  UR                  5       S5        UR                  S5        TR	                  UR                  5       S5        UR                  S5        TR	                  UR                  5       S5        MÃ     g )NFT)r   rE  r-  r‚   rP   ÚgetTcpKeepAliveÚsetTcpKeepAliverH  s       €rW   rJ  Ú0RealSocketTests.test_tcpKeepAlive.<locals>.checkW  s£   ø€ ð %Ó5�Ü!×/Ñ/×:Ñ:¸1¿;¹;×GÑGÐGÐGØŸK™K�	Ø× Ñ  ×!:Ñ!:Ó!<¸eÔDØ×)Ñ)¨$Ô/Ø× Ñ  ×!:Ñ!:Ó!<¸dÔCØ×)Ñ)¨%Ô0Ø× Ñ  ×!:Ñ!:Ó!<¸eÖDò 6rZ   rL  rM  s   ` rW   Útest_tcpKeepAliveÚ!RealSocketTests.test_tcpKeepAliveO  s=   øé € ð
	EÜ0ð
	EÜBVð
	Eà÷
	Eð ×0Ñ0°Ó7×7Ó7ùrP  c              ƒ   ó  #   • [         R                  R                  [        5      (       d   e[	        5       n[        R
                  " SUSS9  UR                  I Sh  v•N   UR                  R                  [        R                  5        g N.7f)zR
Tests whether attempting to establish connection to non-existing UNIX path fails
znon-existingé   )ÚtimeoutN)r   r,   r-  r   r8   r¾   ÚfailDeferredrŒ   r  r   ÚConnectError)rR   r7  s     rW   Útest_FailingÚRealSocketTests.test_Failinge  sj   é € ô ×&Ñ&×1Ñ1´'×:Ñ:Ð:Ð:ä!Ó#ˆÜ×Ò˜N¨G¸QÒ?à×"Ñ"×"Ð"Ø�‰×ÑœE×.Ñ.Õ/ñ 	#ùs   ‚ABÁBÁ/Br[   )r\   r]   r^   r_   r`   rT   r8  r   rE   rA  rN  rV  r]  ra   r[   rZ   rW   r*  r*  þ  sH   † ñð €Dò6ð,2Ø Ð"6Ð8LÐ!MÈtÐ!SÑTð2à	ô2ò<8ò*8õ,
0rZ   r*  )vr`   Úhashlibr   Úosr   r   r   r   r   Úpprintr	   r   r
   r   r   r   Ústructr   Útempfiler   r   Útypingr   r   r   r   r   Úunittestr   r   Ú_AF_UNIXÚImportErrorÚzope.interfacer   r   Útwisted.internetr   r   r   r   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.taskr0   Ú&twisted.internet.test.connectionmixinsr1   r2   r3   r4   r5   Ú#twisted.internet.test.reactormixinsr6   Útwisted.internet.test.test_tcpr7   r8   r9   r:   r;   Útwisted.python.compatr<   Útwisted.python.failurer=   Útwisted.python.filepathr>   Útwisted.python.logr?   r@   rA   Útwisted.python.reflectrB   Útwisted.python.runtimerC   rD   Útwisted.test.test_tcprE   Útwisted.trial.unittestrF   r%  r¶  rI   rf   rh   rz   r�   r¤   r¹  rÂ  rÔ  rÚ  rã  rç  ré  ÚglobalsÚupdateÚmakeTestCaseClassesr  r*  r[   rZ   rW   Ú<module>r     s“  ðñõ
 ß 2Õ 2Ý ß ;Ó ;Ý Ý ß $ß :Õ :Ý ðÝ*ð €Gç 1ç BÕ BÝ 0ß @Ñ @ß M÷ñ ÷
ó ÷ UÑ TÝ -÷õ õ ?÷õ õ /Ý *Ý ?ß ?Ñ ?Ý 0ß 9Ý 6Ý +á
Ð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 ƒ	× Ñ Ð'×;Ñ;Ó=Ô >ñ ˆ˜ÑÐ!HÓIôp0�hó p0ó Jñp0øðU ó ØƒGðús   ÁJ2 Ê2J>Ê=J>