Your IP : 18.116.88.132


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

3

��X]'�@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z
ddlmZm
Z
ddlmZddlZejd�Zejd�ZGdd�d�Zejd	d
��Zejdd��Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z dd �Z!d!d"�Z"d#d$�Z#d%d&�Z$d'd(�Z%d)d*�Z&d+d,�Z'd-d.�Z(d/d0�Z)d1d2�Z*d3d4�Z+d5d6�Z,d7d8�Z-d9d:�Z.d;d<�Z/d=d>�Z0d?d@�Z1dAdB�Z2dS)C�)�print_functionN)�journal�id128)�
_make_lineZ 8441372f8dca4ca98694a6091fd8519fZ 8441370000000000000000001fd85000c@seZdZdd�Zddd�ZdS)�
MockSendercCs
g|_dS)N)�buf)�self�r	�$/usr/lib64/python3.6/test_journal.py�__init__szMockSender.__init__Nc	Ks�d|g}|dk	r,t|d|�}|jd|�||koH|koHdknrltjdd�ddd�\}}}|dk	r�|jd|�|dk	r�|jd	j|��|dk	r�|jd
|�|jdd�|j�D��|jj|�dS)
NzMESSAGE=�hexzMESSAGE_ID=�)�limitr�z
CODE_FILE=zCODE_LINE={:d}z
CODE_FUNC=css|]\}}t||�VqdS)N)r)�.0�key�valr	r	r
�	<genexpr>)sz"MockSender.send.<locals>.<genexpr>)�getattr�append�
_traceback�
extract_stack�format�extend�itemsr)	rZMESSAGE�
MESSAGE_IDZ	CODE_FILEZ	CODE_LINEZ	CODE_FUNC�kwargs�args�idr	r	r
�sends
"zMockSender.send)NNNN)�__name__�
__module__�__qualname__rrr	r	r	r
rsrccsJy
dVWn:ttfk
rD}z|j|kr2tj��WYdd}~XnXdS)N)�OSError�IOError�errno�pytest�skip)�code�er	r	r
�skip_oserror,s

