+
    Dfj                         R t ^ RIt^ RIt^ RIt ^ RIt^ RIHt ^ RI	H
t
 ^ RIHt  ! R R]P                  4      t ! R R	]P                  4      t ! R
 R]P                  4      tR#   ] d    Rt LXi ; i)z&
Tests for L{twisted.internet.fdesc}.
N)fdescznot supported on this platform)untilConcludes)unittestc                   0   a  ] tR t^t o RtR tR tRtV tR# )NonBlockingTestsz=
Tests for L{fdesc.setNonBlocking} and L{fdesc.setBlocking}.
c                   \         P                  ! 4       w  rV P                  \         P                  V4       V P                  \         P                  V4       V P	                  \
        P
                  ! V\
        P                  4      \         P                  ,          4       \        P                  ! V4       V P                  \
        P
                  ! V\
        P                  4      \         P                  ,          4       R# )zB
L{fdesc.setNonBlocking} sets a file description to non-blocking.
N)ospipe
addCleanupcloseassertFalsefcntlF_GETFL
O_NONBLOCKr   setNonBlocking
assertTrueselfrws   &  9/usr/lib/python3/dist-packages/twisted/test/test_fdesc.pytest_setNonBlocking$NonBlockingTests.test_setNonBlocking   s     wwy!$!$Q6FGQAu}}5EF    c                   \         P                  ! 4       w  rV P                  \         P                  V4       V P                  \         P                  V4       \        P
                  ! V4       \        P                  ! V4       V P                  \        P                  ! V\        P                  4      \         P                  ,          4       R# )z;
L{fdesc.setBlocking} sets a file description to blocking.
N)r   r	   r
   r   r   r   setBlockingr   r   r   r   r   s   &  r   test_setBlocking!NonBlockingTests.test_setBlocking'   sw     wwy!$!$Q!Q6FGr    N)	__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes____classdictcell____classdict__s   @r   r   r      s     	G	H 	Hr   r   c                   l   a  ] tR t^3t o RtR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tRtV tR# )ReadWriteTestsz4
Tests for L{fdesc.readFromFD}, L{fdesc.writeToFD}.
c                    \         P                  ! 4       w  V n        V n        \        P
                  ! V P                  4       \        P
                  ! V P                  4       R# )z7
Create a non-blocking pipe that can be used in tests.
N)r   r	   r   r   r   r   r   s   &r   setUpReadWriteTests.setUp8   s;     TVV$TVV$r   c                     \         P                  ! V P                  4        \         P                  ! V P                  4       R#   \         d     L0i ; i  \         d     R# i ; i)z
Close pipes.
N)r   r   r   OSErrorr   r+   s   &r   tearDownReadWriteTests.tearDown@   sS    	HHTVV	HHTVV  		  		s"    A  A AAA%$A%c                D    \         P                  ! V P                  V4      # )z
Write data to the pipe.
)r   	writeToFDr   )r   ds   &&r   writeReadWriteTests.writeM   s     tvvq))r   c                    . p\         P                  ! V P                  VP                  4      pVf   V'       d
   V^ ,          # R# V# )z
Read data from the pipe.
r   )r   
readFromFDr   append)r   lress   &  r   readReadWriteTests.readS   s<     tvvqxx0;tJr   c                    V P                  R4      pV P                  V^ 8  4       V P                  4       pV P                  \	        V4      V4       V P                  RRV V4       R# )z|
Test that the number of bytes L{fdesc.writeToFD} reports as written
with its return value are seen by L{fdesc.readFromFD}.
s   helloN)r5   r   r<   assertEquallen)r   nss   &  r   test_writeAndRead ReadWriteTests.test_writeAndReada   sW    
 JJx AIIKQ#"1q)r   c                   RR,          pV P                  V4      pV P                  V^ 8  4       . p^ p^ pWB8  g   V^28  dD   VP                  V P                  4       4       V\	        VR,          4      ,          pV^,          pKP  RP                  V4      pV P                  \	        V4      V4       V P                  VRV V4       R# )ze
Similar to L{test_writeAndRead}, but use a much larger string to verify
the behavior for that case.
s
   0123456879i'  r   N)r5   r   r9   r<   r@   joinr?   )r   origwrittenresultresultlengthis   &     r   test_writeAndReadLarge%ReadWriteTests.test_writeAndReadLargel   s    
 u$**T"!$$BMM$))+&Cr
O+LFA&!Vg.hw0r   c                    . p\         P                  ! V P                  VP                  4      pV P	                  V. 4       V P                  V4       R# )z
Verify that reading from a file descriptor with no data does not raise
an exception and does not result in the callback function being called.
N)r   r8   r   r9   r?   assertIsNone)r   r:   rJ   s   &  r   test_readFromEmpty!ReadWriteTests.test_readFromEmpty   sA    
 !!$&&!((3B&!r   c                    \         P                  ! V P                  4       V P                  V P	                  4       \
        P                  4       R# )zn
Test that using L{fdesc.readFromFD} on a cleanly closed file descriptor
returns a connection done indicator.
N)r   r   r   r?   r<   r   CONNECTION_DONEr+   s   &r   test_readFromCleanClose&ReadWriteTests.test_readFromCleanClose   0    
 	e&;&;<r   c                    \         P                  ! V P                  4       V P                  V P	                  R4      \
        P                  4       R# )zq
Verify that writing with L{fdesc.writeToFD} when the read end is closed
results in a connection lost indicator.
   sN)r   r   r   r?   r5   r   CONNECTION_LOSTr+   s   &r   test_writeToClosed!ReadWriteTests.test_writeToClosed   3    
 	D)5+@+@Ar   c                    \         P                  ! V P                  4       V P                  V P	                  4       \
        P                  4       R# )zr
