B
    u9a+o  ã               @   s°   d dl mZmZmZmZmZmZmZmZm	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ZedƒZejZG dd„ de
jƒZG dd„ de
jƒZdd	„ Zed
kr¬eƒ  dS )é    )	ÚTESTFNÚrun_unittestÚimport_moduleÚunlinkÚrequiresÚ_2GÚ_4GÚ
gc_collectÚcpython_onlyNÚmmapc               @   sÒ  e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Ze eedƒd¡dd„ ƒZe eedƒd¡dd„ ƒZe eedƒd¡dd„ ƒZdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Ze eed/ƒd0¡d1d2„ ƒZd3d4„ Zd5d6„ Z d7d8„ Z!e ej"d9kd:¡d;d<„ ƒZ#e$e ej"d9kd:¡d=d>„ ƒƒZ%e ej"d9kd:¡d?d@„ ƒZ&e ej"d9kd:¡dAdB„ ƒZ'dCdD„ Z(dEdF„ Z)dGdH„ Z*dIdJ„ Z+e ,ej"d9kdK¡dLdM„ ƒZ-dNdO„ Z.dPS )QÚ	MmapTestsc             C   s   t j t¡rt  t¡ d S )N)ÚosÚpathÚexistsr   r   )Úself© r   ú/usr/lib/python3.7/test_mmap.pyÚsetUp   s    zMmapTests.setUpc             C   s(   yt  t¡ W n tk
r"   Y nX d S )N)r   r   r   ÚOSError)r   r   r   r   ÚtearDown   s    zMmapTests.tearDownc             C   sÌ  t tdƒ}zJ| dt ¡ | d¡ | dtd  ¡ | ¡  t | ¡ dt ¡}W d | ¡  X tt	|ƒƒ}|  
| d¡t¡ |  
t|ƒdt ¡ |  
|d d¡ |  
|dd… d¡ |  t|jt|ƒ¡ |  t|jt|ƒd¡ d|d< d	|td td d …< |  
|d d¡ |  
|dd… d
¡ |  
|td td … d¡ | ¡  t d|¡}|d krj|  d¡ n2| d¡\}}|| }|  
|t¡ |  
|td ¡ | dd¡ |  
| ¡ d¡ | dd¡ |  
| ¡ d¡ | dd¡ |  
| ¡ t|ƒ¡ |  t|jd¡ |  t|jdd¡ |  t|jt|ƒ d d¡ y| d¡ W n tk
rV   Y njX |  
t|ƒd¡ |  t|jdd¡ t tdƒ}z | dd¡ |  
| ¡ d¡ W d | ¡  X |  
| ¡ d¡ | ¡  d S )Nzbw+ó    s   fooé   é   r   s      é3   s   bars   3  é   é   s    foobar s	   [A-Za-z]+zregex match on mmap failed!é   é*   éÿÿÿÿi   i  Úrb)Úopenr   ÚwriteÚPAGESIZEÚflushr   ÚfilenoÚcloseÚstrÚtypeÚassertEqualÚfindÚlenÚassertRaisesÚ
IndexErrorÚ__getitem__Ú__setitem__ÚreÚsearchÚfailÚspanÚseekÚtellÚ
ValueErrorÚresizeÚSystemErrorÚsize)r   ÚfÚmÚtpÚmatchÚstartÚendÚlengthr   r   r   Ú
test_basic   sd    





zMmapTests.test_basicc          
   C   s€  d}t tdƒ}| d| ¡ W d Q R X t tdƒ€}tj| ¡ |tjd}|  |d d … d| d¡ yd| |d d …< W n tk
