test-release.sh 17 KB

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