
    <eC                     z   d dl mZmZmZmZmZmZ d dlmZ d dl	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d dlZd dlZ ed          Zej        Zd ej                     dZdd	Zer ej        d
           G d dej                  Z G d dej                  Zedk    r ej                     dS dS )    )requires_2G_4G
gc_collectcpython_onlyis_emscripten)import_module)TESTFNunlinkNmmappython_
_test_mmap
   c                     d                     t          j        t          j        |                     }t
           d| S )N )k_)joinrandomchoicesstringascii_uppercasetagname_prefix)lengthsuffixs     %/usr/lib/python3.11/test/test_mmap.pyrandom_tagnamer      s9    WWV^F$:fEEEFFF''v'''    z.incompatible with Emscripten's mmap emulation.c                      e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z ej         eed          d          d             Zd Zd Z d Z! ej        e"j#        dk    d          d              Z$e% ej        e"j#        dk    d          d!                         Z& ej        e"j#        dk    d          d"             Z' ej        e"j#        dk    d          d#             Z(d$ Z)d% Z*d& Z+d' Z,d( Z-d) Z.d* Z/d+ Z0 ej         eej        d,          d-          d.             Z1 ej        e"j#        dk    d          d/             Z2 ej        e"j#        dk    d          d0             Z3 ej        e"j#        dk    d          d1             Z4 ej        e"j#        dk    d          d2             Z5d3 Z6d4S )5	MmapTestsc                     t           j                            t                    rt          j        t                     d S d S N)ospathexistsr
   r   selfs    r   setUpzMmapTests.setUp"   s8    7>>&!! 	If	 	r   c                 \    	 t          j        t                     d S # t          $ r Y d S w xY wr"   )r#   r   r
   OSErrorr&   s    r   tearDownzMmapTests.tearDown&   s?    	If 	 	 	DD	s    
++c                 
   t          t          d          }	 |                    dt          z             |                    d           |                    dt          dz
  z             |                                 t
                              |                                dt          z            }|                                 n# |                                 w xY wt          t          |                    }| 
                    |                    d          t                     | 
                    t          |          dt          z             | 
                    |d         d           | 
                    |dd         d           |                     t          |j        t          |                     |                     t          |j        t          |          d           d|d<   d	|t          dz   t          dz   dz   <   | 
                    |d         d           | 
                    |dd         d
           | 
                    |t          dz
  t          dz            d           |                                 t#          j        d|          }||                     d           nV|                    d          \  }}||z
  }| 
                    |t                     | 
                    |t          dz              |                    dd           | 
                    |                                d           |                    dd           | 
                    |                                d           |                    dd           | 
                    |                                t          |                     |                     t.          |j        d           |                     t.          |j        dd           |                     t.          |j        t          |           dz
  d           	 |                    d           | 
                    t          |          d           |                     t.          |j        dd           t          t          d          }	 |                    dd           | 
                    |                                d           |                                 n# |                                 w xY w| 
                    |                                d           n# t4          $ r Y nw xY w|                                 d S )Nzbw+       foo      r   s      3      bars   3        s    foobar s	   [A-Za-z]+zregex match on mmap failed!   *        rb)openr
   writePAGESIZEflushr   filenoclosestrtypeassertEqualfindlenassertRaises
IndexError__getitem____setitem__researchfailspanseektell
ValueErrorresizesizeSystemError)r'   fmtpmatchstartendr   s           r   
test_basiczMmapTests.test_basic,   s    	GGE8O$$$GGFOOOGGEHQJ')))GGIII		!((**a(l33AGGIIIIAGGIIII a\\222Q8,,,1q!!!1Q3+++ 	*amSVV<<<*amSVVUCCC !(.(A+x{1}
$% 	1w'''1Q3***8A:145}EEE				 	,**=II34444AJE35[FUH---S(Q,/// 	
q1%%%	r!2&&&	q3q66*** 	*afb111 	*afa333 	*afs1vvgai;;;	,HHSMMM SVVS)))j!&#q999 VT""Aq!  3///								QVVXXs++++'  	 	 	 D		* 	
					s*   BC CU 8>T T!
UUc           
         d}t          t          d          5 }|                    d|z             d d d            n# 1 swxY w Y   t          t          d          5 }t                              |                                |t          j                  }|                     |d d          d|z  d           	 d|z  |d d <   |                     d           n# t          $ r Y nw xY w	 d|d	<   |                     d           n# t          $ r Y nw xY w	 |	                    d	d	           |                    d
           |                     d           n# t          $ r Y nw xY w	 |	                    d	d	           |
                    d           |                     d           n# t          $ r Y nw xY w	 |                    d|z             |                     d           n# t          $ r Y nt          $ r Y nw xY wt          t          d          5 }|                     |                                d|z  d           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          t          d          5 }	 t                              |                                |dz             }t          j                            d          s|                     d           |                                 nD# t$          $ r7 t          j                            d          r|                     d           Y nw xY wt          j                            d          rBt          t          d          5 }|                    |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          t          d          5 }t                              |                                |t          j                  }d|z  |d d <   |                     |d d          d|z  d           |                                 |                                 d d d            n# 1 swxY w Y   t          t          d          5 }|                                }d d d            n# 1 swxY w Y   |                     |d|z  d           t          t          d          5 }t                              |                                |t          j                  }d|z  |d d <   |                     |d d          d|z  d           |                                 t          t          d          5 }|                     |                                d|z  d           d d d            n# 1 swxY w Y   |                     t          |j        d|z             |                                 d d d            n# 1 swxY w Y   t          t          d          5 }|                     t$          t          j        |                                |d           d d d            n# 1 swxY w Y   t0          j        dk    r`t          t          d          5 }|                     t$          t          j        |                                |t          j        t          j        t          j                   d d d            n# 1 swxY w Y   t          j        t9          t          dd	          z  }t          t          d          5 }t                              |                                ||          }|                     t          |j        d           |                     t          |j
        d	           |                                 d d d            d S # 1 swxY w Y   d S d S )Nr   wb   ar:   accessz#Readonly memory map data incorrect.   bz$Able to write to readonly memory mapr      abc   dr0   z"Able to resize readonly memory mapz*Readonly memory map data file was modifiedr+br3   winz1Opening mmap with size+1 should raise ValueError.z0Opening mmap with size+1 should work on Windows.   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protr_   	PROT_EXECri   s   abcdef)r;   r
   r<   r   r?   ACCESS_READrC   rL   	TypeErrorrN   
