Your IP : 216.73.216.213


Current Path : /proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/test_fcntl.cpython-34.pyc

�
f fd�@s�dZddlZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZed�Z
dd�Ze�ZGdd�d�ZGd	d
�d
ej�Zdd�Zed
kr�e�ndS)z%Test program for the fcntl C module.
�N)�verbose�TESTFN�unlink�run_unittest�
import_module�cpython_only�fcntlcCstytjWntk
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
�}|rptrptdt
|��qpn|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/python34/lib64/python3.4/test/test_fcntl.py�get_lockdatas.
	'*,r!c@s(eZdZdd�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"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$rrr �setUp8szTestFcntl.setUpcCs4|jr&|jjr&|jj�ntt�dS)N)r+�closed�closerr)r$rrr �tearDown;szTestFcntl.tearDowncCs�ttd�|_tj|jj�tjtj�}trLt	d|�ntj|jj�tj
t�}tr�t	dt|��n|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�}trFtd|�ntj|jtj	t
�}tr}tdt|��n|jj�dS)Nr0z#Status from fcntl with O_NONBLOCK: z!String from fcntl with F_SETLKW: )
r1rr+rr2rr3rrr4rrr.)r$r5rrr �test_fcntl_file_descriptorKsz$TestFcntl.test_fcntl_file_descriptorcCs�|jt��tjdtjtj�WdQX|jt��$tjtd�tjtj�WdQX|jt��tjdtjtj�WdQX|jt��$tjtd�tjtj�WdQXdS)N��spam���r:)�assertRaises�
ValueErrorrr2rr3r"�	TypeError)r$rrr �test_fcntl_bad_fileVs%zTestFcntl.test_fcntl_bad_filecCs�ddlm}m}|jt��"tj|dtjtj�WdQX|jt��(tjt	|d�tjtj�WdQX|jt��"tj|dtjtj�WdQX|jt��(tjt	|d�tjtj�WdQXdS)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_MULTISHOTcCs�ytj}tj}Wntk
r7|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_flockszTestFcntl.test_flockcCs3ddl}|jttj|jdtj�dS)Nrr8)rAr;rBrrLr?rM)r$rArrr �test_flock_overflow�szTestFcntl.test_flock_overflowN)r'r(r)r,r/r6r7r>rrC�unittestZskipIfr�machiner�systemrKrNrOrrrr r*6s

$r*cCstt�dS)N)rr*rrrr �	test_main�srS�__main__)�__doc__rrrrrPZtest.supportrrrrrrrr!rr"ZTestCaser*rSr'rrrr �<module>s.	^