a Z^>`@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZddl m!Z!ddl"m#Z#ddl$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*dZ+Gd d d Z,d d d Z-dS)N) _parse_args) findtestsruntestget_abs_moduleSTDTESTSNOTTESTSPASSEDFAILED ENV_CHANGEDSKIPPEDRESOURCE_DENIED INTERRUPTED CHILD_ERRORTEST_DID_NOT_RUNTIMEOUTPROGRESS_MIN_TIMEformat_test_result is_failed) setup_tests)setup_pgo_tests)removepycountformat_duration printlist)supportg^@c@seZdZddZddZd6ddZd7d d Zd d Zd dZddZ ddZ ddZ ddZ ddZ ddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd8d0d1Zd2d3Zd4d5Zd/S)9RegrtestcCsd|_g|_g|_g|_g|_g|_g|_g|_g|_g|_ d|_ d|_ g|_ d|_ t|_d|_d|_d|_d|_d|_d|_d|_d|_dS)NF)nstestsselectedgoodbadskippedresource_deniedsenvironment_changed run_no_testsrerun first_result interrupted test_timestracertime monotonic start_time test_counttest_count_widthnext_single_testnext_single_filename testsuite_xmlwin_load_trackertmp_dirworker_test_nameselfr9-/usr/lib64/python3.9/test/libregrtest/main.py__init__6s. zRegrtest.__init__cCs<t|jt|jBt|jBt|jBt|jBt|jBSN)setr!r"r#r$r%r&r7r9r9r: get_executed`szRegrtest.get_executedFc Cs|j}|j}|ttfvr.|s.|j|j|f|tkrD|j|n|t tfvrb|s|j |n|t krx|j |n|t kr|j|nj|tkr|j||j|nH|tkr|j|n2|tkrd|_n"|tkr|j |n td||r|t tthvr|j ||j}|rddlmm}|D]D}z|j||Wn&|jy|t|tj dYn0q}|ddd}| }||}|dur|j|qWdn1s0Yt|j|jjr.t|jtdd}t}|jjr|jjD]$} | |vrl|| || qTg|j_|jjrt |jjt!t"} nt |jj||} |jj s|jp|jjp| |_#n|j|_#|jjr0|j#dd|_#z"| $|j#d} | | d|_%Wnt&y.Yn0|jj'rz|j#d|j#$|jj'=Wn*t(yt)d|jj't*j+dYn0|jj,r|jj-durt./d |j_-t.0|jj-t.1|j#dS) NZ pynexttestrz\btest_[a-zA-Z0-9_]+\b#rrz1Couldn't find starting test (%s), using all testsr?i)2rrsinglerorpjoinr5r2openreadstripOSErrorfromfilerecompilerSAVEDCWDsplitsearchrCgrouprr_rrrcopyZexcluderjrFaddZtestdirrlistr=r indexr1 IndexErrorstartrErKrLrl randomize random_seedrandom randrangeseedshuffle) r8rfpZ next_testZregexrXmatchZstdtestsZnottestsargZalltestsposr9r9r: find_testssr *    2              zRegrtest.find_testscCs|jD] }t|qdSr<)r rK)r8namer9r9r: list_testss zRegrtest.list_testscCsX|D]N}t|tjjrqt|tjr0||qt|tjrt|rt | qdSr<) isinstanceunittestloaderZ _FailedTestZ TestSuite _list_casesZTestCaserZ match_testrKid)r8suitetestr9r9r:rs    zRegrtest._list_casesc Csdt_t|jj|jj|jD]L}t|j|}ztj |}| |Wq tj yj|j |Yq 0q |j rttjdttt|j ddtjdt|j tjddS)NFr?rskipped:)rverboseZset_match_testsrZ match_testsZ ignore_testsr rrZdefaultTestLoaderZloadTestsFromNamerZSkipTestr#rCrKrLrlrr^r)r8rAZabstestrr9r9r: list_cases s    zRegrtest.list_casescCsd|j_d|j_d|j_||_||d|jdd|_|jD]F}|d|dd|j_t |j|}|j |dd|j t krJqqJ|jrt tt|jddt|j|dS) NTFz'Re-running failed tests in verbose modez Re-running z in verbose mode)r'rz failed again:)rrfailfastZverbose3get_tests_resultr(rZr"r'rrQrBr rKrr^rdisplay_result)r8rArBr9r9r:rerun_failed_tests1s$      zRegrtest.rerun_failed_testscCs |jjr dSttd||jr0tdt|j|}|rhtttt |ddt ||j r|jj st|j s|js|jst |j dkrtdddttt |j dd |jjr|jjd d ttd |jdd D]\}}td|t|fq|j r>tttt |j ddt |j |jrpttdtt |jdt |j|jr|jj stttt |jddt |j|jrttdtt |jdt |j|jrtttt |jddt |jdS)Nz== Tests result: %s ==z(Test suite interrupted by signal SIGINT.rzomitted:rZAllrR)endzOK.T)reversez10 slowest tests: z- %s: %szfailed:z%{} altered the execution environment:rz%s:z re-run testz run no tests:)rr_rKrr)r=r r>rr^rr!r]r"r#Z print_slowr*sortrr%formatr'r&)r8ZomittedrDrr9r9r:rKsd       zRegrtest.display_resultcCs|jjr ddl}|jddd|_tj}d}|jjrJ|dt|jj7}| |d}t |j dD]\}}t }|}|rd||f}||||jrd } tt} |jj| t| d | d } nt|j|} || | jtkrq|t| }t |} | tkrd |t| f}n| jtkr.d}tjD]&} | |vr8| d r8t| q8|jjrdt| |jrdq|qd|rt|dS)NrFT)tracerzRun tests sequentiallyz (timeout: %s)rz%s -- %szDresult = runtest(self.ns, test_name); self.accumulate_result(result))globalslocalsrBz%s in %sztest.) rrZTracer+rLmoduleskeystimeoutrrZ enumeraterr,r-rbdictrZrunctxrrrQrBr rrr startswithrZunloadrrrK)r8rZ save_modulesrvZ previous_testr`rAr.racmdrrBrDmoduler9r9r:run_tests_sequentialsJ            zRegrtest.run_tests_sequentialccs6|D]*}|V|jrdS|jjr|jrdSqqdSr<)r"rfail_env_changedr%)r8rrAr9r9r: _test_forevers zRegrtest._test_forevercCsxtdtgtjRtdtjdddtjtdtt }|rZtd|tdt dt fdS) Nz==T)Zaliasedz %s-endianz== cwd:z == CPU count:z== encodings: locale=%s, FS=%sF) rKplatformZpython_implementationrLversionr byteorderrogetcwd cpu_countlocalegetpreferredencodinggetfilesystemencoding)r8rr9r9r:display_headers zRegrtest.display_headercCsg}|jr|dn@|jjr0|jr0|dn&t|j|j|j|j|jfsV|d|jrf|d|st|dd |}|j rd|j |f}|S)NFAILUREz ENV CHANGEDz NO TEST RUNr SUCCESSz, z %s then %s) r"rCrrr%anyr!r#r)r{r()r8rBr9r9r:rs"      zRegrtest.get_tests_resultcCs|jjs.|jjs6|jjs6|jjs6|js6|jjs6||jjrh|jj\}}}|dkrhd}t |t j dd|jj r~t d|jj |jjr|t|j|_d|_d|_n.t|j|_dt|j|_t|jd|_|jjrd d lm}||n|dS) NzhWARNING: Running tests with --huntrleaks/-R and less than 3 warmup repetitions can give false positives!TrdzUsing random seedrz/{}rr)run_tests_multiprocess)rheaderr_r]rzrrjrrkrKrLstdoutrrZforeverrrr r/r0iterrr^Zuse_mprirr)r8rsrtrurvrr9r9r: run_testss<   zRegrtest.run_testscCs|jrV|jrJt|jd }||jdWdqV1s>0Yn t|j|jrz|j}|jdd|j j dt t |j}t dt|t d||j jrtdtdS)Nw T)Z show_missingZsummarycoverdirzTotal duration: %szTests result: %szleaks %d)r2r1r|writerounlinkr+resultsZ write_resultsrrrKr,r-r.rrZrunleakssystemgetpid)r8rrxZdurationr9r9r:finalizes 0  zRegrtest.finalizec Cs |jjs|jsdSddlmm}|d}dddd}|jD]L}|||D]8}z ||t| |d7<WqRt yYqR0qRq@| D]\}}| |t |qtjtj|jj}t|d*}||D]} || qWdn1s0YdS)NrZ testsuites)rerrorsZfailureswb)rrgr3rHrIrJZElementrCrWgetrEitemsr=strrorpr{rrr|Z tostringlistr) r8rOrootZtotalsrkvrgfsr9r9r:save_xml_results$        zRegrtest.save_xml_resultcCst|jjr|jj|_|js`trVtd|_|jdurBtd|_tj|jd|_n t |_tj |j|_dS)NZ abs_builddirZsrcdirZbuild) rrnr5 sysconfigZis_python_buildZget_config_varrorpr{tempfile gettempdirabspathr7r9r9r: set_temp_dir6s     zRegrtest.set_temp_dircCsLtj|jddt}|jdur.d|}n d|}tj|j|}|S)NT)exist_okztest_python_worker_{}ztest_python_{})romakedirsr5rr6rrpr{)r8pidtest_cwdr9r9r:create_temp_dirLs   zRegrtest.create_temp_dircCstddl}tj|jd}td|j||D]>}tj|rXtd|t|q0td|t |q0dS)Nrz test_python_*zCleanup %s directoryzRemove directory: %szRemove file: %s) globrorpr{r5rKisdirrrmtreer)r8rrprr9r9r:cleanupZs    zRegrtest.cleanupNc Ks||||jjr,|td|}zFtj|dd$||j_ | ||Wdn1sn0YWn>t y}z&t j tddt|jWYd}~n d}~00dS)NrT)r])rm)rwrrrrLrmrrZtemp_cwdrn_main SystemExit faulthandlerZdump_traceback_later EXIT_TIMEOUTcode)r8rrrrexcr9r9r:maings  .z Regrtest.maincCs.|jdur|jSttdr*tdSdS)NrUr)r4rUhasattrror7r9r9r:rUs     zRegrtest.getloadavgc Cs|jdur$ddlm}||j|j|jjr4td|jjt_|jj t_ t |j| ||jj rv| td|jjr|tdtjdkr|jdurddlm}z ||_Wn2ty}ztd|WYd}~n d}~00zJ|||jjr|jr|W|jdurZ|jd|_n|jdurX|jd|_0|||jr|td|jrtd|jj r|j!rtd tddS) Nr)run_tests_workerzPress any key to continue...win32)WindowsLoadTrackerz%Failed to create WindowsLoadTracker: rer)"r6rirrwaitinputr_rZPGOZ pgo_extendedZ PGO_EXTENDEDrrrrLrmrrZtest.libregrtest.win_utilsrr4FileNotFoundErrorrKrrZverbose2r"rcloserrr)rr%)r8rrrrrerrorr9r9r:rsR          $        zRegrtest._main)F)r)N)__name__ __module__ __qualname__r;r>rQrZrbrwrrrrrrrrrrrrrrrrrrUrr9r9r9r:rs2* )  I ;7     rcKstjfd|i|dS)Nr)rr)rrrr9r9r:rsr)N).rVrrrorrrrLrrr,rZtest.libregrtest.cmdlinerZtest.libregrtest.runtestrrrrrrr r r r r rrrrrrZtest.libregrtest.setuprZtest.libregrtest.pgorZtest.libregrtest.utilsrrrrrrrrrr9r9r9r:s2 L   /