HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //usr/lib64/python3.9/site-packages/borg/testsuite/__pycache__/chunker_pytest.cpython-39.pyc
a

HZ�h.�@s8ddlmZddlZddlZddlZddlmZddlmZmZm	Z	m
Z
ddlTdZdeded	fdeded
fdeded	fded
ed
fgZ
deded
fdeded	fdeded
fded
ed	fgZdeded	fgZdeded
fgZd"dd�Zd#dd�Zdd�Zejje�dd�ej�dde
fdefdefdefg�dd���Zejje�dd�ej�dde
dd
fde
dd	fde
ed
fde
ed	fdedd
fdedd	fdeed
fdeed	fdedd
fdedd	fdeed
fdeed	fdedd
fdedd	fdeed
fdeed	fg�dd���Zd d!�ZdS)$�)�BytesION�)�cf�)�Chunker�ChunkerFixed�	sparsemap�
has_seek_hole)�*�TF���cCs�t|d��r}d}|r*|�d|�||7}|D]4\}}}|rL|�d|�n|�|tj�||7}q.|�|�Wd�n1s�0Ytj�|�|ks�J�dS)N�wbr�H�X)�open�write�seek�os�SEEK_CUR�truncate�path�getsize)�fnamer�header_size�fd�total�offset�size�is_data�r!�C/usr/lib64/python3.9/site-packages/borg/testsuite/chunker_pytest.py�make_sparsefile%s
(r#cCs\g}d}|r"|�d|�||7}|D]0\}}}|rD|�d|�n
|�|�||7}q&|S)Nrrr)�append)rr�resultrrrr r!r!r"�make_content5s

r&c
Cs�tsdSt����}tj�|d�}t|dtdfttdfg�t|d��^}z |�	dtj
�}|�	dtj�}Wn,ty�YWd�Wd�dS0Wd�n1s�0Y|dko�|tkWd�S1s�0YdS)NFZtest_sparserT�rb)
r	�tempfileZTemporaryDirectoryrr�joinr#�BSrr�	SEEK_HOLE�	SEEK_DATA�OSError)�tmpdir�fn�fZoffset_holeZoffset_datar!r!r"�fs_supports_sparseDs
>r1z fs does not support sparse files)�reasonzfname, sparse_mapZsparse1Zsparse2Z
onlysparseZ	notsparsecCsJdd�}dd�}t||�}t||�||�|ks6J�||�|ksFJ�dS)Nc	Ss<tj|tjd�}ztt|d��Wt�|�St�|�0dS)N)�flags)�fh)rr�O_RDONLY�listr�close)rr4r!r!r"�get_sparsemap_fh]s
�z(test_sparsemap.<locals>.get_sparsemap_fhcSs<t|d��}tt|d��Wd�S1s.0YdS)Nr')r)rr6r)rrr!r!r"�get_sparsemap_fddsz(test_sparsemap.<locals>.get_sparsemap_fd)�strr#)r.r�
sparse_mapr8r9r/r!r!r"�test_sparsemapTs	
r<z&fname, sparse_map, header_size, sparsecCs@dd�}t||�}t|||d�||||d�t||d�kdS)NcSsJtd||d�}t|d��}t|�|��Wd�S1s<0YdS)Nr)r�sparser')rrr�chunkify)rr=r�chunkerrr!r!r"�
get_chunks�sz(test_chunkify_sparse.<locals>.get_chunks)r)r=r)r:r#r&)r.rr;rr=r@r/r!r!r"�test_chunkify_sparsensrAcst�d�}d\��}td��|d�}t|�}t|�|��}|d=dd�|D�}t|�}t|�}t|�}t	�fdd	�|D��}	t	�fd
d	�|D��}
t
d|�d|�d
|�d|	�d|
��
�d|kr�dks�nJ�|d�ks�J�|d�ks�J�|	dks�J�|
dk�sJ�dS)Ni)�
��ri����cSsg|]}t|��qSr!)�len)�.0�chunkr!r!r"�
<listcomp>��z7test_buzhash_chunksize_distribution.<locals>.<listcomp>c3s|]}t|d�k�VqdS�rN��int�rGr)�min_expr!r"�	<genexpr>�rJz6test_buzhash_chunksize_distribution.<locals>.<genexpr>c3s|]}t|d�k�VqdSrKrLrN)�max_expr!r"rP�rJzcount: z min: z max: z min count: z max count: � �rrB)r�urandomrrrr>rF�min�max�sum�print)�data�maskr?r0�chunksZchunk_sizesZchunks_countZmin_chunksize_observedZmax_chunksize_observedZ	min_countZ	max_countr!)rQrOr"�#test_buzhash_chunksize_distribution�s,

��r\)r)r)�iorrr(Zpytestr?rrrrr	Z	constantsr*Zmap_sparse1Zmap_sparse2Z
map_notsparseZmap_onlysparser#r&r1ZmarkZskipifZparametrizer<rAr\r!r!r!r"�<module>sf�	�

�















