
    Fc4                        d dl Z d dlZd dlZd dlmZmZ d dlmZ d dlZd dl	Z	de j
        v re j
        d         ZnKe j                            e j                            e j                            e          d                    Zg dZh dZh dZh d	Zd
 Z e            ZedddefdZd Zd Zi Zd Z ej        d          j        Zi Zd Z  ej        d          j        Z!i Z"d Z# G d de          Z$ G d de          Z% G d de          Z& G d de&          Z' G d de&          Z(e$)                                 e%)                                 e')                                 e()                                 dS )    N)TestCasecheck_help_consistency)	TestSuite
SRCDIR_ABSz../../..)	bootstraptestdatactdb
dfs_serverpidlauth	packagingpythonincludensswitchlibclicoverityzrelease-scripts	testprogsbinsource3zdocs-xml
buildtoolsfile_server	dynconfigsource4testslibdsselftestlibscripttraffic	testsuitelibgpowintestlibrpc>3   bin/gen_output.pyselftest/tests.pybuildtools/bin/wafscript/autobuild.pyscript/bisect-test.pyscript/show_test_timebin/samba_downgrade_dbselftest/filter-subunitselftest/format-subunitsource3/selftest/tests.pysource4/selftest/tests.pylib/ldb/tests/python/api.pypython/samba/subunit/run.pylib/ldb/tests/python/index.pyctdb/utils/etcd/ctdb_etcd_lockbin/python/samba/subunit/run.py python/samba/tests/smb-notify.py source4/scripting/bin/subunitrun"python/samba/tests/krb5/kcrypto.py#python/samba/tests/krb5/test_rpc.py#python/samba/tests/krb5/test_smb.py#source4/scripting/bin/gen_output.py$python/samba/tests/krb5/kdc_tests.py$python/samba/tests/krb5/s4u_tests.py$python/samba/tests/krb5/spn_tests.py$python/samba/tests/krb5/test_ldap.py%python/samba/tests/krb5/fast_tests.py%python/samba/tests/krb5/rodc_tests.py%python/samba/tests/krb5/salt_tests.py&python/samba/tests/krb5/alias_tests.py&python/samba/tests/krb5/etype_tests.py&python/samba/tests/krb5/test_ccache.py'python/samba/tests/krb5/as_req_tests.py'python/samba/tests/krb5/simple_tests.py'python/samba/tests/krb5/xrealm_tests.py(python/samba/tests/krb5/kdc_base_test.py(python/samba/tests/krb5/kdc_tgs_tests.py(python/samba/tests/krb5/kpasswd_tests.py(python/samba/tests/krb5/lockout_tests.py(python/samba/tests/krb5/nt_hash_tests.py(source4/scripting/bin/samba_downgrade_db)python/samba/tests/dcerpc/raw_protocol.py)python/samba/tests/krb5/test_idmap_nss.py*python/samba/tests/krb5/pac_align_tests.py,python/samba/tests/krb5/rfc4120_constants.py.python/samba/tests/krb5/compatability_tests.py.python/samba/tests/krb5/test_min_domain_uid.py0python/samba/tests/krb5/protected_users_tests.py4python/samba/tests/krb5/as_canonicalization_tests.py@python/samba/tests/krb5/ms_kile_client_principal_lookup_tests.pyselftest/tap2subunit>   wintest/test-s3.pywintest/test-s4-howto.pyrV   >   bin/abpython/examplessource3/script/testsbin/python/samba/testspython/samba/tests/binsource4/dsdb/tests/pythonbin/python/samba/tests/krb5bin/python/samba/tests/dcerpcc            	      f   t                      } t          j        ddt          ddgt          j                  }|j        dk    rh|j                            d          D ]M}|                     t          j
                            t          |                    d                               N| j        S )	zUGenerate a function that quickly answers the question:
    'is this a git file?'
    gitz-Czls-filesz-z)stdoutr       utf-8)set
subprocessrunBASEDIRPIPE
returncoderc   splitaddospathjoindecode__contains__)git_file_cachepfns      3/usr/lib/python3/dist-packages/samba/tests/usage.py_init_git_file_finderrw      s     UUNg" )o		/ 	/ 	/A
 	|q(..'' 	J 	JBrw||GRYYw5G5GHHIIII&&    c           
      z   |st          j        d          j        }|D ]}t          j                            | |          }t          j        |d          D ]M\  }}	}
