
    &j%                         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i ada	ddZ
d Zd ZddZd Zd Zd Zd	 Zd
 Zd Zd ZdS )    Nc                    | a d}t          j        j        rd| d}| dk    rt          j        d|            d S |                     dd          } |                     dd          } t          j        d| d|  d           d S )	N z[loop-]testenv.cfgz	[testenv]testenv_.cfg[)currenttestenvargs	until_nokset_log_prefixreplace)cfg_name
loop_countloop_strs      T/home/osmocom-build/jenkins/workspace/ttcn3-bsc-test/_testenv/testenv/testenv_cfg.pyset_currentr      s    GH| *)J)))=  585566666##J33##FB//A8AAhAAABBBBB    c                      t           j                            t          j        d          } t          j        d|             t          j        d           d S )Nz_testenv/README.mdzMore information:    )	ospathjoinr   ttcn3_hacks_dirloggingerrorsysexit)readmes    r   exit_error_readmer!      sE    W\\'13GHHFM/v//000HQKKKKKr   c                 \   | D ]}| |         D ]}|                     d          st          j        j        rN|                    dd          }t          j        | d| d| d| d           | |         |         | |         |<   nt          j        | d| d| d           | |         |= d	S )
z]Remove _latest keys from cfg or use them instead of the regular keys,
    if --latest is set._latestr   : [z	]: using z instead of z (--latest is set)z]: ignoring z (--latest is not set)N)endswithr   r   latestr   r   debug)cfgr   sectionkeykey_regulars        r   handle_latestr,   %   s      " "w< 	" 	"C<<	** |" \!kk)R88ll'llCll[lllmmm,/L,=G[))ZZ'ZZsZZZ[[[GS!!	"" "r   c                    d}d }| D ]}d| |         v rS|rCt          j        d| d| d           t          j        d           t          j        d           | |         d         }d| |         v rS|sCt          j        d| d| d           t          j        d	           t          j        d           | |         d         }||fS )
Nz	127.0.0.1vty_portz	Error in z
, section :z=  Found vty_port in multiple sections. This is not supported.r   vty_hostz-  Found vty_host in section without vty_port.)r   r   r   r   )r(   r   hostportr)   s        r   get_vty_host_portr3   8   s    DD , ,W%% D$DD'DDDEEE]^^^w<
+DW%% D$DD'DDDEEEMNNNw<
+D:r   c                  l    t           r,t          t                    d                             dd           S d S )N	testsuitepodman_extra)r
   cfgsget r   r   get_podman_extra_current_cfgr:   M   s/     DG}[)--ndCCC4r   c            	      J   t           j        j        } d}d}t                                          D ]\  }}|                                D ]$}d||         v rd}||         d         dk    rd} n%t           j        j        r*|s(t          j        |  d| d           t                       t           j        j        si|rgt          j
        |  d| d| d           t          j
        d	           t          j
        d
           t          j
        d           t                       dS )zBCheck if passed -C or -K args make sense with the testenv configs.FqemuTrequired/z!: doesn't support running in QEMU: z must run in QEMUzUse one of:z  -D, --debian-kernelz  -C, --custom-kernelN)r   r   r5   r7   itemskeyskernelr   criticalr!   r   )r5   qemu_supportedqemu_requiredbasenamer(   r)   s         r   verify_qemu_cfgsrG   S   sI   &INM    #xxzz 	 	GW%%!%w<':55$(M	 & < 	 ~ 	 	WWHWWWXXX|" 	 } 	 MYOOOOWOOOPPPM-(((M1222M1222#   r   c           	          d||         vrdS ddg}||         d         }||vr/t          j        |  d| d| d|            t                       dS dS )z$Verify that qemu= has proper values.r<   Noptionalr=   r$   z]: qemu=z is invalid, must be one of: )r   r   r!   )r   r(   r)   validvalues        r   verify_qemu_sectionrL   m   s    S\!!$EL EE^^'^^5^^W\^^___ r   c           
         g d}g d}dddd}ddg}dd	g}d
| vr%t          j        | d           t                       d| d
         vr%t          j        | d           t                       d| d
         d         v r%t          j        | d           t                       d| d
         d         v r%t          j        | d           t                       d| d
         vr%t          j        | d           t                       | D ]e}| |                                         D ]d}|}	|d
k    r|}	||	v r| d| d| d}
||v r||         |	v r|
d||          dz  }
||v r|
dz  }
t          j        |
           t                       et	          || |           |dvrFd| |         vr<t          j        | d| d           t          j        d           t                       |D ]}|| |         v ryd| |         |         v rit          j        | d| d| d           t          j        d | |         |          d!           t          j        d"           t          j        d#           gt          | |           d S )$N)cleanconfigcopyprepareprogramr6   )
