Your IP : 3.144.99.39


Current Path : /lib64/python3.6/site-packages/systemd/test/__pycache__/
Upload File :
Current File : //lib64/python3.6/site-packages/systemd/test/__pycache__/test_daemon.cpython-36.pyc

3

��X(�@sZddlZddlZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZddlZejdd��Zejdd��Zdd�Zd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Z dd�Z!dd�Z"dd�Z#dd�Z$dd�Z%dd �Z&d!d"�Z'd#d$�Z(d%d&�Z)d'd(�Z*d)d*�Z+d+d,�Z,ej-d2k�rBe.Z/ne0Z/d.d/�Z1d0d1�Z2dS)3�N)�booted�is_fifo�_is_fifo�	is_socket�
_is_socket�is_socket_inet�_is_socket_inet�is_socket_unix�_is_socket_unix�is_socket_sockaddr�_is_socket_sockaddr�is_mq�_is_mq�
listen_fds�notifyccsHy
dVWn8tk
rB}z|jtjkr0tj��WYdd}~XnXdS)N)�OSError�errnoZENOSYS�pytest�skip)�e�r�#/usr/lib64/python3.6/test_daemon.py�skip_enosyss
rccs4tj|�}z
|VWd|dj�|dj�XdS)Nr�)�socketZ
socketpair�close)Zfamily�pairrrr�closing_socketpairs


rcCs*tjjd�rt�s&t�nt�dks&t�dS)Nz/run/systemd/systemFT>FT)�os�path�existsr�AssertionErrorrrrr�test_booted&sr"cCsJ|jd�j}tj|�tj|tjtjB�}t|d�s8t	�t||�sFt	�dS)Nz	test.fifo)
�join�strpath�posix�mkfifor�open�O_RDONLY�
O_NONBLOCKrr!)�tmpdirr�fdrrr�
test__is_fifo.s

r,cCsR|jd�}|jd�|j}tj|tjtjB�}t|d�s>t�t||�sNt�dS)Nz	test.fifo�boo)	r#�writer$rr'r(r)rr!)r*�filerr+rrr�test__is_fifo_file6s

r0cCs\|jd�j}tjt��tdd�s(t�WdQRXtjt��td|�sNt�WdQRXdS)Nz	test.fifor���r1)r#r$r�raisesrrr!)r*rrrr�test__is_fifo_bad_fd?s
r3cCsr|jd�j}tj|�tj|tjtjB�}tj|d�}t	|d�sDt
�t	||�sRt
�t	|d�s`t
�t	||�snt
�dS)Nz	test.fifo�r)r#r$r%r&rr'r(r)�fdopenrr!)r*rr+r/rrr�test_is_fifoHs
r6cCs~|jd�}|jd�|j}tj|tjtjB�}tj|d�}t|d�sJt	�t||�sZt	�t|d�sjt	�t||�szt	�dS)Nz	test.fifor-r4)
r#r.r$rr'r(r)r5rr!)r*r/rr+rrr�test_is_fifo_fileSs

r7cCs\|jd�j}tjt��tdd�s(t�WdQRXtjt��td|�sNt�WdQRXdS)Nz	test.fiforr1r1)r#r$rr2rrr!)r*rrrr�test_is_fifo_bad_fd_s
r8cCs>yt|�Stk
r8}z|jtjks*t�dSd}~XnXdS)NF)r
rr�EBADFr!)�arg�errorrrr�
is_mq_wrapperhs
r<cCs>yt|�Stk
r8}z|jtjks*t�dSd}~XnXdS)NF)rrrr9r!)r:r;rrr�_is_mq_wrapperps
r=c Csttj���}x�|D]�}t|�s&t�t|�s4t�t|�sBt�t��t|d�sZt�WdQRX|j	�}t|�szt�t|�s�t�t|�s�t�t��t|d�s�t�WdQRXt
|�s�t�t|�s�t�t|�s�t�t��t
|d�s�t�WdQRXqWWdQRXdS)Nz127.0.0.1:2000)rr�AF_UNIXrr!r<rrr�filenorr=rr)r�sockr+rrr�test_no_mismatchxs$
rAcCsLttj���6}�x,|D�]"}x�||j�fD]�}t|�s:t�t|tj�sJt�t|tj�s\t�t|tjtj�spt�t|tjtj�s�t�t	��t
|dtjdd�s�t�WdQRXq*Wt|�s�t�t|tj�s�t�t|tj�s�t�t|tjtj�s�t�t|tjtj��st�t	�� t|dtjdd��s0t�WdQRXqWWdQRXdS)Nz8.8.8.8:2000r)
rrr>r?rr!�AF_INET�SOCK_STREAM�
SOCK_DGRAMrrrr)rr@r:rrr�test_is_socket�s"&rEcECs,tjtjtj����}|jd
�|j�\}}dj|�}�x�dD�]�}�xT||j�fD�]B}t��t	|dtj
�stt�WdQRXt��t	|d|tj
�s�t�WdQRXt��t	|d||d�s�t�WdQRXt��t	|d|dd�s�t�WdQRXt��"t	|d||d��st�WdQRXtj
t��t	|ddd�WdQRXt��t	|dtj
��sft�WdQRXt��t	|dtj��s�t�WdQRXqTWtj
t��t|ddd�WdQRXt��t|dtj
��s�t�WdQRXt��t|dtj��st�WdQRX|jd	�q>WWdQRXdS)
N�	127.0.0.1rz:{}r)�	listeningi@�)Zflowinfoz129.168.11.11:23�)rFr)rrr1)�
contextlib�closingrrB�bindZgetsockname�formatr?rrrCr!rr2�
ValueErrorrDrZlisten)r@ZaddrZportrGr:rrr�test_is_socket_sockaddr�s:

   & $  rNcCs�ttj���}x�|D]�}|j�}t|�s*t�t|tj�s:t�t|tj�sLt�t|tjtj�s`t�t|tjtj�svt�t|�s�t�t|tj�s�t�t|tj�s�t�t|tjtj�s�t�t|tjtj�st�qWWdQRXdS)N)	rrr>r?rr!rBrCrD)rr@r+rrr�test__is_socket�s