|
D ]B}|                    d          r|                    d          r/t          j                            ||          }	 t          j        |          }n# t          $ r Y qw xY w|j
        t          j        z  s|dk    st          |          s| ||          s|t	 t          |d          }n,# t          $ r}t          d|d	|           Y d }~d }~ww xY w|                    d
          }|                                  ||          s$ |d|          }||v r	|dz  }||v 	|||<   DO|                                S )Nz\W+F)followlinks~z.instr   rbzcould not open z: (   _)recompilesubrn   ro   rp   walkendswithstatFileNotFoundErrorst_modeS_IXUSRis_git_fileopenOSErrorprintreadcloseitems)dcacheshebang_filterfilename_filtersubdirssafenamesubdirsdrootdirsfilesru   ffnsfelinenames                     rv   script_iteratorr      s     &&:f%%) $	& $	&Fa((B%'WRU%C%C%C "& "&!dE !& !&B{{3'' ! {{7++ ! ',,tR00C!GCLL, ! ! ! !9t|3 ! "eOO{3/?/?O &2.s33 %$%1% $S$AA& % % %!ESSS!!"DEEE$HHHH%  !vvbzz			-~d33 %$#8C,,D%-- %--"%E$KKC!&"&H ;;==s*   1C
C	C	D##
E	-E	E	c                 T    |                      d          d         } | od| vod| vod| v S )Nzbin/   /testldb)	partition)ru   s    rv   elf_file_namer      s:    	f		a	 BD#R-DF"$4D"Drx   c                     | d d         dk    S )N   s   ELF )xs    rv   elf_shebangr      s    RaR5Jrx   c                  T    t          t          t          t          t          dg          S )Nr   )r   r   r   )r   ri   	elf_cacher   r   r   rx   rv   elf_iteratorr      s(    7I*5+8$)7, , , ,rx   s   #!.+perlc                  B    t          t          t          t                    S N)r   ri   perl_script_cacheperl_shebangr   rx   rv   perl_script_iteratorr      s    7$5|DDDrx   s
   #!.+pythonc                  B    t          t          t          t                    S r   )r   ri   python_script_cachepython_shebangr   rx   rv   python_script_iteratorr      s    7$7HHHrx   c                   (    e Zd ZdZed             ZdS )PerlScriptUsageTestszgPerl scripts run without arguments should print a usage string,
        not fail with a traceback.
    c                 N    t                      D ]\  }}t          ||           d S r   )r   r   )clsr   filenames      rv   
initialisezPerlScriptUsageTests.initialise   s8    244 	" 	"ND($!!!!	" 	"rx   N__name__
__module____qualname____doc__classmethodr   r   rx   rv   r   r      s9          " " [" " "rx   r   c                   (    e Zd ZdZed             ZdS )PythonScriptUsageTestsziPython scripts run without arguments should print a usage string,
        not fail with a traceback.
    c                 f   t                      D ]\  }}|                    t          d                              d          }|t          v rt          d|z             Ot          j                            |          t          v rt          d|z             |fd}t          | d|z  |           d S )N r   zskipping %s (EXCLUDE_USAGE)skipping %s (EXCLUDE_DIRS)c                 x   t          |           	 t          j        d|gt          j        t          j                  }|                    d          \  }}n^# t
          $ r"}|                     d|z             Y d }~n7d }~wt          j        $ r"}|                     d|z             Y d }~nd }~ww xY w|                    d          }|                    d          }| 	                    d|           | 
                    d	|                                |                                z   d
|d|           d S )Npython3stderrrc      timeout	Error: %sSubprocess error: %sre   	Tracebackusagezstdout:
z	
stderr:
)r   rg   Popenrj   communicater   failSubprocessErrorrq   assertNotInassertInlower)selfr   rt   outerrr   s         rv   _fz-PythonScriptUsageTests.initialise.<locals>._f
  se   h:"()X)>0:0:A A AA  !}}Q}77HC / / /IIkAo........!1 : : :II4q899999999: jj))jj))  c222gsyy{{SYY[['@'@<?CCEG G G G Gs$   AA 
