test-release.sh 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  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=btc --type=bech32 2:ext $rounds
  234. $gentest_py --coin=ltc 2:ext $rounds
  235. $gentest_py --coin=ltc --type=compressed 2:ext $rounds
  236. $gentest_py --coin=zec 2:ext $rounds
  237. "
  238. }
  239. f_alts='Gen-only altcoin tests completed'
  240. [ "$NO_TMPFILE_REMOVAL" ] || rm -rf /tmp/mmgen-test-release*
  241. if [ "$MSYS2" ]; then
  242. TMPDIR='/tmp/mmgen-test-release'
  243. else
  244. TMPDIR='/tmp/mmgen-test-release-'$(cat /dev/urandom | base32 - | head -n1 | cut -b 1-16)
  245. fi
  246. mkdir -p $TMPDIR
  247. i_monero='Monero'
  248. s_monero='Testing key-address file generation and wallet creation and sync operations for Monero'
  249. s_monero='The monerod (mainnet) daemon must be running for the following tests'
  250. t_monero="
  251. mmgen-walletgen -q -r0 -p1 -Llabel --outdir $TMPDIR -o words
  252. $mmgen_keygen -q --accept-defaults --use-internal-keccak-module --outdir $TMPDIR --coin=xmr $TMPDIR/*.mmwords $monero_addrs
  253. cs1=\$(mmgen-tool -q --accept-defaults --coin=xmr keyaddrfile_chksum $TMPDIR/*-XMR*.akeys)
  254. $mmgen_keygen -q --use-old-ed25519 --accept-defaults --outdir $TMPDIR --coin=xmr $TMPDIR/*.mmwords $monero_addrs
  255. cs2=\$(mmgen-tool -q --accept-defaults --coin=xmr keyaddrfile_chksum $TMPDIR/*-XMR*.akeys)
  256. [ \"\$cs1\" == \"\$cs2\" ]
  257. "
  258. f_monero='Monero tests completed'
  259. [ "$MSYS2" ] || { # password file descriptor issues, cannot use popen_spawn()
  260. t_monero="$t_monero
  261. $mmgen_tool -q --accept-defaults --outdir $TMPDIR keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys addrs=23
  262. $mmgen_tool -q --accept-defaults --outdir $TMPDIR keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys addrs=103-200
  263. rm $TMPDIR/*-MoneroWallet*
  264. $mmgen_tool -q --accept-defaults --outdir $TMPDIR keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys
  265. $mmgen_tool -q --accept-defaults --outdir $TMPDIR syncmonerowallets $TMPDIR/*-XMR*.akeys addrs=3
  266. $mmgen_tool -q --accept-defaults --outdir $TMPDIR syncmonerowallets $TMPDIR/*-XMR*.akeys addrs=23-29
  267. $mmgen_tool -q --accept-defaults --outdir $TMPDIR syncmonerowallets $TMPDIR/*-XMR*.akeys
  268. "
  269. }
  270. [ "$monero_addrs" == '3,23' ] && t_monero_skip='4 8 13'
  271. i_eth='Ethereum'
  272. s_eth='Testing transaction and tracking wallet operations for Ethereum and Ethereum Classic'
  273. t_eth="
  274. $test_py --coin=eth ethdev
  275. $test_py --coin=etc ethdev
  276. "
  277. f_eth='Ethereum tests completed'
  278. i_autosign='Autosign'
  279. s_autosign='The bitcoin, bitcoin-abc and litecoin mainnet and testnet daemons must be running for the following test'
  280. t_autosign="$test_py autosign"
  281. f_autosign='Autosign test complete'
  282. i_autosign_minimal='Autosign Minimal'
  283. s_autosign_minimal='The bitcoin mainnet and testnet daemons must be running for the following test'
  284. t_autosign_minimal="$test_py autosign_minimal"
  285. f_autosign_minimal='Autosign Minimal test complete'
  286. i_autosign_live='Autosign Live'
  287. s_autosign_live="The bitcoin mainnet and testnet daemons must be running for the following test\n"
  288. s_autosign_live+="${YELLOW}Mountpoint, '/etc/fstab' and removable device must be configured "
  289. s_autosign_live+="as described in 'mmgen-autosign --help'${RESET}"
  290. t_autosign_live="$test_py autosign_live"
  291. f_autosign_live='Autosign Live test complete'
  292. i_btc='Bitcoin mainnet'
  293. s_btc='The bitcoin (mainnet) daemon must both be running for the following tests'
  294. t_btc="
  295. $test_py --exclude regtest,autosign_minimal
  296. $test_py --segwit
  297. $test_py --segwit-random
  298. $test_py --bech32
  299. $python scripts/compute-file-chksum.py $REFDIR/*testnet.rawtx >/dev/null 2>&1
  300. "
  301. f_btc='You may stop the bitcoin (mainnet) daemon if you wish'
  302. i_btc_tn='Bitcoin testnet'
  303. s_btc_tn='The bitcoin testnet daemon must both be running for the following tests'
  304. t_btc_tn="
  305. $test_py --testnet=1
  306. $test_py --testnet=1 --segwit
  307. $test_py --testnet=1 --segwit-random
  308. $test_py --testnet=1 --bech32
  309. "
  310. f_btc_tn='You may stop the bitcoin testnet daemon if you wish'
  311. i_btc_rt='Bitcoin regtest'
  312. s_btc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  313. t_btc_rt="$test_py regtest"
  314. f_btc_rt='Regtest (Bob and Alice) mode tests for BTC completed'
  315. i_bch='Bitcoin cash (BCH)'
  316. s_bch='The bitcoin cash daemon (Bitcoin ABC) must both be running for the following tests'
  317. t_bch="$test_py --coin=bch --exclude regtest"
  318. f_bch='You may stop the Bitcoin ABC daemon if you wish'
  319. i_bch_rt='Bitcoin cash (BCH) regtest'
  320. s_bch_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  321. t_bch_rt="$test_py --coin=bch regtest"
  322. f_bch_rt='Regtest (Bob and Alice) mode tests for BCH completed'
  323. i_ltc='Litecoin'
  324. s_ltc='The litecoin daemon must both be running for the following tests'
  325. t_ltc="
  326. $test_py --coin=ltc --exclude regtest
  327. $test_py --coin=ltc --segwit
  328. $test_py --coin=ltc --segwit-random
  329. $test_py --coin=ltc --bech32
  330. "
  331. f_ltc='You may stop the litecoin daemon if you wish'
  332. i_ltc_tn='Litecoin testnet'
  333. s_ltc_tn='The litecoin testnet daemon must both be running for the following tests'
  334. t_ltc_tn="
  335. $test_py --coin=ltc --testnet=1 --exclude regtest
  336. $test_py --coin=ltc --testnet=1 --segwit
  337. $test_py --coin=ltc --testnet=1 --segwit-random
  338. $test_py --coin=ltc --testnet=1 --bech32
  339. "
  340. f_ltc_tn='You may stop the litecoin testnet daemon if you wish'
  341. i_ltc_rt='Litecoin regtest'
  342. s_ltc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  343. t_ltc_rt="$test_py --coin=ltc regtest"
  344. f_ltc_rt='Regtest (Bob and Alice) mode tests for LTC completed'
  345. i_tool2='Tooltest2'
  346. s_tool2="The following tests will run '$tooltest2_py' for all supported coins"
  347. t_tool2="
  348. $tooltest2_py --quiet --fork # run once with --fork so commands are actually executed
  349. $tooltest2_py --quiet --coin=btc --fork
  350. $tooltest2_py --quiet --coin=btc --testnet=1
  351. $tooltest2_py --quiet --coin=ltc
  352. $tooltest2_py --quiet --coin=ltc --testnet=1
  353. $tooltest2_py --quiet --coin=bch
  354. $tooltest2_py --quiet --coin=bch --testnet=1
  355. $tooltest2_py --quiet --coin=zec
  356. $tooltest2_py --quiet --coin=zec --type=zcash_z
  357. $tooltest2_py --quiet --coin=xmr
  358. $tooltest2_py --quiet --coin=dash
  359. $tooltest2_py --quiet --coin=eth
  360. $tooltest2_py --quiet --coin=eth --testnet=1
  361. $tooltest2_py --quiet --coin=eth --token=mm1
  362. $tooltest2_py --quiet --coin=eth --token=mm1 --testnet=1
  363. $tooltest2_py --quiet --coin=etc
  364. "
  365. f_tool2='tooltest2 tests completed'
  366. i_tool='Tooltest'
  367. s_tool="The following tests will run '$tooltest_py' for all supported coins"
  368. t_tool="
  369. $tooltest_py --coin=btc cryptocoin
  370. $tooltest_py --coin=btc mnemonic
  371. $tooltest_py --coin=ltc cryptocoin
  372. $tooltest_py --coin=eth cryptocoin
  373. $tooltest_py --coin=etc cryptocoin
  374. $tooltest_py --coin=dash cryptocoin
  375. $tooltest_py --coin=doge cryptocoin
  376. $tooltest_py --coin=emc cryptocoin
  377. $tooltest_py --coin=zec cryptocoin
  378. $tooltest_py --coin=zec --type=zcash_z cryptocoin
  379. "
  380. [ "$MSYS2" ] && t_tool_skip='10'
  381. f_tool='tooltest tests completed'
  382. i_gen='Gentest'
  383. s_gen="The following tests will run '$gentest_py' on mainnet and testnet for all supported coins"
  384. t_gen="
  385. $gentest_py -q 2 $REFDIR/btcwallet.dump
  386. $gentest_py -q --type=segwit 2 $REFDIR/btcwallet-segwit.dump
  387. $gentest_py -q --type=bech32 2 $REFDIR/btcwallet-bech32.dump
  388. $gentest_py -q 1:2 $rounds
  389. $gentest_py -q --type=segwit 1:2 $rounds
  390. $gentest_py -q --type=bech32 1:2 $rounds
  391. $gentest_py -q --testnet=1 2 $REFDIR/btcwallet-testnet.dump
  392. $gentest_py -q --testnet=1 1:2 $rounds
  393. $gentest_py -q --testnet=1 --type=segwit 1:2 $rounds
  394. $gentest_py -q --coin=ltc 2 $REFDIR/litecoin/ltcwallet.dump
  395. $gentest_py -q --coin=ltc --type=segwit 2 $REFDIR/litecoin/ltcwallet-segwit.dump
  396. $gentest_py -q --coin=ltc --type=bech32 2 $REFDIR/litecoin/ltcwallet-bech32.dump
  397. $gentest_py -q --coin=ltc 1:2 $rounds
  398. $gentest_py -q --coin=ltc --type=segwit 1:2 $rounds
  399. $gentest_py -q --coin=ltc --testnet=1 2 $REFDIR/litecoin/ltcwallet-testnet.dump
  400. $gentest_py -q --coin=ltc --testnet=1 1:2 $rounds
  401. $gentest_py -q --coin=ltc --testnet=1 --type=segwit 1:2 $rounds
  402. "
  403. f_gen='gentest tests completed'
  404. [ -d .git -a -n "$INSTALL" -a -z "$TESTING" ] && {
  405. check
  406. uninstall
  407. install
  408. cd .test-release/pydist/mmgen-*
  409. }
  410. [ "$INSTALL_ONLY" ] && exit
  411. prompt_skip() {
  412. echo -n "Enter 's' to skip, or ENTER to continue: "; read -n1; echo
  413. [ "$REPLY" == 's' ] && return 0
  414. return 1
  415. }
  416. run_tests() {
  417. for t in $1; do
  418. eval echo -e "'\n'"\${GREEN}'###' Running $(echo \$i_$t) tests\$RESET
  419. eval echo -e $(echo \$s_$t)
  420. [ "$PAUSE" ] && prompt_skip && continue
  421. CUR_TEST=$t
  422. do_test $t
  423. eval echo -e \$GREEN$(echo \$f_$t)\$RESET
  424. done
  425. }
  426. check_args() {
  427. for i in $tests; do
  428. echo "$dfl_tests $add_tests" | grep -q "\<$i\>" || { echo "$i: unrecognized argument"; exit; }
  429. done
  430. }
  431. tests=$dfl_tests
  432. [ "$*" ] && tests="$*"
  433. check_args
  434. echo "Running tests: $tests"
  435. START=$(date +%s)
  436. run_tests "$tests"
  437. TIME=$(($(date +%s)-START))
  438. MS=$(printf %02d:%02d $((TIME/60)) $((TIME%60)))
  439. [ "$NO_TMPFILE_REMOVAL" ] || rm -rf /tmp/mmgen-test-release-*
  440. echo -e "${GREEN}All OK. Total elapsed time: $MS$RESET"