Y}|d?dd@|dAdB}|dCdDddE|dFdGtdHtd<I|dJdKddL|dM}|dNdOdP|dQdRdSdTdUV|dW}|dXdYtd<tZ|d[d\td<tZ|d]d^| a tjdkrtttjt_tjrAtjd_r$t'jd`dt_dSdSdSdat_dS)bNahBuild/install everything for a testsuite and run it. examples: ./testenv.py run mgw ./testenv.py run mgw --test TC_crcx ./testenv.py run mgw --podman --binary-repo osmocom:latest ./testenv.py run mgw --io-uring ./testenv.py run ggsn --config open5gs ./testenv.py run ggsn --config 'osmo_ggsn_v4_only' ./testenv.py run ggsn --config 'osmo_ggsn*' )formatter_class descriptionactionT)titledestrequiredinitzinitialize osmo-dev/podman)helpruntime)rrrzosmo-devzprepare osmo-dev (top-level makefile scripts, for building test components from source when using 'run' without '--binary-repo')podmanz-prepare the podman image (for 'run --podman')z-fz--force store_truez$build image even if it is up-to-date)rr runz$build components and run a testsuiteztestsuite options testsuitez8a directory in osmo-ttcn3-hacks.git (msc, bsc, mgw, ...)z-tz--testzKonly run one specific test (e.g. TC_selftest, BTS_Tests_OML.TC_wrong_mdisc)z-cz--configappendz;which testenv.cfg to use (supports * wildcards via fnmatch)z-iz --io-uringzset LIBOSMO_IO_BACKEND=IO_URINGzsource/binary optionsz0All components are built from source by default.z-bz --binary-repo OBS_PROJECTzPuse binary packages from this Osmocom OBS project instead (e.g. osmocom:nightly))metavarr z loop optionsz1Run the testsuite / a single test multiple times.z-uz --until-nokz-run until there was either a failure or errorz QEMU optionszOFor some tests, the SUT can or must run in QEMU, typically to use kernel GTP-U.z-Dz--debian-kernel store_constkerneldebianz"run SUT in QEMU with debian kernel)rrconstr z-Cz--custom-kernelcustomz$run SUT in QEMU with custom kernel (rzconfig file optionszTestsuite and test component configs for nightly/master versions of test components are used, unless a binary repository ending in :latest is set or --latest is used.z--latestzuse latest configszpodman optionsz7All components are run directly on the host by default.z-pz--podmanz run all components inside podmanz-dz--distroz"distribution for podman (default: )defaultr z-sz--shellz:run an interactive shell before stopping daemons/containerzoutput optionsz-lz --log-dirz(log here instead of a random dir in /tmpz-nz--no-teetee store_falsez,don't send test component's output to stdout)rrr z cache optionsz--cachezcache path (default: )r r.z--ccachezccache path (default: cleanzclean previous build artifactsz:latestz7Binary repository ends in :latest, using latest configsF)argparseArgumentParserRawDescriptionHelpFormatteradd_subparsers add_parser add_argumentadd_argument_groupadd_mutually_exclusive_groupcustom_kernel_pathdistro_defaultcache_dir_defaultccache_dir_default parse_argsargsrrr% binary_repoendswithrrlatestr")parsersubsub_initsub_init_runtime sub_podmansub_rungroups r r>r>$s  $ < :   F   hX  M MC~~f+G~HHH..YT].^^L  ",,X@r s sE  . . 0 0E   _   & &~7j k kE   <   & &Y  E  . . 0 0E    1     I4F I I I   & &   E z,=QRRR  & &'79r s sE tZ Cefff   C. C C C     I   & &'7 8 8E t[/YZZZ    ;   & & 7 7E  9%6 9 9 9!   ;&8 ; ; ;" NN7!ANBBB     D {e5dnEE    0 9 9) D D  MS T T TDKKK      r ctjdkrdStjrtjst dtjdkrtjst dtjdkrOt jts+tj dt dtt j td}t j|tj}t j|st d |dS) Nr$z--binary-repo requires --podmanr+z!--kernel-debian requires --podmanr-zjSee _testenv/README.md for more information on downloading a pre-built kernel or building your own kernel.z>For --kernel-custom, put a symlink or copy of your kernel to: r ztestsuite dir not found: )r?rr@r"rr*ospathexistsr:rcriticalrealpath__file__joinr%)ttcn3_hacks_dir_src testsuite_dirs r verify_args_runrTs  {e B B@AAA {ht{BCCC {hrw~~6H'I'I x   t`rttuuu'**h+A+A+ABBGLL!4dnEEM 7>>- ( (LJ=JJKKKLLr c>ttdSN)r>rTrr r init_argsrWsLLLr c6eZdZdddddddZfdZdZxZS) ColorFormatterzzzzz)rinfowarningerrorrNresetc|jD]N}d|}|tjvr'tj||j|<Ot dS)NTESTENV_COLOR_)colorskeysupperrKenvirongetsuper__init__)selfcolorenv_var __class__s r rfzColorFormatter.__init__sy[%%'' = =E6u{{}}66G"*$$%'Z^^G%<%< E" r c|jtjkrd}n_|jtjkrd}nG|jtjkrd}n/|jtjkrd}n|jtjkrd}|j|td|jd|j _ tj ||}|S)NrrZr[r\rNz %(msg)sr]) levelnorDEBUGINFOWARNINGERRORCRITICALr` log_prefix_style_fmt Formatterformat)rgrecordrhresults r rvzColorFormatter.formats >W] * *EE ^w| + +EE ^w . .EE ^w} , ,EE ^w/ / /E"k%0\*\\dkRYFZ\\ "))$77 r )rrrr`rfrv __classcell__)rjs@r rYrYse Fr rYct}tj}|tjg|_tj}||||dSrV) rYr getLoggersetLevelrmhandlers StreamHandler setFormatter addHandler) formatter root_loggerhandlers r init_loggingrsu  I#%%K'''K#%%G ###7#####r c |adSrV)rr)news r set_log_prefixrs JJJr )r2ros.pathrK Exceptionrr?rcrdrLrOrPsrc_dirrQdata_dirr:r; expanduserr<r=rrrr>rTrWrurYrrrr r rs     y     *..*BG,<,<=V=V=V,W,W X X 7<<((H)<)<)<==v F FW\\"'"2"2h3I3I3I"J"JHUU"GLL!3!3J!?!?AUVVW\\"3X>>     TTTnLLL, !!!!!W&!!!H$$$r