Your IP : 216.73.216.213


Current Path : /opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/
Upload File :
Current File : //opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyc

�
��]c@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddlZddlmZddlmZddlmZdge_d�Zd	efd
��YZdejfd��YZd
efd��YZdejfd��YZdefd��YZdefd��YZdefd��YZ de fd��YZ!de fd��YZ"defd��YZ#defd��YZ$defd ��YZ%d!efd"��YZ&d#efd$��YZ'd%efd&��YZ(d'efd(��YZ)d)efd*��YZ*d+efd,��YZ+ej,j-d-�Z.e.r�e/d.d/�Z0nd0�Z1d1�Z2d2�Z3e4d3�Z5dS(4s�
Tests that run inside GDB.

Note: debug information is already imported by the file generated by
Cython.Debugger.Cygdb.make_command_file()
i����N(ttest_support(t	libcython(t	libpython(t
TestLibCythontgdbcs"tj���fd��}|S(Ncs`tt|�j�j�y�|||�SWn,tk
r[}tdtj|���nXdS(NsAn exception occurred:(t_debugttypet__name__t	Exceptiont	tracebackt
format_exc(tselftargstkwargste(tfunc(s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pytwrapper!s(t	functoolstwraps(RR((Rs^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pytprint_on_call_decorator s
tTraceMethodCallMetacBseZd�ZRS(cCsIxB|j�D]4\}}tj|�r
t||t|��q
q
WdS(N(t	iteritemstinspectt
isfunctiontsetattrR(Rtnametbasestdictt	func_nameR((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyt__init__/s(Rt
__module__R(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyR-st
DebugTestCasecBsSeZdZeZd�Zdd�Zd�Zddd�Z	d�Z
d�ZRS(sf
    Base class for test cases. On teardown it kills the inferior and unsets
    all breakpoints.
    cCs{tt|�j|�tj|_tjjd|_tjjd\|_|_	tjj
d|_tjj
d|_dS(Ntcodefiletspamscodefile.hams
codefile.eggs(
tsuperRRRtcytcython_namespacetmoduletfunctions_by_namet	spam_funct	spam_methtfunctions_by_qualified_nametham_funct	eggs_func(RR((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyR=s	
	cCs,tjd|�}|r(||�}n|S(Ns$cy_cvalue("%s")(Rtparse_and_eval(Rtvarnametcast_totresult((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pytread_varGscCstjddt�S(Nsinfo localst	to_string(RtexecutetTrue(R((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyt
local_infoNscCsH|dk	rtj|}ntj�}|jtjj|�|�dS(N(	tNonettest_libcythontsource_to_linenoRtselected_frametassertEqualRtcython_infotlineno(Rtsource_lineR;tframe((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyt
lineno_equalsQscCs;tj|}tjd|dt�tjddt�dS(Nscy break codefile:%dR1trun(R6R7RR2R3(RR<tbreak_lineno((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyt
break_and_runWs
cCsOtjddt�ytjddt�Wntk
r=nXtjd�dS(Nsdelete breakpointsR1skill inferior 1sset args -c "import codefile"(RR2R3tRuntimeError(R((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttearDown\s
N(RRt__doc__Rt
__metaclass__RR5R0R4R>RARC(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyR5s	
		tTestDebugInformationClassescBs#eZd�Zd�Zd�ZRS(cCsA|j|jjd�d	}t|�j|jj�s=t�dS(
sDtest that debug information was parsed properly into data structuresR tc_vart
python_varRt__builtins__RDt__file__N(RGRHRRIRDRJ(R9R%RtsettissubsettglobalstAssertionError(Rtglobal_vars((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_CythonModulehscCsc|jj}|d}|d}|j|jtj�|j|jtj�|j|jd�dS(NRGRHscodefile.c_var(R%RMR9RRtCObjecttPythonObjecttqualified_name(Rtmodule_globalsRGRH((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_CythonVariableos

cCs[|j|jjd�|j|jjd�|j|jj|j�|jjslt|j|jjf��|jjst�|jjs�t�|jjs�t�|j|jj	t
j�|j|jj	t
j�|j|jjdg�|j|jj
tddg��tjd}|j|jj|�|jt|jj�td��dS(Ns
codefile.spamscodefile.SomeClass.spamtatputstsome_c_functionsdef spam(a=0):tabcd(R9R'RSR(R%R+tpf_cnameRNR*RRRQt	argumentststep_into_functionsRKR6R7R;tsortedtlocalstlist(Rtexpected_lineno((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_CythonFunctionws '
(RRRPRURa(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyRFfs		tTestParameterscBseZd�ZRS(cCsCtjd�tjjst�tjd�tjjs?t�dS(Nsset cy_colorize_code onsset cy_colorize_code off(RR2Rt
parameterst
colorize_codeRN(R((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_parameters�s

(RRRe(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyRb�st	TestBreakcBs#eZd�Zd�Zd�ZRS(cCs�ttj�pd�}tjd�|jttj��|d�tj�d}|j|jtj�|jj|j	ks�t
�|js�t
�dS(Nscy break codefile.spamii����((tlenRtbreakpointsR2R9Rt
BP_BREAKPOINTR'tcnametlocationRNtenabled(Rtbreakpoint_amounttbp((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyt
test_break�s
 cCs2tjd�dtjddt�ks.t�dS(Nscy break -p joins	def join(scy runR1(RR2R3RN(R((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_python_break�s
cCsgd}d}|j|�|j|�tjddt�}|j|�|j�j|�sct�dS(Ns	import osscdef int c_var = 12scy stepR1(RAR>RR2R3trstriptendswithRN(Rt	beginlinetnextlinetstep_result((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_break_lineno�s


(RRRoRpRv(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyRf�s	
	t
TestKilledcBseZd�ZRS(cCs>tjd�tjddt�}d|j�ks:t�dS(Ns#set args -c 'import os; os.abort()'scy runR1tabort(RR2R3tlowerRN(Rtoutput((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyt
test_abort�s
(RRR{(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyRw�stDebugStepperTestCasecBseZddd�ZRS(cCs]tj|j�x6|D].\}}|j|j|�||j��qW|j||�dS(N(RR2tcommandR9R0R4R>(Rtvarnames_and_valuesR<R;R-tvalue((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pytstep�s&N(RRR5R�(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyR|�stTestStepcBs)eZdZd�Zd�Zd�ZRS(sb
    Test stepping. Stepping happens in the code found in
    Cython/Debugger/Tests/codefile.
    cCs�tjd�tjddt�|jd�tjddt�|jd�d|_|jdgd	d
�|jddgd	d
�|jdgd	d�|jgd	d�tjddt�|jttj��d�|jtj�dj	d�dS(Nscy break codefile.spamR?R1sdef spam(a=0):scy steps
b = c = d = 0tbiR<sb = 1itcsc = 2isint(10)sputs("spam")tcont(R�i(R�i(R�i(R�i(
RR2R3R>R}R�R9Rgt	inferiorstpid(R((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_cython_step�s


	cCs@|jd�tjddt�|jtj�j�d�dS(Nssome_c_function()scy stepR1RX(RARR2R3R9R8R(R((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_c_step�s
cCs�|jd�tjddt�}tj�}|j|j�d�tj|�j	�}|j
jt��}|j|d�t
jd|�s�t|��dS(Nsos.path.join("foo", "bar")scy stepR1tPyEval_EvalFrameExtjoins\d+    def join\((RARR2R3R8R9RRtFrametget_pyoptco_nametproxyvalRKtretmatchRN(RR/tcurframetpyframet
frame_name((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_python_step�s
(RRRDR�R�R�(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyR��s		tTestNextcBseZd�ZRS(cCsB|jd�d}x(|D] }tjd�|j|�qWdS(Nsc = 2sint(10)sputs("spam")sos.path.join("foo", "bar")ssome_c_function()scy next(sint(10)sputs("spam")sos.path.join("foo", "bar")ssome_c_function()(RARR2R>(Rtlinestline((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_cython_next�s


(RRR�(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyR��stTestLocalsGlobalscBseZd�Zd�ZRS(cCsn|jd�tjddt�}ds:tt|���dsLt|��d|ksjtt|���dS(Nsint(10)s	cy localsR1sa = 0sb = (int) 1sc = (int) 2(RARR2R3RNtrepr(RR/((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_localss

cCs�|jd�tjddt�}d|ks@tt|���d|ks^tt|���d|ks|tt|���d|ks�tt|���d|ks�tt|���dS(	Nsint(10)s
cy globalsR1s	__name__ s__doc__ sos sc_var spython_var (RARR2R3RNR�(RR/((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_globals
s
(RRR�R�(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyR�s	t
TestBacktracecBseZd�ZRS(cCsgttjj_|jd�d�}tjddt�}||�tjddt�}||�dS(Nsos.path.join("foo", "bar")cSs:tjd|�st|��d|ks6t|��dS(Ns-\#\d+ *0x.* in spam\(\) at .*codefile\.pyx:22sos.path.join("foo", "bar")(R�tsearchRN(R/((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pytmatch_backtrace_outputs	scy btR1scy bt -a(	tFalseRRcRdRRARR2R3(RR�R/((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_backtraces
	
(RRR�(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyR�st
TestFunctionscBseZd�ZRS(cCs�|jd�tjddt�}tjd|�s@t|��tjddt�}tjd}t	|�|ks�t||f��tjddt�}d|ks�t�dS(Nsc = 2sprint $cy_cname("b")R1s	__pyx_.*bsprint $cy_lineno()sprint $cy_cvalue("b")s= 1(
RARR2R3R�R�RNR6R7tstr(RR/tsupposed_lineno((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_functions0s

$(RRR�(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyR�.st	TestPrintcBseZd�ZRS(cCs6|jd�tjddt�}|jd|�dS(Nsc = 2s
cy print bR1sb = (int) 1
(RARR2R3R9(RR/((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyt
test_print?s
(RRR�(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyR�=st
TestUpDowncBseZd�ZRS(cCsm|jd�tjd�|jttjd�tjddt�}d|ksWt�d|ksit�dS(Nsos.path.join("foo", "bar")scy stepscy downscy upR1sspam()(RARR2tassertRaisesRBR3RN(RR/((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_updownGs

(RRR�(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyR�EstTestExeccBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCsGtt|�j�tj�\|_|_tj|jd�|_	dS(Nsr+(
R"R�tsetUpttempfiletmkstemptfdttmpfilenametostfdopenttmpfile(R((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyR�SscCs<tt|�j�z|jj�Wdtj|j�XdS(N(R"R�RCR�tcloseR�tremoveR�(R((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyRCXscCs-tjd|j|f�|jj�j�S(Ns$cy exec open(%r, "w").write(str(%s))(RR2R�R�treadtstrip(RR}((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyteval_command`s	cCsg|jd�|jd|jd��tjtjd��}|jj�j	�}|jd|�dS(Nsos.path.join("foo", "bar")s[0]s[a]sX            cy exec
            pass

            "nothing"
            end
            t(
RAR9R�RR2ttextwraptdedentR�R�Rq(RR/((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_cython_execes
cCsD|jd�tjd�tjd�|jd|jd��dS(Nsos.path.join("foo", "bar")scy stepscy exec some_random_var = 14t14tsome_random_var(RARR2R9R�(R((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_python_execvs


(RRR�RCR�R�R�(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyR�Qs
				tCySetcBseZd�ZRS(cCsC|jd�tjd�|jddt�}|j|d�dS(Nsos.path.join("foo", "bar")s!cy set a = $cy_eval("{None: []}")RVR.s
{None: []}(RARR2R0R�R9(Rtstringvalue((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyt
test_cyset�s

(RRR�(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyR�~st
TestCyEvalcBseZdZd�ZRS(s!Test the $cy_eval() gdb function.cCsw|jd�tjddt�}tjd|�s@t|��tjddt�}tjd|�sst|��dS(Nsos.path.join("foo", "bar")sprint $cy_eval("None")R1s\$\d+ = None\nsprint $cy_eval("[a]")s
\$\d+ = \[0\](RARR2R3R�R�RN(RR/((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyttest_cy_eval�s

(RRRDR�(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyR��stTestClosurecBs#eZd�Zd�Zd�ZRS(cCs"tjd|�tjd�dS(Ns	cy break scy run(RR2(Rtfuncname((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pytbreak_and_run_func�scCs�|jd�|jdtjddt��tjd�|jt|jd��d�tjddt�j�}|j|d	�dS(
NtinnerR�s	cy localsR1scy stepRVs'an object's
cy print asa = 'an object'(R�R9RR2R3R�R0R�(Rtprint_result((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyt
test_inner�s

cCs�|jd�|jdtjddt��tjd�|jdtjddt��tjd�tjddt�j�}|j|d�dS(NtouterR�s	cy localsR1scy steps
cy print asa = 'an object'(R�R9RR2R3R�(RR�((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyt
test_outer�s


(RRR�R�R�(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyR��s		t	GDB_DEBUGs/dev/ttytwcGsXtrTtjtjd�jjdg|�}tjdj	d�|D��d�ndS(Nit:t css|]}t|�VqdS(N(R�(t.0tmsg((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pys	<genexpr>�ss
(
t	_do_debugt	itertoolstchaintsyst	_getframetf_codeR�t_debug_filetwriteR�(tmessages((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyR�s	c	Cs�ytjd�Wn1tk
rDd}tj|�tjd�n�Xt|ddg�}tj	|tj
�}tj�}tj
g|D]\}}|j|�^q��}tjdd�j|�}|j�SdS(NtPyModuleObjects�Unable to run tests, Python was not compiled with debugging information. Either compile python with -g or get a debug build (configure with --with-pydebug).itfromlistR�t	verbosity(Rtlookup_typeRBtwarningstwarnR�t_exitt
__import__Rt
getmemberstisclasstunittestt
TestLoadert	TestSuitetloadTestsFromTestCasetTextTestRunnerR?t
wasSuccessful(	t
modulenameR�tmtteststtest_loaderRtclstsuiteR/((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pytrun_unittest_in_module�s

+cCsMddlm}tt�}t|j�}|s9|rItjd�ndS(s~
    Run the libcython and libpython tests. Ensure that an appropriate status is
    returned to the parent test process.
    i����(ttest_libpython_in_gdbiN(tCython.Debugger.TestsR�R�RR�texit(R�tsuccess_libcythontsuccess_libpython((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pytruntests�s
c
CsZ|a|rOtjdtdtdtjdtjtjg�}|j	t
�nt
�dS(Ntcountttracetoutfilet
ignoredirs(tinferior_python_versionR�tTraceR�R3R�tstderrtprefixtexec_prefixtrunfuncR�(tversiont
trace_codettracer((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pytmain�s(6RDR�R�R�R�RR�R�R�R�RR	R�ttestRRtCython.DebuggerRRR�RR6targvRRRtTestCaseRRFRbRfRwR|R�R�R�R�R�R�R�R�R�R�R�tenvirontgetR�topenR�RR�R�R�R(((s^/opt/alt/python27/lib64/python2.7/site-packages/Cython/Debugger/Tests/test_libcython_in_gdb.pyt<module>sX	
1(	
.-