Verify that reading with L{fdesc.readFromFD} when the read end is
closed results in a connection lost indicator.
N)r   r   r   r?   r<   r   rZ   r+   s   &r   test_readFromInvalid#ReadWriteTests.test_readFromInvalid   rW   r   c                    \         P                  ! V P                  4       V P                  V P	                  R4      \
        P                  4       R# )zr
Verify that writing with L{fdesc.writeToFD} when the write end is
closed results in a connection lost indicator.
rY   N)r   r   r   r?   r5   r   rZ   r+   s   &r   test_writeToInvalid"ReadWriteTests.test_writeToInvalid   r]   r   c                R   \         P                  pR pV\         n         V P                  V P                  R4      ^ 4       V\         n        R pV\         n         V P                  V P                  R4      ^ 4       V\         n        R#   T\         n        i ; i  T\         n        i ; i)z(
Test error path for L{fdesc.writeTod}.
c                 D    \        4       p\        P                  Vn        VhN)r/   errnoEAGAINfddataerrs   && r   eagainWrite4ReadWriteTests.test_writeErrors.<locals>.eagainWrite   s    )CCIIr   rY   c                 D    \        4       p\        P                  Vn        Vhrf   )r/   rg   EINTRri   s   && r   
eintrWrite3ReadWriteTests.test_writeErrors.<locals>.eintrWrite   s    )CCIIr   N)r   r5   r?   )r   
oldOsWriterm   rq   s   &   r   test_writeErrorsReadWriteTests.test_writeErrors   s     XX
	
 	"TZZ-q1!BH	
 	"TZZ-q1!BH "BH "BHs   !B	 !B 	BB&)r   r   N)r   r    r!   r"   r#   r,   r0   r5   r<   rC   rM   rQ   rU   r[   r_   rb   rt   r$   r%   r&   s   @r   r)   r)   3   sM     %*	*1("=B=B" "r   r)   c                   :   a  ] tR t^t o RtRtR tR tR tRt	V t
R# )CloseOnExecTestszD
Tests for L{fdesc._setCloseOnExec} and L{fdesc._unsetCloseOnExec}.
z
import os, errno
try:
    os.write(%d, b'lul')
except OSError as e:
    if e.errno == errno.EBADF:
        os._exit(0)
    os._exit(5)
except BaseException:
    os._exit(10)
else:
    os._exit(20)
c                   \         P                  ! 4       pV^ 8X  dZ    \         P                  ! \        P                  \        P                  RV P
                  VP                  4       3,          .4       R# \        \         P                  V^ 4      ^,          #   \         d/    ^ RIpTP                  4        \         P                  ! ^4        R# i ; i)    z-cN)r   forkexecvsys
executableprogramfilenoBaseException	traceback	print_exc_exitr   waitpid)r   fObjpidr   s   &&  r   _execWithFileDescriptor(CloseOnExecTests._execWithFileDescriptor   s    ggi!8	NN^^T4<<4;;=:J+JK ""**c15a88 !  ##%	s   AB 5CCc                   \        V P                  4       R4      ;_uu_ 4       p\        P                  ! VP	                  4       4       V P                  V4      pV P                  \        P                  ! V4      4       V P                  \        P                  ! V4      ^ 4       RRR4       R#   + '       g   i     R# ; i)z
A file descriptor passed to L{fdesc._setCloseOnExec} is not inherited
by a new process image created with one of the exec family of
functions.
wbN)openmktempr   _setCloseOnExecr   r   r   r   	WIFEXITEDr?   WEXITSTATUSr   r   statuss   &  r   test_setCloseOnExec$CloseOnExecTests.test_setCloseOnExec   sz     $++-&&$!!$++-011$7FOOBLL01R^^F3Q7	 '&&&s   BB..B?	c                   \        V P                  4       R4      ;_uu_ 4       p\        P                  ! VP	                  4       4       \        P
                  ! VP	                  4       4       V P                  V4      pV P                  \        P                  ! V4      4       V P                  \        P                  ! V4      ^4       RRR4       R#   + '       g   i     R# ; i)z
A file descriptor passed to L{fdesc._unsetCloseOnExec} is inherited by
a new process image created with one of the exec family of functions.
r   N)r   r   r   r   r   _unsetCloseOnExecr   r   r   r   r?   r   r   s   &  r   test_unsetCloseOnExec&CloseOnExecTests.test_unsetCloseOnExec   s    
 $++-&&$!!$++-0##DKKM211$7FOOBLL01R^^F3R8 '&&&s   B%CC#	r   N)r   r    r!   r"   r#   r~   r   r   r   r$   r%   r&   s   @r   rw   rw      s%     G9$
8
9 
9r   rw   )r#   rg   r   r|   r   twisted.internetr   ImportErrorskiptwisted.python.utilr   twisted.trialr   SynchronousTestCaser   r)   rw   r   r   r   <module>r      sz     	 
' ' . "Hx33 H8Q"X11 Q"h;9x33 ;9s  ,+D,s   A' '	A32A3