r*ccs,y
dVWntk
r&tj�YnXdS)N)�
ValueErrorr&r'r	r	r	r
�skip_valueerror5s
r,cCs|tjj}|tj�tjkst�|tj�tjks0t�|tjd�tjksHt�|tjd�tjks`t�|tj	d�tjksxt�|tj	�tjks�t�|tj	d�tj
ks�t�|tjd�tj
ks�t�|tj�tj
ks�t�|tjd�tjks�t�|tj
d�tjk�st�|tj
�tjk�st�|tj
d�tjk�s2t�|tj�tjk�sHt�|tj�tjk�s^t�|tjd�tjk�sxt�dS)N�)r�JournalHandlerZmap_priority�loggingZNOTSETZ	LOG_DEBUG�AssertionError�DEBUGZLOG_INFO�INFOZLOG_WARNINGZWARNZLOG_ERRZERRORZLOG_CRITZFATALZCRITICALZ	LOG_ALERT)�pr	r	r
�test_priorities<s"r4c
Cs.ddi}tjt��tjf|�WdQRXdS)Nz X  r)r&�raisesr+rr.)�kwr	r	r
�"test_journalhandler_init_exceptionQsr7cCsddd�}tjtjf|�dS)Nr�)�X�X3)rr.r/r2)r6r	r	r
�test_journalhandler_initVs
r;cCs�tjdtjddddd�}t�}dd|jd�}tjtjf|�}|j|�t|j	�dksXt
�d|j	d	ksjt
�d
|j	d	ks|t
�dS)Nztest-logger�testpathr-�testrr8)r9r:�sender_functionzX=3rzX3=4)r/�	LogRecordr2rrrr.�emit�lenrr0)�record�senderr6�handlerr	r	r
�test_journalhandler_infoZs
rEcCsltjdtjddddd�}t�}tjtj|jd�}|j|�t|j	�dksLt
�tdd�|j	dD��sht
�dS)	Nztest-loggerr<r-r=)r>css|]}|jd�VqdS)zMESSAGE_ID=N)�
startswith)r�mr	r	r
rksz4test_journalhandler_no_message_id.<locals>.<genexpr>r)r/r?r2rrr.rr@rArr0�all)rBrCrDr	r	r
�!test_journalhandler_no_message_ides
rIcCsjtjdtjddddd�}t�}tjtj|jtd�}|j|�t	|j
�dksNt�dtj|j
dksft�dS)Nztest-loggerr<r-r=)r>rzMESSAGE_ID=r)
r/r?r2rrr.r�TEST_MIDr@rArr0r)rBrCrDr	r	r
�)test_journalhandler_message_id_on_handlerms
rKcCsltjdtjddddd�}t�}tjtj|jtjd�}|j	|�t
|j�dksPt�dtj|jdksht�dS)Nztest-loggerr<r-r=)r>rzMESSAGE_ID=r)
r/r?r2rrr.rrJrr@rArr0)rBrCrDr	r	r
�-test_journalhandler_message_id_on_handler_hexvs

rLcCsttjdtjddddd�}t|jd<t�}tjtj|jt	d�}|j
|�t|j�dksXt
�dtj|jdkspt
�dS)	Nztest-loggerr<r-r=r)r>rzMESSAGE_ID=r)r/r?r2�	TEST_MID2�__dict__rrr.rrJr@rArr0r)rBrCrDr	r	r
�)test_journalhandler_message_id_on_messages

rOcCsvtjdtjddddd�}tj|jd<t�}tjtj|j	t
d�}|j|�t|j
�dksZt�dtj|j
dksrt�dS)	Nztest-loggerr<r-r=r)r>rzMESSAGE_ID=r)r/r?r2rMrrNrrr.rrJr@rArr0)rBrCrDr	r	r
�-test_journalhandler_message_id_on_message_hex�s
rPcCsRtj�}tjtj�}tjtj�}tjtj�}tjtjtjBtjB�}tjd�}dS)Nr)r�ReaderZ
LOCAL_ONLYZRUNTIME_ONLY�SYSTEM_ONLY)�j1�j2�j3Zj4Zj5Zj6r	r	r
�test_reader_init_flags�srVcCs�tjt��tjtj�WdQRXt��tj|jtjd�}WdQRXt��tj|jtjtjBd�}WdQRXtj|jtjtj	Bd�}dS)N)�path�flags)
r&r5r+rrQZOS_ROOTr,�strpath�CURRENT_USERrR)�tmpdirrSrTrUr	r	r
�test_reader_os_root�sr\cCs>tj|jd�}tjd|jd�tj|jd�}tj|jd�dS)N)rWr)rrQrY)r[rSrTr	r	r
�test_reader_init_path�sr]cCs(tjt��tjddd�WdQRXdS)Nrr-)rW���)r&r5r#rrQr	r	r	r
� test_reader_init_path_invalid_fd�sr_cCs(tjt��tjddd�WdQRXdS)Nr)rW)r&r5r#rrQr	r	r	r
�%test_reader_init_path_nondirectory_fd�sr`cCs�tj|jtj�}ttj��tj|d�}WdQRXt	|�gksBt
�t��tjtj|d�}WdQRXt	|�gkstt
�tjtj
|d�}t	|�gks�t
�dS)N)rW)�os�openrY�O_RDONLYr*r%�ENOSYSrrQ�listr0r,ZSYSTEMrZ)r[�fdrSrTrUr	r	r
�test_reader_init_path_fd�srgcCsVtj|jd�}|�|js t�WdQRX|js4t�tjt��t|�WdQRXdS)N)rW)	rrQrY�closedr0r&r5r#�next)r[�jr	r	r
�test_reader_as_cm�s
rkc	Cs<tj|jd�}|� |jtj�|jtjj�WdQRXdS)N)rW)rrQrYZmessageid_matchrZSD_MESSAGE_JOURNAL_STARTZSD_MESSAGE_JOURNAL_STOPr)r[rjr	r	r
�test_reader_messageid_match�srlc	Cs@tj|jd�}|�$|j�|jt�|jtj�WdQRXdS)N)rW)rrQrYZ	this_bootrJr)r[rjr	r	r
�test_reader_this_boot�s

rmc	Cs@tj|jd�}|�$|j�|jt�|jtj�WdQRXdS)N)rW)rrQrYZthis_machinerJr)r[rjr	r	r
�test_reader_this_machine�s

rncCs^tj|jd�}|�&ttj��|jd�}WdQRXWdQRXt|t�sLt	�|t�ksZt	�dS)N)rWZFOOBAR)
rrQrYr*r%rdZquery_unique�
isinstance�setr0)r[rj�ansr	r	r
�test_reader_query_unique�srrcCs\tj|jd�}|�$ttj��|j�}WdQRXWdQRXt|t�sJt	�|t�ksXt	�dS)N)rW)
rrQrYr*r%rdZenumerate_fieldsrorpr0)r[rjrqr	r	r
�test_reader_enumerate_fields�srscCsLtj|jd�}|�$ttj��|j�}WdQRXWdQRX|dksHt�dS)N)rWF)rrQrYr*r%rd�has_runtime_filesr0)r[rjrqr	r	r
�test_reader_has_runtime_files�s
rucCsLtj|jd�}|�$ttj��|j�}WdQRXWdQRX|dksHt�dS)N)rWF)rrQrYr*r%rdrtr0)r[rjrqr	r	r
� test_reader_has_persistent_files�s
rvcCsPddd�i}tj|j|d�}|jdd�}|dks4t�|jdd�}|dksLt�dS)	NZxxxcSsdS)N�yyyr	)�argr	r	r
�<lambda>sz(test_reader_converters.<locals>.<lambda>)rW�
converterssabcrwZzzzs��)rrQrYZ_convert_fieldr0)r[rzrjrr	r	r
�test_reader_converters�sr{cCs`dd�dd�d�}tj|j|d�}|jddddgdd	gd
��}|ddddgdd	gd
�ks\t�dS)
NcSsdS)Nrwr	)rxr	r	r
ry
sz+test_reader_convert_entry.<locals>.<lambda>cSsdS)N�YYYr	)rxr	r	r
rys)�x1�x2)rWrzsabcs��sdefs��)r}Zy1r~Zy2rwr|)rrQrYZ_convert_entryr0)r[rzrjrr	r	r
�test_reader_convert_entry	srcCsFtj|jd�}tj�}|j|�|jd�tjddd�}|j|�dS)N)rWi90i��r8)rrQrY�timeZ
seek_realtime�datetime)r[rjZnowZlong_agor	r	r
�test_seek_realtimes

r�cCsFttj��tjd�}WdQRX|jd�}|dks6t�td|d�dS)Nztest_journal.pyzmessage...
�zprinted message...)�file)r�N)r*r%�ENOENTr�stream�writer0�print)r��resr	r	r
�test_journal_stream"s

r�)3Z
__future__r�
contextlibr�r%r/rar�Zuuid�	tracebackrZsystemdrrZsystemd.journalrr&ZUUIDrJrMr�contextmanagerr*r,r4r7r;rErIrKrLrOrPrVr\r]r_r`rgrkrlrmrnrrrsrurvr{rr�r�r	r	r	r
�<module>sV

			

	


?>