write_byterQ   rS   readsysplatform
startswithr@   rP   truncateACCESS_WRITEr>   ACCESS_COPYrF   r#   nameMAP_PRIVATE	PROT_READgetattr)r'   mapsizefprT   rU   stuffri   s          r   test_access_parameterzMmapTests.test_access_parameter   s
   &$ 	#2HHT'\"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#&$ 1	O1		!((**gd6F	GGAQqqqT4<1VWWWBG|!!! 		@AAAA    B! 		@AAAA    Bq 		@AAAA    BqT""" 		@AAAA    @7### 		>????        fd## Or  DL!MO O OO O O O O O O O O O O O O O O_1	O 1	O 1	O 1	O 1	O 1	O 1	O 1	O 1	O 1	O 1	O 1	O 1	O 1	O 1	Oh &%   	(AIIahhjj'!)44 |..u55 SIIQRRR				  R R R
 <**511 RIIPQQQR |&&u-- (&%(( (AJJw'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (#	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(* &%   	A		!((**gd6G	HHA<AaaaDQqqqT4<JL L LGGIIIGGIII	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 &$ 	1FFHHE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	WI	K 	K 	K &%   	A		!((**gd6F	GGA<AaaaDQqqqT4'>SU U UGGIIIfd## Yr  DL!WY Y YY Y Y Y Y Y Y Y Y Y Y Y Y Y Y i1W9===GGIII	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 &%   	TAj$)QXXZZQRSSS	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 7gfe$$ Q!!*diW(,(8'+~d>O " Q Q QQ Q Q Q Q Q Q Q Q Q Q Q Q Q Q >GD+q$A$AADfe$$ IIahhjj'I==!!)QWi@@@!!)Q\1===				                  s  =AAAI):
CI)
C'$I)&C''I)+D0I)
DI)DI)+EI)
E%"I)$E%%I))+F*I)*
F74I)6F77I);G)I))
H3I)5	H>I) HI)-II)I	I)I	I))I-0I-	N50L;A	N5>MN5M7N5<NN5N"	"N5%N"	&N55N9<N9BQ//Q36Q3R00R47R4*BX9-V2&X2V6	6X9V6	:;XXX!<Y))Y-0Y-A\\	\B___c                 T    |                      t          t          j        dd           d S )N   )rF   r*   r   r&   s    r   test_bad_file_desczMmapTests.test_bad_file_desc  s$    '49b$77777r   c                    t          t          d          5 }d}t          |          }|                    |           |                                 t
                              |                                |          }d d d            n# 1 swxY w Y   t          |dz             D ]}t          ||dz             D ]t}|||         }|                     |	                    |          |	                    |                     |                     |	                    |dz             d           u|
                                 d S )Nwb+s   aabaac deef  aa r3      xr7   )r;   r
   rE   r<   r>   r   r?   rangerC   rD   r@   )r'   rT   datanrU   rX   finishslices           r   test_tougher_findzMmapTests.test_tougher_find  s`    &%   	)A2DD		AGGDMMMGGIII		!((**a((A	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 1Q3ZZ 	; 	;Eqs++ ; ;UV^,  		%0@0@AAA  !5!5r::::; 	
					   A(B

BBc           
         t          t          d          5 }d}t          |          }|                    |           |                                 t
                              |                                |          }d d d            n# 1 swxY w Y   |                     |                    d          d           |                     |                    d          d           |                     |                    ddd          d           |                     |                    dd          d           |                     |                    ddd          d           |                     |                    ddd	          d           |                     |                    t          d                    d           t          | dz
  |dz             D ]g}t          | dz
  |dz             D ]M}d
D ]H}|                    |||          }|                     |                    |||          ||||f           INhd S )Nr      one two ones   oner      ones   r7   r3   r   )   os   ons   twor      s)r;   r
   rE   r<   r>   r   r?   rC   rD   	bytearrayr   )	r'   rT   r   r   rU   ijpexpecteds	            r   test_find_endzMmapTests.test_find_end  sd   &%   	)A"DD		AGGDMMMGGIII		!((**a((A	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	+++!,,,2..222**A...2..2222..333	& 1 122A666r!tQqS!! 	K 	KAA2a41%% K K= K KA#yyAq11H$$QVVAq!__hAq	JJJJKK	K 	Kr   c                     	 t           j        t           j        z  }t           j        }d}t           j        }n'# t
          $ r}t          j        d          |d }~ww xY wt          dd          D ]}t                                d||dz   z  ||          5 }t                                d||dz   z  ||          5 }|	                    dd	           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d S )
Nr   zmmap flags unavailablei  r7   r3   )rh   ri   i   s   for   )
r   rw   MAP_ANONYMOUSr=   rx   AttributeErrorunittestSkipTestr   rD   )	r'   rh   r=   	PROT_NONErx   er   guardfms	            r   'test_find_does_not_access_beyond_bufferz1MmapTests.test_find_does_not_access_beyond_buffer4  s   	E$t'99E}HIII 	E 	E 	E#$<==1D	Eq$ 	' 	'A2x1q51!&Y  8 8 ';@YYr8q4x#8%*  < < '?AGGE2&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' '' ' ' ' ' ' ' ' ' ' ' ' ' ' '	' 	'sK   36 
A AA%C28CC2CC2"C#C22C6	9C6	c                    t          t          d          5 }d}t          |          }|                    |           |                                 t
                              |                                |          }d d d            n# 1 swxY w Y   |                     |                    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 )
Nr   r   r   r   s   one r   r7   r   r3   )
r;   r
   rE   r<   r>   r   r?   rC   rfindr   )r'   rT   r   r   rU   s        r   
