ó
­«Y]c           @  s
  d  Z  d d l m 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 d d l Z d d l Z y( d d l Z e j e j e j ƒ Z Wn e e f k
 rÇ n Xd Z d e j f d „  ƒ  YZ d „  Z e d	 k re ƒ  n  d S(
   s9   Test largefile support on system where this makes sense.
iÿÿÿÿ(   t   print_functionN(   t   run_unittestt   TESTFNt   verboset   requirest   unlinkI ù•    t   LargeFileTestc           B  sD   e  Z d  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  r t d ƒ n  |  j t d ƒ ‚ } | j d ƒ | j d ƒ | j t ƒ | j d ƒ | j ƒ  t  ry t d ƒ n  |  j t	 j
 | j ƒ  ƒ t j 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   printt   openR   t   writet   seekt   sizet   flusht   assertEqualt   ost   fstatt   filenot   statt   ST_SIZE(   t   selft   f(    (    s$   lib/python2.7/test/test_largefile.pyt	   test_seek&   s    
c         C  s;   t  r t d ƒ n  |  j t j t ƒ t j t d ƒ d  S(   Ns   check file size with os.stati   (   R   R
   R   R   R   R   R   R   (   R   (    (    s$   lib/python2.7/test/test_largefile.pyt   test_osstat3   s    c         C  s\  t  r t d ƒ n  |  j t d ƒ 1} |  j | j ƒ  d ƒ |  j | j d ƒ d ƒ |  j | j ƒ  d ƒ | j d ƒ |  j | j ƒ  d ƒ | j d d ƒ |  j | j ƒ  d ƒ | j d ƒ |  j | j ƒ  d ƒ | j d d ƒ |  j | j ƒ  d ƒ | j d d ƒ |  j | j ƒ  d ƒ | j d d ƒ |  j | j ƒ  d ƒ | j d d ƒ |  j | j ƒ  t d d ƒ | j d	 d ƒ |  j | j ƒ  t d d
 ƒ | j t d d ƒ |  j | j ƒ  d ƒ | j t ƒ |  j | j ƒ  t ƒ |  j | j d ƒ d ƒ | j t d d ƒ |  j | j d ƒ d ƒ |  j | j ƒ  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   t   tellt   readR   R   (   R   R   (    (    s$   lib/python2.7/test/test_largefile.pyt   test_seek_read8   s<    c      	   C  sˆ  t  r t d ƒ n  |  j t d ƒ ]} |  j t j | j ƒ  d d ƒ d ƒ |  j t j | j ƒ  d d ƒ d ƒ |  j t j | j ƒ  d d ƒ d ƒ |  j t j | j ƒ  d d ƒ d ƒ |  j t j | j ƒ  d d ƒ t d d ƒ |  j t j | j ƒ  d d ƒ t d d	 ƒ |  j t j | j ƒ  t d d ƒ d ƒ |  j t j | j ƒ  t d ƒ t ƒ |  j | j	 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   t   lseekR   R   R   (   R   R   (    (    s$   lib/python2.7/test/test_largefile.pyt
   test_lseekY   s    %%%%--*%c         C  s«  t  r t d ƒ n  |  j t d ƒ €} t | d ƒ sI t j d ƒ ‚ n  | j d d ƒ |  j | j	 ƒ  t
 d ƒ t
 d } | j | ƒ | j ƒ  |  j | j	 ƒ  | ƒ | j d d ƒ |  j | j	 ƒ  | ƒ | d 8} | j d	 ƒ | j | ƒ |  j r|  j | j	 ƒ  d	 ƒ n  | j d d ƒ |  j | j	 ƒ  | ƒ | j d ƒ | j d ƒ |  j rx|  j | j	 ƒ  d ƒ n  | j d ƒ |  j t | j ƒ  ƒ 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   t   hasattrt   unittestt   SkipTestR   R   R   R   R    t   new_iot   lenR   (   R   R   t   newsize(    (    s$   lib/python2.7/test/test_largefile.pyt   test_truncateh   s4    


		c         C  sr   |  j  s |  j d ƒ n  xR d d d
 f D]A } |  j t d ƒ ' } | j | ƒ |  j | j ƒ  ƒ Wd  QXq) Wd  S(   Ns$   builtin file doesn't have seekable()i   i   i   R   I   €    iÿÿÿI   €    I   €    I  €    (   R$   t   skipTestR   R   R   t
   assertTruet   seekable(   R   t   posR   (    (    s$   lib/python2.7/test/test_largefile.pyt   test_seekableŒ   s    	(	   t   __name__t
   __module__t   __doc__R   R   R   R   R'   R,   (    (    (    s$   lib/python2.7/test/test_largefile.pyR      s   			!		$c          C  s  t  j d  d k s" t  j d k r< t d d t t ƒ ƒ n„ t t d d d ƒ}  y( |  j d	 ƒ |  j d
 ƒ |  j	 ƒ  Wn: t
 t f k
 rµ |  j ƒ  t t ƒ t j d ƒ ‚ n X|  j ƒ  t j ƒ  } xt j d f t j d f t d f g D]ö \ } } d t f d „  ƒ  Y} t | ƒ | _ | t k	 | _ | t j | _ | j | d ƒ ƒ | j | d ƒ ƒ | j | d ƒ ƒ | j | d ƒ ƒ | t d ƒ , }  t |  d ƒ rÇ| j | d ƒ ƒ n  Wd  QX| j | d ƒ ƒ t t ƒ qô Wz t | ƒ Wd  t t ƒ Xd  S(   Ni   t   wint   darwint	   largefiles-   test requires %s bytes and a long time to runR   t	   bufferingi    I  €    t   xs*   filesystem does not have largefile supportt   Ct   Pyt   Builtint   TestCasec           B  s   e  Z RS(    (   R-   R.   (    (    (    s$   lib/python2.7/test/test_largefile.pyR8   ´   s   R   R   R   R   R    R'   R,   (   t   syst   platformR   t   strR   R   R   R   R   R   t   IOErrort   OverflowErrort   closeR   R"   R#   t	   TestSuitet   iot   pyioR   t   staticmethodR$   R-   t   addTestR!   R   (   R   t   suitet   _opent   prefixR8   (    (    s$   lib/python2.7/test/test_largefile.pyt	   test_main—   s@    "


t   __main__(   R/   t
   __future__R    R   R   R9   R"   t   test.test_supportR   R   R   R   R   R@   t   _pyioRA   t   signalt   SIGXFSZt   SIG_IGNt
   oldhandlert   ImportErrort   AttributeErrorR   R8   R   RG   R-   (    (    (    s$   lib/python2.7/test/test_largefile.pyt   <module>   s$   ({	0