rŽ   Y nX |  d¡ yd|d	< W n tk
rº   Y nX |  d¡ y| 	d	d	¡ | d
¡ W n tk
rô   Y nX |  d¡ y| 	d	d	¡ | 
d¡ W n tk
r0   Y nX |  d¡ y| d| ¡ W n* tk
rd   Y n  tk
rx   Y nX |  d¡ t tdƒ}|  | ¡ d| d¡ W d Q R X W d Q R X t tdƒœ}yt | ¡ |d ¡}W n. tk
r   tj d¡r|  d¡ Y n"X tj d¡s&|  d¡ | ¡  tj d¡r\t tdƒ}| |¡ W d Q R X W d Q R X t tdƒV}tj| ¡ |tjd}d| |d d …< |  |d d … d| d¡ | ¡  | ¡  W d Q R X t tdƒ}| ¡ }W d Q R X |  |d| d¡ t tdƒ–}tj| ¡ |tjd}d| |d d …< |  |d d … d| d¡ | ¡  t tdƒ}|  | ¡ d| d¡ W d Q R X |  t|jd| ¡ | ¡  W d Q R X t tdƒ }| jttj| ¡ |dd W d Q R X tjdkr|t tdƒ*}| jttj| ¡ |tjtjtjd W d Q R X tjttdd	ƒB }t tdƒB}tj| ¡ ||d}|  t|jd¡ |  t|j
d	¡ | ¡  W d Q R X d S )Né
   Úwbó   ar   )Úaccessz#Readonly memory map data incorrect.ó   bz$Able to write to readonly memory mapr   s   abcó   dr   z"Able to resize readonly memory mapz*Readonly memory map data file was modifiedzr+br   Úwinz0Opening mmap with size+1 should work on Windows.z1Opening mmap with size+1 should raise ValueError.ó   cz5Write-through memory map memory not updated properly.z8Write-through memory map data file not updated properly.z4Copy-on-write memory map data not written correctly.z4Copy-on-write test data file should not be modified.é   Úposix)ÚflagsÚprotrD   Z	PROT_EXEC)rL   s   abcdef)r    r   r!   r   r$   ÚACCESS_READr(   Ú	TypeErrorr1   r3   Ú
write_byter6   r7   Úreadr5   ÚsysÚplatformÚ
startswithr%   ÚtruncateZACCESS_WRITEr#   ZACCESS_COPYr+   r   ÚnameZMAP_PRIVATEÚ	PROT_READÚgetattr)r   ÚmapsizeÚfpr9   r:   ZstuffrL   r   r   r   Útest_access_parameterz   sª    





$zMmapTests.test_access_parameterc             C   s   |   ttjdd¡ d S )Néþÿÿÿi   )r+   r   r   )r   r   r   r   Útest_bad_file_desc÷   s    zMmapTests.test_bad_file_descc          	   C   s¸   t tdƒ4}d}t|ƒ}| |¡ | ¡  t | ¡ |¡}W d Q R X xft|d ƒD ]V}xPt||d ƒD ]>}|||… }|  | 	|¡| 	|¡¡ |  | 	|d ¡d¡ qfW qRW | 
¡  d S )Nzwb+s   aabaac deef  aa r   ó   xr   )r    r   r*   r!   r#   r   r$   Úranger(   r)   r%   )r   r9   ÚdataÚnr:   r=   ZfinishÚslicer   r   r   Útest_tougher_findû   s    
zMmapTests.test_tougher_findc             C   sÔ   t tdƒ}d}t|ƒ}| |¡ | ¡  t | ¡ |¡}| ¡  |  | 	d¡d¡ |  | 	d¡d¡ |  | 	ddd¡d¡ |  | 	dd¡d¡ |  | 	ddd¡d¡ |  | 	ddd	¡d¡ |  | 	t
dƒ¡d¡ d S )
Nzwb+s   one two oness   oner   s   onesé   r   r   r[   )r    r   r*   r!   r#   r   r$   r%   r(   r)   Ú	bytearray)r   r9   r_   r`   r:   r   r   r   Útest_find_end  s    

zMmapTests.test_find_endc             C   sÖ   t tdƒ}d}t|ƒ}| |¡ | ¡  t | ¡ |¡}| ¡  |  | 	d¡d¡ |  | 	d¡d¡ |  | 	ddd¡d¡ |  | 	ddd¡d¡ |  | 	dd	d¡d¡ |  | 	dd	d¡d¡ |  | 	t
dƒ¡d¡ d S )
Nzwb+s   one two oness   onerc   s   one r   r   r[   r   )r    r   r*   r!   r#   r   r$   r%   r(   Úrfindrd   )r   r9   r_   r`   r:   r   r   r   Ú
test_rfind   s    

zMmapTests.test_rfindc             C   s\   t tdƒ}| dd ¡ | ¡  t tdƒ}tj| ¡ dtjd}| ¡  | ¡  | ¡  d S )Nzwb+i   rC   r   )rD   )r    r   r!   r%   r   r$   rM   )r   r9   Úmfr   r   r   Útest_double_close3  s    

zMmapTests.test_double_closeÚstatzneeds os.stat()c             C   sv   t tdƒ}| dd ¡ | ¡  t tdƒ}t | ¡ d¡}|  t|ƒdd¡ |  | d¡dd ¡ | ¡  | ¡  d S )Nzwb+i   ó   mzrb+r   z Map size should equal file size.)	r    r   r!   r%   r   r$   r(   r*   rP   )r   r9   rh   r   r   r   Útest_entire_file@  s    

