2017-09-19 22:14:00 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
# Tested on Linux, MinGW-64
|
|
|
|
|
|
2017-09-26 15:41:11 +03:00
|
|
|
PROGNAME=$(basename $0)
|
|
|
|
|
while getopts hint OPT
|
|
|
|
|
do
|
|
|
|
|
case "$OPT" in
|
|
|
|
|
h) printf " %-16s Test MMGen release\n" "${PROGNAME^^}:"
|
|
|
|
|
echo " USAGE: $PROGNAME [options] branch [tests]"
|
|
|
|
|
echo " OPTIONS: '-h' Print this help message"
|
|
|
|
|
echo " '-i' Install only; don't run tests"
|
|
|
|
|
echo " '-n' Don't install; test in place"
|
|
|
|
|
echo " '-t' Print the tests without running them"
|
|
|
|
|
echo " AVAILABLE TESTS:"
|
|
|
|
|
echo " 1 - main"
|
|
|
|
|
echo " 2 - regtest"
|
|
|
|
|
echo " 3 - tool"
|
|
|
|
|
echo " 4 - gen"
|
|
|
|
|
echo " By default, all tests are run"
|
|
|
|
|
exit ;;
|
|
|
|
|
i) INSTALL_ONLY=1 ;;
|
|
|
|
|
n) NO_INSTALL=1 ;;
|
|
|
|
|
t) TESTING=1 ;;
|
|
|
|
|
*) exit ;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
shift $((OPTIND-1))
|
|
|
|
|
|
2017-09-19 22:14:00 +03:00
|
|
|
set -e
|
2017-09-26 15:41:11 +03:00
|
|
|
GREEN="\e[32;1m" YELLOW="\e[33;1m" RESET="\e[0m"
|
|
|
|
|
BRANCH=$1; shift
|
2017-09-19 22:14:00 +03:00
|
|
|
REFDIR=test/ref
|
|
|
|
|
if uname -a | grep -qi mingw; then SUDO='' MINGW=1; else SUDO='sudo' MINGW=''; fi
|
|
|
|
|
|
|
|
|
|
function check {
|
|
|
|
|
[ "$BRANCH" ] || { echo 'No branch specified. Exiting'; exit; }
|
|
|
|
|
[ "$(git diff $BRANCH)" == "" ] || {
|
|
|
|
|
echo "Unmerged changes from branch '$BRANCH'. Exiting"
|
|
|
|
|
exit
|
|
|
|
|
}
|
|
|
|
|
git diff $BRANCH >/dev/null 2>&1 || exit
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function install {
|
|
|
|
|
set -x
|
|
|
|
|
eval "$SUDO rm -rf .test-release"
|
|
|
|
|
git clone --branch $BRANCH --single-branch . .test-release
|
|
|
|
|
cd .test-release
|
|
|
|
|
./setup.py sdist
|
|
|
|
|
mkdir pydist && cd pydist
|
|
|
|
|
if [ "$MINGW" ]; then unzip ../dist/mmgen-*.zip; else tar zxvf ../dist/mmgen-*gz; fi
|
|
|
|
|
cd mmgen-*
|
|
|
|
|
scripts/deinstall.sh
|
|
|
|
|
|
|
|
|
|
[ "$MINGW" ] && ./setup.py build --compiler=mingw32
|
|
|
|
|
eval "$SUDO ./setup.py install"
|
|
|
|
|
}
|
2017-09-26 15:41:11 +03:00
|
|
|
[ -z "$TESTING" ] && LS='\n'
|
2017-09-19 22:14:00 +03:00
|
|
|
function do_test {
|
|
|
|
|
set +x
|
2017-09-25 14:27:39 +03:00
|
|
|
for i in "$@"; do
|
2017-09-26 15:41:11 +03:00
|
|
|
echo -e "$LS${GREEN}Running:$RESET $YELLOW$i$RESET"
|
|
|
|
|
[ "$TESTING" ] || eval "$i"
|
2017-09-19 22:14:00 +03:00
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-25 14:27:39 +03:00
|
|
|
T1=('test/test.py -On'
|
2017-09-19 22:14:00 +03:00
|
|
|
'test/test.py -On --segwit dfl_wallet main ref ref_other'
|
2017-09-25 14:27:39 +03:00
|
|
|
'test/test.py -On --segwit-random dfl_wallet main')
|
|
|
|
|
T2=('test/test.py -On regtest')
|
|
|
|
|
T3=('test/tooltest.py') # tooltest tests both segwit and non-segwit
|
|
|
|
|
T4=("test/gentest.py -q 2 $REFDIR/btcwallet.dump"
|
2017-09-19 22:14:00 +03:00
|
|
|
"test/gentest.py -q --testnet=1 2 $REFDIR/btcwallet-testnet.dump"
|
|
|
|
|
'test/gentest.py -q 1:2 10'
|
|
|
|
|
'test/gentest.py -q --segwit 1:2 10'
|
|
|
|
|
# "scripts/tx-old2new.py -S $REFDIR/tx_*raw >/dev/null 2>&1"
|
2017-09-25 14:27:39 +03:00
|
|
|
"scripts/compute-file-chksum.py $REFDIR/*testnet.rawtx >/dev/null 2>&1")
|
|
|
|
|
|
2017-09-26 15:41:11 +03:00
|
|
|
[ -d .git -a -z "$NO_INSTALL" -a -z "$TESTING" ] && {
|
|
|
|
|
check
|
|
|
|
|
(install)
|
|
|
|
|
eval "cd .test-release/pydist/mmgen-*"
|
|
|
|
|
}
|
|
|
|
|
[ "$INSTALL_ONLY" ] && exit
|
2017-09-19 22:14:00 +03:00
|
|
|
|
2017-09-26 15:41:11 +03:00
|
|
|
if [ "$*" ]; then TESTS=$@; else TESTS='1 2 3 4'; fi
|
|
|
|
|
for t in $TESTS; do
|
|
|
|
|
[ $t == 4 ] && LS=''
|
|
|
|
|
eval "do_test \"\${T$t[@]}\""
|
|
|
|
|
done
|
|
|
|
|
echo -e "$LS${GREEN}All OK$RESET"
|