Your IP : 216.73.216.85


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_fcntl.cpython-35.opt-2.pyc



���]d�@s�ddlZddlZddlZddlZddlZddlmZmZmZm	Z	m
Z
mZe
d�Zdd�Z
e
�ZGdd�d�ZGdd	�d	ej�Zd
d�Zedkr�e�dS)
�N)�verbose�TESTFN�unlink�run_unittest�
import_module�cpython_only�fcntlcCsnytjWntk
r%d}YnXd}tjjd�sMtjdkr�tjd�d	krqd}d
}nd}d}tj|||dd
d
d
t	j
d
�}n�tjjd�r�tjdd
d
d
t	j
d
d
�}netjdkrtjdt	j
d
d
d
d
d
d
�}n,tjd|dt	j
d
d
d
d
d
�}|rjtrjt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�struct�calcsize�packrZF_WRLCKr�print�repr)Z	start_lenZoff_tZpid_t�lockdata�r!�//opt/alt/python35/lib64/python3.5/test_fcntl.py�get_lockdatas.
	'*,r#c@s(eZdZdd�Zdd�ZdS)�BadFilecCs
||_dS)N)�fn)�selfr%r!r!r"�__init__1szBadFile.__init__cCs|jS)N)r%)r&r!r!r"�fileno3szBadFile.filenoN)�__name__�
__module__�__qualname__r'r(r!r!r!r"r$0sr$c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zedd��Z	e
jej
�jd
�o�ej�dkd�dd��Zdd�Zedd��ZdS)�	TestFcntlcCs
d|_dS)N)�f)r&r!r!r"�setUp8szTestFcntl.setUpcCs1|jr#|jjr#|jj�tt�dS)N)r-�closed�closerr)r&r!r!r"�tearDown;s
zTestFcntl.tearDowncCs�ttd�|_tj|jj�tjtj�}trIt	d|�tj|jj�tj
t�}tr�t	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_SETLKWr rr0)r&�rvr!r!r"�test_fcntl_fileno@s$
!zTestFcntl.test_fcntl_filenocCs�ttd�|_tj|jtjtj�}trCtd|�tj|jtj	t
�}trwtdt|��|jj�dS)Nr2z#Status from fcntl with O_NONBLOCK: z!String from fcntl with F_SETLKW: )
r3rr-rr4rr5rrr6r rr0)r&r7r!r!r"�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�
ValueErrorrr4rr5r$�	TypeError)r&r!r!r"�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_MINr:)
�	_testcapirArBr=�
OverflowErrorrr4rr5r$)r&rArBr!r!r"�test_fcntl_bad_file_overflow`s$*$z&TestFcntl.test_fcntl_bad_file_overflowZarmZLinuxz2ARM Linux returns EINVAL for F_NOTIFY DN_MULTISHOTcCs�ytj}tj}Wntk
r7|jd�YnXtjtjjtjj	t
��tj�}ztj|||�Wdtj|�XdS)Nz$F_NOTIFY or DN_MULTISHOT unavailable)
rZF_NOTIFYZDN_MULTISHOTrZskipTestrr3�path�dirname�abspathr�O_RDONLYr0)r&�cmd�flags�fdr!r!r"�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+r:r;r<)
r3rr-r(r�flock�LOCK_SHZLOCK_UNZLOCK_NBZLOCK_EXr=r>r?)r&r(r!r!r"�
test_flockszTestFcntl.test_flockcCs3ddl}|jttj|jdtj�dS)Nrr:)rCr=rDrrNrArO)r&rCr!r!r"�test_flock_overflow�szTestFcntl.test_flock_overflowN)r)r*r+r.r1r8r9r@rrE�unittestZskipIfr�machiner�systemrMrPrQr!r!r!r"r,6s

$r,cCstt�dS)N)rr,r!r!r!r"�	test_main�srU�__main__)rrrrrRZtest.supportrrrrrrrr#r r$ZTestCaser,rUr)r!r!r!r"�<module>s.	^