test-release.sh 17 KB

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