Ñò
à"Ic           @   sì   d  Z  d d k Z d d k Z d d k Z d d k Z d d k l Z l Z l Z l	 Z	 l
 Z
 l Z y( d d k Z e i e i e i ƒ Z Wn e e f j
 o n Xd Z d e i f d „  ƒ  YZ d „  Z e d j o e ƒ  n d S(	   s9   Test largefile support on system where this makes sense.
iÿÿÿÿN(   t   run_unittestt   TESTFNt   verboset   requirest   TestSkippedt   unlinkl    y* t   TestCasec           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s@  Test that each file function works as expected for a large
    (i.e. > 2GB, do  we have to check > 4GB) files.

    NOTE: the order of execution of the test methods is important! test_seek
    must run first to create the test file. File cleanup must also be handled
    outside the test instances because of this.

    c         C   s¸   t  o	 d GHn t t d ƒ i i ƒ  } z… | ~ } | i d ƒ | i d ƒ | i t ƒ | i d ƒ | i ƒ  t  o	 d GHn |  i	 t
 i | i ƒ  ƒ t i t d ƒ Wd  QXd  S(   Ns3   create large file via seek (may be sparse file) ...t   wbt   zi    t   as   check file size with os.fstati   (   R   t   openR   t   __exit__t	   __enter__t   writet   seekt   sizet   flusht   assertEqualt   ost   fstatt   filenot   statt   ST_SIZE(   t   selft   _[1]t   f(    (    s0   /mit/python/lib/python2.6/test/test_largefile.pyt	   test_seek"   s    	&
	c         C   s8   t  o	 d GHn |  i t i t ƒ t i t d ƒ d  S(   Ns   check file size with os.stati   (   R   R   R   R   R   R   R   (   R   (    (    s0   /mit/python/lib/python2.6/test/test_largefile.pyt   test_osstat/   s    	c         C   sj  t  o	 d GHn t t d ƒ i i ƒ  } z7| ~ } |  i | i ƒ  d ƒ |  i | i d ƒ d ƒ |  i | i ƒ  d ƒ | i d ƒ |  i | i ƒ  d ƒ | i d d ƒ |  i | i ƒ  d ƒ | i d ƒ |  i | i ƒ  d ƒ | i d d ƒ |  i | i ƒ  d ƒ | i d d ƒ |  i | i ƒ  d ƒ | i d d ƒ |  i | i ƒ  d ƒ | i d d ƒ |  i | i ƒ  t	 d d ƒ | i d	 d ƒ |  i | i ƒ  t	 d d
 ƒ | i t	 d d ƒ |  i | i ƒ  d ƒ | i t	 ƒ |  i | i ƒ  t	 ƒ |  i | i d ƒ d ƒ | i t	 d d ƒ |  i | i d ƒ d ƒ |  i | i ƒ  d ƒ Wd  QXd  S(   Ns;   play around with seek() and read() with the built largefilet   rbi    i   R   i*   iT   i   iöÿÿÿi
   R	   (
   R   R
   R   R   R   R   t   tellt   readR   R   (   R   R   R   (    (    s0   /mit/python/lib/python2.6/test/test_largefile.pyt   test_seek_read4   s<    	&c      	   C   s–  t  o	 d GHn t t d ƒ i i ƒ  } zc| ~ } |  i t i | i ƒ  d d ƒ d ƒ |  i t i | i ƒ  d d ƒ d ƒ |  i t i | i ƒ  d d ƒ d ƒ |  i t i | i ƒ  d d ƒ d ƒ |  i t i | i ƒ  d d ƒ t	 d d ƒ |  i t i | i ƒ  d d ƒ t	 d d	 ƒ |  i t i | i ƒ  t	 d d ƒ d ƒ |  i t i | i ƒ  t	 d ƒ t	 ƒ |  i | i
 d ƒ d
 ƒ Wd  QXd  S(   Ns4   play around with os.lseek() with the built largefileR   i    i*   i   iT   i   iöÿÿÿi
   R	   (   R   R
   R   R   R   R   R   t   lseekR   R   R   (   R   R   R   (    (    s0   /mit/python/lib/python2.6/test/test_largefile.pyt
   test_lseekU   s    	&%%%%--*%c         C   s  t  o	 d GHn t t d ƒ i i ƒ  } z]| ~ } t | d ƒ p t d ‚ n | i d d ƒ |  i | i	 ƒ  t
 d ƒ t
 d } | i | ƒ | i ƒ  |  i | i	 ƒ  | ƒ | i d d ƒ |  i | i	 ƒ  | ƒ | d 8} | i d	 ƒ | i | ƒ |  i | i	 ƒ  d	 ƒ | i d d ƒ |  i | i	 ƒ  | ƒ | i d ƒ | i d ƒ |  i | i	 ƒ  d ƒ |  i t | i ƒ  ƒ d ƒ Wd  QXd  S(
   Ns   try truncates   r+bt   truncates.   open().truncate() not available on this systemi    i   i   i
   i*   (   R   R
   R   R   R   t   hasattrR   R   R   R   R   R"   t   lenR   (   R   R   R   t   newsize(    (    s0   /mit/python/lib/python2.6/test/test_largefile.pyt   test_truncated   s.    	&


(   t   __name__t
   __module__t   __doc__R   R   R   R!   R&   (    (    (    s0   /mit/python/lib/python2.6/test/test_largefile.pyR      s   			!	c          C   sŽ  t  i d  d j p t  i d j o t d d t t ƒ ƒ n{ t t d ƒ }  y( |  i d ƒ |  i d ƒ |  i	 ƒ  Wn6 t
 t f j
 o$ |  i ƒ  t t ƒ t d	 ‚ n X|  i ƒ  t i ƒ  } | i t d
 ƒ ƒ | i t d ƒ ƒ | i t d ƒ ƒ | i t d ƒ ƒ t t d ƒ i i ƒ  } z4 | ~ }  t |  d ƒ o | i t d ƒ ƒ n Wd  QXt t ƒ z t | ƒ Wd  t t ƒ Xd  S(   Ni   t   wint   darwint	   largefiles-   test requires %s bytes and a long time to runR   l       t   xs*   filesystem does not have largefile supportR   R   R   R!   t   wR"   R&   (   t   syst   platformR   t   strR   R
   R   R   R   R   t   IOErrort   OverflowErrort   closeR   R   t   unittestt	   TestSuitet   addTestR   R   R   R#   R    (   R   t   suiteR   (    (    s0   /mit/python/lib/python2.6/test/test_largefile.pyt	   test_main‡   s2    $


&
t   __main__(   R)   R   R   R/   R5   t   test.test_supportR    R   R   R   R   R   t   signalt   SIGXFSZt   SIG_IGNt
   oldhandlert   ImportErrort   AttributeErrorR   R   R9   R'   (    (    (    s0   /mit/python/lib/python2.6/test/test_largefile.pyt   <module>   s   .o	)