zMmapTests.test_entire_filec          
   C   sr   t tdƒ}| dd ¡ W d Q R X t tdƒ:}tj| ¡ ddtjd}|  t|jd¡ W d Q R X W d Q R X d S )	NrB   i   rk   r   r   i   )ÚoffsetrD   i€8 )	r    r   r!   r   r$   rM   r+   r,   r-   )r   r9   rh   r   r   r   Útest_length_0_offsetO  s
    zMmapTests.test_length_0_offsetc          	   C   sX   t tdƒ}| dd ¡ W d Q R X t tdƒ }| jttj| ¡ ddd W d Q R X d S )NrB   ióÃ rk   zw+br   i  ÿ)rm   )r    r   r!   r+   r5   r   r$   )r   r9   r   r   r   Útest_length_0_large_offset\  s
    z$MmapTests.test_length_0_large_offsetc          	   C   s2  t tdƒ}| d¡ | ¡  t | ¡ d¡}| ddd¡ |  |d d … dd¡ | ¡  | ¡  d}x¼t	t
|ƒƒD ]¬}x¦t	t
|ƒƒD ]–}xt	t
|ƒt||ƒ ƒD ]v}|d |… |||| …  ||| d …  }t d	t
|ƒ¡}||d d …< | |||¡ |  |d d … |¡ | ¡  q W q„W qrW t d	d
¡}dd	ddd
g}	xHt |	|	|	¡D ]6\}
}}y| |
||¡ W n tk
r~   Y nX qLW dddddddg}	x(|	D ] \}
}}|  t|j|
||¡ qžW | ¡  t d	d¡}|  t|jddd¡ |  t|jddd¡ |  t|jddd¡ | ddd¡ | ddd¡ d S )Nzwb+s
   ABCDEabcderA   é   r   s
   ABCDEABCDEz'Map move should have duplicated front 5s
   0123456789r   éd   iœÿÿÿr   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   r   )r    r   r!   r#   r   r$   Zmover(   r%   r^   r*   ÚmaxÚ	itertoolsÚproductr5   r+   )r   r9   rh   r_   ÚdestÚsrcÚcountZexpectedr:   ZoffsetsÚsourcer8   r   r   r   Ú	test_moveg  sH    

,
zMmapTests.test_movec             C   sf   t   dt¡}x"ttƒD ]}|  || dd¡ qW x0ttƒD ]$}|d@ }|||< |  || |¡ q:W d S )Nr   r   z+anonymously mmap'ed contents should be zeroéÿ   )r   r"   r^   r(   )r   r:   ÚxÚbr   r   r   Útest_anonymous˜  s    
zMmapTests.test_anonymousc             C   s&  t   dd¡}|  |j¡ | ttdƒƒ¡ | d¡ |  | ¡ ttdƒƒ¡ | d¡ |  | ¡ ttddƒƒ¡ | d¡ |  | ¡ d¡ | d¡ |  | d ¡ttddƒƒ¡ | d¡ |  | d¡ttddƒƒ¡ | d¡ |  | d	¡ttddƒƒ¡ | d
¡ |  | d¡ttd
dƒƒ¡ d S )Nr   é   r   rc   ó    r   rI   rp   r[   é	   iÖÿÿÿ)	r   Ú
addCleanupr%   r!   Úbytesr^   r3   r(   rP   )r   r:   r   r   r   Útest_read_all¤  s"    






zMmapTests.test_read_allc             C   sR   t   dd¡}|  |j¡ |  t|jd¡ |  t|jd¡ |  t|jdddg¡ d S )Nr   r~   Úfoog      @r   r   r   )r   r   r%   r+   rN   rP   )r   r:   r   r   r   Útest_read_invalid_arg¹  s
    zMmapTests.test_read_invalid_argc             C   s²   t ttdƒƒƒ}t dt|ƒ¡}||d d …< |  |d d … |¡ dd ddddtjddd	d
f}xP|D ]H}xB|D ]:}x4|dd … D ]$}|  ||||… ||||… ¡ q~W qlW qbW d S )Né   r   r   r   r   é   i,  r[   iáÿÿÿiÔþÿÿ)r‚   Úreversedr^   r   r*   r(   rQ   Úmaxsize)r   Úsr:   Úindicesr=   ÚstopÚstepr   r   r   Útest_extended_getsliceÁ  s    

