test-release.sh 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. #!/bin/bash
  2. # Tested on Linux, Armbian, Raspbian, MSYS2
  3. REFDIR='test/ref'
  4. SUDO='sudo'
  5. if [ "$(uname -m)" == 'armv7l' ]; then
  6. ARM32=1
  7. elif uname -a | grep -q 'MSYS'; then
  8. SUDO='' MSYS2=1;
  9. fi
  10. RED="\e[31;1m" GREEN="\e[32;1m" YELLOW="\e[33;1m" RESET="\e[0m"
  11. trap 'echo -e "${GREEN}Exiting at user request$RESET"; exit' INT
  12. umask 0022
  13. export MMGEN_TEST_SUITE=1
  14. export MMGEN_NO_LICENSE=1
  15. export PYTHONPATH=.
  16. test_py='test/test.py -n'
  17. objtest_py='test/objtest.py'
  18. unit_tests_py='test/unit_tests.py --names --quiet'
  19. tooltest_py='test/tooltest.py'
  20. tooltest2_py='test/tooltest2.py --names'
  21. gentest_py='test/gentest.py'
  22. scrambletest_py='test/scrambletest.py'
  23. mmgen_tool='cmds/mmgen-tool'
  24. mmgen_keygen='cmds/mmgen-keygen'
  25. python='python3'
  26. rounds=100 rounds_min=20 rounds_mid=250 rounds_max=500
  27. monero_addrs='3,99,2,22-24,101-104'
  28. dfl_tests='obj unit hash alts monero eth autosign btc btc_tn btc_rt bch bch_rt ltc ltc_tn ltc_rt tool tool2 gen'
  29. add_tests='autosign_minimal autosign_live'
  30. PROGNAME=$(basename $0)
  31. while getopts hbCfFiIlOpRtvV OPT
  32. do
  33. case "$OPT" in
  34. h) printf " %-16s Test MMGen release\n" "${PROGNAME}:"
  35. echo " USAGE: $PROGNAME [options] [tests]"
  36. echo " OPTIONS: '-h' Print this help message"
  37. echo " '-b' Buffer keypresses for all invocations of 'test/test.py'"
  38. echo " '-C' Run tests in coverage mode"
  39. echo " '-f' Speed up the tests by using fewer rounds"
  40. echo " '-F' Reduce rounds even further"
  41. echo " '-i' Create and install Python package, then run tests. A branch"
  42. echo " must be supplied as the first argument"
  43. echo " '-I' Install the package only; don't run tests"
  44. echo " '-l' List the test name symbols"
  45. echo " '-O' Use pexpect.spawn rather than popen_spawn for applicable tests"
  46. echo " '-p' Pause between tests"
  47. echo " '-R' Don't remove temporary files after program has exited"
  48. echo " '-t' Print the tests without running them"
  49. echo " '-v' Run test/test.py with '--exact-output' and other commands with"
  50. echo " '--verbose' switch"
  51. echo " '-V' Run test/test.py and other commands with '--verbose' switch"
  52. echo " AVAILABLE TESTS:"
  53. echo " obj - data objects"
  54. echo " unit - unit tests"
  55. echo " hash - internal hash function implementations"
  56. echo " alts - operations for all supported gen-only altcoins"
  57. echo " monero - operations for Monero"
  58. echo " eth - operations for Ethereum"
  59. echo " autosign - autosign"
  60. echo " btc - bitcoin"
  61. echo " btc_tn - bitcoin testnet"
  62. echo " btc_rt - bitcoin regtest"
  63. echo " bch - bitcoin cash (BCH)"
  64. echo " bch_rt - bitcoin cash (BCH) regtest"
  65. echo " ltc - litecoin"
  66. echo " ltc_tn - litecoin testnet"
  67. echo " ltc_rt - litecoin regtest"
  68. echo " tool - tooltest (all supported coins)"
  69. echo " tool2 - tooltest2 (all supported coins)"
  70. echo " gen - gentest (all supported coins)"
  71. echo " By default, all tests are run"
  72. exit ;;
  73. b) test_py+=" --buf-keypress" ;;
  74. C) mkdir -p 'test/trace'
  75. touch 'test/trace.acc'
  76. test_py+=" --coverage"
  77. tooltest_py+=" --coverage"
  78. tooltest2_py+=" --fork --coverage"
  79. scrambletest_py+=" --coverage"
  80. python="python3 -m trace --count --file=test/trace.acc --coverdir=test/trace"
  81. unit_tests_py="$python $unit_tests_py"
  82. objtest_py="$python $objtest_py"
  83. gentest_py="$python $gentest_py"
  84. mmgen_tool="$python $mmgen_tool"
  85. mmgen_keygen="$python $mmgen_keygen" ;&
  86. f) FAST=1 rounds=10 rounds_min=3 rounds_mid=25 rounds_max=50 monero_addrs='3,23' unit_tests_py+=" --fast" ;;
  87. F) FAST=1 rounds=2 rounds_min=1 rounds_mid=3 rounds_max=5 monero_addrs='3,23' unit_tests_py+=" --fast" ;;
  88. i) INSTALL=1 ;;
  89. I) INSTALL_ONLY=1 ;;
  90. l) echo -e "Default tests:\n $dfl_tests"
  91. echo -e "Additional tests:\n $add_tests"
  92. exit ;;
  93. O) test_py+=" --pexpect-spawn" ;;
  94. p) PAUSE=1 ;;
  95. R) NO_TMPFILE_REMOVAL=1 ;;
  96. t) TESTING=1 ;;
  97. v) EXACT_OUTPUT=1 test_py+=" --exact-output" ;&
  98. V) VERBOSE=1 [ "$EXACT_OUTPUT" ] || test_py+=" --verbose"
  99. tooltest_py+=" --verbose" tooltest2_py+=" --verbose"
  100. gentest_py+=" --verbose" mmgen_tool+=" --verbose"
  101. unit_tests_py="${unit_tests_py/--quiet/--verbose}"
  102. scrambletest_py+=" --verbose" ;;
  103. *) exit ;;
  104. esac
  105. done
  106. [ "$MSYS2" -a ! "$FAST" ] && tooltest2_py+=' --fork'
  107. [ "$EXACT_OUTPUT" -o "$VERBOSE" ] || objtest_py+=" -S"
  108. shift $((OPTIND-1))
  109. [ "$INSTALL" ] && {
  110. BRANCH=$1; shift
  111. BRANCHES=$(git branch)
  112. FOUND_BRANCH=$(for b in ${BRANCHES/\*}; do [ "$b" == "$BRANCH" ] && echo ok; done)
  113. [ "$FOUND_BRANCH" ] || { echo "Branch '$BRANCH' not found!"; exit; }
  114. }
  115. set -e
  116. check() {
  117. [ "$BRANCH" ] || { echo 'No branch specified. Exiting'; exit; }
  118. [ "$(git diff $BRANCH)" == "" ] || {
  119. echo "Unmerged changes from branch '$BRANCH'. Exiting"
  120. exit
  121. }
  122. git diff $BRANCH >/dev/null 2>&1 || exit
  123. }
  124. uninstall() {
  125. set +e
  126. eval "$SUDO ./scripts/uninstall-mmgen.py"
  127. [ "$?" -ne 0 ] && { echo 'Uninstall failed, but proceeding anyway'; sleep 1; }
  128. set -e
  129. }
  130. install() {
  131. set -x
  132. eval "$SUDO rm -rf .test-release"
  133. git clone --branch $BRANCH --single-branch . .test-release
  134. (
  135. cd .test-release
  136. ./setup.py sdist
  137. mkdir pydist && cd pydist
  138. if [ "$MSYS2" ]; then unzip ../dist/mmgen-*.zip; else tar zxvf ../dist/mmgen-*gz; fi
  139. cd mmgen-*
  140. eval "$SUDO ./setup.py clean --all"
  141. [ "$MSYS2" ] && ./setup.py build --compiler=mingw32
  142. eval "$SUDO ./setup.py install --force"
  143. )
  144. set +x
  145. }
  146. do_test() {
  147. set +x
  148. tests=$(eval echo \"'$'"t_$1"\")
  149. skips=$(eval echo \"'$'"t_$1_skip"\")
  150. declare -a tests_arr
  151. n=0
  152. while read test; do
  153. tests_arr[n]="$test"
  154. let n+=1
  155. done <<-EOF
  156. $tests
  157. EOF
  158. n=0
  159. for test in "${tests_arr[@]}"; do
  160. [ -z "$test" -o "${test:0:1}" == '#' ] && continue
  161. let n+=1
  162. echo $skips | grep -q "\<$n\>" && continue
  163. echo -e "${GREEN}Running:$RESET $YELLOW$test$RESET"
  164. # continue
  165. [ "$TESTING" ] || eval "$test" || {
  166. echo -e $RED"Test '$CUR_TEST' failed at command '$test'"$RESET
  167. exit
  168. }
  169. done
  170. }
  171. i_obj='Data object'
  172. s_obj='Testing data objects'
  173. t_obj="
  174. $objtest_py --coin=btc
  175. $objtest_py --coin=btc --testnet=1
  176. $objtest_py --coin=ltc
  177. $objtest_py --coin=ltc --testnet=1
  178. $objtest_py --coin=eth
  179. "
  180. f_obj='Data object test complete'
  181. i_unit='Unit'
  182. s_unit='Running unit'
  183. t_unit="$unit_tests_py"
  184. f_unit='Unit tests run complete'
  185. i_hash='Internal hash function implementations'
  186. s_hash='Testing internal hash function implementations'
  187. t_hash="
  188. $python test/hashfunc.py sha256 $rounds_max
  189. $python test/hashfunc.py sha512 $rounds_max # native sha512 not used by MMGen
  190. $python test/hashfunc.py keccak $rounds_max
  191. "
  192. f_hash='Hash function tests complete'
  193. [ "$ARM32" ] && t_hash_skip='2' # gmpy produces invalid init constants
  194. [ "$MSYS2" ] && t_hash_skip='2 3' # 2:py_long_long issues, 3:no pysha3 for keccak reference
  195. i_alts='Gen-only altcoin'
  196. s_alts='The following tests will test generation operations for all supported altcoins'
  197. t_alts="
  198. $scrambletest_py
  199. $test_py ref_altcoin # generated addrfiles verified against checksums
  200. $gentest_py --all 2:keyconv $rounds_mid
  201. # speed tests, no verification
  202. $gentest_py --coin=btc 2 $rounds
  203. $gentest_py --coin=btc --type=compressed 2 $rounds
  204. $gentest_py --coin=btc --type=segwit 2 $rounds
  205. $gentest_py --coin=btc --type=bech32 2 $rounds
  206. $gentest_py --coin=ltc 2 $rounds
  207. $gentest_py --coin=ltc --type=compressed 2 $rounds
  208. $gentest_py --coin=ltc --type=segwit 2 $rounds
  209. $gentest_py --coin=ltc --type=bech32 2 $rounds
  210. $gentest_py --coin=etc 2 $rounds
  211. $gentest_py --coin=etc --use-internal-keccak-module 2 $rounds_min
  212. $gentest_py --coin=eth 2 $rounds
  213. $gentest_py --coin=eth --use-internal-keccak-module 2 $rounds_min
  214. $gentest_py --coin=xmr 2 $rounds
  215. $gentest_py --coin=xmr --use-internal-keccak-module 2 $rounds_min
  216. $gentest_py --coin=zec 2 $rounds
  217. $gentest_py --coin=zec --type=zcash_z 2 $rounds_mid
  218. "
  219. # disabled, pycoin generates old-style LTC Segwit addrs:
  220. # $gentest_py --coin=ltc --type=segwit 2:ext $rounds
  221. # disabled, no pyethereum:
  222. # $gentest_py --coin=etc 2:ext $rounds
  223. # $gentest_py --coin=eth 2:ext $rounds
  224. # $gentest_py --all 2:pyethereum $rounds
  225. [ "$MSYS2" ] || { # no pycoin, zcash-mini
  226. t_alts="$t_alts
  227. $gentest_py --coin=zec --type=zcash_z 2:ext $rounds_mid
  228. $gentest_py --all 2:zcash_mini $rounds_mid
  229. $gentest_py --all 2:pycoin $rounds
  230. $gentest_py --coin=btc 2:ext $rounds
  231. $gentest_py --coin=btc --type=compressed 2:ext $rounds
  232. $gentest_py --coin=btc --type=segwit 2:ext $rounds
  233. $gentest_py --coin=ltc 2:ext $rounds
  234. $gentest_py --coin=ltc --type=compressed 2:ext $rounds
  235. $gentest_py --coin=zec 2:ext $rounds
  236. "
  237. }
  238. f_alts='Gen-only altcoin tests completed'
  239. [ "$NO_TMPFILE_REMOVAL" ] || rm -rf /tmp/mmgen-test-release*
  240. if [ "$MSYS2" ]; then
  241. TMPDIR='/tmp/mmgen-test-release'
  242. else
  243. TMPDIR='/tmp/mmgen-test-release-'$(cat /dev/urandom | base32 - | head -n1 | cut -b 1-16)
  244. fi
  245. mkdir -p $TMPDIR
  246. i_monero='Monero'
  247. s_monero='Testing key-address file generation and wallet creation and sync operations for Monero'
  248. s_monero='The monerod (mainnet) daemon must be running for the following tests'
  249. t_monero="
  250. mmgen-walletgen -q -r0 -p1 -Llabel --outdir $TMPDIR -o words
  251. $mmgen_keygen -q --accept-defaults --use-internal-keccak-module --outdir $TMPDIR --coin=xmr $TMPDIR/*.mmwords $monero_addrs
  252. cs1=\$(mmgen-tool -q --accept-defaults --coin=xmr keyaddrfile_chksum $TMPDIR/*-XMR*.akeys)
  253. $mmgen_keygen -q --use-old-ed25519 --accept-defaults --outdir $TMPDIR --coin=xmr $TMPDIR/*.mmwords $monero_addrs
  254. cs2=\$(mmgen-tool -q --accept-defaults --coin=xmr keyaddrfile_chksum $TMPDIR/*-XMR*.akeys)
  255. [ \"\$cs1\" == \"\$cs2\" ]
  256. "
  257. f_monero='Monero tests completed'
  258. [ "$MSYS2" ] || { # password file descriptor issues, cannot use popen_spawn()
  259. t_monero="$t_monero
  260. $mmgen_tool -q --accept-defaults --outdir $TMPDIR keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys addrs=23
  261. $mmgen_tool -q --accept-defaults --outdir $TMPDIR keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys addrs=103-200
  262. rm $TMPDIR/*-MoneroWallet*
  263. $mmgen_tool -q --accept-defaults --outdir $TMPDIR keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys
  264. $mmgen_tool -q --accept-defaults --outdir $TMPDIR syncmonerowallets $TMPDIR/*-XMR*.akeys addrs=3
  265. $mmgen_tool -q --accept-defaults --outdir $TMPDIR syncmonerowallets $TMPDIR/*-XMR*.akeys addrs=23-29
  266. $mmgen_tool -q --accept-defaults --outdir $TMPDIR syncmonerowallets $TMPDIR/*-XMR*.akeys
  267. "
  268. }
  269. [ "$monero_addrs" == '3,23' ] && t_monero_skip='4 8 13'
  270. i_eth='Ethereum'
  271. s_eth='Testing transaction and tracking wallet operations for Ethereum and Ethereum Classic'
  272. t_eth="
  273. $test_py --coin=eth ethdev
  274. $test_py --coin=etc ethdev
  275. "
  276. f_eth='Ethereum tests completed'
  277. i_autosign='Autosign'
  278. s_autosign='The bitcoin, bitcoin-abc and litecoin mainnet and testnet daemons must be running for the following test'
  279. t_autosign="$test_py autosign"
  280. f_autosign='Autosign test complete'
  281. i_autosign_minimal='Autosign Minimal'
  282. s_autosign_minimal='The bitcoin mainnet and testnet daemons must be running for the following test'
  283. t_autosign_minimal="$test_py autosign_minimal"
  284. f_autosign_minimal='Autosign Minimal test complete'
  285. i_autosign_live='Autosign Live'
  286. s_autosign_live="The bitcoin mainnet and testnet daemons must be running for the following test\n"
  287. s_autosign_live+="${YELLOW}Mountpoint, '/etc/fstab' and removable device must be configured "
  288. s_autosign_live+="as described in 'mmgen-autosign --help'${RESET}"
  289. t_autosign_live="$test_py autosign_live"
  290. f_autosign_live='Autosign Live test complete'
  291. i_btc='Bitcoin mainnet'
  292. s_btc='The bitcoin (mainnet) daemon must both be running for the following tests'
  293. t_btc="
  294. $test_py --exclude regtest,autosign_minimal
  295. $test_py --segwit
  296. $test_py --segwit-random
  297. $test_py --bech32
  298. $python scripts/compute-file-chksum.py $REFDIR/*testnet.rawtx >/dev/null 2>&1
  299. "
  300. f_btc='You may stop the bitcoin (mainnet) daemon if you wish'
  301. i_btc_tn='Bitcoin testnet'
  302. s_btc_tn='The bitcoin testnet daemon must both be running for the following tests'
  303. t_btc_tn="
  304. $test_py --testnet=1
  305. $test_py --testnet=1 --segwit
  306. $test_py --testnet=1 --segwit-random
  307. $test_py --testnet=1 --bech32
  308. "
  309. f_btc_tn='You may stop the bitcoin testnet daemon if you wish'
  310. i_btc_rt='Bitcoin regtest'
  311. s_btc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  312. t_btc_rt="$test_py regtest"
  313. f_btc_rt='Regtest (Bob and Alice) mode tests for BTC completed'
  314. i_bch='Bitcoin cash (BCH)'
  315. s_bch='The bitcoin cash daemon (Bitcoin ABC) must both be running for the following tests'
  316. t_bch="$test_py --coin=bch --exclude regtest"
  317. f_bch='You may stop the Bitcoin ABC daemon if you wish'
  318. i_bch_rt='Bitcoin cash (BCH) regtest'
  319. s_bch_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  320. t_bch_rt="$test_py --coin=bch regtest"
  321. f_bch_rt='Regtest (Bob and Alice) mode tests for BCH completed'
  322. i_ltc='Litecoin'
  323. s_ltc='The litecoin daemon must both be running for the following tests'
  324. t_ltc="
  325. $test_py --coin=ltc --exclude regtest
  326. $test_py --coin=ltc --segwit
  327. $test_py --coin=ltc --segwit-random
  328. $test_py --coin=ltc --bech32
  329. "
  330. f_ltc='You may stop the litecoin daemon if you wish'
  331. i_ltc_tn='Litecoin testnet'
  332. s_ltc_tn='The litecoin testnet daemon must both be running for the following tests'
  333. t_ltc_tn="
  334. $test_py --coin=ltc --testnet=1 --exclude regtest
  335. $test_py --coin=ltc --testnet=1 --segwit
  336. $test_py --coin=ltc --testnet=1 --segwit-random
  337. $test_py --coin=ltc --testnet=1 --bech32
  338. "
  339. f_ltc_tn='You may stop the litecoin testnet daemon if you wish'
  340. i_ltc_rt='Litecoin regtest'
  341. s_ltc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  342. t_ltc_rt="$test_py --coin=ltc regtest"
  343. f_ltc_rt='Regtest (Bob and Alice) mode tests for LTC completed'
  344. i_tool2='Tooltest2'
  345. s_tool2="The following tests will run '$tooltest2_py' for all supported coins"
  346. t_tool2="
  347. $tooltest2_py --quiet
  348. $tooltest2_py --quiet --coin=btc
  349. $tooltest2_py --quiet --coin=btc --testnet=1
  350. $tooltest2_py --quiet --coin=ltc
  351. $tooltest2_py --quiet --coin=ltc --testnet=1
  352. $tooltest2_py --quiet --coin=bch
  353. $tooltest2_py --quiet --coin=bch --testnet=1
  354. $tooltest2_py --quiet --coin=zec
  355. $tooltest2_py --quiet --coin=zec --type=zcash_z
  356. $tooltest2_py --quiet --coin=xmr
  357. $tooltest2_py --quiet --coin=dash
  358. $tooltest2_py --quiet --coin=eth
  359. $tooltest2_py --quiet --coin=eth --testnet=1
  360. $tooltest2_py --quiet --coin=eth --token=mm1
  361. $tooltest2_py --quiet --coin=eth --token=mm1 --testnet=1
  362. $tooltest2_py --quiet --coin=etc
  363. "
  364. f_tool2='tooltest2 tests completed'
  365. i_tool='Tooltest'
  366. s_tool="The following tests will run '$tooltest_py' for all supported coins"
  367. t_tool="
  368. $tooltest_py --coin=btc cryptocoin
  369. $tooltest_py --coin=btc mnemonic
  370. $tooltest_py --coin=ltc cryptocoin
  371. $tooltest_py --coin=eth cryptocoin
  372. $tooltest_py --coin=etc cryptocoin
  373. $tooltest_py --coin=dash cryptocoin
  374. $tooltest_py --coin=doge cryptocoin
  375. $tooltest_py --coin=emc cryptocoin
  376. $tooltest_py --coin=zec cryptocoin
  377. $tooltest_py --coin=zec --type=zcash_z cryptocoin
  378. "
  379. [ "$MSYS2" ] && t_tool_skip='10'
  380. f_tool='tooltest tests completed'
  381. i_gen='Gentest'
  382. s_gen="The following tests will run '$gentest_py' on mainnet and testnet for all supported coins"
  383. t_gen="
  384. $gentest_py -q 2 $REFDIR/btcwallet.dump
  385. $gentest_py -q --type=segwit 2 $REFDIR/btcwallet-segwit.dump
  386. $gentest_py -q --type=bech32 2 $REFDIR/btcwallet-bech32.dump
  387. $gentest_py -q 1:2 $rounds
  388. $gentest_py -q --type=segwit 1:2 $rounds
  389. $gentest_py -q --type=bech32 1:2 $rounds
  390. $gentest_py -q --testnet=1 2 $REFDIR/btcwallet-testnet.dump
  391. $gentest_py -q --testnet=1 1:2 $rounds
  392. $gentest_py -q --testnet=1 --type=segwit 1:2 $rounds
  393. $gentest_py -q --coin=ltc 2 $REFDIR/litecoin/ltcwallet.dump
  394. $gentest_py -q --coin=ltc --type=segwit 2 $REFDIR/litecoin/ltcwallet-segwit.dump
  395. $gentest_py -q --coin=ltc --type=bech32 2 $REFDIR/litecoin/ltcwallet-bech32.dump
  396. $gentest_py -q --coin=ltc 1:2 $rounds
  397. $gentest_py -q --coin=ltc --type=segwit 1:2 $rounds
  398. $gentest_py -q --coin=ltc --testnet=1 2 $REFDIR/litecoin/ltcwallet-testnet.dump
  399. $gentest_py -q --coin=ltc --testnet=1 1:2 $rounds
  400. $gentest_py -q --coin=ltc --testnet=1 --type=segwit 1:2 $rounds
  401. "
  402. f_gen='gentest tests completed'
  403. [ -d .git -a -n "$INSTALL" -a -z "$TESTING" ] && {
  404. check
  405. uninstall
  406. install
  407. cd .test-release/pydist/mmgen-*
  408. }
  409. [ "$INSTALL_ONLY" ] && exit
  410. prompt_skip() {
  411. echo -n "Enter 's' to skip, or ENTER to continue: "; read -n1; echo
  412. [ "$REPLY" == 's' ] && return 0
  413. return 1
  414. }
  415. run_tests() {
  416. for t in $1; do
  417. eval echo -e "'\n'"\${GREEN}'###' Running $(echo \$i_$t) tests\$RESET
  418. eval echo -e $(echo \$s_$t)
  419. [ "$PAUSE" ] && prompt_skip && continue
  420. CUR_TEST=$t
  421. do_test $t
  422. eval echo -e \$GREEN$(echo \$f_$t)\$RESET
  423. done
  424. }
  425. check_args() {
  426. for i in $tests; do
  427. echo "$dfl_tests $add_tests" | grep -q "\<$i\>" || { echo "$i: unrecognized argument"; exit; }
  428. done
  429. }
  430. tests=$dfl_tests
  431. [ "$*" ] && tests="$*"
  432. check_args
  433. echo "Running tests: $tests"
  434. START=$(date +%s)
  435. run_tests "$tests"
  436. TIME=$(($(date +%s)-START))
  437. MS=$(printf %02d:%02d $((TIME/60)) $((TIME%60)))
  438. [ "$NO_TMPFILE_REMOVAL" ] || rm -rf /tmp/mmgen-test-release-*
  439. echo -e "${GREEN}All OK. Total elapsed time: $MS$RESET"