Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_dtrace.cpython-39.opt-1.pyc

a

��g��@s�ddlZddlZddlZddlZddlZddlZddlZddlm	Z	dd�Z
dd�ZGdd�d�ZGd	d
�d
e�Z
Gdd�de�ZGd
d�d�ZGdd�deej�ZGdd�deej�ZGdd�deej�ZGdd�deej�Zedkr�e��dS)�N)�findfilecCstj�t|dd��S)NZ
dtracedata)Zsubdir)�os�path�abspathr)�filename�r�,/usr/local/lib/python3.9/test/test_dtrace.pyrsrc	Cstt�dd|�}z<dd�|��D�}|jdd�d�dd�|D�}d	�|�WSttfyntd
�|���Yn0dS)aMNormalize DTrace output for comparison.

    DTrace keeps a per-CPU buffer, and when showing the fired probes, buffers
    are concatenated. So if the operating system moves our thread around, the
    straight result can be "non-causal". So we add timestamps to the probe
    firing, sort by that field, then strip it from the outputz\[[0-9]+ refs\]�cSs$g|]}|r|�d�s|�d��qS)�#�	)�
startswith�split��.0�rowrrr�
<listcomp>s�z*normalize_trace_output.<locals>.<listcomp>cSst|d�S)Nr)�int)rrrr�<lambda> �z(normalize_trace_output.<locals>.<lambda>)�keycSsg|]}|d�qS)�rrrrrr!r�
z%tracer produced unparsable output:
{}N)	�re�sub�
splitlines�sort�join�
IndexError�
ValueError�AssertionError�format)�output�resultrrr�normalize_trace_outputs	��r#c@sHeZdZdZdZgZddd�Zd
dd�Zddd�Zddd	�Z	d
d�Z
dS)�TraceBackendNcCspt|jt||j�t|d�|d��}tt||jd���}|����}Wd�n1s^0Y||fS)Nz.py)�script_file�python_file�optimize_pythonz	.expected)r#�trace_pythonr�	EXTENSION�open�read�rstrip)�self�namer'�
actual_output�f�expected_outputrrr�run_case.s
�*zTraceBackend.run_casecCs |j|g}|r|d|g7}|S)Nz-c)�COMMAND)r-r%�
subcommand�commandrrr�generate_trace_command9sz#TraceBackend.generate_trace_commandcCs.|�||�}tj|tjtjdd���\}}|S)NT)�stdout�stderr�universal_newlines)r6�
subprocess�Popen�PIPE�STDOUT�communicate)r-r%r4r5r7�_rrr�trace?s�zTraceBackend.tracecCs<g}|r|�dg|�d�tjg||g�}|�||�S)Nz-O� )�extendr�sys�
executabler@)r-r%r&r'Zpython_flagsr4rrrr(Gs
zTraceBackend.trace_pythonc
Csxz |�td|j��}|��}Wn2tttfyR}zt|�}WYd}~n
d}~00|dkrtt�	d�
|jd|���dS)N�
assert_usablezprobe: successz{}(1) failed: {}r)r@rr)�strip�FileNotFoundError�NotADirectoryError�PermissionError�str�unittestZSkipTestr r3)r-r!ZfnferrrrENs�zTraceBackend.assert_usable)N)N)N)N)�__name__�
__module__�__qualname__r)r3ZCOMMAND_ARGSr2r6r@r(rErrrrr$)s



r$c@seZdZdZgd�ZdS)�
DTraceBackendz.d)Zdtracez-qz-sN�rLrMrNr)r3rrrrrOZsrOc@seZdZdZddgZdS)�SystemTapBackendz.stpZstapz-gNrPrrrrrQ_srQc@sLeZdZdZdZdZedd��Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�ZdS)�
TraceTestsNrcCs|j��dS)N)�backendrE�r-rrr�
setUpClasslszTraceTests.setUpClasscCs&|jj||jd�\}}|�||�dS)N)r')rSr2r'�assertEqual)r-r.r/r1rrrr2ps�
zTraceTests.run_casecCs|�d�dS)NZ
call_stack�r2rTrrr�test_function_entry_returnusz%TraceTests.test_function_entry_returncsztgd��}ttd���}|���Wd�n1s60Y��fdd�}|d�D]}|�|j�qV��t�|�dS)z9Ensure our call stack test hits all function call opcodes)Z
CALL_FUNCTIONZCALL_FUNCTION_EXZCALL_FUNCTION_KWz
call_stack.pyNcsFt�dd�jd�}|jD](}t|tj�r|j|krt�|�SqgS)Nz<string>�exec)�sourcer�mode�optimize)	�compiler'�	co_consts�
isinstance�types�CodeType�co_name�disZget_instructions)�funcname�code�c�Zcode_stringr-rr�get_function_instructions�s�
zFTraceTests.test_verify_call_opcodes.<locals>.get_function_instructions�start)�setr*rr+�discard�opnamerV)r-Zopcodesr0rhZinstructionrrgr�test_verify_call_opcodesxs&z#TraceTests.test_verify_call_opcodescCs|�d�dS)N�gcrWrTrrr�test_gc�szTraceTests.test_gccCs|�d�dS)N�linerWrTrrr�	test_line�szTraceTests.test_line)
rLrMrNZmaxDiffrSr'�classmethodrUr2rXrmrorqrrrrrRds
rRc@seZdZe�ZdZdS)�DTraceNormalTestsrN�rLrMrNrOrSr'rrrrrs�srsc@seZdZe�ZdZdS)�DTraceOptimizedTests�Nrtrrrrru�sruc@seZdZe�ZdZdS)�SystemTapNormalTestsrN�rLrMrNrQrSr'rrrrrw�srwc@seZdZe�ZdZdS)�SystemTapOptimizedTestsrvNrxrrrrry�sry�__main__)rcZos.pathrrr:rCr`rKZtest.supportrrr#r$rOrQrRZTestCasersrurwryrL�mainrrrr�<module>s&14

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists