Your IP : 172.28.240.42


Current Path : /usr/share/apport/testsuite/
Upload File :
Current File : //usr/share/apport/testsuite/test_hookutils.pyc


Yc@sddlZddlZddlZddlZddlZddlZddlZddlZddl	Z
dejfdYZej
dS(iNtTcBseZdZdZdZdZdZdZdZdZ	dZ
eje
jj
jje
jdkd	d
ZdZdZd
ZedZRS(cCstj|_dS(N(ttempfiletmkdtemptworkdir(tself((s-/usr/share/apport/testsuite/test_hookutils.pytsetUpscCstj|jdS(N(tshutiltrmtreeR(R((s-/usr/share/apport/testsuite/test_hookutils.pyttearDown
scCsDd}|d}|d}|jdtjjdk|jtjjdd|jdtjj|jk|jdtjj|jktj}|jd|j|jfj	|j
tjj|j}|jd|k|jd|k|j|j|k|j|j|kdS(	s*module licenses can be validated correctlycSs|tjdd|dd}|jd|j|jtjdd|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_licensetassertEqualRRRRR
Rtnonfree_kernel_modulestassertFalse(RRtgood_kotbad_kotftnonfree((s-/usr/share/apport/testsuite/test_hookutils.pyttest_module_license_evaluation
s 	
	""	
cCski}tjj||j|djd|jt|ddk|j|djddS(s7attach_dmesg() does not overwrite already existing datat	BootDmesgt[itCurrentDmesgN(RRtattach_dmesgRt
startswithtlen(Rtreport((s-/usr/share/apport/testsuite/test_hookutils.pyttest_attach_dmesg4s
cCsidd6}tjj||j|dd d|j|djdidd6dd6}tjj||j|dd|j|dddS(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
cCstdd}|jj}WdQXtdd}|jj}WdQXi}tjj|d|jt|dg|j|d|i}tjj|dd|jt|dg|j|d|i}tjj|d|jt|dg|j|dj	d	i}tjj|dtjj|d|jt|dg|j|d|tjj|ddd
t
|jt|jddg|j|d||j|d|dS(s
attach_file()s	/etc/motdtrbNs
/etc/issues	.etc.motdtMotds/nonexistings.nonexistingsError: t	overwrites
.etc.motd_(
topentreadtstripRRtattach_fileRtlistRR*tFalsetsortedtkeys(RR#t
motd_contentstissue_contentsR,((s-/usr/share/apport/testsuite/test_hookutils.pyttest_attach_fileMs2"cCstdd}|jj}WdQXi}tjj|d|jt|dg|j|d|i}tjj|dd|jt|dg|j|d|i}tjj|d|jt|gdS(sattach_file_if_exists()s	/etc/motdR1Ns	.etc.motdR2s/nonexisting(R4R5R6RRtattach_file_if_existsRR8(RR#R<R,((s-/usr/share/apport/testsuite/test_hookutils.pyttest_attach_file_if_existssscCs||jtjjdtjdd|jtjjtjdd|jttjjtjdddS(trecent_logfiles/nonexistingt.ttThisCantPossiblyHitAnythingiN(	RRRRAtretcompilet
recent_syslogtassertNotEqualR+(R((s-/usr/share/apport/testsuite/test_hookutils.pyttest_recent_logfiles(%cCs
tjj|jd}t|d7}d}x'|dkrY|jd|d8}q3WWdQX|j}tjj	|t
jd}|j}||}tj
jd	||j|d
|j|jd|jt|d|jt|ddS(srecent_logfile on a huge filetsyslogtwi@Bis/Apr 20 11:30:00 komputer kernel: bogus message
iNtkernels[Δ %i kB] ii(tostpathtjoinRR4Rt_get_mem_usageRRRARERFtsyststderrt
assertLessRR*t
assertGreaterR+(RtlogR#tlinest
mem_beforetdatat	mem_aftertdelta_kb((s-/usr/share/apport/testsuite/test_hookutils.pyttest_recent_logfile_overflows

sno ConsoleKit sessioncCsNtjtj}tjtjdidd6}|jtjj|idd6}|jtjj|idd6}|jtjj|tjtjdidd6}|jtjj|idd6}|jtjj|tj	}|jtjj||j
tjjidtjtj|dS(sin_session_of_problem()tCsSat Jan  1 12:00:00 2011tDatesMon Oct 10 21:06:03 2009sTue Jan  1 12:00:00 2211RCN(tlocalet	getlocaletLC_TIMEt	setlocaleR RRtin_session_of_problemRtReportRtNone(Rt	old_ctimeR,((s-/usr/share/apport/testsuite/test_hookutils.pyttest_in_session_of_problems"




cCsttjj|jdd}|jdWdQXtjjd}zf|jtjd<tj	d}|j
tjj
|dtj	d}tjj
|j}|j
t|d	|j|d
jd|j|djd
tjj
}|jd|k|jd|k|jd|k|jd|k||jd
|k||jd|k||jd|k||jd|k|Wd|dk	r|tjd<n
tjdXdS(sxsession_errors()s.xsession-errorsRKs&Loading profile from /etc/profile
gnome-session[1948]: WARNING: standard glib warning
EggSMClient-CRITICAL **: egg_sm_client_set_mode: standard glib assertion
24/02/2012 11:14:46 Sending credentials s3kr1t

** WARNING **: nonstandard warning

WARN  2012-02-24 11:23:47 unity <unknown>: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
NtHOMEtnotfoundRCs
^\w+-CRITICALiisEggSMClient-CRITICALisGdkPixbuf-CRITICALsnonstandard warningtkeyringtcredentialssWARNING: standard glib warnings,'gnome-settings-daemon' received an X WindowtBadMatchs
serial 723(R4RMRNRORRtenvirontgetRERFRRRtxsession_errorst
splitlinesR+RR*R Rdtunsetenv(RR#t	orig_hometpatterntres((s-/usr/share/apport/testsuite/test_hookutils.pyttest_xsession_errorss2$
cCsi}tjj|tjj|tjj|tjj|tjj|tjj|dtjj|dtjj|dtjj|dtjj|ddS(s%functions do not crash (very shallow)tbashRtnonexistingN(	RRtattach_hardwaretattach_alsatattach_networktattach_wifitattach_printingtattach_conffilestattach_upstart_overrides(RR,((s-/usr/share/apport/testsuite/test_hookutils.pyttest_no_crashesscCstjjd}dtjd<z]tjjdg}|jd|ktjjdgdt}|jd|k|Wd|dk	r|tjd<n
tj
dXtjjdg}|j|jdtjjdgd	d
}|j|d
dS(NtLC_MESSAGESsen_US.UTF-8tenvs
LC_MESSAGES=Ctkeep_locales
/non existingsError: [Errno 2]tcattinputthello(
RMRlRmRRtcommand_outputRtTrueR RdRpR*R(Rtorig_lcmtout((s-/usr/share/apport/testsuite/test_hookutils.pyttest_command_outputs
cCsYtdG}x=|D])}|jdrt|jdSqWtdWdQXdS(sGet current memory usage in kBs/proc/self/statussVmSize:is)did not find VmSize: in /proc/self/statusN(R4R*tinttsplittSystemError(tklassR#tline((s-/usr/share/apport/testsuite/test_hookutils.pyRP's

N(t__name__t
__module__RRR%R-R0R>R@RIR[tunittesttskipIfRRRbRcRdRfRtR~RtclassmethodRP(((s-/usr/share/apport/testsuite/test_hookutils.pyRs			'	
		&			9	:		(RRR^RRERtos.pathRMRQtapport.hookutilsRtTestCaseRtmain(((s-/usr/share/apport/testsuite/test_hookutils.pyt<module>s`-