ó Â>Sc@sdZddlZddlZddlZddlZddlZddlZddlZdej fd„ƒYZ ej ƒdS(sTest crash-diggeriÿÿÿÿNtTcBsbeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z RS( c CsÏtjƒ|_tjj|jdƒ}t|dƒ*}|jdtjj|jdƒƒWdQXtjj|jdƒ|_tj |jƒtj tjj|jdƒƒtj tjj|jdƒƒtjj|jd ƒ|_ tjj|jd ƒ|_ t|j dƒ}|jd |j ƒWdQXtj |j d ƒtjj|jd ƒ|_ |tjd> %siítlocktAPPORT_CRASHDB_CONFt.t PYTHONPATHtcrashestAPPORT_REPORT_DIR(ttempfiletmkdtemptworkdirtostpathtjointopentwritet config_dirtmkdirtapport_retrace_logtapport_retracetchmodt lock_filetenvirontapportt fileutilst report_dirtorig_report_dir(tselft crashdb_conftf((s0/usr/share/apport/testsuite/test_crash_digger.pytsetUps,#  cCs#tj|jƒ|jtj_dS(N(tshutiltrmtreeR RRRR(R((s0/usr/share/apport/testsuite/test_crash_digger.pyttearDown7scCs_tjdd|jg|dtjdtjƒ}|jƒ\}}|jdƒ|jdƒfS(sYCall crash-digger with given arguments. Return a pair (stdout, stderr). s crash-diggers--apport-retracetstdouttstderrsUTF-8(t subprocesstPopenRtPIPEt communicatetdecode(Rtargststoutterr((s0/usr/share/apport/testsuite/test_crash_digger.pytcall;s   c CsÁ|jd|jdddtjj|jdƒd|jgƒ\}}|j|dd|ƒ|jd |kƒ|jd |kƒ|jd |kƒ|jd |kƒ|jd |kƒ|j d|kƒ|j d|kdƒ|j d|kdƒt |j ƒ}|j ƒ}WdQX|jt |jƒƒdƒ|j d|kƒ|jd|kƒ|jd|kƒ|j tjj|jƒƒ|j tjjtjj|jddƒƒƒdS(sCrash retracings-cs-as /dev/zeros-dsdup.dbs-vltsno error messages: s0Available releases: ['Testux 1.0', 'Testux 2.2']s retracing #0s retracing #1s retracing #2sEcrash is release FooLinux Pi/2 which does not have a config availablesfailed with statuss#3s!dupcheck crashes are not retraceds#4Nis dup.db -v 0 s dup.db -v 1 s dup.db -v 2 Rtsig(R/RR RRR Rt assertEqualt assertTruet assertFalseRRtreadtlent splitlinestexiststisdir(RR-R.Rt retrace_log((s0/usr/share/apport/testsuite/test_crash_digger.pyt test_crashesFs&-c Cs.tj|j|jdƒt|jdƒ}|jd|jƒWdQXtj|jdƒ|jd|jddd tj j |j d ƒd |j gƒ\}}|j d |kƒ|j d |kƒ|j d|kƒ|j d|kƒ|j d|kƒ|jd|kdƒ|j d|kƒ|jd|kƒ|j d|kƒ|jd|kdƒ|jd|kdƒt|jƒ}|jƒ}WdQX|jt|jƒƒdƒ|jd|kƒ|j d|kƒ|jd|kƒ|j tj j|j ƒƒtj|jd|jƒ|jd|jddd tj j |j d ƒd |j gƒ\}}|j|dƒ|j|dƒtj|j ƒ|jd|jddd tj j |j d ƒd |j gƒ\}}|j d|kƒ|j|dd|ƒ|jtj j|j ƒƒdS(s1Crash retracing if apport-retrace fails on bug #1s.bakRs…#!/bin/sh echo "$@" >> %s while [ -n "$2" ]; do shift; done if [ "$1" = 1 ]; then echo "cannot frobnicate bug" >&2 exit 1 fi Niís-cs-as /dev/zeros-dsdup.dbs-vlt Tracebacks SystemError: retracing #1 faileds0Available releases: ['Testux 1.0', 'Testux 2.2']s retracing #0s retracing #1s retracing #2s should not continue after errorssEcrash is release FooLinux Pi/2 which does not have a config availables#0 failed with statuss#1 failed with status: 1s#3s!dupcheck crashes are not retraceds#4is dup.db -v 0 s dup.db -v 1 s dup.db -v 2 R0sno error messages: (R trenameRRRRRR/RRRR RR3R4R5R2R6R7R8tunlink(RRR-R.R:((s0/usr/share/apport/testsuite/test_crash_digger.pyttest_crashes_error_sH---c Csmtj|j|jdƒt|jdƒ}|jd|jƒWdQXtj|jdƒ|jd|jddd tj j |j d ƒd |j gƒ\}}|j d |kƒ|j d |kƒ|j d|kƒ|jd|kdƒ|j d|kƒt|jƒ}|jƒ}WdQX|j d|kƒ|jd|kƒ|jtj j|j ƒƒdS(s;Crash retracing if apport-retrace reports a transient errors.bakRs‹#!/bin/sh echo "$@" >> %s while [ -n "$2" ]; do shift; done if [ "$1" = 1 ]; then echo "cannot frobnicate crash db" >&2 exit 99 fi Niís-cs-as /dev/zeros-dsdup.dbs-vls0Available releases: ['Testux 1.0', 'Testux 2.2']s retracing #0s retracing #1s retracing #2s should not continue after errorss!transient error reported; haltings dup.db -v 1 s dup.db -v 2 (R R=RRRRRR/RRRR RR3R4R5R8(RRR-R.R:((s0/usr/share/apport/testsuite/test_crash_digger.pyttest_crashes_transient_error—s"-cCsô|jdddtjj|jdƒd|jgƒ\}}|j|dd|ƒ|jd|kd ƒ|jd |kd ƒ|jd |kƒ|jd |kƒ|jd |kƒ|jtjj |j ƒƒ|jtjj |jƒƒdS(sDuplicate checkings-as /dev/zeros-dsdup.dbs-vDlR0sno error messages: s#1ssignal crashes are not retraceds#2schecking #3 for duplicateschecking #4 for duplicates+Report is a duplicate of #3 (not fixed yet)N( R/R RRR RR2R4R3R8R(RR-R.((s0/usr/share/apport/testsuite/test_crash_digger.pyt test_dupcheck·s-c Cs›t|jdƒ}|jdƒWdQX|jd|jdddtjj|jdƒd |j gƒ\}}|j |d d |ƒ|j d |kƒdS( s/apport-retrace's stderr is redirected to stdoutRs%#!/bin/sh echo ApportRetraceError >&2Ns-cs-as /dev/zeros-dsdup.dbs-vlR0sno error messages: tApportRetraceError( RRRR/RR RRR RR2R3(RRR-R.((s0/usr/share/apport/testsuite/test_crash_digger.pyttest_stderr_redirectionÅs -c Cs¹|jd|jdddtjj|jdƒd|jdtjj|jdƒg ƒ\}}|j|d d |ƒ|jd |kƒ|jtjj tjj|jdd ƒƒƒd S(sDuplicate database publishings-cs-as /dev/zeros-dsdup.dbs-vls --publish-dbRR0sno error messages: s retracing #0R1N( R/RR RRR RR2R3R9(RR-R.((s0/usr/share/apport/testsuite/test_crash_digger.pyttest_publish_dbÐs 'c Csý|jd|jddd|jddgƒ\}}|j|dd|ƒ|jd |kƒ|jd |kƒ|jd |kƒ|jd|jddd|jdd gƒ\}}|j|dd |ƒ|jd|k|ƒ|jd |k|ƒdS(sAlternate crash database names-cs-as /dev/zeros-vls --crash-dbtemptyR0sno error messages: s retracing #scrash issfailed with statust nonexistingsno output messages: R<N(R/RRR2R4R3(RR-R.((s0/usr/share/apport/testsuite/test_crash_digger.pyttest_alternate_crashdbÛs( t__name__t __module__R R#R/R;R?R@RARCRDRG(((s0/usr/share/apport/testsuite/test_crash_digger.pyRs %   8  ( t__doc__tunittestR&R R R!tos.pathtapport.fileutilsRtTestCaseRtmain(((s0/usr/share/apport/testsuite/test_crash_digger.pyts H Ü