rN   rP   makepackagerQ   rR   r<   setupr0   r.   rO   rT   rR   )configspackagesprogramsrP   max_jobs_per_gb_ram	titan_minr5   z: missing [testsuite] sectionz!: missing program= in [testsuite] z1: program= in [testsuite] must not have argumentsz-: config= in [testsuite] must not have spacesz : missing config= in [testsuite]r$   z]: z= is invalidz, did you mean z=?z, (this key has been moved to testsrcdir.cfg))DEFAULTr5   rS   z: missing make= in section [z].z#If this is on purpose, set make=no.z  r?   z= in section [z] has multiple spaces:z  ""z-Please separate elements with only one space.r   )r   r   r!   rA   rL   r   r   r3   )r(   r   keys_valid_testsuitekeys_valid_componentkeys_invalid
keys_listskeys_moved_to_testsrcdir_cfgr)   r*   rJ   msgs              r   verifyrd   z   si         L 	J
 	$ 
 #<<<===K(((@@@AAA
c+y)))PPPQQQ
c+x(((LLLMMMs;'''???@@@  w<$$&& 	  	 C(E+%%,e||;;g;;#;;;Cl""|C'8E'A'A>c):>>>>222EEM#D#w///222vS\7Q7QMTJJwJJJKKKM?@@@ 	 	Cc'l""ts7|C/@'@'@[[[[G[[[\\\8CL$5888999MNNN	 c4     r   c                 n   g }| D ]a}t           j                            |          }|dk    r:||                    dd          d                             dd          d         gz  }bd| }|r|dd	                    |           d
z  }n|dt
          j        j         dz  }t          j        |          )Nr   _r   .r   z Invalid parameter for --config: z (valid: all, z, )z (the zG testsuite only has one testenv.cfg file, therefore just omit --config))	r   r   rF   splitr   r   r   r5   NoTraceException)glob_result
config_argrJ   r   rF   rc   s         r   raise_error_config_argrn      s    E C C7##D))}$$hnnS!,,Q/55c2>>qABBE
9Z
9
9C x3		% 0 03333w.wwww

"3
'
''r   c            	      r   t           j                            t          j        t          j        j                  } t           j                            | d          }t          t          j        |                    }|s9t          j
        d|             t                       t          j        d           t          |          dk    ryt           j                            t           j                            | d                    r<t          j
        d           t          j
        d           t          j        d           t          |          dk    rt           j                            t           j                            | d                    sct          j
        d           t          j
        dt           j                            |d	                    d
           t          j        d           t          |          dk    rt          j        j        st          j
        d           |D ]_}t          j
        dt           j                            |                              ddd                              dd                      `t          j
        d           t          j        d           |S )Nztestenv*.cfgzMissing testenv.cfg in: r   r   z/Found multiple testenv*.cfg, and a testenv.cfg.zMThe testenv.cfg file must be renamed, consider naming it testenv_generic.cfg.z9There is only one testenv*.cfg file, so please rename it:z$ mv r   z testenv.cfgz-Found multiple testenv.cfg files, use one of:z -c r   r   r   zLYou can also select all of them (-c all) or use the * character as wildcard.)r   r   r   r   r   r   r5   sortedglobr   r   r!   r   r   lenexistsrF   rO   r   )dir_testsuitepatternretr   s       r   find_configsrw      s   GLL!8',:PQQMgll=.99G
7##
$
$C @@@AAA
3xx!||rw||M='Q'QRR|GHHHefff
3xx1}}RW^^BGLL,V,VWW}QRRRDbg..s1v66DDDEEE
3xx!||GL/|EFFF 	j 	jDMh!1!1$!7!7!?!?
BPQ!R!R!Z!Z[ace!f!fhhiiiideeeJr   c                  P   i } t                      }|D ]}t          j                            |          }|dk    r,|                    d          st          j        d|           |dk    rt          j        d|           t          j                    }|	                    |           t          ||           t          ||           t
          j        j        s|t          |<   t                        d S || |<   t
          j        j        D ]}|dk    r;t!          t
          j        j                  dk    rt          j        d          | a d S d	}| D ]/}d| d
}t#          j        ||          rd}| |         t          |<   0|st%          ||           t                       d S )Nr   r   z@Invalid filename, expected either testenv.cfg or testenv_*.cfg: ztestenv_all.cfgzInvalid filename: allr   z=Can't use multiple --config arguments if one of them is 'all'Fr   T)rw   r   r   rF   
startswithr   rk   configparserConfigParserreadr,   rd   r   rO   r7   rG   rr   fnmatchrn   )cfgs_allconfig_pathsr   rF   r(   rm   matchedru   s           r   initr      s    H>>L ! !7##D))}$$X-@-@-L-L$*]S[]]   (((*+J+J+JKKK'))c4   sD |" 	 DNFF  l)  
7<&''1,,./noooDFF  	4 	4H1111Gx11 4!)(!3X 	="<<<<# r   )r   )N)r{   r~   rq   r   os.pathr   r   r   r7   r
   r   r!   r,   r3   r:   rG   rL   rd   rn   rw   r   r9   r   r   <module>r      s           



 	
C C C C   " " "&   *       4
 
 
S! S! S!l( ( ("  </ / / / /r   