HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_dtrace.cpython-37.pyc
B

��g��@s�ddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
dd�Zdd�ZGdd�d�Z
Gd	d
�d
e
�ZGdd�de
�ZGd
d�dej�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Zdd�Zedkr�e�dS)�N)�findfile�run_unittestcCstj�t|dd��S)NZ
dtracedata)Zsubdir)�os�path�abspathr)�filename�r�,/usr/local/lib/python3.7/test/test_dtrace.pyrsrc	Cstt�dd|�}y:dd�|��D�}|jdd�d�dd�|D�}d	�|�Sttfk
rntd
�|���YnXdS)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>sz*normalize_trace_output.<locals>.<listcomp>cSst|d�S)Nr)�int)rrrr	�<lambda> �z(normalize_trace_output.<locals>.<lambda>)�keycSsg|]}|d�qS)�r)rrrrr	r!s�
z&tracer produced unparseable 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)�TraceBackendNc	Cs\t|jt||j�t|d�|d��}tt||jd���}|����}WdQRX||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�stderrZuniversal_newlines)r6�
subprocess�Popen�PIPEZSTDOUTZcommunicate)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_flagsr4rrr	r(Gs
zTraceBackend.trace_pythonc
Csvy |�td|j��}|��}Wn0tttfk
rP}zt|�}Wdd}~XYnX|dkrrt�	d�
|jd|���dS)N�
assert_usablezprobe: successz{}(1) failed: {}r)r=rr)�strip�FileNotFoundError�NotADirectoryError�PermissionError�str�unittestZSkipTestr r3)r-r!Zfnferrr	rBNszTraceBackend.assert_usable)N)N)N)N)�__name__�
__module__�__qualname__r)r3ZCOMMAND_ARGSr2r6r=r(rBrrrr	r$)s



r$c@seZdZdZdddgZdS)�
DTraceBackendz.dZdtracez-qz-sN)rIrJrKr)r3rrrr	rLZsrLc@seZdZdZddgZdS)�SystemTapBackendz.stpZstapz-gN)rIrJrKr)r3rrrr	rM_srMc@sLeZdZdZdZdZedd��Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�ZdS)�
TraceTestsNrcCs|j��dS)N)�backendrB)r-rrr	�
setUpClasslszTraceTests.setUpClasscCs&|jj||jd�\}}|�||�dS)N)r')rOr2r'�assertEqual)r-r.r/r1rrr	r2pszTraceTests.run_casecCs|�d�dS)NZ
call_stack)r2)r-rrr	�test_function_entry_returnusz%TraceTests.test_function_entry_returnc	sltdddg�}ttd���}|���WdQRX��fdd�}x|d�D]}|�|j�qFW��t�|�dS)	z9Ensure our call stack test hits all function call opcodesZ
CALL_FUNCTIONZCALL_FUNCTION_EXZCALL_FUNCTION_KWz
call_stack.pyNcsFt�dd�jd�}x.|jD]$}t|tj�r|j|krt�|�SqWgS)Nz<string>�exec)�sourcer�mode�optimize)	�compiler'�	co_consts�
isinstance�types�CodeType�co_name�disZget_instructions)�funcname�code�c)�code_stringr-rr	�get_function_instructions�s
zFTraceTests.test_verify_call_opcodes.<locals>.get_function_instructions�start)�setr*rr+�discard�opnamerQ)r-Zopcodesr0rbZinstructionr)rar-r	�test_verify_call_opcodesxsz#TraceTests.test_verify_call_opcodescCs|�d�dS)NZgc)r2)r-rrr	�test_gc�szTraceTests.test_gccCs|�d�dS)N�line)r2)r-rrr	�	test_line�szTraceTests.test_line)
rIrJrKZmaxDiffrOr'�classmethodrPr2rRrgrhrjrrrr	rNdsrNc@seZdZe�ZdZdS)�DTraceNormalTestsrN)rIrJrKrLrOr'rrrr	rl�srlc@seZdZe�ZdZdS)�DTraceOptimizedTests�N)rIrJrKrLrOr'rrrr	rm�srmc@seZdZe�ZdZdS)�SystemTapNormalTestsrN)rIrJrKrMrOr'rrrr	ro�sroc@seZdZe�ZdZdS)�SystemTapOptimizedTestsrnN)rIrJrKrMrOr'rrrr	rp�srpcCsttttt�dS)N)rrlrmrorprrrr	�	test_main�srq�__main__)r]Zos.pathrrr9r@rZrHZtest.supportrrrr#r$rLrMZTestCaserNrlrmrorprqrIrrrr	�<module>s(14