B3"A??B3B..B3test_%s)r   replaceri   lstripEXCLUDE_USAGEr   rn   ro   dirnameEXCLUDE_DIRSsetattrr   r   r   ru   r   s        rv   r   z!PythonScriptUsageTests.initialise   s    466 !	/ !	/ND( !!'2..55c::B]""3h>???wr""l222X=>>>"* G G G G& CT)2....C!	/ !	/rx   Nr   r   rx   rv   r   r      s9          "/ "/ ["/ "/ "/rx   r   c                   N    e 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S )HelpTestSuper`Python scripts run with -h or --help should print a help string,
    and exit with success.
    TFNc                      t          d          )Nz+Subclass this and add an iterator function!)NotImplementedError)r   s    rv   iteratorzHelpTestSuper.iterator.  s    ! #B C C 	Crx   c                 r   |                                  D ]\  }}|                    t          d                              d          }|t          v rt          d|z             Ot          j                            |          t          v rt          d|z             |fd}t          | d|z  |           d S )Nr   r   zskipping %s (EXCLUDE_HELP)r   c                    t          |           dD ]}||g}| j        r|                    d| j                   	 t          j        |t          j        t          j                  }|                    d          \  }}n^# t          $ r"}|                     d|z             Y d }~n7d }~wt          j	        $ r"}|                     d|z             Y d }~nd }~ww xY w|
                    d          }|
                    d          }| j        r|d	|}|d d
                                         }| j        r2t          || j        | j                  }	|	|                     |	           | j        r)|                     |j        dd|||j        ||fz             | j        r|                     d|d           | j        r|                     d	|d           d S )N)z--helpz-hr   r   r   r   r   r   re   
i  z1%s %s
returncode should not be %d
err:
%s
out:
%sr   zlacks "Usage:"
zexpected multi-line output)r   interpreterinsertrg   r   rj   r   r   r   r   rq   check_merged_out_and_errr   check_consistencyr   options_startoptions_endcheck_return_codeassertEqualrk   check_contains_usager   check_multiline)
r   r   hcmdrt   r   r   r   outlerrorss
             rv   r   z$HelpTestSuper.initialise.<locals>._fB  sM   h) 0O 0OA#Q-C' 8

1d&6777>&,S4>O4>OE E E $%===#;#;SS" 3 3 3		+/22222222%5 > > >		"81"<========> **W--C**W--C4 4*-##ss3tt9??,,D - .!78<8J8<8H"J "J "- IIf---- P((q*>*2Aq|S#)N*OP P P 0 Igt5GHHH+ OdC1MNNNa0O 0Os$   AB
CB((C:CCr   )r   r   ri   r   EXCLUDE_HELPr   rn   ro   r   r   r   r   s        rv   r   zHelpTestSuper.initialise2  s    !llnn B	/ B	/ND( !!'2..55c::B\!!2X=>>>wr""l222X=>>>"* 2O 2O 2O 2Oh CT)2....EB	/ B	/rx   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rx   rv   r   r      s~          O$KMKC C C C/ C/ [C/ C/ C/rx   r   c                       e Zd ZdZeZdZdS )PythonScriptHelpTestsr   r   N)r   r   r   r   r   r   r   r   rx   rv   r  r  y  s$          &HKKKrx   r  c                       e Zd ZdZeZdZdZdS )ElfHelpTestsz^ELF binaries run with -h or --help should print a help string,
    and exit with success.
    FTN)r   r   r   r   r   r   r   r   r   rx   rv   r  r    s-          H#rx   r  )*rn   sysrg   samba.testsr   r   unittestr   r   r   environri   ro   abspathrp   r   __file__	TEST_DIRSr   r   r   rw   r   r   r   r   r   r   r   matchr   r   r   r   r   r   r   r   r   r  r  r   r   rx   rv   <module>r     s  " 
			 



     8 8 8 8 8 8 8 8       				 2:j&GGgoobgll27??8+D+D+57 7 8 8G     	F4 4 4l  	 	 	' ' '  $#%% T#'$(%, , , ,^E E E   	, , , rz,''- E E E N++1 I I I" " " " "8 " " "(/ (/ (/ (/ (/X (/ (/ (/VV/ V/ V/ V/ V/H V/ V/ V/r    M   $ $ $ $ $= $ $ $    ! ! !  ! ! # # #      " " "        rx   