Your IP : 216.73.216.60


Current Path : /opt/alt/python36/lib64/python3.6/test/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/test/__pycache__/test_fcntl.cpython-36.pyc

3

� fd�@s�dZddlZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZed�Z
dd�Ze�ZGdd�d�ZGd	d
�d
ej�Zdd�Zed
kr�e�dS)z%Test program for the fcntl C module.
�N)�verbose�TESTFN�unlink�run_unittest�
import_module�cpython_only�fcntlcCsy
tjWntk
r"d}YnXd}tjjd�s>tjdkr�tjd�d	krVd}d
}nd}d}tj|||dd
d
d
t	j
d
�}nltjjd�r�tjdd
d
d
t	j
d
d
�}nFtjdkr�tjdt	j
d
d
d
d
d
d
�}n tjd|dt	j
d
d
d
d
d
�}|�rt�rtdt
|��|S)NZllZqq�netbsd�freebsd�openbsd�bsdos�darwin�l��iZlxxxxZhhrZgnukfreebsdZqqihhi�aix3�aix4�hp-uxB�	unixware7Zhhllliiz
struct.pack: )r	r
rr)rrrr)�os�O_LARGEFILE�AttributeError�sys�platform�
startswith�structZcalcsizeZpackrZF_WRLCKr�print�repr)Z	start_lenZoff_tZpid_t�lockdata�r�4/opt/alt/python36/lib64/python3.6/test/test_fcntl.py�get_lockdatas.



 r!c@seZdZdd�Zdd�ZdS)�BadFilecCs
||_dS)N)�fn)�selfr#rrr �__init__1szBadFile.__init__cCs|jS)N)r#)r$rrr �fileno3szBadFile.filenoN)�__name__�
__module__�__qualname__r%r&rrrr r"0sr"c@s~eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zedd��Z	e
jej
�jd
�oXej�dkd�dd��Zdd�Zedd��ZdS)�	TestFcntlcCs
d|_dS)N)�f)r$rrr �setUp8szTestFcntl.setUpcCs&|jr|jjr|jj�tt�dS)N)r+�closed�closerr)r$rrr �tearDown;s
zTestFcntl.tearDowncCshttd�|_tj|jj�tjtj�}tr2t	d|�tj|jj�tj
t�}trZt	dt|��|jj
�dS)N�wbz#Status from fcntl with O_NONBLOCK: z!String from fcntl with F_SETLKW: )�openrr+rr&�F_SETFLr�
O_NONBLOCKrr�F_SETLKWrrr.)r$�rvrrr �test_fcntl_fileno@s
zTestFcntl.test_fcntl_filenocCs`ttd�|_tj|jtjtj�}tr.td|�tj|jtj	t
�}trRtdt|��|jj�dS)Nr0z#Status from fcntl with O_NONBLOCK: z!String from fcntl with F_SETLKW: )
r1rr+rr2rr3rrr4rrr.)r$r5rrr �test_fcntl_file_descriptorKs
z$TestFcntl.test_fcntl_file_descriptorc Cs�|jt��tjdtjtj�WdQRX|jt��tjtd�tjtj�WdQRX|jt��tjdtjtj�WdQRX|jt��tjtd�tjtj�WdQRXdS)N��spam���r:)�assertRaises�
ValueErrorrr2rr3r"�	TypeError)r$rrr �test_fcntl_bad_fileVs zTestFcntl.test_fcntl_bad_filec Cs�ddlm}m}|jt��tj|dtjtj�WdQRX|jt�� tjt	|d�tjtj�WdQRX|jt��tj|dtjtj�WdQRX|jt�� tjt	|d�tjtj�WdQRXdS)Nr)�INT_MAX�INT_MINr8)
�	_testcapir?r@r;�
OverflowErrorrr2rr3r")r$r?r@rrr �test_fcntl_bad_file_overflow`s $ z&TestFcntl.test_fcntl_bad_file_overflowZarmZLinuxz2ARM Linux returns EINVAL for F_NOTIFY DN_MULTISHOTcCsrytj}tj}Wntk
r.|jd�YnXtjtjjtjj	t
��tj�}ztj|||�Wdtj|�XdS)Nz$F_NOTIFY or DN_MULTISHOT unavailable)
rZF_NOTIFYZDN_MULTISHOTrZskipTestrr1�path�dirname�abspathr�O_RDONLYr.)r$�cmd�flags�fdrrr �test_fcntl_64_bitms
zTestFcntl.test_fcntl_64_bitcCs�ttd�|_|jj�}tj|tj�tj|tj�tj|jtjtjB�tj|jtj�tj|tj	�tj|tj�|j
ttjdtj�|j
ttjdtj�dS)Nzwb+r8r9r:)
r1rr+r&r�flock�LOCK_SHZLOCK_UNZLOCK_NBZLOCK_EXr;r<r=)r$r&rrr �
test_flocks
zTestFcntl.test_flockcCs&ddl}|jttj|jdtj�dS)Nrr8)rAr;rBrrLr?rM)r$rArrr �test_flock_overflow�szTestFcntl.test_flock_overflowN)r'r(r)r,r/r6r7r>rrC�unittestZskipIfr�machiner�systemrKrNrOrrrr r*6s

r*cCstt�dS)N)rr*rrrr �	test_main�srS�__main__)�__doc__rrrrrPZtest.supportrrrrrrrr!rr"ZTestCaser*rSr'rrrr �<module>s ^