_e(ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddlm Z ddl Z ddl Z ej dZgZejejzdzZdZejddfdZ dd Zd ddd d ZddZe ddZdZdZe ddZdS)N) lru_cachec|tdtjtD]}t j|ddS)z)Clean up any remaining isolated test dirszCleaning up testcases directory)fileT ignore_errorsN)printsysstderr TEST_TEMPDIRSshutilrmtree)dir_s 0/Users/thom/git/pqcrypto/pqclean/test/helpers.pycleanup_testcasesrsT +z00 d$/////00_cddtdD}tj|d||S)zReturns a unique directory namec3HK|]}tjtVdS)N)secretschoiceALPHABET).0is r zmktmpdir.. s,>>7>(++>>>>>>rz{}_{})joinrangeospathformat)parentprefixuniqs rmktmpdirr%sL 77>>U1XX>>> > >D 7<<vt < < = ==r.. testcasesc tj|n#t$rYnwxYwt||tjt tjddtjtjdfd}fd}||fS)zIsolates the test files in a separate directory, to help parallelise. Especially Windows is problematic and needs isolation of all test files: its build process will create .obj files EVERYWHERE. crypto_blaschemeimplc \tjtjtjdt jtjddtjdt jtjdddtjddt jtjdddtjdddD]U}t jtjdd|tjd|Vt jdS)zIsolate the files to be testedtestr&commonMakefileMakefile.Microsoft_nmake)r. test_common crypto_sign crypto_kemN)rmakedirsmkdirr rr copytreecopy)d impl_path new_impl_dir scheme_dirtest_dirs r initializerz'isolate_test_files..initializer7sh J h//000  GLLx ( ("',,x*J*J L L L  BGLLvz::GLL6:>> @ @ @ BGLLv/IJJGLL63MNN P P PH  A O T61-- Xvq11      <00000rc4tjddS)zClean up the isolated filesTrN)r r )r<sr destructorz&isolate_test_files..destructorPs hd333333r) rr5FileExistsErrorr%r abspathr appendr)r9 test_prefixdirr=r?r:r;r<s` @@@risolate_test_filesrE$s        [))Hwx((H"""h h??J7??27<< F#C#CDDL11111111244444 lK <  )stdoutr cwdenvutf-8Got unexpected return code {})renvironr7updaterr subprocessrunPIPESTDOUTrKdecode returncoder!)command working_dirrMexpected_returncode print_outputenv_results rrun_subprocessr^Ws" :??  DDL  C C  +  1 1 1222 ^   F- fm""7++,,,& $7777 + 2 263D E E8777!6=#7#7#@#@AA =   ( ((rrYrMrZc6tjdkrRgd}dD]J}||vrD||dd|d|<Kndg}t g|d|D|||| S) zz Runs a make target in the specified working directory Usage: make('clean', 'targetb', SCHEME='bla') nt)nmakez/fr0z/NOLOGOz/E)IMPLEMENTATIONSCHEME-rz {}_UPPERCASEmakec@g|]\}}d||S)z{}={})r!)rkvs r zmake..s* > > >tq!gnnQ"" > > >rr_)rnameupperreplacer!r^items)rYrMrZargskwargs make_commandenvvars rrfrfxs w$))) 3 A AFv,,..66sB??~,,V445 A x   > >v||~~ > > >   /    r%This test is not supported on Windowscfd}|S)Ncjtj|fd}tjdkr|S|S)Nc4ddl}|jddS)NrTallow_module_level)pytestskip)rorprymessages r skip_windowsz3skip_windows..wrapper..skip_windowss) MMM FKD 9 9 9 9 9 9rra) functoolswrapsrrk)fr|r{s rwrapperzskip_windows..wrappersI    : : : :   : 7d?? Hr)r{rs` rr|r|s# Nr)maxsizec6tj|}|r|S|dkrtjdksdtjvr}|d}|ddkr|ddkr|ddkrdS?t!jgdt jt j}|jdks"Jd|j|jdD]} tj| } | ds_| dsJ| tjddst;jddS| |d rdS| tjdd|j rdSdSdS)!NrPQCLEAN_ONLY_TESTS,FPQCLEAN_SKIP_TESTSTPQCLEAN_ONLY_TYPESPQCLEAN_SKIP_TYPESPQCLEAN_ONLY_SCHEMESPQCLEAN_SKIP_SCHEMESPQCLEAN_ONLY_DIFFgit)rstatusz --porcelain=2z--branchr&)rKr rLrNrJ#z branch.headmaster)rdiffz --name-onlyz origin/master)rKr rOr3r2r-duplicate_consistencyz9Running all tests as there are changes outside of schemesr)base)lenlistvaluesrrPlowersplit isinstancepqcleanImplementationr*Schemetyperkr rrRrSrTrUrWrKrV splitlinesr!r normpath startswithrlogginginfo) testnamerorpthingr* branch_result branch_linetokens diff_result diff_lines r permit_testrs 4yyA~~V]]__%%a(Qrz))~~2:.B#C#I#I#K#K#Q#QRU#V#VVV5rz)) >>  rz*>?EEGGMMcRR R R5%/00 E7> * *trz)){  ""bj1E&F&L&L&N&N&T&TUX&Y&YYY5rz)) ;    "*-A"B"H"H"J"J"P"PQT"U"U U U5++{  ""bj1G&H&N&N&P&P&V&VWZ&[&[[[5++ ;    "*-C"D"J"J"L"L"R"RSV"W"W W W5bj(( <   *'N>>>!!( M'1,,t,3::7CCNNPP $ $ $**3//!9##q ](B(BayH,,#tt$.???!!(K )Q.../66{7MNN/..(/66w??JJLL  G,,Y77 !,,\:: %00?? %00fF]1^1^__ L"677744''  (;(;<< 44'' V=TV\VaVgVgViVi(j(jkk 44 5 4rcjtddtjfd}|S)Ntest_c\tg|Ri|r|i|Stjd)NzTest disabled by filter)runittestSkipTest)rorpfuncfuncnames rrzfiltered_test..wrappersJ x 1$ 1 1 1& 1 1 ?4((( (#$=>> >r)__name__rr}r~)rrrs` @r filtered_testrsT}S\\]]+H_T?????? Nrrcd}|d|vr=ddl}|}d|ddvrgd|d<|9d|v=|S)NflagsrzApple M brand_rawr)sha3sha256sha1aescrc32neonasimd)cpuinfo get_cpu_infoget)the_infors rrrsyH  gX55''))  ["55 5 5!!!HW   gX55 Or)rFNrT)rs)atexitr}rrrr stringrRr rrryrregisterrr ascii_lettersdigitsrr%r rrEr^rfr|rrrrrrrrs     000  &- /# 5>>>7<<k::0=0=0=0=fLM $))))B Tq<     4FFF2OOOd    1r