tooltest.py 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. #!/usr/bin/env python3
  2. #
  3. # mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
  4. # Copyright (C)2013-2023 The MMGen Project <mmgen@tuta.io>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. """
  19. test/tooltest.py: Tests for the 'mmgen-tool' utility
  20. """
  21. import sys,os,time
  22. from subprocess import run,PIPE
  23. import include.test_init
  24. from mmgen.cfg import Config,gc
  25. from mmgen.color import red,yellow,green,blue,cyan
  26. from mmgen.util import msg,msg_r,Msg,die
  27. opts_data = {
  28. 'text': {
  29. 'desc': "Test suite for the 'mmgen-tool' utility",
  30. 'usage':'[options] [command]',
  31. 'options': """
  32. -h, --help Print this help message
  33. -C, --coverage Produce code coverage info using trace module
  34. -d, --debug Produce debugging output (stderr from spawned script)
  35. --, --longhelp Print help message for long options (common options)
  36. -l, --list-cmds List and describe the tests and commands in this test suite
  37. -s, --testing-status List the testing status of all 'mmgen-tool' commands
  38. -t, --type=t Specify address type (valid choices: 'zcash_z')
  39. -v, --verbose Produce more verbose output
  40. """,
  41. 'notes': """
  42. If no command is given, the whole suite of tests is run.
  43. """
  44. }
  45. }
  46. sys.argv = [sys.argv[0]] + ['--skip-cfg-file'] + sys.argv[1:]
  47. cfg = Config(opts_data=opts_data)
  48. from test.include.common import (
  49. set_globals,
  50. mk_tmpdir,
  51. cleandir,
  52. write_to_tmpfile,
  53. ok,
  54. read_from_file,
  55. read_from_tmpfile,
  56. cmp_or_die,
  57. getrand,
  58. getrandhex,
  59. end_msg,
  60. init_coverage,
  61. get_tmpfile,
  62. )
  63. set_globals(cfg)
  64. vmsg = cfg._util.vmsg
  65. proto = cfg._proto
  66. assert cfg.type in (None,'zcash_z'), 'Only zcash-z permitted for --type argument'
  67. cmd_data = {
  68. 'cryptocoin': {
  69. 'desc': 'Cryptocoin address/key commands',
  70. 'cmd_data': {
  71. 'randwif': (),
  72. 'randpair': (), # create 4 pairs: uncomp,comp,segwit,bech32
  73. 'wif2addr': ('randpair','o4'),
  74. 'wif2hex': ('randpair','o4'),
  75. 'privhex2pubhex': ('wif2hex','o3'), # segwit only
  76. 'pubhex2addr': ('privhex2pubhex','o3'), # segwit only
  77. 'hex2wif': ('wif2hex','io2'), # uncomp, comp
  78. 'addr2pubhash': ('randpair','o4'), # uncomp, comp, bech32
  79. 'pubhash2addr': ('addr2pubhash','io4'), # uncomp, comp, bech32
  80. },
  81. },
  82. 'mnemonic': {
  83. 'desc': 'mnemonic commands',
  84. 'cmd_data': {
  85. 'hex2mn': (),
  86. 'mn2hex': ('hex2mn','io3'),
  87. 'mn_rand128': (),
  88. 'mn_rand192': (),
  89. 'mn_rand256': (),
  90. 'mn_stats': (),
  91. 'mn_printlist': (),
  92. },
  93. },
  94. }
  95. if proto.coin in ('BTC','LTC'):
  96. cmd_data['cryptocoin']['cmd_data'].update({
  97. 'pubhex2redeem_script': ('privhex2pubhex','o3'),
  98. 'wif2redeem_script': ('randpair','o3'),
  99. 'wif2segwit_pair': ('randpair','o2'),
  100. 'privhex2addr': ('wif2hex','o4'), # compare with output of randpair
  101. 'pipetest': ('randpair','o3')
  102. })
  103. if proto.coin == 'XMR' or cfg.type == 'zcash_z':
  104. del cmd_data['cryptocoin']['cmd_data']['pubhash2addr']
  105. del cmd_data['cryptocoin']['cmd_data']['addr2pubhash']
  106. tcfg = {
  107. 'name': 'the tool utility',
  108. 'enc_passwd': 'Ten Satoshis',
  109. 'tmpdir': 'test/tmp/10',
  110. 'tmpdir_num': 10,
  111. 'refdir': 'test/ref',
  112. 'txfile': {
  113. 'btc': ('0B8D5A[15.31789,14,tl=1320969600].rawtx',
  114. '0C7115[15.86255,14,tl=1320969600].testnet.rawtx'),
  115. 'bch': ('460D4D-BCH[10.19764,tl=1320969600].rawtx',
  116. '359FD5-BCH[6.68868,tl=1320969600].testnet.rawtx'),
  117. 'ltc': ('AF3CDF-LTC[620.76194,1453,tl=1320969600].rawtx',
  118. 'A5A1E0-LTC[1454.64322,1453,tl=1320969600].testnet.rawtx'),
  119. },
  120. 'addrfile': '98831F3A{}[1,31-33,500-501,1010-1011]{}.addrs',
  121. 'addrfile_chk': {
  122. 'btc': ('6FEF 6FB9 7B13 5D91','424E 4326 CFFE 5F51'),
  123. 'bch': ('6FEF 6FB9 7B13 5D91','424E 4326 CFFE 5F51'),
  124. 'ltc': ('AD52 C3FE 8924 AAF0','4EBE 2E85 E969 1B30'),
  125. }
  126. }
  127. ref_subdir = '' if proto.base_coin == 'BTC' else proto.name.lower()
  128. altcoin_pfx = '' if proto.base_coin == 'BTC' else '-'+proto.base_coin
  129. tn_ext = ('','.testnet')[proto.testnet]
  130. spawn_cmd = [
  131. 'scripts/exec_wrapper.py',
  132. os.path.relpath(os.path.join(include.test_init.repo_root,'cmds','mmgen-tool')) ]
  133. if cfg.coverage:
  134. d,f = init_coverage()
  135. spawn_cmd = ['python3','-m','trace','--count','--coverdir='+d,'--file='+f] + spawn_cmd
  136. elif gc.platform == 'win':
  137. spawn_cmd = ['python3'] + spawn_cmd
  138. add_spawn_args = ['--data-dir='+tcfg['tmpdir']] + ['--{}{}'.format(
  139. k.replace('_','-'),
  140. '='+getattr(cfg,k) if getattr(cfg,k) is not True else '')
  141. for k in ('testnet','rpc_host','regtest','coin','type') if getattr(cfg,k)]
  142. if cfg.list_cmds:
  143. fs = ' {:<{w}} - {}'
  144. Msg('Available commands:')
  145. w = max(map(len,cmd_data))
  146. for cmd in cmd_data:
  147. Msg(fs.format(cmd,cmd_data[cmd]['desc'],w=w))
  148. Msg('\nAvailable utilities:')
  149. Msg(fs.format('clean','Clean the tmp directory',w=w))
  150. sys.exit(0)
  151. if cfg.testing_status:
  152. tested_in = {
  153. 'tooltest.py': [],
  154. 'test.py': (
  155. 'encrypt','decrypt','find_incog_data',
  156. 'addrfile_chksum','keyaddrfile_chksum','passwdfile_chksum',
  157. 'add_label','remove_label','remove_address','twview',
  158. 'getbalance','listaddresses','listaddress',
  159. 'daemon_version','extract_key_from_geth_wallet',
  160. 'mn2hex_interactive','rand2file',
  161. 'rescan_address','rescan_blockchain','resolve_address',
  162. 'twexport','twimport','txhist'
  163. ),
  164. 'tooltest2.py': run(
  165. ['python3','test/tooltest2.py','--list-tested-cmds'],
  166. stdout = PIPE,
  167. check = True
  168. ).stdout.decode().split()
  169. }
  170. for v in cmd_data.values():
  171. tested_in['tooltest.py'] += list(v['cmd_data'].keys())
  172. Msg(green("Testing status of 'mmgen-tool' commands:"))
  173. for l in ('tooltest.py','tooltest2.py','test.py'):
  174. Msg('\n ' + blue(l+':'))
  175. Msg(' '+'\n '.join(sorted(tested_in[l])))
  176. ignore = ()
  177. from mmgen.main_tool import get_cmds
  178. uc = sorted(
  179. set(get_cmds()) -
  180. set(ignore) -
  181. set(tested_in['tooltest.py']) -
  182. set(tested_in['tooltest2.py']) -
  183. set(tested_in['test.py'])
  184. )
  185. if uc:
  186. Msg(yellow('\n {}\n {}'.format('Untested commands:','\n '.join(uc))))
  187. sys.exit(0)
  188. from mmgen.key import is_wif
  189. from mmgen.addr import is_coin_addr
  190. def is_wif_loc(s):
  191. return is_wif(proto,s)
  192. def is_coin_addr_loc(s):
  193. return is_coin_addr(proto,s)
  194. msg_w = 35
  195. def test_msg(m):
  196. msg_r(green(f'Testing {m}\n') if cfg.verbose else '{:{w}}'.format(f'Testing {m}', w=msg_w+8))
  197. compressed = cfg.type or ('','compressed')['C' in proto.mmtypes]
  198. segwit = ('','segwit')['S' in proto.mmtypes]
  199. bech32 = ('','bech32')['B' in proto.mmtypes]
  200. type_compressed_arg = ([],['--type=' + (cfg.type or 'compressed')])[bool(cfg.type) or 'C' in proto.mmtypes]
  201. type_segwit_arg = ([],['--type=segwit'])['S' in proto.mmtypes]
  202. type_bech32_arg = ([],['--type=bech32'])['B' in proto.mmtypes]
  203. class MMGenToolTestUtils:
  204. def run_cmd(self,name,tool_args,kwargs='',extra_msg='',silent=False,strip=True,add_opts=[],binary=False):
  205. sys_cmd = (
  206. spawn_cmd +
  207. add_spawn_args +
  208. ['-r0','-d',tcfg['tmpdir']] +
  209. add_opts +
  210. [name.lower()] +
  211. tool_args +
  212. kwargs.split()
  213. )
  214. if extra_msg:
  215. extra_msg = f'({extra_msg})'
  216. full_name = ' '.join([name.lower()]+add_opts+kwargs.split()+extra_msg.split())
  217. if not silent:
  218. if cfg.verbose:
  219. sys.stderr.write(green(f'Testing {full_name}\nExecuting '))
  220. sys.stderr.write(cyan(' '.join(sys_cmd)+'\n'))
  221. else:
  222. msg_r('Testing {:{w}}'.format( full_name+':', w=msg_w ))
  223. cp = run(sys_cmd,stdout=PIPE,stderr=PIPE)
  224. out = cp.stdout
  225. err = cp.stderr
  226. if cfg.debug:
  227. from test.include.common import dmsg
  228. try:
  229. dmsg(err.decode())
  230. except:
  231. dmsg(repr(err))
  232. if not binary:
  233. out = out.decode()
  234. if cp.returncode != 0:
  235. msg('{}\n{}\n{}'.format(
  236. red('FAILED'),
  237. yellow('Command stderr output:'),
  238. err.decode() ))
  239. die(2,f'Called process returned with an error (retcode {cp.returncode})')
  240. return (out,out.rstrip())[bool(strip)]
  241. def run_cmd_chk(self,name,f1,f2,kwargs='',extra_msg='',strip_hex=False,add_opts=[]):
  242. idata = read_from_file(f1).rstrip()
  243. odata = read_from_file(f2).rstrip()
  244. ret = self.run_cmd(name,[odata],kwargs=kwargs,extra_msg=extra_msg,add_opts=add_opts)
  245. vmsg('In: ' + repr(odata))
  246. vmsg('Out: ' + repr(ret))
  247. def cmp_equal(a,b):
  248. return (a.lstrip('0') == b.lstrip('0')) if strip_hex else (a == b)
  249. if cmp_equal(ret,idata):
  250. ok()
  251. else:
  252. die(4, f"Error: values don't match:\nIn: {idata!r}\nOut: {ret!r}")
  253. return ret
  254. def run_cmd_nochk(self,name,f1,kwargs='',add_opts=[]):
  255. odata = read_from_file(f1).rstrip()
  256. ret = self.run_cmd(name,[odata],kwargs=kwargs,add_opts=add_opts)
  257. vmsg('In: ' + repr(odata))
  258. vmsg('Out: ' + repr(ret))
  259. return ret
  260. def run_cmd_out(self,name,carg=None,Return=False,kwargs='',fn_idx='',extra_msg='',
  261. literal=False,chkdata='',hush=False,add_opts=[]):
  262. if carg:
  263. write_to_tmpfile(tcfg,f'{name}{fn_idx}.in',carg+'\n')
  264. ret = self.run_cmd(name,([],[carg])[bool(carg)],kwargs=kwargs,
  265. extra_msg=extra_msg,add_opts=add_opts)
  266. if carg:
  267. vmsg('In: ' + repr(carg))
  268. vmsg('Out: ' + (repr(ret),ret)[literal])
  269. if ret or ret == '':
  270. write_to_tmpfile(tcfg,f'{name}{fn_idx}.out',ret+'\n')
  271. if chkdata:
  272. cmp_or_die(ret,chkdata)
  273. return
  274. if Return:
  275. return ret
  276. elif not hush:
  277. ok()
  278. else:
  279. die(4,f'Error for command {name!r}')
  280. def run_cmd_randinput(self,name,strip=True,add_opts=[]):
  281. s = getrand(128)
  282. fn = name+'.in'
  283. write_to_tmpfile(tcfg,fn,s,binary=True)
  284. ret = self.run_cmd(name,[get_tmpfile(tcfg,fn)],strip=strip,add_opts=add_opts)
  285. fn = name+'.out'
  286. write_to_tmpfile(tcfg,fn,ret+'\n')
  287. ok()
  288. vmsg(f'Returned: {ret}')
  289. tu = MMGenToolTestUtils()
  290. def ok_or_die(val,chk_func,s,skip_ok=False):
  291. try:
  292. ret = chk_func(val)
  293. except:
  294. ret = False
  295. if ret:
  296. if not skip_ok:
  297. ok()
  298. else:
  299. die(4,f'Returned value {val!r} is not a {s}')
  300. class MMGenToolTestCmds:
  301. # Cryptocoin
  302. def randwif(self,name):
  303. for n,k in enumerate(['',compressed]):
  304. ao = ['--type='+k] if k else []
  305. ret = tu.run_cmd_out(name,add_opts=ao,Return=True,fn_idx=n+1)
  306. ok_or_die(ret,is_wif_loc,'WIF key')
  307. def randpair(self,name):
  308. for n,k in enumerate(['',compressed,segwit,bech32]):
  309. ao = ['--type='+k] if k else []
  310. wif,addr = tu.run_cmd_out(name,add_opts=ao,Return=True,fn_idx=n+1,literal=True).split()
  311. ok_or_die(wif,is_wif_loc,'WIF key',skip_ok=True)
  312. ok_or_die(addr,is_coin_addr_loc,'Coin address')
  313. def wif2addr(self,name,f1,f2,f3,f4):
  314. for n,f,k in (
  315. (1,f1,''),
  316. (2,f2,compressed),
  317. (3,f3,segwit),
  318. (4,f4,bech32)
  319. ):
  320. ao = ['--type='+k] if k else []
  321. wif = read_from_file(f).split()[0]
  322. tu.run_cmd_out(name,wif,add_opts=ao,fn_idx=n)
  323. def wif2hex(self,name,f1,f2,f3,f4):
  324. for n,f,m in (
  325. (1,f1,''),
  326. (2,f2,compressed),
  327. (3,f3,'{} for {}'.format( compressed or 'uncompressed', segwit or 'p2pkh' )),
  328. (4,f4,'{} for {}'.format( compressed or 'uncompressed', bech32 or 'p2pkh' ))
  329. ):
  330. wif = read_from_file(f).split()[0]
  331. tu.run_cmd_out(name,wif,fn_idx=n,extra_msg=m)
  332. def privhex2addr(self,name,f1,f2,f3,f4):
  333. keys = [read_from_file(f).rstrip() for f in (f1,f2,f3,f4)]
  334. for n,k in enumerate(('',compressed,segwit,bech32)):
  335. ao = ['--type='+k] if k else []
  336. ret = tu.run_cmd(name,[keys[n]],add_opts=ao).rstrip()
  337. iaddr = read_from_tmpfile(tcfg,f'randpair{n+1}.out').split()[-1]
  338. vmsg(f'Out: {ret}')
  339. cmp_or_die(iaddr,ret)
  340. ok()
  341. def hex2wif(self,name,f1,f2,f3,f4):
  342. for fi,fo,k in (
  343. (f1,f2,''),
  344. (f3,f4,compressed)):
  345. ao = ['--type='+k] if k else []
  346. tu.run_cmd_chk(name,fi,fo,add_opts=ao)
  347. def addr2pubhash(self,name,f1,f2,f3,f4):
  348. for n,f,m,ao in (
  349. (1,f1,'',[]),
  350. (2,f2,'from {}'.format( compressed or 'uncompressed' ),[]),
  351. (4,f4,'',type_bech32_arg),
  352. ):
  353. addr = read_from_file(f).split()[-1]
  354. tu.run_cmd_out(name,addr,fn_idx=n,add_opts=ao,extra_msg=m)
  355. def pubhash2addr(self,name,f1,f2,f3,f4,f5,f6,f7,f8):
  356. for _,fi,fo,m,ao in (
  357. (1,f1,f2,'',[]),
  358. (2,f3,f4,'from {}'.format( compressed or 'uncompressed' ),[]),
  359. (4,f7,f8,'',type_bech32_arg)
  360. ):
  361. tu.run_cmd_chk(name,fi,fo,add_opts=ao,extra_msg=m)
  362. def privhex2pubhex(self,name,f1,f2,f3): # from Hex2wif
  363. addr = read_from_file(f3).strip()
  364. tu.run_cmd_out(name,addr,add_opts=type_compressed_arg,fn_idx=3) # what about uncompressed?
  365. def pubhex2redeem_script(self,name,f1,f2,f3): # from above
  366. addr = read_from_file(f3).strip()
  367. tu.run_cmd_out(name,addr,add_opts=type_segwit_arg,fn_idx=3)
  368. rs = read_from_tmpfile(tcfg,'privhex2pubhex3.out').strip()
  369. tu.run_cmd_out('pubhex2addr',rs,add_opts=type_segwit_arg,fn_idx=3,hush=True)
  370. addr1 = read_from_tmpfile(tcfg,'pubhex2addr3.out').strip()
  371. addr2 = read_from_tmpfile(tcfg,'randpair3.out').split()[1]
  372. cmp_or_die(addr1,addr2)
  373. ok()
  374. def wif2redeem_script(self,name,f1,f2,f3): # compare output with above
  375. wif = read_from_file(f3).split()[0]
  376. ret1 = tu.run_cmd_out(name,wif,add_opts=type_segwit_arg,fn_idx=3,Return=True)
  377. ret2 = read_from_tmpfile(tcfg,'pubhex2redeem_script3.out').strip()
  378. cmp_or_die(ret1,ret2)
  379. ok()
  380. def wif2segwit_pair(self,name,f1,f2): # does its own checking, so just run
  381. wif = read_from_file(f2).split()[0]
  382. tu.run_cmd_out(name,wif,add_opts=type_segwit_arg,fn_idx=2)
  383. def pubhex2addr(self,name,f1,f2,f3):
  384. addr = read_from_file(f3).strip()
  385. tu.run_cmd_out(name,addr,add_opts=type_segwit_arg,fn_idx=3)
  386. def pipetest(self,name,f1,f2,f3):
  387. wif = read_from_file(f3).split()[0]
  388. cmd = ( '{c} {a} wif2hex {wif}' +
  389. ' | {c} {a} --type=compressed privhex2pubhex -' +
  390. ' | {c} {a} --type=segwit pubhex2redeem_script -' +
  391. ' | {c} {a} --type=segwit redeem_script2addr -').format(
  392. c=' '.join(spawn_cmd),
  393. a=' '.join(add_spawn_args),
  394. wif=wif)
  395. test_msg('command piping')
  396. if cfg.verbose:
  397. sys.stderr.write(green('Executing ') + cyan(cmd) + '\n')
  398. res = run(cmd,stdout=PIPE,shell=True).stdout.decode().strip()
  399. addr = read_from_tmpfile(tcfg,'wif2addr3.out').strip()
  400. cmp_or_die(addr,res)
  401. ok()
  402. # Mnemonic
  403. def hex2mn(self,name):
  404. for n,size,m in ((1,16,'128-bit'),(2,24,'192-bit'),(3,32,'256-bit')):
  405. hexnum = getrandhex(size)
  406. tu.run_cmd_out(name,hexnum,fn_idx=n,extra_msg=m)
  407. def mn2hex(self,name,f1,f2,f3,f4,f5,f6):
  408. for f_i,f_o,m in ((f1,f2,'128-bit'),(f3,f4,'192-bit'),(f5,f6,'256-bit')):
  409. tu.run_cmd_chk(name,f_i,f_o,extra_msg=m,strip_hex=True)
  410. def mn_rand128(self,name):
  411. tu.run_cmd_out(name)
  412. def mn_rand192(self,name):
  413. tu.run_cmd_out(name)
  414. def mn_rand256(self,name):
  415. tu.run_cmd_out(name)
  416. def mn_stats(self,name):
  417. tu.run_cmd_out(name)
  418. def mn_printlist(self,name):
  419. tu.run_cmd(name,[])
  420. ok()
  421. # main()
  422. start_time = int(time.time())
  423. mk_tmpdir(tcfg['tmpdir'])
  424. def gen_deps_for_cmd(cdata):
  425. fns = []
  426. if cdata:
  427. name,code = cdata
  428. io,count = (code[:-1],int(code[-1])) if code[-1] in '0123456789' else (code,1)
  429. for c in range(count):
  430. fns += ['{}{}{}'.format(
  431. name,
  432. (c+1 if count > 1 else ''),
  433. ('.in' if ch == 'i' else '.out'),
  434. ) for ch in io]
  435. return fns
  436. def do_cmds(cmd_group):
  437. tc = MMGenToolTestCmds()
  438. gdata = cmd_data[cmd_group]['cmd_data']
  439. for cmd in gdata:
  440. fns = gen_deps_for_cmd(gdata[cmd])
  441. cmdline = [cmd] + [os.path.join(tcfg['tmpdir'],fn) for fn in fns]
  442. getattr(tc,cmd)(*cmdline)
  443. try:
  444. if cfg._args:
  445. if len(cfg._args) != 1:
  446. die(1,'Only one command may be specified')
  447. cmd = cfg._args[0]
  448. if cmd in cmd_data:
  449. cleandir(tcfg['tmpdir'],do_msg=True)
  450. msg('Running tests for {}:'.format( cmd_data[cmd]['desc'] ))
  451. do_cmds(cmd)
  452. elif cmd == 'clean':
  453. cleandir(tcfg['tmpdir'],do_msg=True)
  454. sys.exit(0)
  455. else:
  456. die(1,f'{cmd!r}: unrecognized command')
  457. else:
  458. cleandir(tcfg['tmpdir'],do_msg=True)
  459. for cmd in cmd_data:
  460. msg('Running tests for {}:'.format( cmd_data[cmd]['desc'] ))
  461. do_cmds(cmd)
  462. if cmd is not list(cmd_data.keys())[-1]:
  463. msg('')
  464. except KeyboardInterrupt:
  465. die(1,green('\nExiting at user request'))
  466. end_msg(int(time.time()) - start_time)