ó
‹wÛjc           @   sv   d  d l  Z  d  d l m Z d  d l Z e j d ƒ Z d e  j f d „  ƒ  YZ d d „ Z	 e
 d k rr e	 ƒ  n  d S(   iÿÿÿÿN(   t   test_supportt   resourcet   ResourceTestc           B   s>   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s_   |  j  t t j ƒ |  j  t t j d d ƒ |  j  t t j ƒ |  j  t t j d d d ƒ d  S(   Ni*   (   t   assertRaisest	   TypeErrorR   t	   getrlimitt	   setrlimit(   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_resource.pyt	   test_args   s    c         C   sm   y t  j t  j ƒ \ } } Wn t k
 r< |  j d ƒ n X|  j t  j | ƒ t  j t  j | | f ƒ d  S(   Ns   RLIMIT_FSIZE not available(   R   R   t   RLIMIT_FSIZEt   AttributeErrort   skipTestt   assertEqualt   RLIM_INFINITYR   (   R   t   curt   max(    (    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_resource.pyt   test_fsize_ismax   s    c         C   sx  y t  j t  j ƒ \ } } Wn t k
 r< |  j d ƒ n Xzy# t  j t  j d | f ƒ t } Wn t k
 r| t } n Xt	 t
 j d ƒ } z  | j d d ƒ yI | j d ƒ | j ƒ  x+ t d ƒ D] } t j d ƒ | j ƒ  qÊ WWn t k
 r| s‚  qn X| r.t  j t  j | | f ƒ n  Wd  | j ƒ  XWd  | rct  j t  j | | f ƒ n  t
 j t
 j ƒ Xd  S(   Ns   RLIMIT_FSIZE not availablei   t   wbt   Xt   Yi   gš™™™™™¹?(   R   R   R	   R
   R   R   t   Truet
   ValueErrort   Falset   openR    t   TESTFNt   writet   flusht   ranget   timet   sleept   IOErrort   closet   unlink(   R   R   R   t	   limit_sett   ft   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_resource.pyt   test_fsize_enforced   s8    



 c         C   sµ   d } y t  j t  j ƒ \ } } Wn t k
 rB |  j d ƒ n Xy t  j t  j | | f ƒ Wn t t f k
 ry n Xy t  j t  j | | f ƒ Wn t t f k
 r° n Xd  S(   Nl   
 i2   s   RLIMIT_FSIZE not availablel          +ÛO¦ ±tC3’y+v° (   R   R   R	   R
   R   R   t   OverflowErrorR   (   R   t   too_bigR   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_resource.pyt   test_fsize_toobigL   s    c         C   s„   |  j  t t j ƒ |  j  t t j d d ƒ t j t j ƒ } t j t j ƒ } y t j t j ƒ } Wn t t f k
 r n Xd  S(   Ni*   (	   R   R   R   t	   getrusaget   RUSAGE_SELFt   RUSAGE_CHILDRENt   RUSAGE_BOTHR   R
   (   R   t	   usageselft   usagechildrent	   usageboth(    (    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_resource.pyt   test_getrusage\   s    c         C   sd   y t  j t  j ƒ } Wn t k
 r6 |  j d ƒ n Xd d d „  ƒ  Y} t  j t  j | ƒ  ƒ d  S(   Ns   RLIMIT_CPU not availablet   BadSequencec           B   s   e  Z d  „  Z 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_resource.pyt   __len__n   s    c         S   s,   | d k r" t  t t d ƒ ƒ ƒ St ‚ d  S(   Ni    i   i@B (   i    i   (   t   lent   tupleR   t
   IndexError(   R   t   key(    (    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_resource.pyt   __getitem__p   s    (   t   __name__t
   __module__R1   R6   (    (    (    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_resource.pyR0   m   s   	(    (   R   R   t
   RLIMIT_CPUR
   R   R   (   R   t   limitsR0   (    (    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_resource.pyt   test_setrusage_refcounth   s    (   R7   R8   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_resource.pyR   	   s   			.		c         C   s   t  j t ƒ d  S(   N(   R    t   run_unittestR   (   t   verbose(    (    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_resource.pyt	   test_mainw   s    t   __main__(   t   unittestt   testR    R   t   import_moduleR   t   TestCaseR   t   NoneR>   R7   (    (    (    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_resource.pyt   <module>   s   n