ó
‹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 Z d d l m Z e	 e d ƒ s e j
 d ƒ ‚ n  d e j f d „  ƒ  YZ d „  Z e d	 k r· e ƒ  n  d S(
   s   
Tests for kqueue wrapper.
iÿÿÿÿN(   t   test_supportt   kqueues   test works only on BSDt
   TestKQueuec           B   s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   sp   t  j ƒ  } |  j | j ƒ  d k | j ƒ  ƒ |  j | j ƒ | j ƒ  |  j | j ƒ |  j t | j ƒ d  S(   Ni    (   t   selectR   t
   assertTruet   filenot   closedt   closet   assertRaisest
   ValueError(   t   selft   kq(    (    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_kqueue.pyt   test_create_queue   s    "
c         C   sç  t  j j ƒ  } t j | ƒ } t j d ƒ } |  j | j | ƒ |  j | j t j ƒ |  j | j	 t j
 ƒ |  j | j d ƒ |  j | j d ƒ |  j | j d ƒ |  j | | ƒ |  j | | ƒ |  j t | | ƒ d ƒ |  j | | k  ƒ |  j | | k ƒ |  j t | d  ƒ d ƒ |  j t | d ƒ d ƒ |  j t | d ƒ d ƒ |  j t | d  ƒ t d  | ƒ ƒ |  j t | d ƒ t d | ƒ ƒ |  j t | d ƒ t d | ƒ ƒ t j | t j ƒ } |  j | j | ƒ |  j | j t j ƒ |  j | j	 t j
 ƒ |  j | j d ƒ |  j | j d ƒ |  j | j d ƒ |  j | | ƒ |  j | | ƒ t j | t j t j ƒ } |  j | j | ƒ |  j | j t j ƒ |  j | j	 t j ƒ |  j | j d ƒ |  j | j d ƒ |  j | j d ƒ |  j | | ƒ |  j | | ƒ t j d d d d d	 d
 ƒ } |  j | j d ƒ |  j | j d ƒ |  j | j	 d ƒ |  j | j d ƒ |  j | j d	 ƒ |  j | j d
 ƒ |  j | | ƒ |  j | | ƒ d } t j | d d d | d | ƒ } |  j | j | ƒ |  j | j d ƒ |  j | j	 d ƒ |  j | j d ƒ |  j | j | d ƒ |  j | j | ƒ |  j | | ƒ |  j | | ƒ d } t j d d | ƒ } |  j | j d ƒ |  j | j d ƒ |  j | j	 | ƒ |  j | j d ƒ |  j | j d ƒ |  j | j d ƒ |  j | | ƒ |  j | | ƒ d } t j d d d | ƒ } |  j | j d ƒ |  j | j d ƒ |  j | j	 d ƒ |  j | j | ƒ |  j | j d ƒ |  j | j d ƒ |  j | | ƒ |  j | | ƒ d  S(   Niè  i    iÿÿÿÿi   t   evi   i   i   i   i   iÿ  iÿÿ  Iÿÿÿÿ    (   t   syst   stderrR   R   t   keventt   assertEqualt   identt   filtert   KQ_FILTER_READt   flagst	   KQ_EV_ADDt   fflagst   datat   udatat   assertNotEqualt   cmpR   t   Nonet   KQ_FILTER_WRITEt   KQ_EV_ONESHOT(   R
   t   fdR   t   othert   bignum(    (    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_kqueue.pyt   test_create_event   sš    ###"c         C   s  t  j  ƒ  } | j d ƒ | j d ƒ t  j  ƒ  } | j t ƒ y! | j d | j ƒ  d f ƒ Wn0 t  j k
 r’ } |  j | j	 d t
 j ƒ n X| j ƒ  \ } } t j ƒ  } t j j | j ƒ  ƒ } t j | j ƒ  t j t j t j Bƒ } | j | g d ƒ t j | j ƒ  t j t j t j Bƒ } | j | g d ƒ t j | j ƒ  t j t j t j Bƒ } | j | g d ƒ t j | j ƒ  t j t j t j Bƒ } | j | g d ƒ | j d  d d ƒ }	 t d „  |	 Dƒ ƒ }	 |  j |	 t | j ƒ  t j f | j ƒ  t j f g ƒ ƒ | j d ƒ | j d ƒ xY t d ƒ D]> }
 | j d  d d ƒ }	 t |	 ƒ d k rrPn  t j d	 ƒ qAW|  j d
 ƒ t d „  |	 Dƒ ƒ }	 |  j |	 t | j ƒ  t j f | j ƒ  t j f | j ƒ  t j f | j ƒ  t j f g ƒ ƒ t j | j ƒ  t j t j ƒ } | j | g d ƒ t j | j ƒ  t j t j ƒ } | j | g d ƒ t j | j ƒ  t j t j ƒ } | j | g d d ƒ | j g  d d ƒ }	 t d „  |	 Dƒ ƒ }	 |  j |	 t | j ƒ  t j f g ƒ ƒ | j  ƒ  | j  ƒ  | j  ƒ  d  S(   Ns	   127.0.0.1i    i   i   c         s   s!   |  ] } | j  | j f Vq d  S(   N(   R   R   (   t   .0t   e(    (    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_kqueue.pys	   <genexpr>”   s    s   Hello!s   world!!!i
   g      ð?s'   timeout waiting for event notificationsc         s   s!   |  ] } | j  | j f Vq d  S(   N(   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_kqueue.pys	   <genexpr>¥   s    g®Gáz®ï?c         s   s!   |  ] } | j  | j f Vq d  S(   N(   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_kqueue.pys	   <genexpr>»   s    (   s	   127.0.0.1i    (!   t   sockett   bindt   listent   setblockingt   Falset   connectt   getsocknamet   errorR   t   argst   errnot   EINPROGRESSt   acceptR   R   t   fromfdR   R   R   R   t   KQ_EV_ENABLEt   controlR   R   t   sett   sendt   ranget   lent   timet   sleept   failt   KQ_EV_DELETER   (   R
   t   serverSockett   clientR$   t   servert   addrR   t   kq2R   t   eventst   i(    (    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_kqueue.pyt   test_queue_eventp   s„    !

c         C   sô   t  j ƒ  } t j ƒ  \ } } | j d ƒ t  j | t  j t  j t  j Bƒ } t  j | t  j t  j t  j Bƒ } | j	 | | g d d ƒ } |  j
 | ƒ |  j | d j t  j @ƒ |  j | j | d j ƒ d ƒ | j ƒ  | j ƒ  | j ƒ  d  S(   Nt   fooi   i    (   R   R   R%   t
   socketpairR5   R   R   R   R2   R3   R   t   assertFalseR   t   KQ_EV_ERRORR   t   recvR   R   (   R
   R   t   at   bt   event1t   event2t   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_kqueue.pyt   testPairÃ   s    "" 

c            sÍ   t  j ƒ  } t j ƒ  \ } } t  j | t  j t  j t  j Bƒ ‰  | j ˆ  g d ƒ | j ˆ  f d ƒ d d ‡  f d †  ƒ  Y} | j | ƒ  d ƒ | j t	 ˆ  g ƒ d ƒ | j
 ƒ  | j
 ƒ  | j
 ƒ  d  S(   Ni    t   BadListc              s    e  Z d  „  Z ‡  f d †  Z RS(   c         S   s   d S(   Ni    (    (   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_kqueue.pyt   __len__Þ   s    c         3   s    x t  d ƒ D] } ˆ  Vq Wd  S(   Nid   (   R6   (   R
   RB   (   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_kqueue.pyt   __iter__à   s    (   t   __name__t
   __module__RP   RQ   (    (   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_kqueue.pyRO   Ý   s   	(    (   R   R   R%   RE   R   R   R   R2   R3   t   iterR   (   R
   R   RI   RJ   RO   (    (   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_kqueue.pyt   test_issue30058Ó   s    "

(   RR   RS   R   R"   RC   RN   RU   (    (    (    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_kqueue.pyR      s
   		X	S	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_kqueue.pyt	   test_mainë   s    t   __main__(   t   __doc__R%   R.   R8   R   R   t   unittestt   testR    t   hasattrt   SkipTestt   TestCaseR   RW   RR   (    (    (    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_kqueue.pyt   <module>   s   Ü	