Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/internet/test/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/internet/test/test_iocp.pyc


Nc@s{dZddlZddlmZddlmZddlmZmZmZm	Z	m
Z
mZddlmZddl
mZddlmZy\dd	lmZmZmZdd
lmZmZmZddlmZddlmZWnek
rd
ZnXyeeej Wne
k
r>Z!e"e!Z#nXdZ#dej%fdYZ&dej%fdYZ'dS(s,
Tests for L{twisted.internet.iocpreactor}.
iN(tarray(tpack(tAF_INET6tAF_INETtSOCK_STREAMt
SOL_SOCKETterrortsocket(tverifyClass(tunittest(tmsg(tiocpsupportttcptudp(tIOCPReactortEVENTS_PER_LOOPt
KEY_NORMAL(tIReadWriteHandle(tSO_UPDATE_ACCEPT_CONTEXTs%This test only applies to IOCPReactortSupportTestscBsAeZdZdZdZdZedk	r?ee_nRS(sn
    Tests for L{twisted.internet.iocpreactor.iocpsupport}, low-level reactor
    implementation helpers.
    c	Cstd|ft|t}|j|j|jd|jdt|t}|j|j|jty!|j	||j
dfWn5tk
r\}}|j|t
jt
jfnXt|t}|j|jtddd}|jdtj|j|j|d
|jtttd|j|j||jd	 |j
d	 ftj|j|d
S(s
        Create a C{SOCK_STREAM} connection to localhost using a socket with an
        address family of C{family} and assert that the result of
        L{iocpsupport.get_accept_addrs} is consistent with the result of
        C{socket.getsockname} and C{socket.getpeername}.
        sfamily = %rtiitctitPiN(Ri(R
RRt
addCleanuptclosetbindtlistentsetblockingtFalsetconnecttgetsocknameRtassertInterrnotEINPROGRESStEWOULDBLOCKRtassertEqualt_iocptaccepttfilenotNonet
setsockoptRRRtgetpeernametget_accept_addrs(	tselftfamilyt	localhosttporttclientterrnumtmessagetservertbuff((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_iocp.pyt_acceptAddressTest&s,


! ( cCs|jtddS(s
        L{iocpsupport.get_accept_addrs} returns a three-tuple of address
        information about the socket associated with the file descriptor passed
        to it.  For a connection using IPv4:

          - the first element is C{AF_INET}
          - the second element is a two-tuple of a dotted decimal notation IPv4
            address and a port number giving the peer address of the connection
          - the third element is the same type giving the host address of the
            connection
        s	127.0.0.1N(R5R(R,((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_iocp.pyttest_ipv4AcceptAddressFscCs|jtddS(s
        Like L{test_ipv4AcceptAddress}, but for IPv6 connections.  In this case:

          - the first element is C{AF_INET6}
          - the second element is a two-tuple of a hexadecimal IPv6 address
            literal and a port number giving the peer address of the connection
          - the third element is the same type giving the host address of the
            connection
        s::1N(R5R(R,((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_iocp.pyttest_ipv6AcceptAddressUs
N(	t__name__t
__module__t__doc__R5R6R7tipv6SkipR(tskip(((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_iocp.pyR!s	 		tIOCPReactorTestCasecBs#eZdZdZdZRS(cCs-t}|j|j|jddS(sd
        Test reactor behavior (doIteration) when there are no pending time
        events.
        N(RtwakeUptfailIftdoIterationR((R,tir((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_iocp.pyttest_noPendingTimerEventsfs	
cCs$tttjtttjdS(sY
        Verify that IOCP socket-representing classes implement IReadWriteHandle
        N(RRRt
ConnectionR
tPort(R,((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_iocp.pyttest_reactorInterfacespscCsdddY}t}|}tj|j|}x.ttdD]}|jjdt|qKW|j	d|j|jt|j	d|j|jtddS(s
        Verify that we don't lose an event when more than EVENTS_PER_LOOP
        events occur in the same reactor iteration
        tFakeFDcBs eZdZdZdZRS(icSsdS(NRF((R,((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_iocp.pyt	logPrefixscSs|jd7_dS(Ni(tcounter(R,trctbytestevt((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_iocp.pytcbs(R8R9RHRGRL(((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_iocp.pyRF}s	iiN((
RR%tEventRLtrangeRR/t	postEventRR@R(R$RH(R,RFRAtfdteventt_((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_iocp.pyttest_maxEventsPerIterationxs		

(R8R9RBRERS(((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_iocp.pyR=es	
	((R:R!RtstructRRRRRRRtzope.interface.verifyRt
twisted.trialR	ttwisted.python.logR
ttwisted.internet.iocpreactorRR%RR
t$twisted.internet.iocpreactor.reactorRRRt'twisted.internet.iocpreactor.interfacesRt"twisted.internet.iocpreactor.constRtImportErrorR<RtetstrR;R(tTestCaseRR=(((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_iocp.pyt<module>s*.

D