z MmapTests.test_extended_getslicec       	      C   sè   t ttdƒƒƒ}t dt|ƒ¡}dd ddddtjddd	d
f}x¦|D ]ž}x˜|D ]}xŠ|dd … D ]z}||d d …< |  |d d … |¡ t|ƒ}||||… }t t|ƒƒ}|||||…< |||||…< |  |d d … t |ƒ¡ q^W qLW qBW d S )Nr†   r   r   r   r   r‡   i,  r[   iáÿÿÿiÔþÿÿ)	r‚   rˆ   r^   r   r*   rQ   r‰   r(   Úlist)	r   rŠ   r:   r‹   r=   rŒ   r   ÚLr_   r   r   r   Útest_extended_set_del_sliceÏ  s    

z%MmapTests.test_extended_set_del_slicec             C   sB   |  d| ¡ |  d¡ |  d|d  ¡ | ¡  t | ¡ d¡S )Nr   s   foor   r   )r!   r#   r   r$   )r   r9   Úhalfsizer   r   r   Úmake_mmap_fileã  s
    
zMmapTests.make_mmap_filec          	   C   sJ   t tdƒ}| ¡  t tdƒ$}| jtdtj| ¡ dtjd W d Q R X d S )Nzw+br   zcannot mmap an empty filer   )rD   )r    r   r%   ZassertRaisesRegexr5   r   r$   rM   )r   r9   r   r   r   Útest_empty_fileë  s    
zMmapTests.test_empty_filec             C   sÄ  t tdƒ}z‚tj}|  ||¡}| ¡  | ¡  |d }t tdƒ}xXdD ]P}y$tj| ¡ ||d}|  dd¡ W n tt	t
fk
rŠ   Y qHX |  dd¡ qHW | ¡  t tdƒ}tj| ¡ || |d}|  |dd… d	¡ | ¡  y| d
¡ W n tk
r   Y n~X |  t|ƒd
¡ |  t|jdd¡ |  |dd… d	¡ t tdƒ}| dd¡ |  | ¡ |d
 ¡ | ¡  |  | ¡ |d
 ¡ | ¡  W d | ¡  yt t¡ W n tk
r¼   Y nX X d S )Nzw+br   zr+b)r[   r   N)rm   r   r   r   s   fooi   i  r   )r    r   r   ZALLOCATIONGRANULARITYr“   r%   r$   r(   r5   rN   ÚOverflowErrorr6   r7   r*   r+   r3   r4   r8   r   r   r   )r   r9   r’   r:   rX   rm   r   r   r   Útest_offsetô  sL    




