python (3.11.7)

(root)/
lib/
python3.11/
test/
__pycache__/
test_dtrace.cpython-311.pyc

etddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZe
j
sejddZdZGddZGd	d
eZGddeZGd
dZGddeejZGddeejZGddeejZGddeejZGddejZedkrejdSdS)N)support)findfileztest module requires subprocessc^tjt|dS)N
dtracedata)subdir)ospathabspathr)filenames D/BuggyBox/python/3.11.7/bootstrap/lib/python3.11/test/test_dtrace.pyr
r
s#
7??8H\BBBCCCcJtjdd|}	d|D}|dd|D}d|S#t
tf$r#td|wxYw)	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\]cfg|].}||d|d/S)#	)
startswithsplit.0rows  r
<listcomp>z*normalize_trace_output.<locals>.<listcomp>!sN



>>#..
IIdOO


r
c,t|dS)Nr)int)rs r<lambda>z(normalize_trace_output.<locals>.<lambda>&sCAKKr
)keycg|]
}|dS)rs  rrz*normalize_trace_output.<locals>.<listcomp>'s+++S#a&+++r

z%tracer produced unparsable output:
{})	resub
splitlinessortjoin
IndexError
ValueErrorAssertionErrorformat)outputresults  rnormalize_trace_outputr,sV&F
3
3F


((**



	//000++F+++yy   
#


4;;FCC

	

sAA..4B"c@eZdZdZdZgZddZddZddZddZ	dZ
dS)TraceBackendNc	ht|t||jzt|dz|}t	t||jzdz5}|}dddn#1swxYwY||fS)Nz.py)script_filepython_fileoptimize_pythonz	.expected)r,trace_pythonr
	EXTENSIONopenreadrstrip)selfnamer2
actual_outputfexpected_outputs      rrun_casezTraceBackend.run_case4s.t/@/@t~ 566u--+0A0-0-..
'$/+=>>
?
?	01ffhhoo//O	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0 //s2'B%%B),B)c.|j|gz}|r|d|gz
}|S)Nz-c)COMMAND)r8r0
subcommandcommands    rgenerate_trace_commandz#TraceBackend.generate_trace_command?s,,+.	*j))Gr
c|||}tj|tjtjd\}}|S)NTstdoutstderruniversal_newlines)rB
subprocessPopenPIPESTDOUTcommunicate)r8r0r@rArE_s      rtracezTraceBackend.traceEsX--k:FF$W,6O,6,=8<>>>?Jkmm	
r
cg}|r|dg|zdtjg|z|gz}|||S)Nz-O )extendr%sys
executablerN)r8r0r1r2python_flagsr@s      rr3zTraceBackend.trace_pythonMs`	: 8999XXs~.=
MNN
zz+z222r
c^	|td|jz}|}n3#tt
tf$r}t|}Yd}~nd}~wwxYw|dkr3tj	d
|jd|dS)N
assert_usablezprobe: successz{}(1) failed: {}r)rNr
r4stripFileNotFoundErrorNotADirectoryErrorPermissionErrorstrunittestSkipTestr)r?)r8r*fnfes   rrVzTraceBackend.assert_usableTs	ZZ$.(H I IJJF\\^^FF!#5G			YYFFFFFF	%%%#"))$,q/6BB
&%s>AA1A,,A1N)__name__
__module____qualname__r4r?COMMAND_ARGSr=rBrNr3rVrr
rr.r./sIGL	0	0	0	03333					r
r.ceZdZdZgdZdS)
DTraceBackendz.d)dtracez-qz-sNr`rarbr4r?rr
rrere`sI$$$GGGr
receZdZdZddgZdS)SystemTapBackendz.stpstapz-gNrgrr
rririesItnGGGr
ricNeZdZdZdZdZedZdZdZ	dZ
dZdZdS)	
TraceTestsNrc8|jdSr_)backendrVr8s r
setUpClasszTraceTests.setUpClassrs""$$$$$r
cz|j||j\}}|||dS)N)r2)rnr=r2assertEqual)r8r9r:r<s    rr=zTraceTests.run_casevsG)-)>)>$"6*?*8*8&
88888r
c0|ddS)N
call_stackr=ros rtest_function_entry_returnz%TraceTests.test_function_entry_return{s

l#####r
c\tgd}ttd5}|dddn#1swxYwYfd}|dD]}||jt|dS)z9Ensure our call stack test hits all function call opcodes)
CALL_FUNCTIONCALL_FUNCTION_EXCALL_FUNCTION_KWz
call_stack.pyNctddj}|jD]=}t|tjr!|j|krtj|cS>gS)Nz<string>exec)sourcermodeoptimize)	compiler2	co_consts
isinstancetypesCodeTypeco_namedisget_instructions)funcnamecodeccode_stringr8s   rget_function_instructionszFTraceTests.test_verify_call_opcodes.<locals>.get_function_instructionssu+$. &$($8:::D
^
3
3a003QY(5J5J/22222Ir
start)setr5r
r6discardopnamerr)r8opcodesr;rinstructionrs`    @rtest_verify_call_opcodesz#TraceTests.test_verify_call_opcodes~sOOOPP
'/**
+
+	#q&&((K	#	#	#	#	#	#	#	#	#	#	#	#	#	#	#
	
	
	
	
	
	54W==	0	0KOOK.////(((((sAAAc0|ddS)Ngcruros rtest_gczTraceTests.test_gcs

