Your IP : 216.73.216.213


Current Path : /opt/alt/python39/lib64/python3.9/test/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/__pycache__/test_fcntl.cpython-39.opt-1.pyc

a

XC?h��@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: )�os�O_LARGEFILE�AttributeError�sys�platform�
startswith�structZcalcsizeZpackrZF_WRLCKr�print�repr)Z	start_lenZoff_tZpid_t�lockdata�r�4/opt/alt/python39/lib64/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__rr!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
r0c@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��dSr5)
r'rr-rr7r
r8rrr9rrr*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�
ValueErrorrr7r
r8r�	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�)
�	_testcapirDrEr@�
OverflowErrorrr7r
r8r)rrDrErrr�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_SHr/�LOCK_NB�LOCK_EXr@rArB)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-rrTrSr(rr.�start�joinr/�assertEqual�exitcode�rr,�prrr�test_lockf_exclusive�szTestFcntl.test_lockf_exclusivecCshttd�|_tjtjB}t�|j|�ttt|fd�}|�	�|�
�t�|jtj�|�|j
d�dSrV)r'rr-rrRrSr(rr0rYrZr/r[r\r]rrr�test_lockf_share�szTestFcntl.test_lockf_sharecCs&ddl}|�ttj|jdtj�dS)NrrF)rGr@rHrrQrDrR)rrGrrr�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)Nr6zutf-8)
r'rr-r
rJrL�encoderr!Z	F_GETPATH�bytes�lenr[)rZexpected�resrrr�test_fcntl_f_getpath�szTestFcntl.test_fcntl_f_getpathN)r"r#r$r2r4r<r=rCrrI�unittestZskipIfr�machiner�systemrPrUr_r`rarrfrrrrr1Es*

�





r1�__main__)�__doc__rr
rrrgZmultiprocessingrZtest.supportrrrrrrrrrr.r0ZTestCaser1r"�mainrrrr�<module>s 	{