test_rfindzMmapTests.test_rfindD  s   &%   	)A"DD		AGGDMMMGGIII		!((**a((A	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	!,,,))1---B//333B//333B//333B//4446!2!233Q77777r   c                    t          t          d          5 }|                    ddz             d d d            n# 1 swxY w Y   t          t          d          5 }t                              |                                dt          j                  }|                                 |                                 d d d            d S # 1 swxY w Y   d S )Nr      r]   r:   r^   )r;   r
   r<   r   r?   rl   r@   r'   rT   mfs      r   test_double_closezMmapTests.test_double_closeV  s)   &%   	"AGGEDL!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" &$ 	1188::uT5EFFBHHJJJHHJJJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s    ;??A"C

CCc                    t          t          d          5 }|                    ddz             d d d            n# 1 swxY w Y   t          t          d          5 }t                              |                                d          5 }|                     t          |          dd           |                     |                    d          ddz             d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr   r      mzrb+r   z Map size should equal file size.)r;   r
   r<   r   r?   rC   rE   ro   r   s      r   test_entire_filezMmapTests.test_entire_file`  s   &%   	"AGGEDL!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" &%   	;AYYqxxzz1%%	;)+SWWe-OPPPRWWU^^UT\:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;sD   ;??.C>	AC&C>&C*	*C>-C*	.C>>DDc                    t          t          d          5 }|                    ddz             d d d            n# 1 swxY w Y   t          t          d          5 }t                              |                                ddt          j                  5 }|                     t          |j        d           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )	Nr\   i   r   r:   r   r   offsetr_   i8 )	r;   r
   r<   r   r?   rl   rF   rG   rH   r   s      r   test_length_0_offsetzMmapTests.test_length_0_offsetj  s   
 &$ 	(1GGY$&'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( &$ 	E1188::qt?OPP ETV!!*bneDDDE E E E E E E E E E E E E E E	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	EsC   ;??;C"C8CC	CC	CC #C c                 b   t          t          d          5 }|                    ddz             d d d            n# 1 swxY w Y   t          t          d          5 }|                     t          t
          j        |                                dd           d d d            d S # 1 swxY w Y   d S )Nr\   i r   w+br   i  r   )r;   r
   r<   rF   rP   r   r?   r'   rT   s     r   test_length_0_large_offsetz$MmapTests.test_length_0_large_offsetv  s!    &$ 	#1GGFTM"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# &%   	1Aj$)QXXZZ%/  1 1 1	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   ;??<B$$B(+B(c           	      p   t          t          d          5 }|                    d           |                                 t                              |                                d          }|                    ddd           |                     |d d          dd           |                                 d d d            n# 1 swxY w Y   d}t          t          |                    D ]}t          t          |                    D ]}t          t          |          t          ||          z
            D ]}|d |         ||||z            z   |||z   d          z   }t                              d	t          |                    }||d d <   |                    |||           |                     |d d          |           |                                 ьt                              d	d
          }g d}	t          j        |	|	|	          D ].\  }
}}	 |                    |
||           # t          $ r Y +w xY wg d}	|	D ])\  }
}}|                     t          |j        |
||           *|                                 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 )Nr   s
   ABCDEabcder      r   s
   ABCDEABCDEz'Map move should have duplicated front 5
   0123456789r7   d   )ir7   r   r3   r   ))r7   r7   r7   )r7   r7   r   )r7   r   r7   )r   r7   r7   )r7   r   r   )r   r7   r   )r   r   r7   r3   r0   )r;   r
   r<   r>   r   r?   moverC   r@   r   rE   max	itertoolsproductrP   rF   )r'   rT   r   r   destsrccountr   rU   offsetssourcerR   s               r   	test_movezMmapTests.test_move  sb   &%   	AGGM"""GGIII188::r**BGGAq!RUM3\]]]HHJJJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 #d))$$ 	 	DSYY''  "3t99s4~~#=>>  E#ETE{T#c%i--@@4U
CTTH		"c$ii00AAaaaDFF4e,,,$$QqqqT8444GGIIII IIb#'''"+"3GWg"N"N 	 	FD$vtT****   7 7 7") 	F 	FFD$j!&&$EEEE				IIb!*afaA666*afaA666*afaA666	q!Q	q!Qs$   B!CC
CH00
H=<H=c                 (   t                                dt                    }t          t                    D ]}|                     ||         dd            t          t                    D ](}|dz  }|||<   |                     ||         |           )d S )Nr7   r   z+anonymously mmap'ed contents should be zero   )r   r=   r   rC   )r'   rU   xbs       r   test_anonymouszMmapTests.test_anonymous  s    IIb(##x 	L 	LAQqT1JL L L L x 	& 	&ADAAaDQqT1%%%%	& 	&r   c           	      n   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 )Nr7      r   r   r   r/   rf   r   r   	   i)	r   
addCleanupr@   r<   bytesr   rN   rC   ro   r'   rU   s     r   test_read_allzMmapTests.test_read_all  s   IIb"    	
eBii  !!!	q			5r#3#3444	q			5q"#6#6777	r


3'''	q			uU1b\\':':;;;	q			U5B<<%8%8999	q			U5B<<%8%8999	q			eE!RLL&9&9:::::r   c                 :   t                                dd          }|                     |j                   |                     t          |j        d           |                     t          |j        d           |                     t          |j        g d           d S )Nr7   r   foog      @)r3   r0   r/   )r   r   r@   rF   rm   ro   r   s     r   test_read_invalid_argzMmapTests.test_read_invalid_arg  s    IIb"   )QVU333)QVS111)QVYYY77777r   c                    t          t          t          d                              }t                              dt	          |                    }||d d <   |                     |d d          |           dd ddddt          j        ddd	d
f}|D ]<}|D ]7}|dd          D ]*}|                     ||||         ||||                    +8=d S N   r7   r   r3   r/      i,  r   ii)r   reversedr   r   rE   rC   rp   maxsize)r'   srU   indicesrX   stopsteps          r   test_extended_getslicez MmapTests.test_extended_getslice  s    (5::&&''IIb#a&&!!!!!111q!!!dAq"c3;BTJ 	9 	9E 9 9#ABBK 9 9D$$QuT$%7%&uT$%79 9 9 999	9 	9r   c                 0   t          t          t          d                              }t                              dt	          |                    }dd ddddt
          j        ddd	d
f}|D ]}|D ]}|dd          D ]}||d d <   |                     |d d          |           t          |          }||||         }t          t          |                    }|||||<   |||||<   |                     |d d          t          |                     d S r   )	r   r   r   r   rE   rp   r   rC   list)	r'   r   rU   r   rX   r   r   Lr   s	            r   test_extended_set_del_slicez%MmapTests.test_extended_set_del_slice  s?   (5::&&''IIb#a&&!!dAq"c3;BTJ 	5 	5E 5 5#ABBK 
5 
5DAaaaD$$QqqqT1---QA U4_-D $00D)-AeDo&)-AeDo&$$QqqqT5884444
55	5 	5r   c                    |                     d|z             |                     d           |                     d|dz
  z             |                                 t                              |                                d          S )Nr-   r.   r/   r   )r<   r>   r   r?   )r'   rT   halfsizes      r   make_mmap_filezMmapTests.make_mmap_file  so    	!"""		(Q,'(((	


yy!((**a(((r   c           	      @   t          t          d          }|                                 t          t          d          5 }|                     t          dt
          j        |                                dt
          j                   d d d            d S # 1 swxY w Y   d S )Nr   r:   zcannot mmap an empty filer   r^   )r;   r
   r@   assertRaisesRegexrP   r   r?   rl   r   s     r   test_empty_filezMmapTests.test_empty_file  s    &%  				&$ 	<1"":#>#'9ahhjj!*.*: # < < <	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<s   ABBBc                 z   t          t          d          }	 t          j        }|                     ||          }|                                 |                                 |dz  }t          t          d          }dD ]{}	 t                              |                                ||          }|                     dd           |                     dd           _# t          t          t          f$ r Y xw xY w|                                 t          t          d          }t                              |                                ||z
  |          }|                     |dd         d	           |                                 	 |                    d
           |                     t          |          d
           |                     t          |j        dd           |                     |dd         d	           t          t          d          }|                    dd           |                     |                                |d
z              |                                 |                     |                                |d
z              n# t"          $ r Y nw xY w|                                 |                                 	 t%          j        t                     d S # t(          $ r Y d S w xY w# |                                 	 t%          j        t                     w # t(          $ r Y w w xY wxY w)Nr   r0   rc   )r   r7   Nr   r   r3   r/   r.   r8   r9   r:   )r;   r
   r   ALLOCATIONGRANULARITYr   r@   r?   rC   rP   rm   OverflowErrorrQ   rE   rF   rN   rO   rR   rS   r#   r   r*   )r'   rT   r   rU   rz   r   s         r   test_offsetzMmapTests.test_offset  s   &%  4	1H##Q11AGGJJJGGJJJlGVU##A( + ++		!((**gf	EEA$$Q*** $$Q**** #I}=   D GGIII VU##A		!((**g&8	JJAQqsVV,,,GGIII;
   Q---!!*afc1===  1Q3000 &&q!  8c>:::			  8c>::::    " GGIII GGIII	&!!!!!    GGIII	&!!!!   s   A(K:  ACK: C63K: 5C66BK: J C9K: 
J"K: !J""K: K) )
K76K7:L:L*)L:*
L74L:6L77L:c                 V     G d dt           j                   } |t                     d S )Nc                       e Zd Zd ZdS )*MmapTests.test_subclass.<locals>.anon_mmapc                 8    t          j         j        | dg|R i |S )Nr7   )r   __new__)klassargskwargss      r   r   z2MmapTests.test_subclass.<locals>.anon_mmap.__new__F  s'    y(DTDDDVDDDr   N)__name__
__module____qualname__r    r   r   	anon_mmapr   E  s(        E E E E Er   r   )r   r=   )r'   r   s     r   test_subclasszMmapTests.test_subclassD  sN    	E 	E 	E 	E 	E	 	E 	E 	E 		(r   rx   zneeds mmap.PROT_READc                    d}t          t          d          5 }|                    d|z             d d d            n# 1 swxY w Y   t          t          d          5 }t                              |                                |t          j                  }|                     t          |j        d           d d d            d S # 1 swxY w Y   d S )Nr   r\   r]   r:   rk   r   )r;   r
   r<   r   r?   rx   rF   rm   )r'   rz   r{   rT   rU   s        r   test_prot_readonlyzMmapTests.test_prot_readonlyJ  s+   &$ 	#2HHT'\"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#&$ 	91		!((**gDN	CCAi%888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9s"   =AAACC	C	c                 P    |                      t          j        t                     d S r"   )assertIsr   errorr*   r&   s    r   
test_errorzMmapTests.test_errorS  s    dj'*****r   c                 |   d}t          t          d          5 }|                    dt          |          z             d d d            n# 1 swxY w Y   t          t          d          5 }t                              |                                t          |                    }d d d            n# 1 swxY w Y   t          t          |                    D ]p}|                     |                                |           |	                    ||                    |                     |                                |dz              q| 
                    t          |j	        d           |                     |d d          |           |                    d           t          t          |                    D ]}|                     |                                |           |                     |                                ||                    |                     |                                |dz              | 
                    t          |j                   |                    d           |                     |                    d          d	           |                     |                                d
           |                    d           |                    d           |                     |                                d
           |                     |d d          d           |                    t          d                     |                     |                                d           |                     |d d          d           | 
                    t          |j        d           d S )Nr   r\   r   rc   r3   x   r   r/   s   345r5   r2   s
   012bar6789s   bazr   s
   012barbaz9s   ba)r;   r
   r<   rE   r   r?   r   rC   rO   rn   rF   rP   rN   	read_bytero   r   )r'   r   r{   rT   rU   r   s         r   test_io_methodszMmapTests.test_io_methodsV  s~   &$ 	%2HHT#d))^$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%&%   	1A		!((**c$ii00A	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 s4yy!! 	, 	,AQVVXXq)))LLa!!!QVVXXqs++++*alG<<<111t$$$	q			s4yy!! 	, 	,AQVVXXq)))Q[[]]DG444QVVXXqs++++*ak222	q			F+++1%%%	q				1%%%111}---		&!!"""1%%%111}---*agu55555s#   &A

AA*;B11B58B5c                 J   dD ]}t                                dd          }|                    |           |                     |d         |           |                    d           |                     |                                |           |                                 d S )N)      r   r7   r3   r   )r   rn   rC   rN   r  r@   )r'   r   rU   s      r   test_non_ascii_bytezMmapTests.test_non_ascii_bytex  s      	 	A		"a  ALLOOOQqT1%%%FF1IIIQ[[]]A...GGIIII	 	r   ntzrequires Windowsc                    d}d}t          |          t          |          k    sJ t                      }t                      }t                              dt          |          |          }||d d <   t                              dt          |          |          }||d d <   |                     |d d          |           |                     |d d          |           |                                 |                                 t                              dt          |          |          }||d d <   t                              dt          |          |          }||d d <   |                     |d d          |           |                     |d d          |           |                                 |                                 d S )Nr   s
   abcdefghijr7   tagname)rE   r   r   rC   r@   )r'   data1data2tagname1tagname2m1m2s          r   test_tagnamezMmapTests.test_tagname  s   5zzSZZ''''!##!## YYr3u::xY88111YYr3u::xY88111AAA&&&AAA&&&







 YYr3u::xY88111YYr3u::xY88111AAA&&&AAA&&&









r   c                 ,   t                                dd          }t                      }t                                dd|          }|                     t          j        |          t          j        |          t          |          z   dz              d S )Nr7   r   r  r3   )r   r   rC   rp   	getsizeofrE   )r'   r  r  r  s       r   test_sizeofzMmapTests.test_sizeof  s     YYr3 ""YYr3Y00r**r**S\\9A=	? 	? 	? 	? 	?r   c                    t                      }t                              dd|          }	 t                              dd|          d d           n#  Y nxY w|                                 t          t          d          5 }|                    d           d d d            n# 1 swxY w Y   t          t          d          }t                              |                                d          }|                                 	 |                    d           n#  Y nxY w	 |d d           n#  Y nxY w|                                 d S )	Nr7     r    r\   s
   xxxxxxxxxxrc   r   )r   r   r@   r;   r
   r<   r?   rQ   )r'   r  rU   r{   rT   s        r   test_crasher_on_windowsz!MmapTests.test_crasher_on_windows  sn    !""IIb$I00	IIb$I00333	D				 &$ 	2HHW	 	 	 	 	 	 	 	 	 	 	 	 	 	 	IIahhjj!$$					HHQKKKK	D	aaaDDD	D						s5   %A AB%%B),B)D D!%
D0 0D4c                 F   t          j                     }	 |                     t                    5  t                              |                                d          }d d d            n# 1 swxY w Y   |                                 d S # |                                 w xY wNr   )socketrF   r*   r   r?   r@   )r'   r   rU   s      r   test_invalid_descriptorz!MmapTests.test_invalid_descriptor  s    
 MOO	""7++ . .IIahhjj"--. . . . . . . . . . . . . . . GGIIIIIAGGIIIIs.   B
 .A)B
 )A--B
 0A-1B
 
B c                     t                                dd          5 }|                     |j                   d d d            n# 1 swxY w Y   |                     |j                   d S )Nr7   r   )r   assertFalseclosed
assertTruer   s     r   test_context_managerzMmapTests.test_context_manager  s    YYr2 	'!QX&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'!!!!!s   AA
Ac                 @   |                      t                    5 }t                              dd          5 }t          # 1 swxY w Y   	 d d d            n# 1 swxY w Y   |                     |j        t          d           |                     |j        d           d S )Nr7   r   z)wrong exception raised in context managerzcontext manager failed)rF   	Exceptionr   r*   assertIsInstance	exceptionr"  r!  )r'   excrU   s      r   test_context_manager_exceptionz(MmapTests.test_context_manager_exception  s    y)) 	S2r"" a        	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	cmWI	K 	K 	K":;;;;;s,   A?A	AA	AAAc                     t                                dd          }t          j        |          }|                      |            |           ~t	                       |                      |            d            d S )Nr7   r   )r   weakrefrefr   r   )r'   mmwrs      r   test_weakrefzMmapTests.test_weakref  sh    YYr2[__bbddBbbddD!!!!!r   c                    t                                dd          }|                     |                    d          d           |                     |                    d          d           |                     |                    d          d           |                     |                    d	          d
           d S )Nr7   r   r   r   r   r3   s   yzr0      pythonr5   )r   rC   r<   )r'   r-  s     r   0test_write_returning_the_number_of_bytes_writtenz:MmapTests.test_write_returning_the_number_of_bytes_written  s    YYr2#***$+++%!,,,),,a00000r   c                 (   t                                dd          }|                     |j                   |                    d           	 |                    d           n%# t
          $ r |                     d           Y nw xY w|                     |                    d          d           |                     t          |j
                   |                     t          |j        d           |                     t          |j        d	           d S )
Nr7   i    r  r   zresizing not supported   r   r6   ra   )r   r   r@   ro   rQ   rS   skipTestrC   rF   rP   r  rn   r<   r   s     r   test_resize_past_poszMmapTests.test_resize_past_pos  s    IIb$   	t	4HHTNNNN 	4 	4 	4MM233333	4S)))*ak222*alB777*agv66666s   A" "BBc                    t                                dd          }|                     t                    5  ||z    d d d            n# 1 swxY w Y   |                     t                    5  |dz   d d d            d S # 1 swxY w Y   d S )Nr7   r   r0   )r   rF   rm   r   s     r   test_concat_repeat_exceptionz&MmapTests.test_concat_repeat_exception  s   IIb"y)) 	 	EE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	 	EE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s#   AAA-B  BBc                    t                                dd          }|                     |j                   |                    d           |                                }|                     |           t          j                            d          r1| 	                    t          |j        dt          d                     d S d S )Nr7   r   r1  linuxr3   )r   r   r@   r<   r>   assertIsNonerp   rq   rr   rF   r*   rE   )r'   r-  results      r   test_flush_return_valuez!MmapTests.test_flush_return_value  s     YYr2!!!
&!!!<""7++ 	D grxC	NNCCCCC	D 	Dr   c           
      0   t          j        d          }t          j        d          }d}t          d |D                       }t          ||          D ]@\  }}d|z  }||z
  }d}	d|dz  |d	z  |d
z  f}
t	          t
          d          5 }|                    |           |                                 t          j	        |	|
          D ]\  }}t          t          |          }t                              |                                |||          5 }|                    |           |                    t          |                    }|                     |           |                     |                    d          |           |                     |                    d          t'          |                     |                     |                    d          t'          |                     |                     |                    d          t'          |                     d d d            n# 1 swxY w Y   |                    t          |                    }|                     |           	 d d d            n# 1 swxY w Y   Bd S )Nzr<mmap.mmap closed=False, access=(?P<access>\S+), length=(?P<length>\d+), pos=(?P<pos>\d+), offset=(?P<offset>\d+)>z<mmap.mmap closed=True>)2   r   r  i@B i c              3   T   K   | ]#}|d z  t           j        z  t           j        z  V  $dS )r0   N)r   r   ).0rz   s     r   	<genexpr>z&MmapTests.test_repr.<locals>.<genexpr>  sU       N N9@ !A)CC45 N N N N N Nr   r]   )ACCESS_DEFAULTrl   ru   rt   r   r   r   rf   r   )r_   r   r_   r   posr   )rJ   compiletuplezipr;   r
   r<   r>   r   r   ry   r   r?   rN   rW   reprassertIsNotNonerC   grouprA   )r'   open_mmap_repr_patclosed_mmap_repr_patmapsizesr   r   rz   r   r   accesses	positionsr{   r_   rD  accintr-  rW   s                    r   	test_reprzMmapTests.test_repr  s
   Z'( (  "z*DEE: N NDLN N N N N"7H55 	0 	0OFG'>Dv%F7HFBJ	619=Ife$$ 0


#,#4Xy#I#I 0 0KFC$T622F299;;#)*0*0 # 2 2 
M 68 2 8 8b B B,,U333((X)>)>GGG((X)>)>FLLL((U););SXXFFF((X)>)>FLLL
M 
M 
M 
M 
M 
M 
M 
M 
M 
M 
M 
M 
M 
M 
M 166tBxx@@E((////00 0 0 0 0 0 0 0 0 0 0 0 0 0 0	0 	0s8   
B
J	DH8	,J	8H<<J	?H< <J		J	J	madvisezneeds madvisec                 *   dt           z  }t                              d|          }|                     t          d          5  |                    t          j        |           d d d            n# 1 swxY w Y   |                     t          d          5  |                    t          j        d           d d d            n# 1 swxY w Y   |                     t          d          5  |                    t          j        dd           d d d            n# 1 swxY w Y   |                     t          d          5  |                    t          j        t           t          j                   d d d            n# 1 swxY w Y   | 	                    |                    t          j                  d            | 	                    |                    t          j        t                     d            | 	                    |                    t          j        t           |          d            | 	                    |                    t          j        dd          d            | 	                    |                    t          j        d|          d            d S )Nr0   r7   zmadvise start out of boundszmadvise length invalidr   zmadvise length too large)
r=   r   r   rP   rR  MADV_NORMALr   rp   r   rC   )r'   rR   rU   s      r   test_madvisezMmapTests.test_madvise0  s   8|IIb$##J0MNN 	. 	.IId&---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.##J0MNN 	, 	,IId&+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,##J0HII 	/ 	/IId&2...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/##M3MNN 	? 	?IId&#+>>>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?4#344d;;;4#3X>>EEE4#3XtDDdKKK4#3Q::DAAA4#3Q==tDDDDDsH   !A..A25A2!CCC'"DDD;1E88E<?E<c                 j   t           }d|z  }t          d t          |          D                       }t                              d|          }||dd<   |                    |           |                     t          |          |           |                     |d|         |d|                    dS )zIf the mmap is backed by the pagefile ensure a resize up can happen
        and that the original data is still in place
        r0   c              3   >   K   | ]}t          j        d           V  dS r   Nr   getrandbitsrA  r   s     r   rB  zCMmapTests.test_resize_up_when_mapped_to_pagefile.<locals>.<genexpr>J  -      FFqV'**FFFFFFr   r7   Nr=   r   r   r   rQ   rC   rE   r'   
start_sizenew_sizer   rU   s        r   &test_resize_up_when_mapped_to_pagefilez0MmapTests.test_resize_up_when_mapped_to_pagefileC  s    
 
z>FFE*4E4EFFFFFIIb*%%!!!	Q***;J;kzk):;;;;;r   c                 j   t           }|dz  }t          d t          |          D                       }t                              d|          }||dd<   |                    |           |                     t          |          |           |                     |d|         |d|                    dS )zIf the mmap is backed by the pagefile ensure a resize down up can happen
        and that a truncated form of the original data is still in place
        r0   c              3   >   K   | ]}t          j        d           V  dS rX  rY  r[  s     r   rB  zEMmapTests.test_resize_down_when_mapped_to_pagefile.<locals>.<genexpr>Y  r\  r   r7   Nr]  r^  s        r   (test_resize_down_when_mapped_to_pagefilez2MmapTests.test_resize_down_when_mapped_to_pagefileR  s    
 
?FFE*4E4EFFFFFIIb*%%!!!	Q***9H9tIXI77777r   c                    dt           z  }t           }t          t          d          }|                    |           	 t                              |                                |          }t                              |                                |          }|                     t                    5  |                    |           ddd           n# 1 swxY w Y   |                     t                    5  |                    |           ddd           n# 1 swxY w Y   |	                                 |                    |           | 
                    |                                |           | 
                    t          j        |                                          j        |           |	                                 dS # |	                                 w xY w)zqIf more than one mapping is held against a named file on Windows, neither
        mapping can be resized
        r0   r   N)r=   r;   r
   rs   r   r?   rF   r*   rQ   r@   rC   rR   r#   statst_size)r'   r_  reduced_sizerT   r  r  s         r   +test_resize_fails_if_mapping_held_elsewherez5MmapTests.test_resize_fails_if_mapping_held_elsewherea  s   
 \
	

:	188::z22B188::z22B""7++ ( (		,'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (""7++ ( (		,'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (HHJJJIIl###RWWYY555RWQXXZZ008,GGGGGIIIIIAGGIIIIsU   A4G 1CG CG CG 8DG DG !D"BG G!c                    dt           z  }t           }t                      }d}t          d t          |          D                       }t                              d||          }t                              d||          }||d|<   |                     |d|         |           |                     t                    5  |                    |           ddd           n# 1 swxY w Y   |                     |	                                |           |                     |d|         |           |                     |d|         |           dS )zIf a more than one mapping exists of the same name, none of them can
        be resized: they'll raise an Exception and leave the original mapping intact
        r0   r   c              3   >   K   | ]}t          j        d           V  dS rX  rY  r[  s     r   rB  zUMmapTests.test_resize_succeeds_with_error_for_second_named_mapping.<locals>.<genexpr>  s-      GGqV'**GGGGGGr   r7   r  N)
r=   r   r   r   r   rC   rF   r*   rQ   rR   )r'   r_  rh  r  data_lengthr   r  r  s           r   8test_resize_succeeds_with_error_for_second_named_mappingzBMmapTests.test_resize_succeeds_with_error_for_second_named_mappingy  s~   
 \
!##GGE+4F4FGGGGGYYr:wY77YYr:wY77<K<L[L)4000w'' 	$ 	$IIl###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$J///L[L)4000L[L)400000s   C##C'*C'c           	      b
    G d d          }t           j        t           j        t           j        t           j        g}t           j        t           j        t           j        g}|D ]} ||          5 \  }}|                     t          d          5  | |                      ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y    ||          5 \  }}|                     t          d          5  | |            d          ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y    ||          5 \  }}|                     t          d          5  | |            dd          ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y    ||          5 \  }}|                     t          d          5  |d |            d          ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y    ||          5 \  }}|                     t          d          5  |                     |                       ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y    ||          5 \  }}|                     t          d          5  |                    dd	 |                       ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |D ]+} ||          5 \  }}|                     t          d          5  d
| |            d<   ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y    ||          5 \  }}|                     t          d          5  d| |            dd<   ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y    ||          5 \  }}|                     t          d          5  d|d |            d<   ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y    ||          5 \  }}|                     t          d          5  |	                    d	d |                       ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y    ||          5 \  }}|                     t          d          5  |
                     |                       ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   -dS )zj
        gh-103987: Test that mmap objects raise ValueError
                for closed mmap files
        c                   "    e Zd ZddZd Zd ZdS )KMmapTests.test_mmap_closed_by_int_scenarios.<locals>.MmapClosedByIntContextreturnNc                     || _         d S r"   r^   )r'   r_   s     r   __init__zTMmapTests.test_mmap_closed_by_int_scenarios.<locals>.MmapClosedByIntContext.__init__  s    $r   c                 Z   t          t          d          | _        | j                            t	          j        d                     | j                                         t                              | j                                        d| j	                   G fdd          }|fS )Nr   r   r^   c                       e Zd Z fdZdS )`MmapTests.test_mmap_closed_by_int_scenarios.<locals>.MmapClosedByIntContext.__enter__.<locals>.Xc                 0                                      dS r  )r@   r   s    r   	__index__zjMmapTests.test_mmap_closed_by_int_scenarios.<locals>.MmapClosedByIntContext.__enter__.<locals>.X.__index__  s    			!rr   N)r   r   r   rx  )rU   s   r   Xrv    s.        " " " " " " "r   ry  )
r;   r
   rT   r<   r   	randbytesr>   r   r?   r_   )r'   ry  rU   s     @r   	__enter__zUMmapTests.test_mmap_closed_by_int_scenarios.<locals>.MmapClosedByIntContext.__enter__  s    fe,,V-c22333IIdfmmoos4;IGG" " " " " " " " " "
 1vr   c                 8    | j                                          d S r"   )rT   r@   )r'   exc_type	exc_value	tracebacks       r   __exit__zTMmapTests.test_mmap_closed_by_int_scenarios.<locals>.MmapClosedByIntContext.__exit__  s    r   )rq  N)r   r   r   rs  r{  r  r   r   r   MmapClosedByIntContextrp    sF        % % % %      r   r  zmmap closed or invalidN   r0   r      1r3   s
   1111111111s   11111)r   rl   rt   ru   rC  r   rP   ro   rD   r   rn   )r'   r  read_access_modeswrite_access_modesr_   rU   ry  s          r   !test_mmap_closed_by_int_scenariosz+MmapTests.test_mmap_closed_by_int_scenarios  s
   	 	 	 	 	 	 	 	, 	
 
 ( 	) 	)F''// 6Aq++J8PQQ  aaccFF                             ('//  6Aq++J8PQQ    aaccBhKK                                                           ('// $6Aq++J8PQQ $ $aaccBlOO$ $ $ $ $ $ $ $ $ $ $ $ $ $ $$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ ('// %6Aq++J8PQQ % %b1133m$$% % % % % % % % % % % % % % %% % % % % % % % % % % % % % % ('//  6Aq++J8PQQ    FF1133KKK                                                           ('// )6Aq++J8PQQ ) )FF4AACC((() ) ) ) ) ) ) ) ) ) ) ) ) ) )) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) 	& 	&F''// ,6Aq++J8PQQ , ,"+AaaccBhK, , , , , , , , , , , , , , ,, , , , , , , , , , , , , , , ('// /6Aq++J8PQQ / /&.AaaccBlO/ / / / / / / / / / / / / / // / / / / / / / / / / / / / / ('// 06Aq++J8PQQ 0 0'/Ab1133m$0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ('// &6Aq++J8PQQ & &FF1a%%%& & & & & & & & & & & & & & && & & & & & & & & & & & & & & ('// &6Aq++J8PQQ & &LL%%%& & & & & & & & & & & & & & && & & & & & & & & & & & & & &#	& 	&sR  /CB+C+B//C2B/3CC		C	D-7D