dr
c0|ddS)Nlineruros r	test_linezTraceTests.test_lines

fr
)
r`rarbmaxDiffrnr2classmethodrpr=rvrrrrr
rrlrljsGGO%%[%999
$$$)))2r
rlc&eZdZeZdZdS)DTraceNormalTestsrNr`rarbrernr2rr
rrrmooGOOOr
rc&eZdZeZdZdS)DTraceOptimizedTestsNrrr
rrrrr
rc&eZdZeZdZdS)SystemTapNormalTestsrNr`rarbrirnr2rr
rrr!  GOOOr
rc&eZdZeZdZdS)SystemTapOptimizedTestsrNrrr
rrrrr
rcFeZdZedZedZdZdZdS)CheckDtraceProbesctjdr<|\}}tjrtd|d|dSdSt
jd)NWITH_DTRACEzreadelf version: .z9CPython must be configured with the --with-dtrace option.)	sysconfigget_config_varget_readelf_versionrverboseprintr\r])clsreadelf_major_versionreadelf_minor_versions   rrpzCheckDtraceProbes.setUpClasss#M22	a;>;R;R;T;T8!#8
[Y*?YYBWYYZZZZZ
[
[#$_```r
c
d	ddg}tj|tjtjd}|5|\}}dddn#1swxYwY|jr3tdd|d|jd|d	|n"#t$rtj	d
wxYwtjd|}|tj	d|t|
d
t|
dfS)Nreadelfz	--versionTrDzCommand rPz failed with exit code z	: stdout=z stderr=z!Couldn't find readelf on the pathz!^(?:GNU) readelf.*?\b(\d+)\.(\d+)z!Unable to parse readelf version: rr)rHrIrJrL
returncode	Exceptionr%OSErrorr\r]r!searchrgroup)cmdprocversionrFmatchs     rrz%CheckDtraceProbes.get_readelf_versions	Ik*C#!!#'	D
5
5"&"2"2"4"4
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
<sxx}}<<&*o<<%<<17<<
	I	I	I#$GHHH	I
	>HH=#$Q$Q$QRRR5;;q>>""CA$7$777s.2BABABA =BB=cddtjg}tj|tjtjd\}}|S)Nrz-nTrD)rRrSrHrIrJrKrL)r8rArErMs    rget_readelf_outputz$CheckDtraceProbes.get_readelf_outputsQdCN3$?$#	



+--	
r
c|}gd}|D]F}||5|||dddn#1swxYwYGdS)N)zName: import__find__load__donezName: import__find__load__startzName: auditzName: gc__startzName: gc__donezName: function__entryzName: function__returnz
Name: line)
probe_name)rsubTestassertIn)r8readelf_outputavailable_probe_namesrs    rtest_check_probesz#CheckDtraceProbes.test_check_probess0022	!
	!
	!
0	:	:J44
:
:

j.999
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:	:	:sAA	A	N)	r`rarbrrpstaticmethodrrrrr
rrrsiaa[a88\8::::::r
r__main__)ros.pathrr!rHrRrrr\testrtest.supportrhas_subprocess_supportr]r
r,r.rerirlTestCaserrrrrr`mainrr
r<module>rsw



				



!!!!!!%?
(
=
>
>>DDD


2........b%%%%%L%%%
|
11111111h
H$5
:x'8
:x'8
j(*;C:C:C:C:C:)C:C:C:LzHMOOOOOr