rOc
Cs~ttj��j}xb|D]Z}xT||j�fD]D}t|�s4t�t|dd�sFt�t|tj�sVt�t|tj�s$t�q$WqWWdQRXdS)Nz
/no/such/path)r)rrr>r?r	r!rCrD)rr@r:rrr�test_is_socket_unix�s
rPc
Csrttj��^}xV|D]N}|j�}t|�s*t�t|ddd�s>t�t|tj�sNt�t|tj�st�qWWdQRXdS)Nrrz
/no/such/pathr1)rrr>r?r
r!rCrD)rr@r+rrr�test__is_socket_unix�s
rQcCsFtjd�tjd�t�gks"t�td�gks2t�td�gksBt�dS)N�
LISTEN_FDS�
LISTEN_PIDTF)r�unsetenvrr!rrrr�test_listen_fds_no_fds�s


rUcCsZdtjd<ttj��tjd<td�dddgks2t�td�dddgksHt�t�gksVt�dS)	N�3rRrSF���T)r�environ�str�getpidrr!rrrr�test_listen_fds�s

r]cCsPdtjd<ttj��tjd<td�dgks.t�t�dgks>t�t�gksLt�dS)N�1rRrSFrW)rrZr[r\rr!rrrr�test_listen_fds_default_unset�s

r_cCs�td�dkst�t��tdgd�dks,t�WdQRXtdddgd�dksNt�tdtj�d�dksft�tdtj�d	d�dks�t�dS)
NzREADY=1Fz	FDSTORE=1)�fdsr�)�pid)rbr`)r)rr!rrr\rrrr�test_notify_no_socketsrcrWc/Cs�dtjd<tjt��td�WdQRXtjt��$t��tdgd�WdQRXWdQRXtjt��tdddgd�WdQRXtjt��tdtj�d�WdQRXtjt��tdtj�d
d	�WdQRXdS)Nz	/dev/null�
NOTIFY_SOCKETzREADY=1z	FDSTORE=1)r`rra)rb)rbr`)r)rrZrr2�connection_errorrrr\rrrr�test_notify_bad_sockets
 rfcCs�|jd�j}tjtjtj�}y|j|�Wn2tjk
r\}ztjd|�WYdd}~XnXt	tdd�}|j
tj|d�|tj
d<td�s�t�t��tdgd	�s�t�WdQRXtddd
gd	�s�t�tdtj�d�s�t�tdtj�d
d�s�t�dS)Nrzfailed to bind socket (%s)�SO_PASSCRED�rrdzREADY=1z	FDSTORE=1)r`ra)rb)rbr`)r)r#r$rr>rDrKr;rZxfail�getattrZ
setsockoptZ
SOL_SOCKETrrZrr!rr\)r*rr@rrgrrr�test_notify_with_sockets 
rj)rW)3�sysrr%rrIrZsystemd.daemonrrrrrrrr	r
rrr
rrrr�contextmanagerrrr"r,r0r3r6r7r8r<r=rArErNrOrPrQrUr]r_rc�version_info�ConnectionRefusedErrorrerrfrjrrrr�<module>sBD
	
			&			

?>