ó
‹wÛjc           @   sÑ   d  Z  d d l Z d d l Z d d l Z d d l Z d d l m Z m Z m Z m	 Z	 m
 Z
 m Z e
 d ƒ Z d „  Z e ƒ  Z d d d „  ƒ  YZ d e j f d	 „  ƒ  YZ d
 „  Z e d k rÍ e ƒ  n  d S(   s]   Test program for the fcntl C module.

OS/2+EMX doesn't support the file locking operations.

iÿÿÿÿN(   t   verboset   TESTFNt   unlinkt   run_unittestt   import_modulet   cpython_onlyt   fcntlc       	   C   si  t  j j d ƒ r d }  n+ y t j Wn t k
 r? d }  n Xd }  t  j j d ƒ sg t  j d k rÇ t j d	 ƒ d
 k r‹ d	 } d } n d } d	 } t j | | | d d d d t	 j
 d ƒ } n} t  j d k r t j d t	 j
 d d d d d d ƒ } nD t  j d k rd  } n, t j d |  d t	 j
 d d d d d ƒ } | ret red Gt | ƒ GHqen  | S(   Nt   atheost   qqt   llt   netbsdt   freebsdt   openbsdt   bsdost   darwint   li   t   it   lxxxxt   hhi    t   aix3t   aix4s   hp-uxBt	   unixware7t   hhllliit   os2emxs   struct.pack: (   R
   R   R   R   (   R   R   s   hp-uxBR   (   R   (   t   syst   platformt
   startswitht   ost   O_LARGEFILEt   AttributeErrort   structt   calcsizet   packR   t   F_WRLCKt   NoneR    t   repr(   t	   start_lent   off_tt   pid_tt   lockdata(    (    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_fcntl.pyt   get_lockdata   s2    	
	*	,t   BadFilec           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   | |  _  d  S(   N(   t   fn(   t   selfR*   (    (    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_fcntl.pyt   __init__7   s    c         C   s   |  j  S(   N(   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_fcntl.pyt   fileno9   s    (   t   __name__t
   __module__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_fcntl.pyR)   6   s   	t	   TestFcntlc           B   sM   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z e d „  ƒ Z d „  Z	 RS(   c         C   s   d  |  _ d  S(   N(   R"   t   f(   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_fcntl.pyt   setUp>   s    c         C   s4   |  j  r& |  j  j r& |  j  j ƒ  n  t t ƒ d  S(   N(   R1   t   closedt   closeR   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_fcntl.pyt   tearDownA   s    c         C   s¤   t  t d ƒ |  _ t j |  j j ƒ  t j t j ƒ } t rH d G| GHn  t	 j
 d k r“ t j |  j j ƒ  t j t ƒ } t r“ d Gt | ƒ GHq“ n  |  j j ƒ  d  S(   Nt   ws#   Status from fcntl with O_NONBLOCK: R   s!   String from fcntl with F_SETLKW: (   R   (   t   openR   R1   R   R-   t   F_SETFLR   t
   O_NONBLOCKR    R   R   t   F_SETLKWR'   R#   R4   (   R+   t   rv(    (    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_fcntl.pyt   test_fcntl_filenoF   s    $!c         C   sn   t  t d ƒ |  _ t j |  j t j t j ƒ } t j d k r] t j |  j t j	 t
 ƒ } n  |  j j ƒ  d  S(   NR6   R   (   R   (   R7   R   R1   R   R8   R   R9   R   R   R:   R'   R4   (   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_fcntl.pyt   test_fcntl_file_descriptorR   s
    c         C   sÌ   |  j  t ƒ � t j d t j t j ƒ Wd  QX|  j  t ƒ �$ t j t d ƒ t j t j ƒ Wd  QX|  j  t ƒ � t j d t j t j ƒ Wd  QX|  j  t ƒ �$ t j t d ƒ t j t j ƒ Wd  QXd  S(   Niÿÿÿÿt   spam(   t   assertRaisest
   ValueErrorR   R8   R   R9   R)   t	   TypeError(   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_fcntl.pyt   test_fcntl_bad_fileZ   s    %c         C   sò   d d l  m } m } |  j t ƒ �" t j | d t j t j ƒ Wd  QX|  j t ƒ �( t j t	 | d ƒ t j t j ƒ Wd  QX|  j t ƒ �" t j | d t j t j ƒ Wd  QX|  j t ƒ �( t j t	 | d ƒ t j t j ƒ Wd  QXd  S(   Niÿÿÿÿ(   t   INT_MAXt   INT_MINi   (
   t	   _testcapiRC   RD   R?   R@   R   R8   R   R9   R)   (   R+   RC   RD   (    (    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_fcntl.pyt   test_fcntl_bad_file_overflowd   s    #)#c         C   s¨   y t  j } t  j } Wn t k
 r6 |  j d ƒ n Xt j t j j t j j	 t
 ƒ ƒ t j ƒ } z/ y t  j  | | | ƒ Wn t k
 r‘ n XWd  t j | ƒ Xd  S(   Ns$   F_NOTIFY or DN_MULTISHOT unavailable(   R   t   F_NOTIFYt   DN_MULTISHOTR   t   skipTestR   R7   t   patht   dirnamet   abspathR   t   O_RDONLYt   IOErrorR4   (   R+   t   cmdt   flagst   fd(    (    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_fcntl.pyt   test_fcntl_64_bitq   s    	- (
   R.   R/   R2   R5   R<   R=   RB   R   RF   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_fcntl.pyR0   <   s   					
c           C   s   t  t ƒ d  S(   N(   R   R0   (    (    (    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_fcntl.pyt	   test_main„   s    t   __main__(    (   t   __doc__R   R   R   t   unittestt   test.test_supportR    R   R   R   R   R   R   R(   R'   R)   t   TestCaseR0   RS   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_fcntl.pyt   <module>   s   .	 	H	