D-DD-DD--D1	4D1	F"F6FFF	F
FF	 F	/HG."H.G22H5G26HH		H		I;:I$I;$I((I;+I(,I;;I?	I?	K30 KK3K  K3#K $K33K7	:K7	M"/M?M"MM"MM""M&	)M&	8ON4(O4N88O;N8<OO	O	!P4 PP4P!!P4$P!%P44P8	;P8	
R,) R	R,RR,RR,,R0	3R0	T"!T?T"TT"TT""T&	)T&	N)7r   r   r   r(   r+   rZ   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   
skipUnlesshasattrr   r   r   r  r  r#   rv   r  r   r  r  r  r#  r)  r/  r2  r6  r8  r=  rQ  rU  ra  rd  ri  rm  r  r   r   r   r    r        sK           \ \ \|{ { {z8 8 8  $K K K.' ' ' 8 8 8$  ; ; ;
E 
E 
E1 1 1- - -^
& 
& 
&; ; ;*8 8 89 9 95 5 5() ) )< < <7 7 7r   X{335KLL9 9 ML9+ + + 6  6  6D   XD*<==  >=6 XD*<==? ? >= \? XD*<==  >=4 XD*<==	 	 >=	" " "
< < <" " "1 1 17 7 7  D D D"0 "0 "0H XI66HHE E IHE$ XD*<==< < >=< XD*<==8 8 >=8 XD*<==  >=. XD*<==1 1 >=1(T& T& T& T& T&r   r    c                       e Zd Zd Zd Zd Zd Zd Zd Z e	j
        ej        ek    d          d             Z e	j
        ej        ek    d          d	             Zd
S )LargeMmapTestsc                 .    t          t                     d S r"   r   r
   r&   s    r   r(   zLargeMmapTests.setUp      vr   c                 .    t          t                     d S r"   r  r&   s    r   r+   zLargeMmapTests.tearDown  r  r   c                    t           j        d d         dk    st           j        dk    r t          ddt          d          z             t	          t
          d          }	 |                    |           |                    |           |                                 n\# t          t          t          f$ rB 	 |                                 n# t          t          f$ r Y nw xY wt          j        d          w xY w|S )	Nr/   rd   darwin	largefilez-test requires %s bytes and a long time to run        r   z*filesystem does not have largefile support)rp   rq   r   rA   r;   r
   rN   r<   r>   r*   r   rP   r@   r   r   )r'   
num_zeroestailrT   s       r   _make_test_filezLargeMmapTests._make_test_file  s   <u$$(@(@[?#kBRBRRT T T		RFF:GGDMMMGGIIII
3 	R 	R 	R				]+   #$PQQQ	R s0   >B C76C
C7CC7CC7c                 @   |                      dd          5 }t                              |                                ddt          j                  5 }|                     |d         d           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nl        r   l        r   i    )r  r   r?   rl   rC   r'   rT   rU   s      r   test_large_offsetz LargeMmapTests.test_large_offset  s   !!+t44 	3188::qTEUVV 3Z[  9r2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3s5   ;BA;/B;A?	?BA?	BBBc                 "   |                      dd          5 }t          j        dk     r|                     t                    5  t
                              |                                dt
          j                   d d d            n# 1 swxY w Y   |                     t                    5  t
                              |                                dt
          j                   d d d            n# 1 swxY w Y   t
                              |                                dt
          j                  5 }| 	                    |
                                d           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nl    r  r  r^   r   r   )r  rp   r   rF   r   r   r?   rl   rP   rC   rR   r  s      r   test_large_filesizez"LargeMmapTests.test_large_filesize  sU   !!+t44 		8{[(( &&}55 P PIIahhjj+d>NIOOOP P P P P P P P P P P P P P P&&z22 F FIIahhjj!D4DIEEEF F F F F F F F F F F F F F F188::wt7GHH 8A  ;7778 8 8 8 8 8 8 8 8 8 8 8 8 8 8		8 		8 		8 		8 		8 		8 		8 		8 		8 		8 		8 		8 		8 		8 		8 		8 		8 		8s}   +F:B<FB	FB	F-:C3'F3C7	7F:C7	;<F7)E, F,E0	0F3E0	4FFFc                    d}|t          |          dz  z
  }|t          |          z   }|                     ||          5 }t                              |                                dt          j                  5 }|                     |||         |           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Ns     DEARdear  r0   r   r^   )rE   r  r   r?   rl   rC   )r'   boundaryr  rX   rY   rT   rU   s          r   _test_around_boundaryz$LargeMmapTests._test_around_boundary  s5   3t99>)c$ii!!%.. 	5!188::q1ABB 5a  59t4445 5 5 5 5 5 5 5 5 5 5 5 5 5 5	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s6    :B=:B%B=%B)	)B=,B)	-B==CCz!test cannot run on 32-bit systemsc                 :    |                      t                     d S r"   )r  r   r&   s    r   test_around_2GBzLargeMmapTests.test_around_2GB      ""3'''''r   c                 :    |                      t                     d S r"   )r  r   r&   s    r   test_around_4GBzLargeMmapTests.test_around_4GB  r  r   N)r   r   r   r(   r+   r  r  r  r  r   r  rp   r   r   r  r  r   r   r   r  r    s              "3 3 3

8 
8 
85 5 5 Xs*,OPP( ( QP( Xs*,OPP( ( QP( ( (r   r  __main__)r   ) test.supportr   r   r   r   r   r   test.support.import_helperr	   test.support.os_helperr
   r   r   r#   rJ   r   r   r  r   rp   r+  r   r=   getpidr   r   r   TestCaser    r  r   mainr   r   r   <module>r     s                  5 4 4 4 4 4 1 1 1 1 1 1 1 1  				 				        



  }V=2929;;222( ( ( (  N
(
L
M
MMB& B& B& B& B&! B& B& B&H:( :( :( :( :(X& :( :( :(z zHMOOOOO r   