test-release.sh 17 KB

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