tooltest.py 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. #!/usr/bin/env python
  2. #
  3. # mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
  4. # Copyright (C)2013-2017 Philemon <mmgen-py@yandex.com>
  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,subprocess
  22. repo_root = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]),os.pardir)))
  23. os.chdir(repo_root)
  24. sys.path.__setitem__(0,repo_root)
  25. # Import this _after_ local path's been added to sys.path
  26. from mmgen.common import *
  27. from collections import OrderedDict
  28. cmd_data = OrderedDict([
  29. ('util', {
  30. 'desc': 'base conversion, hashing and file utilities',
  31. 'cmd_data': OrderedDict([
  32. ('Strtob58', ()),
  33. ('B58tostr', ('Strtob58','io')),
  34. ('Hextob58', ()),
  35. ('B58tohex', ('Hextob58','io')),
  36. ('B58randenc', ()),
  37. ('Hextob32', ()),
  38. ('B32tohex', ('Hextob32','io')),
  39. ('Randhex', ()),
  40. ('Id6', ()),
  41. ('Id8', ()),
  42. ('Str2id6', ()),
  43. ('Hash160', ()),
  44. ('Hash256', ()),
  45. ('Hexreverse', ()),
  46. ('Hexlify', ()),
  47. ('Hexdump', ()),
  48. ('Unhexdump', ('Hexdump','io')),
  49. ('Rand2file', ()),
  50. ])
  51. }
  52. ),
  53. ('cryptocoin', {
  54. 'desc': 'Cryptocoin address/key commands',
  55. 'cmd_data': OrderedDict([
  56. ('Randwif', ()),
  57. ('Randpair', ()), # create 3 pairs: uncomp,comp,segwit
  58. ('Wif2addr', ('Randpair','o3')),
  59. ('Wif2hex', ('Randpair','o3')),
  60. ('Privhex2pubhex', ('Wif2hex','o3')),
  61. ('Pubhex2addr', ('Privhex2pubhex','o3')),
  62. ('Pubhex2redeem_script', ('Privhex2pubhex','o3')),
  63. ('Wif2redeem_script', ('Randpair','o3')),
  64. ('Wif2segwit_pair', ('Randpair','o2')),
  65. ('Privhex2addr', ('Wif2hex','o3')), # compare with output of Randpair
  66. ('Hex2wif', ('Wif2hex','io2')),
  67. ('Addr2hexaddr', ('Randpair','o2')),
  68. ('Hexaddr2addr', ('Addr2hexaddr','io2')),
  69. ('Pipetest', ('Randpair','o3')),
  70. ])
  71. }
  72. ),
  73. ('mnemonic', {
  74. 'desc': 'mnemonic commands',
  75. 'cmd_data': OrderedDict([
  76. ('Hex2mn', ()),
  77. ('Mn2hex', ('Hex2mn','io3')),
  78. ('Mn_rand128', ()),
  79. ('Mn_rand192', ()),
  80. ('Mn_rand256', ()),
  81. ('Mn_stats', ()),
  82. ('Mn_printlist', ()),
  83. ])
  84. }
  85. ),
  86. ('rpc', {
  87. 'desc': 'Coin daemon RPC commands',
  88. 'cmd_data': OrderedDict([
  89. # ('keyaddrfile_chksum', ()), # interactive
  90. ('Addrfile_chksum', ()),
  91. ('Getbalance', ()),
  92. ('Listaddresses', ()),
  93. ('Twview', ()),
  94. ('Txview', ()),
  95. ])
  96. }
  97. ),
  98. ])
  99. cfg = {
  100. 'name': 'the tool utility',
  101. 'enc_passwd': 'Ten Satoshis',
  102. 'tmpdir': 'test/tmp10',
  103. 'tmpdir_num': 10,
  104. 'refdir': 'test/ref',
  105. 'txfile': {
  106. 'btc': 'FFB367[1.234]{}.rawtx',
  107. 'bch': '99BE60-BCH[106.6789]{}.rawtx',
  108. 'ltc': '75F455-LTC[106.6789]{}.rawtx',
  109. },
  110. 'addrfile': '98831F3A{}[1,31-33,500-501,1010-1011]{}.addrs',
  111. 'addrfile_chk': {
  112. 'btc': ('6FEF 6FB9 7B13 5D91','3C2C 8558 BB54 079E'),
  113. 'ltc': ('AD52 C3FE 8924 AAF0','5738 5C4F 167C F9AE'),
  114. }
  115. }
  116. opts_data = lambda: {
  117. 'desc': "Test suite for the 'mmgen-tool' utility",
  118. 'usage':'[options] [command]',
  119. 'options': """
  120. -h, --help Print this help message
  121. --, --longhelp Print help message for long options (common options)
  122. -l, --list-cmds List and describe the tests and commands in this test suite
  123. -L, --list-names List the names of all tested 'mmgen-tool' commands
  124. -s, --system Test scripts and modules installed on system rather than
  125. those in the repo root
  126. -v, --verbose Produce more verbose output
  127. """,
  128. 'notes': """
  129. If no command is given, the whole suite of tests is run.
  130. """
  131. }
  132. sys.argv = [sys.argv[0]] + ['--skip-cfg-file'] + sys.argv[1:]
  133. cmd_args = opts.init(opts_data,add_opts=['exact_output','profile'])
  134. ref_subdir = '' if g.proto.base_coin == 'BTC' else g.proto.name
  135. altcoin_pfx = '' if g.proto.base_coin == 'BTC' else '-'+g.proto.base_coin
  136. tn_ext = ('','.testnet')[g.testnet]
  137. mmgen_cmd = 'mmgen-tool'
  138. if not opt.system:
  139. os.environ['PYTHONPATH'] = repo_root
  140. mmgen_cmd = os.path.relpath(os.path.join(repo_root,'cmds',mmgen_cmd))
  141. spawn_cmd = ([],['python'])[g.platform == 'win'] + [mmgen_cmd]
  142. add_spawn_args = ['--data-dir='+cfg['tmpdir']] + ['--{}{}'.format(
  143. k.replace('_','-'),'='+getattr(opt,k) if getattr(opt,k) != True else '')
  144. for k in ('testnet','rpc_host','regtest','coin') if getattr(opt,k)]
  145. if opt.list_cmds:
  146. fs = ' {:<{w}} - {}'
  147. Msg('Available commands:')
  148. w = max([len(i) for i in cmd_data])
  149. for cmd in cmd_data:
  150. Msg(fs.format(cmd,cmd_data[cmd]['desc'],w=w))
  151. Msg('\nAvailable utilities:')
  152. Msg(fs.format('clean','Clean the tmp directory',w=w))
  153. sys.exit(0)
  154. if opt.list_names:
  155. acc = []
  156. for v in cmd_data.values():
  157. acc += v['cmd_data'].keys()
  158. tc = sorted(c.lower() for c in acc)
  159. msg('{}\n{}'.format(green('Tested commands:'),'\n'.join(tc)))
  160. import mmgen.tool
  161. tested_in_tool = ('Encrypt','Decrypt','Find_incog_data','Keyaddrfile_chksum','Passwdfile_chksum')
  162. ignore = ('Help','Usage')
  163. uc = sorted(c.lower() for c in set(mmgen.tool.cmd_data.keys()) - set(acc) - set(ignore) - set(tested_in_tool))
  164. msg('\n{}\n{}'.format(yellow('Untested commands:'),'\n'.join(uc)))
  165. die()
  166. import binascii
  167. from mmgen.test import *
  168. from mmgen.tx import is_wif,is_coin_addr
  169. msg_w = 35
  170. def test_msg(m):
  171. m2 = 'Testing {}'.format(m)
  172. msg_r(green(m2+'\n') if opt.verbose else '{:{w}}'.format(m2,w=msg_w+8))
  173. class MMGenToolTestSuite(object):
  174. def __init__(self):
  175. pass
  176. def gen_deps_for_cmd(self,cmd,cdata):
  177. fns = []
  178. if cdata:
  179. name,code = cdata
  180. io,count = (code[:-1],int(code[-1])) if code[-1] in '0123456789' else (code,1)
  181. for c in range(count):
  182. fns += ['%s%s%s' % (
  183. name,
  184. ('',c+1)[count > 1],
  185. ('.out','.in')[ch=='i']
  186. ) for ch in io]
  187. return fns
  188. def get_num_exts_for_cmd(self,cmd,dpy): # dpy required here
  189. num = str(tool_cfgs['tmpdir_num'])
  190. # return only first file - a hack
  191. exts = gen_deps_for_cmd(dpy)
  192. return num,exts
  193. def do_cmds(self,cmd_group):
  194. cdata = cmd_data[cmd_group]['cmd_data']
  195. for cmd in cdata: self.do_cmd(cmd,cdata[cmd])
  196. def do_cmd(self,cmd,cdata):
  197. fns = self.gen_deps_for_cmd(cmd,cdata)
  198. file_list = [os.path.join(cfg['tmpdir'],fn) for fn in fns]
  199. self.__class__.__dict__[cmd](*([self,cmd] + file_list))
  200. def run_cmd(self,name,tool_args,kwargs='',extra_msg='',silent=False,strip=True):
  201. sys_cmd = (
  202. spawn_cmd +
  203. add_spawn_args +
  204. ['-r0','-d',cfg['tmpdir'],name.lower()] +
  205. tool_args +
  206. kwargs.split()
  207. )
  208. if extra_msg: extra_msg = '({})'.format(extra_msg)
  209. full_name = ' '.join([name.lower()]+kwargs.split()+extra_msg.split())
  210. if not silent:
  211. if opt.verbose:
  212. sys.stderr.write(green('Testing {}\nExecuting '.format(full_name)))
  213. sys.stderr.write(cyan(' '.join(sys_cmd)+'\n'))
  214. else:
  215. msg_r('Testing {:{w}}'.format(full_name+':',w=msg_w))
  216. p = subprocess.Popen(sys_cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
  217. a,b = p.communicate()
  218. retcode = p.wait()
  219. if retcode != 0:
  220. msg('%s\n%s\n%s'%(red('FAILED'),yellow('Command stderr output:'),b))
  221. die(1,red('Called process returned with an error (retcode %s)' % retcode))
  222. return (a,a.rstrip())[bool(strip)]
  223. def run_cmd_chk(self,name,f1,f2,kwargs='',extra_msg='',strip_hex=False):
  224. idata = read_from_file(f1).rstrip()
  225. odata = read_from_file(f2).rstrip()
  226. ret = self.run_cmd(name,[odata],kwargs=kwargs,extra_msg=extra_msg)
  227. vmsg('In: ' + repr(odata))
  228. vmsg('Out: ' + repr(ret))
  229. def cmp_equal(a,b):
  230. return (a.lstrip('0') == b.lstrip('0')) if strip_hex else (a == b)
  231. if cmp_equal(ret,idata): ok()
  232. else:
  233. die(3,red(
  234. "Error: values don't match:\nIn: %s\nOut: %s" % (repr(idata),repr(ret))))
  235. return ret
  236. def run_cmd_nochk(self,name,f1,kwargs=''):
  237. odata = read_from_file(f1).rstrip()
  238. ret = self.run_cmd(name,[odata],kwargs=kwargs)
  239. vmsg('In: ' + repr(odata))
  240. vmsg('Out: ' + repr(ret))
  241. return ret
  242. def run_cmd_out(self,name,carg=None,Return=False,kwargs='',fn_idx='',extra_msg='',literal=False,chkdata='',hush=False):
  243. if carg: write_to_tmpfile(cfg,'%s%s.in' % (name,fn_idx),carg+'\n')
  244. ret = self.run_cmd(name,([],[carg])[bool(carg)],kwargs=kwargs,extra_msg=extra_msg)
  245. if carg: vmsg('In: ' + repr(carg))
  246. vmsg('Out: ' + (repr(ret),ret.decode('utf8'))[literal])
  247. if ret or ret == '':
  248. write_to_tmpfile(cfg,'%s%s.out' % (name,fn_idx),ret+'\n')
  249. if chkdata:
  250. cmp_or_die(ret,chkdata)
  251. return
  252. if Return: return ret
  253. else:
  254. if not hush: ok()
  255. else:
  256. die(3,red("Error for command '%s'" % name))
  257. def run_cmd_randinput(self,name,strip=True):
  258. s = os.urandom(128)
  259. fn = name+'.in'
  260. write_to_tmpfile(cfg,fn,s,binary=True)
  261. ret = self.run_cmd(name,[get_tmpfile_fn(cfg,fn)],strip=strip)
  262. fn = name+'.out'
  263. write_to_tmpfile(cfg,fn,ret+'\n')
  264. ok()
  265. vmsg('Returned: %s' % ret)
  266. # Util
  267. def Strtob58(self,name): self.run_cmd_out(name,getrandstr(16))
  268. def B58tostr(self,name,f1,f2): self.run_cmd_chk(name,f1,f2)
  269. def Hextob58(self,name): self.run_cmd_out(name,getrandhex(32))
  270. def B58tohex(self,name,f1,f2): self.run_cmd_chk(name,f1,f2,strip_hex=True)
  271. def B58randenc(self,name):
  272. ret = self.run_cmd_out(name,Return=True)
  273. ok_or_die(ret,is_b58_str,'base 58 string')
  274. def Hextob32(self,name): self.run_cmd_out(name,getrandhex(24))
  275. def B32tohex(self,name,f1,f2): self.run_cmd_chk(name,f1,f2,strip_hex=True)
  276. def Randhex(self,name):
  277. ret = self.run_cmd_out(name,Return=True)
  278. ok_or_die(ret,binascii.unhexlify,'hex string')
  279. def Id6(self,name): self.run_cmd_randinput(name)
  280. def Id8(self,name): self.run_cmd_randinput(name)
  281. def Str2id6(self,name):
  282. s = getrandstr(120,no_space=True)
  283. s2 = ' %s %s %s %s %s ' % (s[:3],s[3:9],s[9:29],s[29:50],s[50:120])
  284. ret1 = self.run_cmd(name,[s],extra_msg='unspaced input'); ok()
  285. ret2 = self.run_cmd(name,[s2],extra_msg='spaced input')
  286. cmp_or_die(ret1,ret2)
  287. vmsg('Returned: %s' % ret1)
  288. def Hash160(self,name): self.run_cmd_out(name,getrandhex(16))
  289. def Hash256(self,name): self.run_cmd_out(name,getrandstr(16))
  290. def Hexreverse(self,name): self.run_cmd_out(name,getrandhex(24))
  291. def Hexlify(self,name): self.run_cmd_out(name,getrandstr(24))
  292. def Hexdump(self,name): self.run_cmd_randinput(name,strip=False)
  293. def Unhexdump(self,name,fn1,fn2):
  294. ret = self.run_cmd(name,[fn2],strip=False)
  295. orig = read_from_file(fn1,binary=True)
  296. cmp_or_die(orig,ret)
  297. def Rand2file(self,name):
  298. of = name + '.out'
  299. dlen = 1024
  300. self.run_cmd(name,[of,str(1024),'threads=4','silent=1'],strip=False)
  301. d = read_from_tmpfile(cfg,of,binary=True)
  302. cmp_or_die(dlen,len(d))
  303. # Cryptocoin
  304. def Randwif(self,name):
  305. for n,k in enumerate(['','compressed=1']):
  306. ret = self.run_cmd_out(name,kwargs=k,Return=True,fn_idx=n+1)
  307. ok_or_die(ret,is_wif,'WIF key')
  308. def Randpair(self,name):
  309. for n,k in enumerate(['','compressed=1','segwit=1 compressed=1']):
  310. wif,addr = self.run_cmd_out(name,kwargs=k,Return=True,fn_idx=n+1).split()
  311. ok_or_die(wif,is_wif,'WIF key',skip_ok=True)
  312. ok_or_die(addr,is_coin_addr,'Coin address')
  313. def Wif2addr(self,name,f1,f2,f3):
  314. for n,f,k,m in ((1,f1,'',''),(2,f2,'','compressed'),(3,f3,'segwit=1','compressed')):
  315. wif = read_from_file(f).split()[0]
  316. self.run_cmd_out(name,wif,kwargs=k,fn_idx=n,extra_msg=m)
  317. def Wif2hex(self,name,f1,f2,f3):
  318. for n,f,m in ((1,f1,''),(2,f2,'compressed'),(3,f3,'compressed for segwit')):
  319. wif = read_from_file(f).split()[0]
  320. self.run_cmd_out(name,wif,fn_idx=n,extra_msg=m)
  321. def Privhex2addr(self,name,f1,f2,f3):
  322. keys = [read_from_file(f).rstrip() for f in (f1,f2,f3)]
  323. for n,k in enumerate(('','compressed=1','compressed=1 segwit=1')):
  324. ret = self.run_cmd(name,[keys[n]],kwargs=k).rstrip()
  325. iaddr = read_from_tmpfile(cfg,'Randpair{}.out'.format(n+1)).split()[-1]
  326. cmp_or_die(iaddr,ret)
  327. def Hex2wif(self,name,f1,f2,f3,f4):
  328. for n,fi,fo,k in ((1,f1,f2,''),(2,f3,f4,'compressed=1')):
  329. ret = self.run_cmd_chk(name,fi,fo,kwargs=k)
  330. def Addr2hexaddr(self,name,f1,f2):
  331. for n,f,m in ((1,f1,''),(2,f2,'from compressed')):
  332. addr = read_from_file(f).split()[-1]
  333. self.run_cmd_out(name,addr,fn_idx=n,extra_msg=m)
  334. def Hexaddr2addr(self,name,f1,f2,f3,f4):
  335. for n,fi,fo,m in ((1,f1,f2,''),(2,f3,f4,'from compressed')):
  336. self.run_cmd_chk(name,fi,fo,extra_msg=m)
  337. def Privhex2pubhex(self,name,f1,f2,f3): # from Hex2wif
  338. addr = read_from_file(f3).strip()
  339. self.run_cmd_out(name,addr,kwargs='compressed=1',fn_idx=3) # what about uncompressed?
  340. def Pubhex2redeem_script(self,name,f1,f2,f3): # from above
  341. addr = read_from_file(f3).strip()
  342. self.run_cmd_out(name,addr,fn_idx=3)
  343. rs = read_from_tmpfile(cfg,name+'3.out').strip()
  344. self.run_cmd_out('pubhex2addr',rs,kwargs='p2sh=1',fn_idx=3,hush=True)
  345. addr1 = read_from_tmpfile(cfg,'pubhex2addr3.out').strip()
  346. addr2 = read_from_tmpfile(cfg,'Randpair3.out').split()[1]
  347. cmp_or_die(addr1,addr2)
  348. def Wif2redeem_script(self,name,f1,f2,f3): # compare output with above
  349. wif = read_from_file(f3).split()[0]
  350. ret1 = self.run_cmd_out(name,wif,fn_idx=3,Return=True)
  351. ret2 = read_from_tmpfile(cfg,'Pubhex2redeem_script3.out').strip()
  352. cmp_or_die(ret1,ret2)
  353. def Wif2segwit_pair(self,name,f1,f2): # does its own checking, so just run
  354. wif = read_from_file(f2).split()[0]
  355. self.run_cmd_out(name,wif,fn_idx=2)
  356. def Pubhex2addr(self,name,f1,f2,f3):
  357. addr = read_from_file(f3).strip()
  358. self.run_cmd_out(name,addr,fn_idx=3)
  359. def Pipetest(self,name,f1,f2,f3):
  360. wif = read_from_file(f3).split()[0]
  361. cmd = ( '{c} {a} wif2hex {wif} | ' +
  362. '{c} {a} privhex2pubhex - compressed=1 | ' +
  363. '{c} {a} pubhex2redeem_script - | ' +
  364. '{c} {a} pubhex2addr - p2sh=1').format(
  365. c=' '.join(spawn_cmd),
  366. a=' '.join(add_spawn_args),
  367. wif=wif)
  368. test_msg('command piping')
  369. if opt.verbose:
  370. sys.stderr.write(green('Executing ') + cyan(cmd) + '\n')
  371. p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
  372. res = p.stdout.read().strip()
  373. addr = read_from_tmpfile(cfg,'Wif2addr3.out').strip()
  374. cmp_or_die(res,addr)
  375. # Mnemonic
  376. def Hex2mn(self,name):
  377. for n,size,m in ((1,16,'128-bit'),(2,24,'192-bit'),(3,32,'256-bit')):
  378. hexnum = getrandhex(size)
  379. self.run_cmd_out(name,hexnum,fn_idx=n,extra_msg=m)
  380. def Mn2hex(self,name,f1,f2,f3,f4,f5,f6):
  381. for f_i,f_o,m in ((f1,f2,'128-bit'),(f3,f4,'192-bit'),(f5,f6,'256-bit')):
  382. self.run_cmd_chk(name,f_i,f_o,extra_msg=m,strip_hex=True)
  383. def Mn_rand128(self,name): self.run_cmd_out(name)
  384. def Mn_rand192(self,name): self.run_cmd_out(name)
  385. def Mn_rand256(self,name): self.run_cmd_out(name)
  386. def Mn_stats(self,name): self.run_cmd_out(name)
  387. def Mn_printlist(self,name):
  388. self.run_cmd(name,[])
  389. ok()
  390. # RPC
  391. def Addrfile_chksum(self,name):
  392. fn = os.path.join(cfg['refdir'],ref_subdir,cfg['addrfile'].format(altcoin_pfx,tn_ext))
  393. self.run_cmd_out(name,fn,literal=True,chkdata=cfg['addrfile_chk'][g.coin.lower()][g.testnet])
  394. def Getbalance(self,name):
  395. self.run_cmd_out(name,literal=True)
  396. def Listaddresses(self,name):
  397. self.run_cmd_out(name,literal=True)
  398. def Twview(self,name):
  399. self.run_cmd_out(name,literal=True)
  400. def Txview(self,name):
  401. fn = os.path.join(cfg['refdir'],ref_subdir,cfg['txfile'][g.coin.lower()].format(tn_ext))
  402. self.run_cmd_out(name,fn,literal=True)
  403. # main()
  404. import time
  405. start_time = int(time.time())
  406. ts = MMGenToolTestSuite()
  407. mk_tmpdir(cfg['tmpdir'])
  408. if cmd_args:
  409. if len(cmd_args) != 1:
  410. die(1,'Only one command may be specified')
  411. cmd = cmd_args[0]
  412. if cmd in cmd_data:
  413. msg('Running tests for %s:' % cmd_data[cmd]['desc'])
  414. ts.do_cmds(cmd)
  415. elif cmd == 'clean':
  416. cleandir(cfg['tmpdir'])
  417. sys.exit(0)
  418. else:
  419. die(1,"'%s': unrecognized command" % cmd)
  420. else:
  421. cleandir(cfg['tmpdir'])
  422. for cmd in cmd_data:
  423. msg('Running tests for %s:' % cmd_data[cmd]['desc'])
  424. ts.do_cmds(cmd)
  425. if cmd is not cmd_data.keys()[-1]: msg('')
  426. t = int(time.time()) - start_time
  427. msg(green(
  428. 'All requested tests finished OK, elapsed time: %02i:%02i' % (t/60,t%60)))