ó Â>Sc@s“ddlZddlZddlZddlZddlZddlZddlZddlZddl Z dej fd„ƒYZ ej ƒdS(iÿÿÿÿNtTcBsÎeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z e jejjjjejƒƒdkd ƒd „ƒZd „Zd„Zd„Zed„ƒZRS(cCstjƒ|_dS(N(ttempfiletmkdtemptworkdir(tself((s-/usr/share/apport/testsuite/test_hookutils.pytsetUpscCstj|jƒdS(N(tshutiltrmtreeR(R((s-/usr/share/apport/testsuite/test_hookutils.pyttearDown scCsDd„}|dƒ}|dƒ}|jdtjjdƒkƒ|jtjjdƒdƒ|jdtjj|jƒkƒ|jdtjj|jƒkƒtjƒ}|jd|j|jfj ƒƒ|j ƒtjj |jƒ}|j d|kƒ|jd|kƒ|j |j|kƒ|j|j|kƒdS( s*module licenses can be validated correctlycSs|tjdd|ddƒ}|jd|jƒƒ|jƒtjdd|ddƒ}tjd|jd|jgƒ|S( Ntprefixs%s-tsuffixs.Ss'.section .modinfo .string "license=%s" s.kos /usr/bin/ass-o(RtNamedTemporaryFiletwritetencodetflusht subprocesstcalltname(tlicensetasmtko((s-/usr/share/apport/testsuite/test_hookutils.pyt _build_kos   tGPLtBADtisofssdoes-not-existtinvalidsisofs does-not-exist %s %s N( t assertTruetapportt hookutilst_get_module_licenset assertEqualRRR R R Rtnonfree_kernel_modulest assertFalse(RRtgood_kotbad_kotftnonfree((s-/usr/share/apport/testsuite/test_hookutils.pyttest_module_license_evaluations   ""   cCski}tjj|ƒ|j|djdƒƒ|jt|dƒdkƒ|j|djdƒƒdS(s7attach_dmesg() does not overwrite already existing datat BootDmesgt[iôt CurrentDmesgN(RRt attach_dmesgRt startswithtlen(Rtreport((s-/usr/share/apport/testsuite/test_hookutils.pyttest_attach_dmesg5s cCsŸidd6}tjj|ƒ|j|dd dƒ|j|djdƒƒidd6dd6}tjj|ƒ|j|ddƒ|j|ddƒdS(s7attach_dmesg() does not overwrite already existing datat existingbootR&i2R(R'texistingcurrentN(RRR)RRR*(RR,((s-/usr/share/apport/testsuite/test_hookutils.pyttest_dmesg_overwrite?s cCsìtdƒ}|jƒjƒ}WdQXtdƒ}|jƒjƒ}WdQXi}tjj|dƒ|jt|ƒdgƒ|j|d|ƒi}tjj|ddƒ|jt|ƒdgƒ|j|d|ƒi}tjj|dƒ|jt|ƒdgƒ|j|dj dƒƒi}tjj|dƒtjj|dƒ|jt|ƒdgƒ|j|d|ƒtjj|ddd t ƒ|jt |j ƒƒdd gƒ|j|d|ƒ|j|d |ƒdS( s attach_file()s /etc/passwdNs /etc/issues .etc.passwdtPasswds /nonexistings .nonexistingsError: t overwrites .etc.passwd_( topentreadtstripRRt attach_fileRtlistRR*tFalsetsortedtkeys(RR#tpasswd_contentstissue_contentsR,((s-/usr/share/apport/testsuite/test_hookutils.pyttest_attach_fileNs2"cCs°tjj|jdƒ}t|dƒ}|jdƒWdQXi}tjj||ddƒ|j |ddƒtjj||dddt ƒ|j |ddj dƒƒdS( sattach_file() for binary filestdatatwbsaöbÿxNtkeyt force_unicodesaöb�xsUTF-8( tostpathtjoinRR3R RRR6RtTruetdecode(RtmyfileR#R,((s-/usr/share/apport/testsuite/test_hookutils.pyttest_attach_file_binarytscCsétdƒ}|jƒjƒ}WdQXi}tjj|dƒ|jt|ƒdgƒ|j|d|ƒi}tjj|ddƒ|jt|ƒdgƒ|j|d|ƒi}tjj|dƒ|jt|ƒgƒdS(sattach_file_if_exists()s /etc/passwdNs .etc.passwdR1s /nonexisting(R3R4R5RRtattach_file_if_existsRR7(RR#R;R,((s-/usr/share/apport/testsuite/test_hookutils.pyttest_attach_file_if_exists‚scCs||jtjjdtjdƒƒdƒ|jtjjtjdƒƒdƒ|jttjjtjdƒƒƒdƒdS(trecent_logfiles /nonexistingt.ttThisCantPossiblyHitAnythingiN( RRRRKtretcompilet recent_syslogtassertNotEqualR+(R((s-/usr/share/apport/testsuite/test_hookutils.pyttest_recent_logfile™s(%cCs~ddd}ddd}i}tjj|ƒ|jd|kƒi}dddd |d GSI 16 (level, low) s>[ 2.997544] i915 0000:00:02.0: setting latency timer to 64 s7[ 3.061584] i915 0000:00:02.0: irq 42 for MSI/MSI-X tTagssC[ 32.420248] type=1400 audit(1344562672.449:2): apparmor="STATUS"s7 operation="profile_load" name="/sbin/dhclient" pid=894s comm="apparmor_parser" tapparmortAuditLogtbogustagsbogustag apparmors/usr/sbin/cupsds/usr/sbin/cups.*s /usr/sbin/cups/usr/sbin/nonexistents/usr/bin/nonexistents/usr/sbin/anotherones? operation="capable" parent=1 profile="/usr/sbin/blah" pid=1361N(RRtattach_mac_eventsRR R(Rt denied_logt denied_hexR,tprofiles((s-/usr/share/apport/testsuite/test_hookutils.pyttest_attach_mac_events sŠ                  cCs tjj|jdƒ}t|dƒ7}d}x'|dkrY|jdƒ|d8}q3WWdQX|jƒ}tjj |t j dƒƒ}|jƒ}||}t j jd |ƒ|j|d ƒ|j|jdƒƒ|jt|ƒd ƒ|jt|ƒdƒdS( srecent_logfile on a huge filetsyslogtwi@Bis/Apr 20 11:30:00 komputer kernel: bogus message iNtkernels [Δ %i kB] iˆi †(RBRCRDRR3R t_get_mem_usageRRRKRORPtsyststderrt assertLessRR*t assertGreaterR+(RtlogR#tlinest mem_beforeR>t mem_aftertdelta_kb((s-/usr/share/apport/testsuite/test_hookutils.pyttest_recent_logfile_overflow#s    sno logind sessioncCsNtjtjƒ}tjtjdƒidd6}|jtjj|ƒƒidd6}|jtjj|ƒƒidd6}|jtjj|ƒƒtjtjdƒidd6}|jtjj|ƒƒidd6}|jtjj|ƒƒtj ƒ}|jtjj|ƒƒ|j tjjiƒdƒtjtj|ƒdS(sin_session_of_problem()tCsSat Jan 1 12:00:00 2011tDatesMon Oct 10 21:06:03 2009sTue Jan 1 12:00:00 2038RMN( tlocalet getlocaletLC_TIMEt setlocaleR RRtin_session_of_problemRtReportRtNone(Rt old_ctimeR,((s-/usr/share/apport/testsuite/test_hookutils.pyttest_in_session_of_problem8s"      cCsættjj|jdƒdddƒ}|jdƒWdQXtjjdƒ}zf|jtjd:0 some unicode ♥ ♪ GNOME_KEYRING_CONTROL=/tmp/keyring-u7hrD6 (gnome-settings-daemon:5115): Gdk-WARNING **: The program 'gnome-settings-daemon' received an X Window System error. This probably reflects a bug in the program. The error was 'BadMatch (invalid parameter attributes)'. (Details: serial 723 error_code 8 request_code 143 minor_code 22) (Note to programmers: normally, X errors are reported asynchronously; that is, you will receive the error a while after causing it. To debug your program, run it with the --sync command line option to change this behavior. You can then get a meaningful backtrace from your debugger if you break on the gdk_x_error() function.)" GdkPixbuf-CRITICAL **: gdk_pixbuf_scale_simple: another standard glib assertion NtHOMEtnotfoundRMs ^\w+-CRITICALiisEggSMClient-CRITICALisGdkPixbuf-CRITICALsnonstandard warningtkeyringt credentialssWARNING: standard glib warnings,'gnome-settings-daemon' received an X WindowtBadMatchs serial 723(R3RBRCRDRR tenvirontgetRORPRRRtxsession_errorst splitlinesR+RR*R Rttunsetenv(RR#t orig_hometpatterntres((s-/usr/share/apport/testsuite/test_hookutils.pyttest_xsession_errorsWs2*  cCsïi}tjj|ƒtjj|ƒtjj|ƒtjj|ƒtjj|ƒtjj|dƒtjj|dƒtjj|dƒtjj|dƒtjj|dƒtjj |dƒtjj |dƒtjj |ƒdS(s%functions do not crash (very shallow)tbashRt nonexistingN( RRtattach_hardwaret attach_alsatattach_networkt attach_wifitattach_printingtattach_conffilestattach_upstart_overridestattach_upstart_logstattach_default_grub(RR,((s-/usr/share/apport/testsuite/test_hookutils.pyttest_no_crashes‘scCstjjdƒ}dtjds` ÿÁ