ó
ŠwÛjc           @   sú   d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z e e d ƒ ss e j	 d ƒ ‚ n  y e j
 ƒ  Wn: e k
 r½ Z e j e j k r· e j	 d ƒ ‚ n  ‚  n Xd e j f d „  ƒ  YZ d	 „  Z e d
 k rö e ƒ  n  d S(   s   
Tests for epoll wrapper.
iÿÿÿÿN(   t   test_supportt   epolls   test works only on Linux 2.6s   kernel doesn't support epoll()t	   TestEPollc           B   sb   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z RS(
   c         C   sB   t  j  ƒ  |  _ |  j j d ƒ |  j j d ƒ |  j g |  _ d  S(   Ns	   127.0.0.1i    i   (   s	   127.0.0.1i    (   t   sockett   serverSockett   bindt   listent   connections(   t   self(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_epoll.pyt   setUp+   s    c         C   s"   x |  j  D] } | j ƒ  q
 Wd  S(   N(   R   t   close(   R   t   skt(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_epoll.pyt   tearDown2   s    c         C   s±   t  j  ƒ  } | j t ƒ y$ | j d |  j j ƒ  d f ƒ Wn0 t  j k
 ro } |  j | j d t	 j
 ƒ n Xt d ƒ ‚ |  j j ƒ  \ } } |  j j | | f ƒ | | f S(   Ns	   127.0.0.1i   i    s&   Connect should have raised EINPROGRESS(   R   t   setblockingt   Falset   connectR   t   getsocknamet   errort   assertEqualt   argst   errnot   EINPROGRESSt   AssertionErrort   acceptR   t   extend(   R   t   clientt   et   servert   addr(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_epoll.pyt   _connected_pair6   s    $c         C   sŸ   y t  j d ƒ } Wn% t k
 r: } t t | ƒ ƒ ‚ n X|  j | j ƒ  d k | j ƒ  ƒ |  j | j ƒ | j ƒ  |  j | j ƒ |  j	 t
 | j ƒ d  S(   Ni   i    (   t   selectR   t   OSErrorR   t   strt
   assertTruet   filenot   closedR
   t   assertRaisest
   ValueError(   R   t   epR   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_epoll.pyt   test_createD   s    "
c         C   s‘   |  j  t t j d d d ƒ |  j  t t j d ƒ |  j  t t j d  ƒ |  j  t t j d ƒ |  j  t t j d g ƒ |  j  t t j i  ƒ d  S(   Ni   i   i   t   foo(    (   R$   t	   TypeErrorR   R   t   None(   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_epoll.pyt   test_badcreateO   s    c         C   s¹  |  j  ƒ  \ } } t j d ƒ } zD | j | j ƒ  t j t j Bƒ | j | j ƒ  t j t j Bƒ Wd  | j ƒ  Xt j d ƒ } z8 | j | t j t j Bƒ | j | t j t j Bƒ Wd  | j ƒ  Xt j d ƒ } zÐ |  j t	 | j t
 ƒ  t j t j Bƒ |  j t	 | j d  t j t j Bƒ |  j t | j d t j t j Bƒ |  j t | j d t j t j Bƒ | j | t j t j Bƒ |  j t | j | t j t j Bƒ Wd  | j ƒ  Xd  S(   Ni   iÿÿÿÿi'  (   R   R   R   t   registerR"   t   EPOLLINt   EPOLLOUTR
   R$   R)   t   objectR*   R%   t   IOError(   R   R   R   R&   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_epoll.pyt   test_addW   s2     $c         C   s+  |  j  ƒ  \ } } t j d ƒ } t j j | j ƒ  ƒ } | j | j ƒ  t j t j Bƒ | j | j ƒ  t j t j Bƒ | j d d ƒ } | j d d ƒ } |  j	 t
 | ƒ d ƒ |  j	 t
 | ƒ d ƒ | j ƒ  y | j d d ƒ Wn0 t k
 r} |  j	 | j d t j | ƒ n X|  j d ƒ d  S(   Ni   i   i   gÍÌÌÌÌÌì?i    s%   epoll on closed fd didn't raise EBADF(   R   R   R   t   fromfdR"   R,   R-   R.   t   pollR   t   lenR
   R0   R   R   t   EBADFt   fail(   R   R   R   R&   t   ep2t   eventst   events2R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_epoll.pyt   test_fromfd}   s      
!c         C   sz  |  j  ƒ  \ } } t j d ƒ } | j | j ƒ  t j t j Bt j Bƒ | j | j ƒ  t j t j Bt j Bƒ t j ƒ  } | j	 d d ƒ } t j ƒ  } |  j
 | | d k | | ƒ | j ƒ  | j ƒ  t j f | j ƒ  t j f g } | j ƒ  |  j | | ƒ | j	 d d d d ƒ } |  j
 | ƒ | j d ƒ | j d	 ƒ t j ƒ  } | j	 d d ƒ } t j ƒ  } |  j
 | | d
 k ƒ | j ƒ  | j ƒ  t j t j Bf | j ƒ  t j t j Bf g } | j ƒ  |  j | | ƒ | j | j ƒ  ƒ | j | j ƒ  t j ƒ t j ƒ  } | j	 d d ƒ } t j ƒ  } |  j
 | | d
 k ƒ | j ƒ  t j f g } |  j | | ƒ d  S(   Ni   i   i   gš™™™™™¹?t   timeoutgÍÌÌÌÌÌ @t	   maxeventss   Hello!s   world!!!g{®Gáz„?(   R   R   R   R,   R"   R-   R.   t   EPOLLETt   timeR3   t   assertFalset   sortR   t   sendt
   unregistert   modify(   R   R   R   R&   t   nowR8   t   thent   expected(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_epoll.pyt   test_control_and_wait“   sH    



c         C   s<   |  j  t t j d ƒ |  j  t t j ƒ  j d t j ƒ d  S(   Niþÿÿÿiÿÿÿÿ(   R$   R%   R   R   R,   R-   (   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_epoll.pyt   test_errorsÄ   s    c         C   s–   |  j  ƒ  \ } } | j ƒ  } t j d ƒ } | j | ƒ t j ƒ  } | j d d ƒ } t j ƒ  } |  j | | d k ƒ | j ƒ  | j	 | ƒ d  S(   Ni   i   i   g{®Gáz„?(
   R   R"   R   R   R,   R>   R3   R?   R
   RB   (   R   R   R   t   fdR&   RD   R8   RE   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_epoll.pyt   test_unregister_closedÉ   s    
(   t   __name__t
   __module__R	   R   R   R'   R+   R1   R:   RG   RH   RJ   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_epoll.pyR   )   s   						&		1	c           C   s   t  j t ƒ d  S(   N(   R    t   run_unittestR   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_epoll.pyt	   test_main×   s    t   __main__(   t   __doc__R   R   R>   R   t   unittestt   testR    t   hasattrt   SkipTestR   R0   R   t   ENOSYSt   TestCaseR   RN   RK   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_epoll.pyt   <module>   s$   ®	