a P}|jd?dd@d|dAdB}|jdCdDddEd|jdFdGt dHt d<dI|jdJdKddLd|dM}|jdNdOdPd|jdQdRdSdTdUdV|dW}|jdXdYt d<t dZ|jd[d\t d<t dZ|jd]d^d| a t jdkrvtt jt _t jr|t jd_r|td`dt _ndat _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*' )Zformatter_classZ 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)rrrunz$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-repoZ OBS_PROJECTzPuse binary packages from this Osmocom OBS project instead (e.g. osmocom:nightly))metavarrz 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-kernelZ store_constkerneldebianz"run SUT in QEMU with debian kernel)rrZconstrz-Cz--custom-kernelcustomz$run SUT in QEMU with custom kernel (r zconfig 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: )defaultrz-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-teeteeZ store_falsez,don't send test component's output to stdout)rrrz cache optionsz--cachezcache path (default: )rr z--ccachezccache path (default: cleanzclean previous build artifactsz:latestz7Binary repository ends in :latest, using latest configsF)argparseArgumentParserZRawDescriptionHelpFormatterZadd_subparsersZ add_parser add_argumentZadd_argument_groupZadd_mutually_exclusive_groupcustom_kernel_pathdistro_defaultcache_dir_defaultccache_dir_default parse_argsargsrrr binary_repoendswithr r Zlatestr)parsersubZsub_initZsub_init_runtimeZ sub_podmanZsub_rungrouprrrr*$s              r*cCstjdkrdStjr"tjs"tdtjdkr:tjs:tdtjdkrhtjt sht dtdt tj t d}tj|tj}tj|std |dS) Nrz--binary-repo requires --podmanrz!--kernel-debian requires --podmanrzjSee _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,rrrospathexistsr&r criticalrealpath__file__joinr)Zttcn3_hacks_dir_srcZ testsuite_dirrrrverify_args_runs   r8cCsttdSN)r*r8rrrr init_argssr:cs6eZdZdddddddZfddZd d ZZS) ColorFormatterzzzzz)r infowarningerrorr4resetcsH|jD].}d|}|tjvr tj||j|<q tdS)NZTESTENV_COLOR_)colorskeysupperr1environgetsuper__init__)selfcolorZenv_var __class__rrrFs  zColorFormatter.__init__cCs|jtjkrd}nF|jtjkr$d}n4|jtjkr6d}n"|jtjkrHd}n|jtjkrXd}|j|td|jd|j _ tj ||}|S)Nr r<r=r>r4z %(msg)sr?) levelnor DEBUGINFOWARNINGERRORCRITICALr@ log_prefix_style_fmt Formatterformat)rGrecordrHresultrrrrUs     "zColorFormatter.format)rrrr@rFrU __classcell__rrrIrr;s r;cCs@t}t}|tjg|_t}||||dSr9) r;r getLoggersetLevelrLhandlers StreamHandler setFormatter addHandler) formatterZ root_loggerhandlerrrr init_loggings  racCs|adSr9)rQ)newrrrset_log_prefixsrc)r#r Zos.pathr1 Exceptionrr+rCrDr2r5r6Zsrc_dirr7Zdata_dirr&r' expanduserr(r)rQrr*r8r:rTr;rarcrrrrs& $