zMmapTests.test_offsetc             C   s   G dd„ dt j ƒ}|tƒ d S )Nc               @   s   e Zd Zdd„ ZdS )z*MmapTests.test_subclass.<locals>.anon_mmapc             _   s   t j j| df|ž|ŽS )Nr   )r   Ú__new__)ÚklassÚargsÚkwargsr   r   r   r—   /  s    z2MmapTests.test_subclass.<locals>.anon_mmap.__new__N)Ú__name__Ú
__module__Ú__qualname__r—   r   r   r   r   Ú	anon_mmap.  s   rž   )r   r"   )r   rž   r   r   r   Útest_subclass-  s    zMmapTests.test_subclassrV   zneeds mmap.PROT_READc          	   C   sd   d}t tdƒ}| d| ¡ W d Q R X t tdƒ}tj| ¡ |tjd}|  t|jd¡ | ¡  d S )NrA   rB   rC   r   )rL   r„   )	r    r   r!   r   r$   rV   r+   rN   r%   )r   rX   rY   r9   r:   r   r   r   Útest_prot_readonly3  s    
zMmapTests.test_prot_readonlyc             C   s   |   tjt¡ d S )N)ÚassertIsr   Úerrorr   )r   r   r   r   Ú
test_error=  s    zMmapTests.test_errorc          	   C   sÎ  d}t tdƒ}| dt|ƒ ¡ W d Q R X t tdƒ}t | ¡ t|ƒ¡}| ¡  xFtt|ƒƒD ]6}|  | 	¡ |¡ | 
|| ¡ |  | 	¡ |d ¡ q`W |  t|j
d¡ |  |d d … |¡ | d¡ xLtt|ƒƒD ]<}|  | 	¡ |¡ |  | ¡ || ¡ |  | 	¡ |d ¡ qÖW |  t|j¡ | d¡ |  | d¡d	¡ |  | 	¡ d
¡ | d¡ | d¡ |  | 	¡ d
¡ |  |d d … d¡ | tdƒ¡ |  | 	¡ d¡ |  |d d … d¡ |  t|jd¡ d S )Ns
   0123456789rB   r]   zr+br   éx   r   r   s   345r   s   bars
   012bar6789s   bazr€   s
   012barbaz9s   ba)r    r   r!   r*   r   r$   r%   r^   r(   r4   rO   r+   r5   r3   Ú	read_byterP   rd   )r   r_   rY   r9   r:   Úir   r   r   Útest_io_methods@  s:    




zMmapTests.test_io_methodsc             C   sZ   xTdD ]L}t   dd¡}| |¡ |  |d |¡ | d¡ |  | ¡ |¡ | ¡  qW d S )N)é   éÈ   rz   r   r   r   )r   rO   r(   r3   r¥   r%   )r   r|   r:   r   r   r   Útest_non_ascii_bytec  s    


zMmapTests.test_non_ascii_byteÚntzrequires Windowsc             C   sü   d}d}t j dt|ƒdd}||d d …< t j dt|ƒdd}||d d …< |  |d d … |¡ |  |d d … |¡ | ¡  | ¡  t j dt|ƒdd}||d d …< t j dt|ƒdd}||d d …< |  |d d … |¡ |  |d d … |¡ | ¡  | ¡  d S )Ns
   0123456789s
   abcdefghijr   r„   )ÚtagnameZboo)r   r*   r(   r%   )r   Zdata1Zdata2Úm1Úm2r   r   r   Útest_tagnamel  s$    zMmapTests.test_tagnamec             C   sH   t   dd¡}d}t j dd|d}|  t |¡t |¡t|ƒ d ¡ d S )Nr   rq   r„   )r¬   r   )r   r(   rQ   Ú	getsizeofr*   )r   r­   r¬   r®   r   r   r   Útest_sizeof†  s
    zMmapTests.test_sizeofc          	   C   sÊ   t j dddd}yt j ddddd d …  W n   Y nX | ¡  ttdƒ}| d¡ W d Q R X ttdƒ}t   | ¡ d	¡}| ¡  y| d	¡ W n   Y nX y|d d …  W n   Y nX | ¡  d S )
Nr   iè  r„   )r¬   iˆ  rB   s
   xxxxxxxxxxzr+br   )r   r%   r    r   r!   r$   r6   )r   r:   rY   r9   r   r   r   Útest_crasher_on_windows  s(    
z!MmapTests.test_crasher_on_windowsc          	   C   sB   t   ¡ }z*|  t¡ t | ¡ d¡}W d Q R X W d | ¡  X d S )NrA   )Úsocketr+   r   r   r$   r%   )r   rŠ   r:   r   r   r   Útest_invalid_descriptor©  s
    z!MmapTests.test_invalid_descriptorc          	   C   s4   t   dd¡}|  |j¡ W d Q R X |  |j¡ d S )Nr   rA   )r   ZassertFalseÚclosedÚ
assertTrue)r   r:   r   r   r   Útest_context_managerµ  s    zMmapTests.test_context_managerc          
   C   sT   |   t¡"}t dd¡
}t‚W d Q R X W d Q R X |  |jtd¡ |  |jd¡ d S )Nr   rA   z)wrong exception raised in context managerzcontext manager failed)r+   Ú	Exceptionr   r   ZassertIsInstanceZ	exceptionr¶   rµ   )r   Úexcr:   r   r   r   Útest_context_manager_exceptionº  s    
z(MmapTests.test_context_manager_exceptionc             C   s>   t   dd¡}t |¡}|  |ƒ |¡ ~tƒ  |  |ƒ d ¡ d S )Nr   r~   )r   ÚweakrefÚrefr¡   r	   )r   ÚmmZwrr   r   r   Útest_weakrefÃ  s    
zMmapTests.test_weakrefc             C   sX   t   dd¡}|  | d¡d¡ |  | d¡d¡ |  | d¡d¡ |  | d	¡d
¡ d S )Nr   r~   r   r   r]   r   s   yzr   s   pythonr   )r   r(   r!   )r   r½   r   r   r   Ú0test_write_returning_the_number_of_bytes_writtenÌ  s
    z:MmapTests.test_write_returning_the_number_of_bytes_writtenz(cannot resize anonymous mmaps on Windowsc             C   s”   t   dd¡}|  |j¡ | d¡ y| d¡ W n tk
rN   |  d¡ Y nX |  | d¡d¡ |  t	|j
¡ |  t	|jd¡ |  t	|jd	¡ d S )
Nr   i    iˆ  i   zresizing not supportedé   r   r   s   abc)r   r   r%   rP   r6   r7   ZskipTestr(   r+   r5   r¥   rO   r!   )r   r:   r   r   r   Útest_resize_past_posÓ  s    
zMmapTests.test_resize_past_posc          	   C   sL   t   dd¡}|  t¡ ||  W d Q R X |  t¡ |d  W d Q R X d S )Nr   r~   r   )r   r+   rN   )r   r:   r   r   r   Útest_concat_repeat_exceptioná  s
    z&MmapTests.test_concat_repeat_exceptionN)/r›   rœ   r   r   r   r@   rZ   r\   rb   re   rg   ri   ÚunittestÚ
skipUnlessÚhasattrr   rl   rn   ro   ry   r}   rƒ   r…   rŽ   r‘   r“   r”   r–   rŸ   r   r    r£   r§   rª   rU   r¯   r
   r±   r²   r´   r·   rº   r¾   r¿   ZskipIfrÁ   rÂ   r   r   r   r   r      sJ   ^}1	9
#			r   c               @   sp   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Ze	 
ejekd¡dd„ ƒZe	 
ejekd¡dd„ ƒZdS )ÚLargeMmapTestsc             C   s   t tƒ d S )N)r   r   )r   r   r   r   r   ë  s    zLargeMmapTests.setUpc             C   s   t tƒ d S )N)r   r   )r   r   r   r   r   î  s    zLargeMmapTests.tearDownc             C   s¨   t jd d… dkst jdkr.tddtdƒ ƒ ttdƒ}y | |¡ | |¡ | ¡  W nJ t	t
tfk
r¢   y| ¡  W n t	t
fk
r’   Y nX t d¡‚Y nX |S )	Nr   rG   ÚdarwinZ	largefilez-test requires %s bytes and a long time to runl        zw+bz*filesystem does not have largefile support)rQ   rR   r   r&   r    r   r3   r!   r#   r   r•   r5   r%   rÃ   ZSkipTest)r   Z
num_zeroesÚtailr9   r   r   r   Ú_make_test_fileñ  s    


zLargeMmapTests._make_test_filec          
   C   sP   |   dd¡:}tj| ¡ ddtjd}|  |d d¡ W d Q R X W d Q R X d S )Nl   ÿÿ ó    r   l        )rm   rD   iÿÿÿé    )rÉ   r   r$   rM   r(   )r   r9   r:   r   r   r   Útest_large_offset  s    z LargeMmapTests.test_large_offsetc          
   C   s°   |   dd¡š}tjdk rp|  t¡ tj| ¡ dtjd W d Q R X |  t¡ tj| ¡ dtjd W d Q R X tj| ¡ dtjd}|  	| 
¡ d¡ W d Q R X W d Q R X d S )Nl   ÿÿ rÊ   l        )rD   r   i   )rÉ   rQ   r‰   r+   r•   r   r$   rM   r5   r(   r8   )r   r9   r:   r   r   r   Útest_large_filesize  s    
  z"LargeMmapTests.test_large_filesizec          
   C   sr   d}|t |ƒd  }|t |ƒ }|  ||¡<}tj| ¡ dtjd}|  |||… |¡ W d Q R X W d Q R X d S )Ns     DEARdear  r   r   )rD   )r*   rÉ   r   r$   rM   r(   )r   ÚboundaryrÈ   r=   r>   r9   r:   r   r   r   Ú_test_around_boundary  s    z$LargeMmapTests._test_around_boundaryz!test cannot run on 32-bit systemsc             C   s   |   t¡ d S )N)rÏ   r   )r   r   r   r   Útest_around_2GB  s    zLargeMmapTests.test_around_2GBc             C   s   |   t¡ d S )N)rÏ   r   )r   r   r   r   Útest_around_4GB!  s    zLargeMmapTests.test_around_4GBN)r›   rœ   r   r   r   rÉ   rÌ   rÍ   rÏ   rÃ   rÄ   rQ   r‰   r   rÐ   rÑ   r   r   r   r   rÆ   é  s   rÆ   c               C   s   t ttƒ d S )N)r   r   rÆ   r   r   r   r   Ú	test_main&  s    rÒ   Ú__main__)Ztest.supportr   r   r   r   r   r   r   r	   r
   rÃ   r   r/   rs   r³   rQ   r»   r   r"   ZTestCaser   rÆ   rÒ   r›   r   r   r   r   Ú<module>   s&   ,     ^=