Your IP : 216.73.216.52


Current Path : /opt/alt/python310/lib64/python3.10/test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/__pycache__/test_fcntl.cpython-310.pyc

o

0�i��@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
ddlmZddl
mZmZed�Zdd	�Ze�ZGd
d�d�Zdd
�Zdd�ZGdd�dej�Zedkr_e��dSdS)z%Test program for the fcntl C module.
�N)�Process)�verbose�cpython_only)�
import_module)�TESTFN�unlink�fcntlc
CsztjWntyd}Ynwd}tj�d�stjdkr@t�d�dkr*d}d}nd}d}t�|||d	d
d
d
t	j
d
�}n6tj�d�rSt�dd
d
d
t	j
d
d
�}n#tjd
vrft�dt	j
d
d
d
d
d
d
�}nt�d	|d	t	j
d
d
d
d
d
�}|r�tr�t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�6/opt/alt/python310/lib64/python3.10/test/test_fcntl.py�get_lockdatas2
�
�
 rc@seZdZdd�Zdd�ZdS)�BadFilecCs
||_dS�N��fn)�selfrrrr�__init__3�
zBadFile.__init__cCs|jSrr�rrrr�fileno5szBadFile.filenoN)�__name__�
__module__�__qualname__rr"rrrrr2srcCsVt|d�}z zt�||�Wn	tyYnwW|��dSW|��dS|��w�N�wb+)�openr�lockf�BlockingIOError�close�Zfname�cmd�frrr�try_lockf_on_other_process_fail8s
���r/cCs0t|d�}t�||�t�|tj�|��dSr&)r(rr)�LOCK_UNr+r,rrr�try_lockf_on_other_processAs
r1c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zedd��Z	e
�e�
��d
�o,e��dkd�dd��Zdd�Ze
�e��dkd�dd��Ze
�e��dkd�dd��Zedd��Ze
�ejdkd�dd��Ze
�eed �oqeed!�d"�d#d$��Zd%S)&�	TestFcntlcCs
d|_dSr)r.r!rrr�setUpIr zTestFcntl.setUpcCs$|jr|jjs|j��tt�dSr)r.�closedr+rrr!rrr�tearDownLs
zTestFcntl.tearDowncCshttd�|_t�|j��tjtj�}trt	d|�t�|j��tj
t�}tr-t	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+�rZrvrrr�test_fcntl_filenoQs
zTestFcntl.test_fcntl_filenocCs`ttd�|_t�|jtjtj�}trtd|�t�|jtj	t
�}tr)tdt|��|j��dSr6)
r(rr.rr8r
r9rrr:rrr+r;rrr�test_fcntl_file_descriptor\s
z$TestFcntl.test_fcntl_file_descriptorcCs�|�t��t�dtjtj�Wd�n1swY|�t��t�td�tjtj�Wd�n1s9wY|�t��t�dtjtj�Wd�n1sWwY|�t��t�td�tjtj�Wd�dS1sxwYdS)N����spam)�assertRaises�
ValueErrorrr8r
r9r�	TypeErrorr!rrr�test_fcntl_bad_filegs���"�zTestFcntl.test_fcntl_bad_filecCsddlm}m}|�t��t�|dtjtj�Wd�n1s#wY|�t��t�t	|d�tjtj�Wd�n1sEwY|�t��t�|dtjtj�Wd�n1sewY|�t��t�t	|d�tjtj�Wd�dS1s�wYdS)Nr)�INT_MAX�INT_MIN�)
�	_testcapirDrEr@�
OverflowErrorrr8r
r9r)rrDrErrr�test_fcntl_bad_file_overflowqs���"�z&TestFcntl.test_fcntl_bad_file_overflowZarmZLinuxz2ARM Linux returns EINVAL for F_NOTIFY DN_MULTISHOTc	Csxztj}tj}Wnty|�d�Ynwt�tj�tj�	t
��tj�}zt�|||�Wt�|�dSt�|�w)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_EXr@rArB)rr"rrr�
test_flock�s
zTestFcntl.test_flockZAIXzAIX returns PermissionErrorcC�httd�|_tjtjB}t�|j|�ttt|fd�}|�	�|�
�t�|jtj�|�|j
d�dS�Nr')�target�argsr)r(rr.rrTrSr)rr/�start�joinr0�assertEqual�exitcode�rr-�prrr�test_lockf_exclusive��zTestFcntl.test_lockf_exclusivecCrVrW)r(rr.rrRrSr)rr1rZr[r0r\r]r^rrr�test_lockf_share�razTestFcntl.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)Nr7zutf-8)
r(rr.r
rJrL�encoderr"Z	F_GETPATH�bytes�lenr\)rZexpected�resrrr�test_fcntl_f_getpath�szTestFcntl.test_fcntl_f_getpath�F_SETPIPE_SZ�F_GETPIPE_SZzAF_SETPIPE_SZ and F_GETPIPE_SZ are not available on all platforms.c	Cs�t��\}}z4t�|tj�}|d}|dkrt�d��t�|tj|�|�t�|tj�|�Wt�|�t�|�dSt�|�t�|�w)N�iz+default pipesize too small to perform test.)	r
�piperrj�unittestZSkipTestrir\r+)rZtest_pipe_rZtest_pipe_wZpipesize_defaultZpipesizerrr�test_fcntl_f_pipesize�s ��

�zTestFcntl.test_fcntl_f_pipesizeN)r#r$r%r3r5r<r=rCrrIrmZskipIfr�machiner�systemrPrUr`rbrcrrhZ
skipUnless�hasattrrrnrrrrr2Gs6

�






�r2�__main__)�__doc__rr
rrrmZmultiprocessingrZtest.supportrrZtest.support.import_helperrZtest.support.os_helperrrrrrrr/r1ZTestCaser2r#�mainrrrr�<module>s*	