Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_fcntl.cpython-39.pyc

a

��g��@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZmZm
Z
ed�Zdd�Ze�ZGdd	�d	�Zd
d�Zdd
�ZGdd�dej�Zedkr�e��dS)z%Test program for the fcntl C module.
�N)�Process)�verbose�TESTFN�unlink�
import_module�cpython_only�fcntlc
Cs
z
tjWnty d}Yn0d}tj�d�s<tjdkr�t�d�dkrTd}d}nd}d}t�|||d	d
d
d
t	j
d
�}nltj�d�r�t�dd
d
d
t	j
d
d
�}nFtjd
vr�t�dt	j
d
d
d
d
d
d
�}n t�d	|d	t	j
d
d
d
d
d
�}|�rt�rtdt
|��|S)NZllZqq)ZnetbsdZfreebsdZopenbsd�darwin�l��iZlxxxxZhhrZgnukfreebsdZqqihhi)zhp-uxBZ	unixware7Zhhllliiz
struct.pack: )�osZO_LARGEFILE�AttributeError�sys�platform�
startswith�struct�calcsize�packrZF_WRLCKr�print�repr)Z	start_lenZoff_tZpid_t�lockdata�r�+/usr/local/lib/python3.9/test/test_fcntl.py�get_lockdatas2

��
 rc@seZdZdd�Zdd�ZdS)�BadFilecCs
||_dS�N��fn)�selfrrrr�__init__1szBadFile.__init__cCs|jSrr�rrrr�fileno3szBadFile.filenoN)�__name__�
__module__�__qualname__r r"rrrrr0srcCsJt|d�}z0zt�||�Wnty.Yn0W|��n
|��0dS�N�wb+)�openr�lockf�BlockingIOError�close�Zfname�cmd�frrr�try_lockf_on_other_process_fail6s
r/cCs0t|d�}t�||�t�|tj�|��dSr&)r(rr)�LOCK_UNr+r,rrr�try_lockf_on_other_process?s
r1c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zedd��Z	e
�e�
��d
�oXe��dkd�dd��Zdd�Ze
�e��dkd�dd��Ze
�e��dkd�dd��Zedd��Ze
�ejdkd�dd��Zd S)!�	TestFcntlcCs
d|_dSr)r.r!rrr�setUpGszTestFcntl.setUpcCs$|jr|jjs|j��tt�dSr)r.�closedr+rrr!rrr�tearDownJs
zTestFcntl.tearDowncCshttd�|_t�|j��tjtj�}tr2t	d|�t�|j��tj
t�}trZt	dt|��|j�
�dS�N�wbz#Status from fcntl with O_NONBLOCK: z!String from fcntl with F_SETLKW: )r(rr.rr"�F_SETFLr
�
O_NONBLOCKrr�F_SETLKWrrr+�r�rvrrr�test_fcntl_filenoOs
zTestFcntl.test_fcntl_filenocCs`ttd�|_t�|jtjtj�}tr.td|�t�|jtj	t
�}trRtdt|��|j��dSr6)
r(rr.rr8r
r9rrr:rrr+r;rrr�test_fcntl_file_descriptorZs
z$TestFcntl.test_fcntl_file_descriptorcCs�|�t��"t�dtjtj�Wd�n1s20Y|�t��&t�td�tjtj�Wd�n1sr0Y|�t��"t�dtjtj�Wd�n1s�0Y|�t��&t�td�tjtj�Wd�n1s�0YdS)N����spam)�assertRaises�
ValueErrorrr8r
r9r�	TypeErrorr!rrr�test_fcntl_bad_filees040zTestFcntl.test_fcntl_bad_filecCsddlm}m}|�t��&t�|dtjtj�Wd�n1sF0Y|�t��*t�t	|d�tjtj�Wd�n1s�0Y|�t��&t�|dtjtj�Wd�n1s�0Y|�t��*t�t	|d�tjtj�Wd�n1�s0YdS)Nr)�INT_MAX�INT_MIN�)
�	_testcapirErFrA�
OverflowErrorrr8r
r9r)rrErFrrr�test_fcntl_bad_file_overflowos484z&TestFcntl.test_fcntl_bad_file_overflowZarmZLinuxz2ARM Linux returns EINVAL for F_NOTIFY DN_MULTISHOTc	Cszztj}tj}Wnty,|�d�Yn0t�tj�tj�	t
��tj�}zt�|||�Wt�|�nt�|�0dS)Nz$F_NOTIFY or DN_MULTISHOT unavailable)
rZF_NOTIFYZDN_MULTISHOTrZskipTestr
r(�path�dirname�abspathr�O_RDONLYr+)rr-�flags�fdrrr�test_fcntl_64_bit|s
zTestFcntl.test_fcntl_64_bitcCs�ttd�|_|j��}t�|tj�t�|tj�t�|jtjtjB�t�|jtj�t�|tj	�t�|tj�|�
ttjdtj�|�
ttjdtj�dS)Nr'r?r@)
r(rr.r"r�flock�LOCK_SHr0�LOCK_NB�LOCK_EXrArBrC)rr"rrr�
test_flock�s
zTestFcntl.test_flockZAIXzAIX returns PermissionErrorcCshttd�|_tjtjB}t�|j|�ttt|fd�}|�	�|�
�t�|jtj�|�|j
d�dS�Nr')�target�argsr)r(rr.rrUrTr)rr/�start�joinr0�assertEqual�exitcode�rr-�prrr�test_lockf_exclusive�szTestFcntl.test_lockf_exclusivecCshttd�|_tjtjB}t�|j|�ttt|fd�}|�	�|�
�t�|jtj�|�|j
d�dSrW)r(rr.rrSrTr)rr1rZr[r0r\r]r^rrr�test_lockf_share�szTestFcntl.test_lockf_sharecCs&ddl}|�ttj|jdtj�dS)NrrG)rHrArIrrRrErS)rrHrrr�test_flock_overflow�s�zTestFcntl.test_flock_overflowr	z$F_GETPATH is only available on macoscCsLttd�|_tj�t��d�}t�|j��tj	t
t|���}|�||�dS)Nr7zutf-8)
r(rr.r
rKrM�encoderr"Z	F_GETPATH�bytes�lenr\)rZexpected�resrrr�test_fcntl_f_getpath�szTestFcntl.test_fcntl_f_getpathN)r#r$r%r3r5r=r>rDrrJ�unittestZskipIfr�machiner�systemrQrVr`rarbrrgrrrrr2Es*

�





r2�__main__)�__doc__rr
rrrh�multiprocessingrZtest.supportrrrrrrrrrr/r1ZTestCaser2r#�mainrrrr�<module>s 	{

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists