ó
qxPXc           @   sW  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l	 Z	 d  d l
 Z
 d  d l Z y d  d l m Z Wn! e k
 rÇ d  d l m Z n Xd  d l Z d  d l m Z d  d l Z d  d l Z d  d l Z d  d l Z d e j j f d „  ƒ  YZ d e  j f d „  ƒ  YZ e  j ƒ  d S(   iÿÿÿÿN(   t   StringIO(   t   _t   TestSuiteUserInterfacec           B   s•   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s?   Concrete apport.ui.UserInterface suitable for automatic testingc         C   sõ   t  j ƒ  |  _ |  j j d ƒ |  j j ƒ  |  j j t j d <t j	 j
 j |  ƒ t j j j d  i d d 6d d 6ƒ |  _ t |  _ d |  _ t |  _ d |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ t |  _ |  j ƒ  d  S(   Nsz   default = 'testsuite'
databases = {
    'testsuite': {
        'impl': 'memory',
        'bug_pattern_url': None,
    }
}
t   APPORT_CRASHDB_CONFi   t
   dummy_datat    t	   dupdb_urli    (   t   tempfilet   NamedTemporaryFilet   crashdb_conft   writet   flusht   namet   ost   environt   apportt   uit   UserInterfacet   __init__t   crashdb_implt   memoryt   CrashDatabaset   Nonet   crashdbt   Falset   ic_progress_activet   ic_progress_pulsest   upload_progress_activet   upload_progress_pulsest   present_package_error_responset   present_kernel_error_responset   present_details_responset   question_yesno_responset   question_choice_responset   question_file_responset
   opened_urlt   present_details_shownt	   clear_msg(   t   self(    (    s&   /usr/share/apport/testsuite/test_ui.pyR      s*    													c         C   s(   d  |  _ d  |  _ d  |  _ d  |  _ d  S(   N(   R   t	   msg_titlet   msg_textt   msg_severityt   msg_choices(   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyR%   ;   s    			c         C   s   t  |  _ |  j S(   N(   t   TrueR$   R   (   R&   t	   is_update(    (    s&   /usr/share/apport/testsuite/test_ui.pyt   ui_present_report_detailsB   s    	c         C   s   | |  _  | |  _ d |  _ d  S(   Nt   info(   R'   R(   R)   (   R&   t   titlet   text(    (    s&   /usr/share/apport/testsuite/test_ui.pyt   ui_info_messageF   s    		c         C   s   | |  _  | |  _ d |  _ d  S(   Nt   error(   R'   R(   R)   (   R&   R/   R0   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   ui_error_messageK   s    		c         C   s   d |  _  t |  _ d  S(   Ni    (   R   R+   R   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt!   ui_start_info_collection_progressP   s    	c         C   s"   |  j  s t ‚ |  j d 7_ d  S(   Ni   (   R   t   AssertionErrorR   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt!   ui_pulse_info_collection_progressT   s    c         C   s   t  |  _ d  S(   N(   R   R   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt    ui_stop_info_collection_progressX   s    c         C   s   d |  _  t |  _ d  S(   Ni    (   R   R+   R   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   ui_start_upload_progress[   s    	c         C   s"   |  j  s t ‚ |  j d 7_ d  S(   Ni   (   R   R5   R   (   R&   t   progress(    (    s&   /usr/share/apport/testsuite/test_ui.pyt   ui_set_upload_progress_   s    c         C   s   t  |  _ d  S(   N(   R   R   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   ui_stop_upload_progressc   s    c         C   s   | |  _  d  S(   N(   R#   (   R&   t   url(    (    s&   /usr/share/apport/testsuite/test_ui.pyt   open_urlf   s    c         C   s   | |  _  |  j S(   N(   R(   R    (   R&   R0   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   ui_question_yesnoi   s    	c         C   s   | |  _  | |  _ |  j S(   N(   R(   R*   R!   (   R&   R0   t   optionst   multiple(    (    s&   /usr/share/apport/testsuite/test_ui.pyt   ui_question_choicem   s    		c         C   s   | |  _  |  j S(   N(   R(   R"   (   R&   R0   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   ui_question_filer   s    	(   t   __name__t
   __module__t   __doc__R   R%   R-   R1   R3   R4   R6   R7   R8   R:   R;   R=   R>   RA   RB   (    (    (    s&   /usr/share/apport/testsuite/test_ui.pyR      s    	'													t   Tc           B   sW  e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! d „  Z" d  „  Z# d! „  Z$ d" „  Z% d# „  Z& d$ „  Z' d% „  Z( d& „  Z) d' „  Z* d( „  Z+ d) „  Z, d* „  Z- d+ „  Z. d, „  Z/ d- „  Z0 d. „  Z1 d/ „  Z2 d0 „  Z3 d1 „  Z4 d2 „  Z5 d3 „  Z6 d4 „  Z7 d5 „  Z8 d6 „  Z9 d7 „  Z: d8 „  Z; d9 „  Z< d: „  Z= d; „  Z> d< „  Z? d= „  Z@ d> „  ZA d? „  ZB d@ „  ZC RS(A   c         C   s•  x< d d d d g D]( } y t  j | =Wq t k
 r: q Xq Wt j j |  _ t j ƒ  t j _ t j	 j
 |  _ t j ƒ  t j	 _
 t j j |  _ t j ƒ  \ } t j _ t  j | ƒ t j |  _ d g t _ t ƒ  |  _	 t j ƒ  |  _ d |  j d <d |  j d	 <d
 |  j d <d d |  j d <d d |  j d <t j ƒ  |  _ |  j ƒ  t j ƒ  |  _ t j j |  _ |  j t j _ d t  j d <d t  j d <d  S(   Nt   LANGt   LANGUAGEt   LC_MESSAGESt   LC_ALLs   ui-tests	   /bin/basht   ExecutablePaths   libfoo1 1-1t   Packaget   foot   SourcePackaget   Aiè  t   Fooi † t   CoreDumpt   1t   APPORT_IGNORE_OBSOLETE_PACKAGESt   APPORT_DISABLE_DISTRO_CHECK(   R   R   t   KeyErrorR   t	   fileutilst
   report_dirt   orig_report_dirR   t   mkdtempR   t   symptom_script_dirt   orig_symptom_script_dirt   reportt   _ignore_filet   orig_ignore_filet   mkstempt   closet   syst   argvt	   orig_argvR   t   ReportR   t   report_filet   update_report_filet   hookdirt	   _hook_dirt   orig_hook_dir(   R&   t   vt   fd(    (    s&   /usr/share/apport/testsuite/test_ui.pyt   setUpw   s8    
c         C   sA   |  j  j d ƒ |  j  j ƒ  |  j j |  j  ƒ |  j  j ƒ  d  S(   Ni    (   Re   t   seekt   truncateR\   R
   R   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyRf   ¡   s    c         C   s  |  j  t _ t j t j j ƒ |  j t j _ d  |  _ t j t j
 j ƒ |  j t j
 _ d  |  _ t j t j j ƒ |  j t j _ d  |  _
 |  j j ƒ  |  j t j d d g ƒ d d ƒ x< t j d ƒ D]+ } y t j | ƒ WqÌ t k
 rö qÌ XqÌ Wt j |  j ƒ |  j t j _ d  S(   Nt   pidofs   /bin/yesi   s   no stray test processess   /var/crash/_usr_bin_yes.*.crash(   Rc   Ra   Rb   t   shutilt   rmtreeR   RV   RW   RX   R   R   RZ   R[   R   t   unlinkR\   R]   R^   Re   R`   t   assertEqualt
   subprocesst   callt   globt   OSErrorRg   Ri   Rh   (   R&   t   f(    (    s&   /usr/share/apport/testsuite/test_ui.pyt   tearDown§   s&    			"c         C   sä   |  j  |  j j d ƒ d ƒ |  j  |  j j d ƒ d ƒ |  j  |  j j d ƒ d ƒ |  j  |  j j d ƒ d ƒ |  j  |  j j d	 ƒ d
 ƒ |  j  |  j j d ƒ d ƒ |  j  |  j j d ƒ d ƒ |  j  |  j j d ƒ d ƒ d S(   s   format_filesize()i    s   0.0 KBi   s   2.0 KBi 
  s   2.6 KBi?B s	   1000.0 KBi@B s   1.0 MBgš™™™™™@s   2.7 MBi   s   1.0 GBs   2.6 GBNg    p™DAi  	=I €–˜    (   Rs   R   t   format_filesize(   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_format_filesizeÂ   s    c         C   s%  |  j  j |  j j ƒ t j j |  j j ƒ } t |  j  j ƒ  ƒ | } |  j	 | d k ob | d k ƒ |  j  j
 ƒ  } |  j	 | d k ƒ |  j	 | d k  ƒ d d |  j  j d <|  j  j ƒ  } |  j	 | | d k ƒ |  j	 | | d	 k  ƒ |  j  j
 ƒ  } |  j	 | d
 k ƒ |  j	 | d	 k  ƒ d S(   s=   get_complete_size() and get_reduced_size() for loaded Reportsg®Gáz®ï?g)\Âõ(ð?iè  i'  RO   iPÃ  t	   ExtraInfoiìÂ  i`ê  i8Ç  N(   R   t   load_reportRe   R   R   t   patht   getsizet   floatt   get_complete_sizet
   assertTruet   get_reduced_sizeR\   (   R&   t   fsizet   complete_ratiot   rst   s(    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_get_size_loadedÎ   s    c         C   sw   t  j d ƒ |  j _ d |  j j d <|  j j ƒ  } |  j | d k ƒ |  j | d k  ƒ |  j | |  j j ƒ  ƒ d S(   sA   get_complete_size() and get_reduced_size() for on-the-fly Reportst   Bugt   Worldt   Helloi   id   N(   R   Rd   R   R\   R   R‚   Rs   Rƒ   (   R&   R‡   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_get_size_constructedå   s    c         C   sz  |  j  j |  j j ƒ |  j |  j  j |  j ƒ |  j |  j  j d	 ƒ |  j d =|  j d =|  j d =|  j ƒ  |  j  j |  j j ƒ |  j	 |  j  j d	 k ƒ |  j |  j  j t
 d ƒ ƒ |  j |  j  j d ƒ |  j  j ƒ  |  j j d ƒ |  j j ƒ  |  j j d ƒ |  j j ƒ  |  j  j |  j j ƒ |  j	 |  j  j d	 k ƒ |  j |  j  j t
 d ƒ ƒ |  j |  j  j d ƒ d	 S(
   s   load_report()RL   RN   RK   s   Invalid problem reportR.   i    s4   Type: test
Package: foo 1-1
CoreDump: base64
bOgUs=
R2   N(   R   R}   Re   R   Rs   R\   R'   R   Rf   R‚   R   R)   R%   Rm   Rn   R
   R   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_load_reportñ   s*    



	c         C   s‡  t  j j t j j d ƒ } t  j j t j j d ƒ } d | |  j d <|  j ƒ  |  j j	 |  j
 j ƒ |  j j ƒ  t j d ƒ |  j t  j j | ƒ ƒ |  j t  j j | ƒ ƒ t  j | ƒ d | |  j d <|  j ƒ  |  j j	 |  j
 j ƒ |  j j ƒ  t j d ƒ |  j t  j j | ƒ ƒ |  j t  j j | ƒ ƒ t  j | ƒ |  j d =d |  j d <|  j ƒ  |  j j	 |  j
 j ƒ d S(   s	   restart()t   ProcCmdlinet   Customs   touch i   t   RespawnCommands   /nonexistingN(   R   R~   t   joinR   RV   RW   R\   Rf   R   R}   Re   R   t   restartt   timet   sleepR‚   t   existsRr   (   R&   t   pt   r(    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_restart  s,    



c         C   sv   t  j ƒ  |  j _ |  j j ƒ  |  j t d d d d g ƒ j t |  j j j ƒ  ƒ ƒ ƒ |  j	 |  j j
 d d ƒ d S(   s9   collect_info() on report without information (distro bug)t   Datet   Unamet   DistroReleaset   ProblemTypei    s1   no progress dialog for distro bug info collectionN(   R   Rd   R   R\   t   collect_infoR‚   t   sett   issubsett   keysRs   R   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_collect_info_distro6  s    c      
   C   sú   t  j d ƒ |  _ d |  j d <|  j ƒ  |  j j |  j j ƒ d t f |  j j d <t	 j
 d ƒ |  j j d <|  j j ƒ  |  j t d d	 d
 d d d d d g ƒ j t |  j j j ƒ  ƒ ƒ ƒ |  j |  j j d k d ƒ |  j |  j j t d ƒ d S(   s1   collect_info() on report with only ExecutablePathR‰   s	   /bin/bashRK   s
   /etc/fstabt   Fstabt   Testt   CompressedValueRN   RL   Rœ   Rš   t   DependenciesR›   R™   i    s/   progress dialog for package bug info collections8   progress dialog for package bug info collection finishedN(   R   Rd   R\   Rf   R   R}   Re   R   R+   t   problem_reportR¤   R   R‚   Rž   RŸ   R    R   Rs   R   R   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_collect_info_exepathA  s    
(c      	   C   sª   t  j d ƒ |  j _ d |  j _ |  j j ƒ  |  j t d d d d d d d	 g ƒ j t |  j j j	 ƒ  ƒ ƒ ƒ |  j |  j j
 d
 k d ƒ |  j |  j j t d ƒ d S(   s'   collect_info() on report with a packageR‰   t   bashRN   RL   Rœ   Rš   R¥   R›   R™   i    s/   progress dialog for package bug info collections8   progress dialog for package bug info collection finishedN(   R   Rd   R   R\   t   cur_packageR   R‚   Rž   RŸ   R    R   Rs   R   R   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_collect_info_packageV  s    	(c         C   sj   t  j d ƒ |  j _ d |  j _ |  j j |  j _ |  j j ƒ  |  j t	 j
 |  j j ƒ j t
 j @ƒ d S(   s8   collect_info() leaves the report accessible to the groupR‰   R¨   N(   R   Rd   R   R\   R©   Re   R   R   R‚   R   t   statt   st_modet   S_IRGRP(   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_collect_info_permissionse  s
    c         C   s[  |  j  j |  j j ƒ |  j |  j  j ƒ  t ƒ |  j |  j  j d ƒ |  j |  j  j	 d ƒ d } | |  j
 d <|  j ƒ  |  j  j |  j j ƒ |  j |  j  j ƒ  t ƒ |  j |  j  j d ƒ |  j |  j  j	 | ƒ d |  j  _	 d } d |  j
 d <|  j ƒ  |  j  j |  j j ƒ |  j |  j  j ƒ  t ƒ |  j |  j  j d ƒ |  j |  j  j	 d ƒ d S(   s   handle_duplicate()s   http://example.com/1t   KnownReportR.   RR   N(   R   R}   Re   R   Rs   t   handle_duplicateR   R'   R   R#   R\   Rf   R+   R)   (   R&   t   demo_url(    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_handle_duplicaten  s&    

c         C   s2   g  t  _ t ƒ  |  _ |  j |  j j ƒ  t ƒ d S(   s0   running the frontend without any pending reportsN(   Ra   Rb   R   R   Rs   t   run_argvR   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_nopending‡  s    	c         C   s°   |  j  ƒ  } t j j t j j d ƒ } t | d ƒ  } | j | ƒ Wd QXg  t	 _
 t ƒ  |  _ i t d 6t d 6t d 6t d 6|  j _ |  j j ƒ  |  j |  j j t ƒ d S(   s8   running the frontend with pending reports offers restarts
   test.crasht   wbNR\   t	   blacklistt   examineR’   (   t   _gen_test_crashR   R~   R‘   R   RV   RW   t   openR
   Ra   Rb   R   R   R   R   R³   Rs   t   offer_restartR+   (   R&   R—   Re   Rx   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_restartŽ  s    	
c         C   sN   d d g t  _ t ƒ  |  _ |  j |  j j ƒ  t ƒ |  j |  j j d ƒ d S(   s-   run_report_bug() without specifying argumentss   ui-tests   -fR2   N(   Ra   Rb   R   R   Rs   R³   R   R)   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_report_bug_noargsž  s    c         C   s   d d g t  _ t ƒ  |  _ t  j } t ƒ  t  _ |  j |  j j ƒ  t ƒ t  j j	 ƒ  } | t  _ |  j | t
 j j d ƒ d S(   s6   run_report_bug() as "ubuntu-bug" with version arguments
   ubuntu-bugs   -vs   
N(   Ra   Rb   R   R   t   stdoutR    Rs   R³   R+   t   getvalueR   t   __version__(   R&   t   orig_stdoutt   output(    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_version¦  s    		c         C   sš  d d d d g t  _ t ƒ  |  _ i t d 6t d 6t d 6t d 6|  j _ |  j |  j j ƒ  t ƒ |  j |  j j	 d ƒ |  j |  j j d ƒ |  j |  j j ƒ |  j |  j j d	 |  j j j ƒ  ƒ |  j |  j j d
 k ƒ |  j |  j j d d ƒ |  j d |  j j j ƒ  k ƒ |  j d |  j j j ƒ  k ƒ |  j |  j j d d ƒ d d d d g t  _ t ƒ  |  _ |  j j ƒ  |  j |  j j	 d ƒ d S(   s   run_report_bug() for a packages   ui-tests   -fs   -pR¨   R\   R¶   R·   R’   s   http://bash.bugs.example.com/%ii    RN   R¥   t   ProcEnvironRœ   R‰   t   nonexisting_gibberishR2   N(   Ra   Rb   R   R   R+   R   R   Rs   R³   R)   R   R'   R‚   R$   R#   R   t	   latest_idR   R\   R    (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_report_bug_package²  s(    
&c         C   s•  t  j ƒ  } | d k rh t  j t  j d t  j ƒ t j j ƒ  ƒ t  j d d g ƒ t	 sh t
 d ƒ ‚ n  t j d ƒ zr d d d	 d
 d t | ƒ g t _ t ƒ  |  _ i t d 6t	 d 6t	 d 6t	 d 6|  j _ |  j |  j j ƒ  t ƒ Wd t  j | t j ƒ t  j | d ƒ X|  j d |  j j j ƒ  k ƒ |  j d |  j j j ƒ  k ƒ |  j d |  j j j ƒ  k ƒ |  j |  j j d d ƒ |  j d |  j j k ƒ |  j d |  j j j ƒ  k ƒ |  j |  j j d d ƒ |  j d |  j j j ƒ  k ƒ |  j d
 |  j j d k ƒ |  j |  j j d ƒ |  j |  j j d ƒ |  j |  j j  d |  j j! j" ƒ  ƒ |  j |  j j# ƒ |  j |  j j$ d k ƒ d S(   s*   run_report_bug() for a pid with extra tagsi    s	   /dev/nulls   /usr/bin/yest   yess   Could not execute /usr/bin/yesg      à?s   ui-tests   -fs   --tagRM   s   -PR\   R¶   R·   R’   NRN   R¥   t   ProcMapsRK   RŽ   RÃ   Rœ   R‰   t   Tagss$   http://coreutils.bugs.example.com/%i(%   R   t   forkt   dup2R¹   t   O_WRONLYRa   R½   t   filenot   execvR   R5   R“   R”   t   strRb   R   R   R+   R   Rs   R³   t   killt   signalt   SIGKILLt   waitpidR‚   R\   R    t   assertFalseR)   R   R'   R#   R   RÅ   R$   R   (   R&   t   pid(    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_report_bug_pid_tagsÏ  s<    (!
&c         C   sa   d } xT t  r\ | d 7} y t j | d ƒ Wq	 t k
 rX } | j t j k rY PqY q	 Xq	 W| S(   s   Find and return an unused PIDi   i    (   R+   R   RÐ   Rw   t   errnot   ESRCH(   t   klassRÕ   t   e(    (    s&   /usr/share/apport/testsuite/test_ui.pyt   _find_unused_pidù  s    	
c         C   sD   |  j  ƒ  } d d d t | ƒ g t _ t ƒ  |  _ |  j j ƒ  d S(   s&   run_report_bug() for a nonexisting pids   ui-tests   -fs   -PN(   RÛ   RÏ   Ra   Rb   R   R   R³   (   R&   RÕ   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_report_bug_wrong_pid  s    c         C   s    t  } t j ƒ  d k r4 t j d d d ƒ t } n  zH d d d d g t _ t ƒ  |  _ |  j j	 ƒ  |  j
 |  j j d ƒ Wd	 | r› t j d d d ƒ n  Xd	 S(
   s9   run_report_bug() for a pid which runs as a different useri    i   iÿÿÿÿs   ui-tests   -fs   -PRR   R2   N(   R   R   t   getuidt	   setresuidR+   Ra   Rb   R   R   R³   Rs   R)   (   R&   t   restore_root(    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_report_bug_noperm_pid  s    	c         C   s*  t  j ƒ  \ } } t j | t d ƒ j ƒ  ƒ t j | ƒ t j | d ƒ t j ƒ  } | d k r¡ t j	 t j d t j
 ƒ t j j ƒ  ƒ t j | | g ƒ n  zA d d d t | ƒ g t _ t ƒ  |  _ |  j t |  j j ƒ Wd t j | t j ƒ t j ƒ  t j | ƒ X|  j |  j j d	 ƒ d S(
   s3   run_report_bug() for a pid of an unpackaged programs   /usr/bin/yesií  i    s	   /dev/nulls   ui-tests   -fs   -PNR2   (   R   R_   R   R
   R¹   t   readR`   t   chmodRÊ   RË   RÌ   Ra   R½   RÍ   RÎ   RÏ   Rb   R   R   t   assertRaisest
   SystemExitR³   RÐ   RÑ   RÒ   t   waitRr   Rs   R)   (   R&   Rk   t   exenameRÕ   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt"   test_run_report_bug_unpackaged_pid$  s     (
c         C   s  d } xc t j d ƒ D]R } t | ƒ j ƒ  j ƒ  } t | d ƒ } | t j j @r t | d ƒ } Pq q W|  j	 | d k ƒ d d d t
 | ƒ g t _ t ƒ  |  _ i t d 6t d 6t d	 6t d
 6|  j _ |  j j ƒ  |  j |  j j d j t j j ƒ  ƒ ƒ d S(   s-   run_report_bug() for a pid of a kernel threads   /proc/[0-9]*/stati   i    s   ui-tests   -fs   -PR\   R¶   R·   R’   RL   N(   R   Rv   R¹   Rá   t   splitt   intR   R   t
   PF_KTHREADRÔ   RÏ   Ra   Rb   R   R+   R   R   R³   R‚   R\   t
   startswitht	   packagingt   get_kernel_package(   R&   RÕ   R~   R«   t   flags(    (    s&   /usr/share/apport/testsuite/test_ui.pyt!   test_run_report_bug_kernel_thread>  s     
c         C   s  t  j j t j j d ƒ } t  j | ƒ t  j j | d ƒ } d d d d d | g t _ t	 ƒ  |  _
 |  j |  j
 j ƒ  t ƒ |  j |  j
 j d ƒ |  j |  j
 j d ƒ |  j |  j
 j d ƒ |  j |  j
 j ƒ |  j |  j
 j d k ƒ t j ƒ  } | j t | ƒ ƒ |  j | d	 d ƒ |  j d
 | j ƒ  k ƒ |  j d | j ƒ  k ƒ |  j | d d ƒ d d | g t _ t	 ƒ  |  _
 i t d 6t d 6t d 6t d 6|  j
 _ |  j |  j
 j ƒ  t ƒ |  j |  j
 j d ƒ |  j |  j
 j d ƒ |  j |  j
 j ƒ d S(   s/   run_report_bug() with saving report into a filet   homes   bashisbad.apports   ui-tests   -fs   -pR¨   s   --savei    RN   R¥   RÃ   Rœ   R‰   s   -cR\   R¶   R·   R’   N(   R   R~   R‘   R   RV   RW   t   mkdirRa   Rb   R   R   Rs   R³   R+   R)   R   R'   R#   RÔ   R$   R‚   R   Rd   t   loadR¹   R    R   R   R(   (   R&   t   dt
   reportfileR—   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_report_bug_fileT  s6    
c         C   sŒ  d } t  j | t  j ƒ s+ t | d ƒ ‚ t  j ƒ  } | d k rÔ t  j t  j d t  j ƒ t j	 j
 ƒ  ƒ t j j ƒ  t  j ƒ  t j t j d ƒ t  j t j j ƒ t  j | | g ƒ t sÔ t d | ƒ ‚ n  t j d ƒ t j ƒ  } | | d <d	 | d
 <| j | ƒ | j ƒ  t  j j t j j d ƒ } t  j | t j  ƒ t  j! | d ƒ t j d ƒ t  j j" | ƒ s{t ‚ | f | d <| S(   s&   Generate a Report with real crash datas   /usr/bin/yess    is not executablei    s	   /dev/nulliÿÿÿÿs   Could not execute g      à?RK   t   11t   Signalt   coreRQ   (   iÿÿÿÿiÿÿÿÿ(#   R   t   accesst   X_OKR5   RÊ   RË   R¹   RÌ   Ra   R½   RÍ   t   stdinR`   t   setsidt   resourcet	   setrlimitt   RLIMIT_COREt   chdirR   RV   RW   RÎ   R   R“   R”   Rd   t   add_proc_infot   add_user_infoR~   R‘   RÐ   RÑ   t   SIGSEGVRÓ   R•   (   R&   t   test_executableRÕ   R—   t   coredump(    (    s&   /usr/share/apport/testsuite/test_ui.pyR¸   {  s0    %(



c         C   sö  |  j  ƒ  } t j j t j j d ƒ } | j t | d ƒ ƒ t	 ƒ  |  _
 i t d 6t d 6t d 6t d 6|  j
 _ |  j
 j | ƒ |  j |  j
 j d ƒ |  j |  j
 j d ƒ |  j |  j
 j d ƒ |  j |  j
 j d ƒ |  j |  j
 j t ƒ | j t | d ƒ ƒ t	 ƒ  |  _
 i t d 6t d 6t d 6t d 6|  j
 _ |  j
 j | ƒ |  j |  j
 j d |  j
 j ƒ |  j |  j
 j d ƒ |  j |  j
 j d |  j
 j j ƒ  ƒ |  j |  j
 j ƒ |  j |  j
 j d ƒ |  j |  j
 j ƒ |  j d	 |  j
 j j ƒ  k ƒ |  j d
 |  j
 j j ƒ  k ƒ |  j d |  j
 j j ƒ  k ƒ |  j d |  j
 j j ƒ  k ƒ |  j d |  j
 j j ƒ  k ƒ |  j d |  j
 j j ƒ  k ƒ |  j |  j
 j d d ƒ |  j t  |  j
 j d ƒ d k ƒ |  j |  j
 j d j! d ƒ ƒ |  j |  j
 j j" ƒ  ƒ | j t | d ƒ ƒ t	 ƒ  |  _
 i t d 6t d 6t d 6t d 6|  j
 _ |  j
 j | ƒ |  j |  j
 j d ƒ |  j |  j
 j d ƒ |  j |  j
 j d ƒ |  j |  j
 j d ƒ |  j |  j
 j j" ƒ  ƒ |  j |  j
 j t ƒ d S(   s   run_crash()s
   test.crasht   wR\   R¶   R·   R’   i    s$   http://coreutils.bugs.example.com/%iRN   R¥   t
   StacktraceRÃ   t   ExecutableTimestampt   StacktraceAddressSignatureRœ   t   CrashRQ   i'  t   Titles   yes crashed with SIGSEGVN(#   R¸   R   R~   R‘   R   RV   RW   R
   R¹   R   R   R   R   t	   run_crashRs   R)   R   R'   R#   R   Rº   R+   R(   R   RÅ   RÔ   R   t   assertNotEqualR‚   R$   R\   R    t   lenRë   t   check_ignored(   R&   R—   Re   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_crashŸ  sd    

&# 
c         C   s€  |  j  ƒ  } d | d <t j j t j j d ƒ } | j t | d ƒ ƒ i t	 d 6t
 d 6t
 d 6t
 d 6|  j _ |  j j | ƒ |  j |  j j d |  j j ƒ |  j d	 |  j j j ƒ  k ƒ |  j d
 |  j j j ƒ  k ƒ |  j d |  j j j ƒ  k ƒ |  j d |  j j j ƒ  k ƒ |  j d |  j j j ƒ  k ƒ |  j |  j j d d ƒ |  j |  j j d ƒ |  j |  j j ƒ d S(   s4   run_crash() for an abort() without assertion messaget   6R÷   s
   test.crashR  R\   R¶   R·   R’   RN   R¥   R  RÃ   R  N(   R¸   R   R~   R‘   R   RV   RW   R
   R¹   R+   R   R   R   R  Rs   R)   R   R(   R‚   R\   R    RÔ   R$   (   R&   R—   Re   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_crash_abortá  s$    

c         C   sÿ   t  j ƒ  } d | d <d | d <t j ƒ  | d <d | d _ | j ƒ  t j j t  j	 j
 d ƒ } | j t | d ƒ ƒ i t d	 6t d
 6t d 6t d 6|  j _ |  j j | ƒ |  j |  j j d |  j j ƒ |  j d |  j j k ƒ |  j |  j j ƒ d S(   s$   run_crash() for an invalid core dumps   /usr/bin/yesRK   Rö   R÷   RQ   t   AAAAAAAAs
   test.crashR  R\   R¶   R·   R’   R2   t
   decompressN(   R   Rd   R¦   R¤   t	   gzipvalueR  R   R~   R‘   RV   RW   R
   R¹   R+   R   R   R   R  Rs   R)   R(   R‚   R$   (   R&   R—   Re   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_crash_brokenþ  s     



c         C   sÝ  d |  j  d <|  j ƒ  d d |  j j g t _ t ƒ  |  _ i t d 6t	 d 6t	 d 6t	 d 6|  j _
 |  j |  j j ƒ  t ƒ |  j |  j j d ƒ |  j |  j j d ƒ |  j |  j j ƒ d |  j  d <d	 |  j  d
 <|  j ƒ  d d |  j j g t _ t ƒ  |  _ i t d 6t	 d 6t	 d 6t	 d 6|  j _
 |  j |  j j ƒ  t ƒ |  j d |  j j k d |  j j |  j j f ƒ |  j |  j j d ƒ d d d g t _ t ƒ  |  _ |  j |  j j ƒ  t ƒ |  j |  j j d ƒ d S(   s8   run_crash() through a file specified on the command lineR¨   RL   s   ui-tests   -cR\   R¶   R·   R’   u   It stinks. â™¥t   UnreportableReasons
   It stinks.s   %s: %sR.   s   /nonexisting.crashR2   N(   R\   Rf   Re   R   Ra   Rb   R   R   R+   R   R   Rs   R³   R(   R   R)   R‚   R$   R'   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_crash_argv_file  s:    



c         C   s»   d |  j  d <d |  j  d <d |  j  d <|  j ƒ  i t d 6t d 6t d	 6t d
 6|  j _ |  j j |  j j ƒ |  j	 d |  j j
 k d |  j j |  j j
 f ƒ |  j |  j j d ƒ d S(   s8   run_crash() on a crash with the UnreportableReason fields
   It stinks.R  s	   /bin/bashRK   s   bash 1RL   R\   R¶   R·   R’   s   %s: %sR.   N(   R\   Rf   R+   R   R   R   R  Re   R   R‚   R(   R'   Rs   R)   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_crash_unreportable@  s    

c         C   sÙ   t  j d d ƒ } | j d ƒ | j ƒ  d |  j d <d d t j j | j ƒ d |  j d	 <|  j	 ƒ  i t
 d
 6t d 6t d 6t d 6|  j _ |  j j |  j j ƒ |  j t j j d ƒ ƒ |  j d |  j j ƒ d S(   s   Package: path traversalt   suffixs   .pys5   def add_info(r, u):
  open('/tmp/pwned', 'w').close()s	   /bin/bashRK   s   ../i   i    RL   R\   R¶   R·   R’   s
   /tmp/pwneds   invalid Package:N(   R   R   R
   R   R\   R   R~   t   splitextR   Rf   R+   R   R   R   R  Re   RÔ   R•   t   assertInR(   (   R&   t   bad_hook(    (    s&   /usr/share/apport/testsuite/test_ui.pyt    test_run_crash_malicious_packageR  s    
(

c         C   sa   d |  j  d <d |  j  d <d |  j  d <|  j ƒ  |  j j |  j j ƒ |  j |  j j d ƒ d S(   s,   run_crash() on a crash with the Ignore fieldR+   t   Ignores	   /bin/bashRK   s   bash 1RL   N(	   R\   Rf   R   R  Re   R   Rs   R)   R   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_crash_ignoref  s    
c         C   s©  d } t  j | t  j ƒ s+ t | d ƒ ‚ t  j ƒ  } | d k r¡ t  j ƒ  t  j t  j d t  j ƒ t	 j
 j ƒ  ƒ t  j | | g ƒ t s¡ t d | ƒ ‚ n  zH t j d ƒ t j ƒ  } | | d <d | d	 <| j | ƒ | j ƒ  Wd
 t  j | t j ƒ t  j | d ƒ Xt  j j t j j d ƒ } | j t | d ƒ ƒ t ƒ  |  _ |  j j | ƒ |  j  |  j j! d ƒ |  j" d |  j j# k d |  j j$ |  j j# f ƒ d
 S(   s-   run_crash() for a crash dump without CoreDumps   /usr/bin/yess    is not executablei    s	   /dev/nulls   Could not execute g      à?RK   t   42R÷   Ns
   test.crashR  R2   R   s   %s: %s(%   R   Rù   Rú   R5   RÊ   Rü   RË   R¹   RÌ   Ra   R½   RÍ   RÎ   R   R“   R”   R   Rd   R  R  RÐ   RÑ   RÒ   RÓ   R~   R‘   RV   RW   R
   R   R   R  Rs   R)   R‚   R(   R'   (   R&   R  RÕ   R—   Re   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_crash_nocorep  s0    %
(

c         C   s  |  j  ƒ  } | j ƒ  | d =t j j t j j d ƒ } | j t	 | d ƒ ƒ t
 ƒ  |  _ i t d 6t d 6t d 6t d 6|  j _ |  j j | ƒ |  j |  j j d	 d |  j j t |  j j ƒ t |  j j ƒ f ƒ |  j |  j j d	 ƒ |  j |  j j ƒ d	 S(
   s€   run_crash() pre-retraced reports.

        This happens with crashes which are pre-processed by
        apport-retrace.
        RQ   s
   test.crashR  R\   R¶   R·   R’   s   has %s message: %s: %sN(   R¸   t   add_gdb_infoR   R~   R‘   R   RV   RW   R
   R¹   R   R   R   R   R  Rs   R)   R   RÏ   R'   R(   R‚   R$   (   R&   R—   Re   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_crash_preretraced•  s    

/c         C   s7  |  j  ƒ  |  j _ |  j j ƒ  d |  j j d <t j j t j j	 d ƒ } |  j j j
 t | d ƒ ƒ t ƒ  |  _ i t d 6t d 6t d 6t d 6|  j _ |  j j | ƒ |  j |  j j d	 ƒ |  j |  j j d d
 |  j j t |  j j ƒ t |  j j ƒ f ƒ |  j |  j j j d ƒ ƒ |  j |  j j ƒ d S(   s­   run_crash() on complete report on uninstalled package

        This happens when reporting a problem from a different machine through
        copying a .crash file.
        s   uninstalled_pkg 1RL   s
   test.crashR  R\   R¶   R·   R’   t   uninstalled_pkgs   has %s message: %s: %ss!   http://coreutils.bugs.example.comN(   R¸   R   R\   R   R   R~   R‘   R   RV   RW   R
   R¹   R   R+   R   R   R  Rs   R©   R)   R   RÏ   R'   R(   R‚   R#   Rë   R$   (   R&   Re   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_crash_precollected±  s     
/c         C   s¿   t  j ƒ  } d | d <d | d <t j j t  j j d ƒ } | j t | d ƒ ƒ i t	 d 6t
 d 6t
 d	 6t
 d
 6|  j _ |  j j | ƒ |  j |  j j t d ƒ ƒ |  j |  j j d ƒ d S(   s'   run_crash() on various error conditionss	   /bin/bashRK   t	   foobarbazRL   s
   test.crashR  R\   R¶   R·   R’   s   Invalid problem reportR2   N(   R   Rd   R   R~   R‘   RV   RW   R
   R¹   R+   R   R   R   R  Rs   R'   R   R)   (   R&   R—   Re   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_crash_errorsÏ  s    


c         C   s—  |  j  ƒ  } d | d <d | d <t j j t j j d ƒ } | j t | d ƒ ƒ i t	 d 6t
 d 6t
 d	 6t
 d
 6|  j _ |  j j | ƒ |  j |  j j t d ƒ ƒ |  j |  j j d ƒ t j ƒ  } d | d <d | d <d | d <|  j j | ƒ |  j |  j j t d ƒ ƒ |  j |  j j d ƒ t j ƒ  } d | d <d | d <d | d <|  j j | ƒ |  j |  j j t d ƒ ƒ |  j |  j j d ƒ d S(   s=   run_crash() on reports with subsequently uninstalled packagess   /bin/nonexistingRK   R¨   RL   s
   test.crashR  R\   R¶   R·   R’   s   Invalid problem reportR.   s   /usr/bin/pythont   InterpreterPaths5   ZeroDivisionError: integer division or modulo by zerot	   Tracebacks   /bin/shs   /usr/bin/nonexistingN(   R¸   R   R~   R‘   R   RV   RW   R
   R¹   R+   R   R   R   R  Rs   R'   R   R)   Rd   (   R&   R—   Re   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_crash_uninstalledâ  s4    








c         C   s4  |  j  ƒ  } t t | d ƒ d ƒ | d <t j j t j j d ƒ } | j	 t
 | d ƒ ƒ i t d 6t d 6t d 6t d 6|  j _ |  j j | ƒ |  j d |  j j k ƒ |  j |  j j d	 |  j j k d
 |  j j |  j j f ƒ |  j d |  j j k d
 |  j j |  j j f ƒ |  j |  j j d ƒ d S(   s6   run_crash() on binary that got updated in the meantimeR  i
   s
   test.crashR  R\   R¶   R·   R’   RK   s   %s: %st   changedR.   N(   R¸   RÏ   Ré   R   R~   R‘   R   RV   RW   R
   R¹   R+   R   R   R   R  RÔ   R\   R‚   R(   R'   Rs   R)   (   R&   R—   Re   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_crash_updated_binary  s    
"c         C   s™  t  j d ƒ } d | d <d | d <d | d <d | d <| j ƒ  t j j t  j j d ƒ } | j t	 | d	 ƒ ƒ t
 ƒ  |  _ i t d
 6t d 6t d 6t d 6|  j _ |  j j | ƒ |  j |  j j d ƒ |  j |  j j d ƒ |  j |  j j d ƒ |  j |  j j d ƒ |  j |  j j ƒ | j t	 | d	 ƒ ƒ t
 ƒ  |  _ i t d
 6t d 6t d 6t d 6|  j _ |  j j | ƒ |  j |  j j d ƒ |  j |  j j d ƒ |  j |  j j d |  j j j ƒ  ƒ |  j |  j j ƒ |  j d |  j j j ƒ  k ƒ |  j d |  j j j ƒ  k ƒ |  j |  j j d d ƒ |  j d |  j j j ƒ  k ƒ |  j d |  j j j ƒ  k ƒ |  j d |  j j j ƒ  k ƒ d S(   s   run_crash() for a package errorRL   R¨   RN   s   It broket   ErrorMessages   foo
bart   VarLogPackagerlogs
   test.crashR  R\   R¶   R·   R’   i    s   http://bash.bugs.example.com/%iRœ   t   ArchitectureR›   Rš   N(   R   Rd   t   add_os_infoR   R~   R‘   RV   RW   R
   R¹   R   R   R   R   R  Rs   R)   R   R'   R#   R   R‚   R$   R+   R   RÅ   R\   R    (   R&   R—   Re   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_crash_package   sH    






&c         C   s›  t  t j j |  j d ƒ d ƒ } | j d ƒ | j ƒ  t j d ƒ } t j	 j
 ƒ  | d <d | d <t j j t j j d ƒ } | j t  | d ƒ ƒ t ƒ  |  _ i t d	 6t d
 6t d 6t d 6|  j _ |  j j | ƒ |  j |  j j d d |  j j |  j j f ƒ |  j |  j j d ƒ |  j |  j j d ƒ |  j |  j j d ƒ |  j |  j j ƒ | j t  | d ƒ ƒ t ƒ  |  _ i t d	 6t d
 6t d 6t d 6|  j _ |  j j | ƒ |  j |  j j d t |  j j ƒ d t |  j j ƒ ƒ |  j |  j j d ƒ |  j |  j j d |  j j j ƒ  ƒ |  j |  j j ƒ |  j d |  j j j  ƒ  k ƒ |  j d |  j j j  ƒ  k ƒ |  j |  j j d d ƒ d S(   s   run_crash() for a kernel errors   source_linux.pyR  sE   def add_info(report, ui):
    report['KernelDebug'] = 'LotsMoreInfo'
t   KernelCrashRL   t   linuxRN   s
   test.crashR\   R¶   R·   R’   s   error: %s - %si    t    s    http://linux.bugs.example.com/%it   KernelDebugRœ   N(!   R¹   R   R~   R‘   Rg   R
   R`   R   Rd   Rì   Rí   RV   RW   R   R   R   R   R  Rs   R)   R   R'   R(   R#   R   R‚   R$   R+   RÏ   R   RÅ   R\   R    (   R&   Rx   R—   Re   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_crash_kernelR  sH    !



'&c         C   s€  |  j  ƒ  } d t j ƒ  d | d <d t j ƒ  d | d <t j j t j j d ƒ } | j t	 | d ƒ ƒ t
 ƒ  |  _ i t d 6t d	 6t d
 6t d 6|  j _ |  j j | ƒ |  j |  j j d |  j j ƒ |  j d |  j j k ƒ t ƒ  } |  j j j | ƒ t j t j ƒ  ƒ } t j ƒ  d | d | d | d t j ƒ  g } x. | D]& } |  j | | j ƒ  k d | ƒ qRWd S(   s   run_crash() anonymizationu
   Ã¤ %s â™¥ i   t   ProcUnicodeValues
   Ã¤ %s â™¥ t   ProcByteArrayValues
   test.crashR  R\   R¶   R·   R’   t   ProcCwdi    i   i   s"   dump contains sensitive string: %sN(   R¸   R   t   unameR~   R‘   R   RV   RW   R
   R¹   R   R   R+   R   R   R  Rs   R)   R   R(   RÔ   R\   R    t   pwdt   getpwuidRÝ   t   getcwdR¾   (   R&   R—   Re   t   dumpR–   t   bad_stringsR‡   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_crash_anonymity†  s&    
	1c            sw  t  j ƒ  ‰  ˆ  d d ˆ  d ˆ  d ˆ  d f ‰  t  j } t j j j } ‡  f d †  t  _ d „  } zó |  j ƒ  } | t j j _ d | d	 <t  j j t j	 j
 d
 ƒ } | j t | d ƒ ƒ t ƒ  |  _ i t d 6t d 6t d 6t d 6|  j _ |  j j | ƒ |  j |  j j d |  j j ƒ |  j |  j j d	 d ƒ |  j |  j j j ƒ  d ƒ Wd | t  _ | t j j _ Xd S(   sB   run_crash() anonymization runs after info and duplicate collectioni    t
   0xDEADBEEFi   i   i   c              s   ˆ  S(   N(    (    (   R;  (    s&   /usr/share/apport/testsuite/test_ui.pyt   <lambda>ª  s    c         S   s0   d |  d <d |  d <|  j  ƒ  d  k s, t ‚ d  S(   Ns€   #0  0xDEADBEEF in h (p=0x0) at crash.c:25
#1  0x10000042 in g (x=1, y=42) at crash.c:26
#1  0x10000001 in main () at crash.c:40
R  sC   
10000000-DEADBEF0 r-xp 00000000 08:02 100000           /bin/crash
RÈ   (   t   crash_signature_addressesR   R5   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   fake_add_gdb_info¬  s    

s   my 0xDEADBEEFt   ProcAuxInfos
   test.crashR  R\   R¶   R·   R’   s   my hostnameN(   R   R;  R   R\   Rd   R#  R¸   R~   R‘   RV   RW   R
   R¹   R   R   R+   R   R   R  Rs   R)   R   R(   RD  (   R&   t
   orig_unamet   orig_add_gdb_infoRE  R—   Re   (    (   R;  s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_crash_anonymity_order¡  s.    %		


 	c            sš  t  j ƒ  ‰  ˆ  d d ˆ  d ˆ  d ˆ  d f ‰  t  j } ‡  f d †  t  _ z=|  j ƒ  } d | d <d	 | d
 <d | d <t  j j t j j d ƒ } | j t	 | d ƒ ƒ t
 ƒ  |  _ i t d 6t d 6t d 6t d 6|  j _ |  j j | ƒ |  j |  j j d |  j j ƒ |  j |  j j d j d ƒ |  j j d ƒ |  j |  j j d d ƒ |  j |  j j d
 d ƒ |  j |  j j d d ƒ Wd | t  _ Xd S(   s2   run_crash() anonymization only catches whole wordsi    t   edi   i   i   c              s   ˆ  S(   N(    (    (   R;  (    s&   /usr/share/apport/testsuite/test_ui.pyRC  Ö  s    s   my edt	   ProcInfo1s   "ed.localnet"t	   ProcInfo2t	   educationt	   ProcInfo3s
   test.crashR  R\   R¶   R·   R’   R  s   yes crashed with SIGSEGVs   my hostnames   "hostname.localnet"N(   R   R;  R¸   R~   R‘   R   RV   RW   R
   R¹   R   R   R+   R   R   R  Rs   R)   R   R(   R‚   R\   Rë   (   R&   RG  R—   Re   (    (   R;  s&   /usr/share/apport/testsuite/test_ui.pyt"   test_run_crash_anonymity_substringÏ  s0    %	



c         C   s­  |  j  ƒ  } t j j t j j d ƒ } t ƒ  |  _ i t	 d 6t
 d 6t
 d 6t
 d 6|  j _ t | d ƒ  } | j | ƒ Wd QXd „  |  j j _ |  j j | ƒ |  j |  j j d	 d
 ƒ |  j |  j j d ƒ |  j |  j j d ƒ t ƒ  |  _ i t	 d 6t
 d 6t
 d 6t
 d 6|  j _ t | d ƒ  } | j | ƒ Wd QXd „  |  j j _ |  j j | ƒ |  j |  j j d	 d ƒ |  j |  j j d ƒ |  j |  j j d ƒ d S(   s%   run_crash() for already known problems
   test.crashR\   R¶   R·   R’   R  Nc         S   s   t  S(   N(   R+   (   R—   (    (    s&   /usr/share/apport/testsuite/test_ui.pyRC  þ  s    R¯   RR   R.   c         S   s   d S(   Ns   http://myreport/1(    (   R—   (    (    s&   /usr/share/apport/testsuite/test_ui.pyRC    s    s   http://myreport/1(   R¸   R   R~   R‘   R   RV   RW   R   R   R+   R   R   R¹   R
   R   t   knownR  Rs   R\   R)   R#   R   (   R&   R—   Re   Rx   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_crash_knownð  s4    

c         C   sg   d d d g t  _ t ƒ  |  _ |  j |  j j ƒ  t ƒ |  j d |  j j k ƒ |  j	 |  j j
 ƒ d S(   s7   run_update_report() on a nonexisting package (from bug)s   ui-tests   -uRR   s$   No additional information collected.N(   Ra   Rb   R   R   Rs   R³   R   R‚   R(   RÔ   R$   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt3   test_run_update_report_nonexisting_package_from_bug  s    	c         C   sm   d d d d d g t  _ t ƒ  |  _ |  j |  j j ƒ  t ƒ |  j d |  j j k ƒ |  j	 |  j j
 ƒ d S(   s;   run_update_report() on a nonexisting package (CLI argument)s   ui-tests   -uRR   s   -pt   bars$   No additional information collected.N(   Ra   Rb   R   R   Rs   R³   R   R‚   R(   RÔ   R$   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt.   test_run_update_report_nonexisting_package_cli  s    	c         C   sj  d d d g t  _ t ƒ  |  _ i t d 6t d 6t d 6t d 6|  j _ d |  j j j d	 ƒ d
 <d |  j j j d	 ƒ d <|  j	 |  j j
 ƒ  t ƒ |  j	 |  j j d |  j j ƒ |  j	 |  j j d ƒ |  j	 |  j j d ƒ |  j |  j j ƒ |  j |  j j d k ƒ |  j |  j j d j d ƒ ƒ |  j d |  j j j ƒ  k ƒ |  j d |  j j j ƒ  k ƒ d S(   s5   run_update_report() on an existing package (from bug)s   ui-tests   -uRR   R\   R¶   R·   R’   R¨   i   RN   RL   i    s   bash R¥   RÃ   N(   Ra   Rb   R   R   R+   R   R   R   t   downloadRs   R³   R)   R   R(   R'   R#   R‚   R$   R   R\   Rë   R    (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt0   test_run_update_report_existing_package_from_bug(  s"    
 c         C   sa  d d d d d d d g t  _ t ƒ  |  _ i t d 6t d	 6t d
 6t d 6|  j _ |  j |  j j ƒ  t ƒ |  j |  j j	 d |  j j ƒ |  j |  j j d ƒ |  j |  j j d ƒ |  j |  j j ƒ |  j |  j j d k ƒ |  j |  j j d j d ƒ ƒ |  j d |  j j j ƒ  k ƒ |  j d |  j j j ƒ  k ƒ |  j d |  j j d k ƒ d S(   sH   run_update_report() on an existing package (CLI argument) with extra tags   ui-tests   -uRR   s   -pR¨   s   --tagRM   R\   R¶   R·   R’   i    RL   s   bash R¥   RÃ   RÉ   N(   Ra   Rb   R   R   R+   R   R   Rs   R³   R)   R   R(   R'   R#   R‚   R$   R   R\   Rë   R    (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt0   test_run_update_report_existing_package_cli_tags?  s     
 c         C   s;  d d d d g t  _ t ƒ  |  _ i t d 6t d 6t d 6t d 6|  j _ |  j |  j j ƒ  t ƒ |  j |  j j	 d |  j j ƒ |  j |  j j d ƒ |  j |  j j d ƒ |  j |  j j ƒ |  j |  j j d	 k ƒ |  j |  j j d
 j d ƒ ƒ |  j d |  j j j ƒ  k ƒ |  j d |  j j j ƒ  k ƒ d S(   s=   run_update_report() on an existing package (-collect program)s   apport-collects   -pR¨   RR   R\   R¶   R·   R’   i    RL   s   bash R¥   RÃ   N(   Ra   Rb   R   R   R+   R   R   Rs   R³   R)   R   R(   R'   R#   R‚   R$   R   R\   Rë   R    (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt3   test_run_update_report_existing_package_cli_cmdnameU  s    
 c         C   sm  d d d g t  _ t ƒ  |  _ i t d 6t d 6t d 6t d 6|  j _ t t j	 j
 |  j d ƒ d	 ƒ  } | j d
 ƒ Wd QX|  j |  j j ƒ  t |  j j ƒ |  j |  j j d |  j j ƒ |  j |  j j d ƒ |  j |  j j d ƒ |  j |  j j ƒ |  j |  j j d k ƒ |  j |  j j d d ƒ |  j |  j j d d ƒ |  j d |  j j j ƒ  k ƒ d S(   s@   run_update_report() on an uninstalled package with a source hooks   ui-tests   -uRR   R\   R¶   R·   R’   s   source_foo.pyR  s1   def add_info(r, ui):
  r["MachineType"]="Laptop"
Ni    RL   s   foo (not installed)t   MachineTypet   LaptopRÃ   (   Ra   Rb   R   R   R+   R   R   R¹   R   R~   R‘   Rg   R
   Rs   R³   R\   R)   R   R(   R'   R#   R‚   R$   R   R    (   R&   Rx   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt,   test_run_update_report_noninstalled_but_hookj  s"    
$"c         C   së  t  j j ƒ  } t  j j | ƒ } |  j | | d ƒ |  j t  j j | ƒ d d | ƒ |  j t t  j j | ƒ d d | d d g t _	 t
 ƒ  |  _ i t d 6t d	 6t d
 6t d 6|  j _ t t j j |  j d | ƒ d ƒ  } | j d ƒ Wd QX|  j |  j j ƒ  t |  j j ƒ |  j |  j j d |  j j ƒ |  j |  j j d ƒ |  j |  j j d ƒ |  j |  j j ƒ |  j |  j j d k ƒ |  j |  j j d d | ƒ |  j |  j j d d ƒ |  j d |  j j j  ƒ  k ƒ d S(   sU   run_update_report() on a source package which does not have a binary of the same namesI   this test assumes that the kernel binary package != kernel source packageR   s@   this test assumes that the kernel binary package %s is installeds   ui-tests   -ps   -uRR   R\   R¶   R·   R’   s   source_%s.pyR  s1   def add_info(r, ui):
  r["MachineType"]="Laptop"
Ni    RL   s   %s (not installed)RY  RZ  RÃ   (!   R   Rì   Rí   t
   get_sourceR  t   get_versionRã   t
   ValueErrorRa   Rb   R   R   R+   R   R   R¹   R   R~   R‘   Rg   R
   Rs   R³   R\   R)   R   R(   R'   R#   R‚   R$   R   R    (   R&   t
   kernel_pkgt
   kernel_srcRx   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt.   test_run_update_report_different_binary_source‚  s0    
("c         C   s‚   t  t j j |  j d ƒ d ƒ } | j d d j g  | j ƒ  D] } d | ^ q= ƒ ƒ | j ƒ  d |  j j	 _
 |  j j ƒ  d  S(   Ns   coreutils.pyR  s   def add_info(report, ui):
%s
s   
s       t	   coreutils(   R¹   R   R~   R‘   Rg   R
   t
   splitlinesR`   R   R?   t   packaget   run_report_bug(   R&   t   codeRx   t   l(    (    s&   /usr/share/apport/testsuite/test_ui.pyt	   _run_hook¥  s    !	.
c         C   sƒ   i t  d 6t  d 6t  d 6t  d 6|  j _ |  j d ƒ |  j |  j j d d ƒ |  j |  j j d d ƒ |  j |  j j d	 ƒ d
 S(   s'   interactive hooks: HookUI.information()R\   R¶   R·   R’   sE   report['begin'] = '1'
ui.information('InfoText')
report['end'] = '1'
t   beginRR   t   endt   InfoTextN(   R   R   R   Rh  Rs   R\   R(   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt"   test_interactive_hooks_information­  s    
c         C   sC  i t  d 6t  d 6t  d 6t  d 6|  j _ t |  j _ |  j d ƒ |  j |  j j d d ƒ |  j |  j j d d ƒ |  j |  j j d	 ƒ |  j |  j j d
 d ƒ t  |  j _ |  j j	 ƒ  |  j |  j j d
 d ƒ |  j |  j j d d ƒ d |  j _ |  j j	 ƒ  |  j |  j j d
 d ƒ |  j |  j j d d ƒ d S(   s!   interactive hooks: HookUI.yesno()R\   R¶   R·   R’   sU   report['begin'] = '1'
report['answer'] = str(ui.yesno('YesNo?'))
report['end'] = '1'
Ri  RR   Rj  s   YesNo?t   answerR+   R   R   N(   R   R   R   R+   R    Rh  Rs   R\   R(   Re  R   (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_interactive_hooks_yesno¼  s&    
c         C   sö   i t  d 6t  d 6t  d 6t  d 6|  j _ d |  j _ |  j d ƒ |  j |  j j d d ƒ |  j |  j j d	 d ƒ |  j |  j j d
 ƒ |  j |  j j d d ƒ d |  j _ |  j j	 ƒ  |  j |  j j d d ƒ |  j |  j j d	 d ƒ d S(   s    interactive hooks: HookUI.file()R\   R¶   R·   R’   s
   /etc/fstabsW   report['begin'] = '1'
report['answer'] = str(ui.file('YourFile?'))
report['end'] = '1'
Ri  RR   Rj  s	   YourFile?Rm  R   N(
   R   R   R   R"   Rh  Rs   R\   R(   R   Re  (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_interactive_hooks_file×  s    
c         C   sù   i t  d 6t  d 6t  d 6t  d 6|  j _ d g |  j _ |  j d ƒ |  j |  j j d d ƒ |  j |  j j d	 d ƒ |  j |  j j d
 ƒ |  j |  j j d d ƒ d |  j _ |  j j	 ƒ  |  j |  j j d d ƒ |  j |  j j d	 d ƒ d S(   s"   interactive hooks: HookUI.choice()R\   R¶   R·   R’   i   sk   report['begin'] = '1'
report['answer'] = str(ui.choice('YourChoice?', ['foo', 'bar']))
report['end'] = '1'
Ri  RR   Rj  s   YourChoice?Rm  s   [1]R   N(
   R   R   R   R!   Rh  Rs   R\   R(   R   Re  (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_interactive_hooks_choicesí  s    
c         C   s   |  j  t |  j d ƒ d S(   s   interactive hooks: user cancelss>   report['begin'] = '1'
raise StopIteration
report['end'] = '1'
N(   Rã   Rä   Rh  (   R&   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_interactive_hooks_cancel  s    c         C   sK  d d d g t  _ t ƒ  |  _ i t d 6t d 6t d 6t d 6|  j _ |  j |  j j ƒ  t ƒ |  j	 d |  j j
 k ƒ |  j |  j j d	 ƒ t t j j t j j d
 ƒ d ƒ } | j d ƒ | j ƒ  t  j } d d d g t  _ t ƒ  |  _ t ƒ  t  _ |  j t |  j j ƒ t  j j ƒ  } | t  _ |  j	 d | k ƒ t t j j t j j d ƒ d ƒ } | j d ƒ | j ƒ  d d d g t  _ t ƒ  |  _ t ƒ  t  _ |  j t |  j j ƒ t  j j ƒ  } | t  _ |  j	 d | k ƒ t t j j t j j d ƒ d ƒ } | j d ƒ | j ƒ  d d d g t  _ t ƒ  |  _ t ƒ  t  _ |  j t |  j j ƒ t  j j ƒ  } | t  _ |  j	 d | k ƒ |  j	 d | k ƒ t t j j t j j d ƒ d ƒ } | j d ƒ | j ƒ  d d d g t  _ t ƒ  |  _ i t d 6t d 6t d 6t d 6|  j _ |  j |  j j ƒ  t ƒ |  j |  j j
 d, ƒ |  j |  j j d, ƒ |  j	 |  j j ƒ |  j |  j j d d ƒ |  j	 d |  j j k ƒ |  j |  j j d d ƒ |  j	 |  j j d  j d! ƒ ƒ |  j |  j j d" d# ƒ d d$ d% d d g t  _ t ƒ  |  _ i t d 6t d 6t d 6t d 6|  j _ |  j |  j j ƒ  t ƒ |  j |  j j
 d, ƒ |  j |  j j d, ƒ |  j	 |  j j ƒ |  j |  j j d d ƒ |  j	 d% |  j j d& k ƒ t t j j t j j d ƒ d ƒ } | j d' ƒ | j ƒ  d d d g t  _ t ƒ  |  _ i t d 6t d 6t d 6t d 6|  j _ t |  j _ |  j |  j j ƒ  t ƒ |  j	 |  j j ƒ |  j |  j j
 d( ƒ |  j |  j j d d) ƒ |  j	 d |  j j k ƒ |  j |  j j d d ƒ |  j	 |  j j d  j d! ƒ ƒ |  j |  j j d" d# ƒ |  j |  j j d* d+ ƒ d, S(-   s   run_symptom()s   ui-tests   -st   foobarR\   R¶   R·   R’   s   foobar" is not knownR2   s   nopkg.pyR  s   def run(report, ui):
    pass
t   nopkgs&   did not determine the affected packages   norun.pys"   def something(x, y):
    return 1
t   noruns   norun.py crashed:s   crash.pys$   def run(report, ui):
    return 1/0
t   crashs   crash.py crashed:s   ZeroDivisionError:s
   itching.pysB   def run(report, ui):
  report["itch"] = "scratch"
  return "bash"
t   itchingt   itcht   scratchR›   RN   R¨   RL   s   bash Rœ   R‰   s   --tagRM   RÉ   sn   def run(report, ui):
    report['itch'] = 'slap'
    report['q'] = str(ui.yesno('do you?'))
    return 'bash'
s   do you?t   slapt   qR+   N(   Ra   Rb   R   R   R+   R   R   Rs   R³   R‚   R(   R)   R¹   R   R~   R‘   R   RZ   R
   R`   t   stderrR    Rã   Rä   R¾   R   R$   R\   Rë   R    (   R&   Rx   t   orig_stderrt   err(    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_run_symptom  s¶    
$
		$
	$
	$

 
$

 c         C   s  t  t j j t j j d ƒ d ƒ } | j d ƒ | j ƒ  t  t j j t j j d ƒ d ƒ } | j d ƒ | j ƒ  d d g t	 _
 t ƒ  |  _ i t d 6t d	 6t d
 6t d 6|  j _ d |  j _ |  j |  j j ƒ  t ƒ |  j |  j j d ƒ |  j d |  j j k ƒ |  j t |  j j ƒ t d d d g ƒ ƒ |  j |  j j d ƒ |  j |  j j d ƒ |  j |  j j ƒ |  j j j d ƒ g |  j _ |  j |  j j ƒ  t ƒ |  j |  j j d ƒ |  j |  j j d k ƒ |  j |  j j ƒ |  j |  j j d j d ƒ ƒ d S(   sD   run_report_bug() without specifying arguments and available symptomss   foo.pyR  sI   description = 'foo does not work'
def run(report, ui):
    return 'bash'
s   bar.pys*   def run(report, ui):
  return "coreutils"
s   ui-tests   -fR\   R¶   R·   R’   s   kind of problemRS  s   foo does not works   Other problemi    RL   R¨   N(   R¹   R   R~   R‘   R   R   RZ   R
   R`   Ra   Rb   R   R+   R   R   R   R!   Rs   R³   R)   R‚   R(   Rž   R*   R   R\   RÔ   R$   t   indexRë   (   R&   Rx   (    (    s&   /usr/share/apport/testsuite/test_ui.pyt!   test_run_report_bug_list_symptoms~  s8    $
$

c            sÎ  ‡  f d †  } | d d i	 t d 6d d 6d d 6d d 6d d 6d d 6d d	 6t d
 6g  d 6ƒ ˆ  j t | d d i  ƒ | d d i	 t d 6d d 6d d 6d d 6d d 6d d 6d d	 6t d
 6g  d 6ƒ t t j j t	 j
 j d ƒ d ƒ } | j d ƒ | j ƒ  | d d i	 t d 6d d 6d d 6d d 6d d 6d d 6d d	 6t d
 6g  d 6ƒ | d d i	 t d 6d d 6d d 6d d 6d d 6d d 6d d	 6t d
 6g  d 6ƒ xe d D]] } | d d | i	 t d 6d d 6d d 6d | d 6d d 6d d 6d d	 6t d
 6g  d 6ƒ q¦W| d d i	 t d 6d d 6d d 6d d 6d d 6d d 6d d	 6t d
 6g  d 6ƒ | d d i t d 6d d 6d d 6d d 6d d 6g  d 6ƒ | d d i t d 6d d 6d d 6d d 6d d 6g  d 6ƒ d S(   s3   parse_args() option inference for a single argumentc            s¡   |  g t  _ | r% t  j j | ƒ n  t  j } t d d ƒ t  _ z t j j ƒ  } Wd  t  j j ƒ  | t  _ Xd  | d <ˆ  j
 | j g  ƒ ˆ  j
 | j | ƒ d  S(   Ns	   /dev/nullR  t   version(   Ra   Rb   t   appendR{  R¹   R   R   R   R`   R   Rs   t   argsR?   (   t   program_namet   argt   expected_optsR|  R   (   R&   (    s&   /usr/share/apport/testsuite/test_ui.pyt   _chk©  s    	

s
   apport-gtkt   filebugRd  RÕ   t
   crash_filet   symptomt   update_reportt   savet   windowt   tags   apport-collects
   apport-kdeRb  s   coreutils.pyR  sE   description = 'foo does not work'
def run(report, ui):
return 'bash'
s
   apport-clit   1234s   .crashs   .apports	   /tmp/f oos   /usr/bin/tailiÒ  s   apport-update-bugN(   s   .crashs   .apport(   R   R   Rã   Rä   R+   R¹   R   R~   R‘   R   R   RZ   R
   R`   (   R&   R‡  Rx   R  (    (   R&   s&   /usr/share/apport/testsuite/test_ui.pyt   test_parse_argv_single_arg¦  sN    $
c            sn  ‡  f d †  } | g  i	 t  d 6d d 6d d 6d d 6d d 6d d 6d d 6t d	 6g  d
 6ƒ | d g i	 t  d 6d d 6d d 6d d 6d d 6d d 6d d 6t d	 6g  d
 6ƒ t t j j t j j	 d ƒ d ƒ } | j
 d ƒ | j ƒ  | d g i	 t  d 6d d 6d d 6d d 6d d 6d d 6d d 6t d	 6g  d
 6ƒ t j t j j t j j	 d ƒ ƒ | d g i	 t  d 6d d 6d d 6d d 6d d 6d d 6d d 6t d	 6g  d
 6ƒ xe d D]] } | d | g i	 t d 6d d 6d d 6d | d 6d d 6d d 6d d 6t d	 6g  d
 6ƒ q¬W| d g i	 t  d 6d d 6d d 6d d 6d d 6d d 6d d 6t d	 6g  d
 6ƒ | d d d g i	 t  d 6d d 6d d 6d d 6d d 6d d 6d d 6t d	 6g  d
 6ƒ | d d d g i	 t  d 6d d 6d d 6d d 6d d 6d d 6d d 6t d	 6d g d
 6ƒ | d d d d d g i	 t  d 6d d 6d d 6d d 6d d 6d d 6d d 6t d	 6d d g d
 6ƒ d S(   s3   parse_args() option inference when invoked as *-bugc            sŒ   d g |  t  _ t  j } t d d ƒ t  _ z t j j ƒ  } Wd  t  j j ƒ  | t  _ Xd  | d <ˆ  j	 | j
 g  ƒ ˆ  j	 | j | ƒ d  S(   Ns
   apport-bugs	   /dev/nullR  R  (   Ra   Rb   R{  R¹   R   R   R   R`   R   Rs   Rƒ  R?   (   Rƒ  R†  R|  R   (   R&   (    s&   /usr/share/apport/testsuite/test_ui.pyR‡  ò  s    	

Rˆ  Rd  RÕ   R‰  RŠ  R‹  RŒ  R  RŽ  Rb  s   coreutils.pyR  sE   description = 'foo does not work'
def run(report, ui):
return 'bash'
R  s   .crashs   .apports	   /tmp/f oos   /usr/bin/tails   --saves
   foo.apports   --tagRM   RS  N(   s   .crashs   .apport(   R+   R   R   R¹   R   R~   R‘   R   R   RZ   R
   R`   Rr   (   R&   R‡  Rx   R  (    (   R&   s&   /usr/share/apport/testsuite/test_ui.pyt   test_parse_argv_apport_bugï  sX    $
"c         C   s~  |  j  j |  j j ƒ t j d } |  j  j } z.d „  |  j  _ d t j d <|  j |  j  j ƒ  t	 ƒ t j
 j t j
 j t j
 j t j
 j t ƒ ƒ ƒ d ƒ } t j t j
 j | d ƒ t j ƒ rí | t j d <|  j |  j  j ƒ  t ƒ n" |  j |  j  j ƒ  t	 t g k ƒ d „  |  j  _ |  j |  j  j ƒ  t	 ƒ | |  j  _ |  j |  j  j ƒ  t	 ƒ Wd | t j d <| |  j  _ Xd S(   s(   can_examine_locally() for a crash reportt   PATHc         S   s   t  S(   N(   R+   (   t   command(    (    s&   /usr/share/apport/testsuite/test_ui.pyRC  N  s    R   t   bins   apport-retracec         S   s   t  S(   N(   R   (   R“  (    (    s&   /usr/share/apport/testsuite/test_ui.pyRC  ^  s    N(   R   R}   Re   R   R   R   t   ui_run_terminalRs   t   can_examine_locallyR   R~   R‘   t   dirnamet   realpatht   __file__Rù   Rú   R+   R‚   (   R&   t	   orig_patht   orig_fnt
   src_bindir(    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_can_examine_locally_crashF  s(    	'	$"c         C   so   |  j  j |  j j ƒ |  j  j d =|  j  j } z, d „  |  j  _ |  j |  j  j ƒ  t ƒ Wd | |  j  _ Xd S(   s,   can_examine_locally() for a non-crash reportRQ   c         S   s   t  S(   N(   R+   (   R“  (    (    s&   /usr/share/apport/testsuite/test_ui.pyRC  q  s    N(	   R   R}   Re   R   R\   R•  Rs   R–  R   (   R&   R›  (    (    s&   /usr/share/apport/testsuite/test_ui.pyt    test_can_examine_locally_nocrashi  s    c         C   sƒ  |  j  j j ƒ  } d d d d g t _ t ƒ  |  _  d „  |  j  j _ i t d 6t d 6t d 6t d	 6|  j  _	 |  j
 |  j  j ƒ  t ƒ |  j
 |  j  j d ƒ |  j
 |  j  j d ƒ |  j |  j  j ƒ |  j
 |  j  j d
 d ƒ |  j d |  j  j j ƒ  k ƒ |  j d |  j  j j ƒ  k ƒ |  j
 |  j  j d d ƒ |  j
 |  j  j d ƒ |  j
 |  j  j d ƒ |  j
 |  j  j j ƒ  | ƒ d S(   s%   crash database does not accept reports   ui-tests   -fs   -pR¨   c         S   s   t  S(   N(   R   (   R—   (    (    s&   /usr/share/apport/testsuite/test_ui.pyRC  ƒ  s    R\   R¶   R·   R’   RN   R¥   RÃ   Rœ   R‰   i    N(   R   R   RÅ   Ra   Rb   R   t   acceptsR+   R   R   Rs   R³   R)   R   R'   R‚   R$   R\   R    R#   R   (   R&   t   latest_id_before(    (    s&   /usr/share/apport/testsuite/test_ui.pyt   test_db_no_acceptv  s&    
(D   RC   RD   Rl   Rf   Ry   R{   Rˆ   RŒ   R   R˜   R¡   R§   Rª   R®   R²   R´   R»   R¼   RÂ   RÆ   RÖ   t   classmethodRÛ   RÜ   Rà   Rç   Rï   Rõ   R¸   R  R  R  R  R  R  R   R"  R$  R&  R(  R+  R-  R2  R7  RA  RI  RO  RQ  RR  RT  RV  RW  RX  R[  Ra  Rh  Rl  Rn  Ro  Rp  Rq  R~  R€  R  R‘  R  Rž  R¡  (    (    (    s&   /usr/share/apport/testsuite/test_ui.pyRF   v   s‚   	*						$	!												*	
				'	$	B			+			
	%				)		2	4		.	!	"							#								r	(	I	W	#	(   t   unittestRp   RÑ   R   Rý   R<  R“   R   Ra   Rt   R×   Rv   t	   cStringIOR    t   ImportErrort   iot	   apport.uiR   R   t   apport.reportR¦   t   apport.crashdb_impl.memoryR«   R   R   R   t   TestCaseRF   t   main(    (    (    s&   /usr/share/apport/testsuite/test_ui.pyt   <module>   s*   l$eÿ ÿ ÿ ÿ ÿ ÿ ÿ *