2024-07-27 09:42:44 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-07-26 14:07:35 +00:00
|
|
|
#
|
2024-10-18 10:32:06 +00:00
|
|
|
# MMGen Wallet, a terminal-based cryptocurrency wallet
|
2025-02-16 14:42:27 +00:00
|
|
|
# Copyright (C)2013-2025 The MMGen Project <mmgen@tuta.io>
|
2022-07-26 14:07:35 +00:00
|
|
|
# Licensed under the GNU General Public License, Version 3:
|
|
|
|
|
# https://www.gnu.org/licenses
|
|
|
|
|
# Public project repositories:
|
2023-11-17 13:35:42 +00:00
|
|
|
# https://github.com/mmgen/mmgen-wallet
|
|
|
|
|
# https://gitlab.com/mmgen/mmgen-wallet
|
2022-07-26 14:07:35 +00:00
|
|
|
|
2019-05-25 15:04:13 +00:00
|
|
|
# Tested on Linux, Armbian, Raspbian, MSYS2
|
2017-09-19 22:14:00 +03:00
|
|
|
|
2024-01-19 11:05:09 +00:00
|
|
|
# cfg.sh must implement:
|
2022-07-26 14:07:35 +00:00
|
|
|
# list_avail_tests()
|
|
|
|
|
# init_groups()
|
|
|
|
|
# init_tests()
|
|
|
|
|
. 'test/test-release.d/cfg.sh'
|
|
|
|
|
|
2024-01-19 11:05:09 +00:00
|
|
|
run_test() {
|
2022-07-26 14:07:35 +00:00
|
|
|
set +x
|
|
|
|
|
tests="t_$1"
|
|
|
|
|
skips="t_$1_skip"
|
|
|
|
|
|
|
|
|
|
while read skip test; do
|
|
|
|
|
[ "$test" ] || continue
|
|
|
|
|
echo "${!skips}" | grep -q $skip && continue
|
|
|
|
|
|
|
|
|
|
if [ "$LIST_CMDS" ]; then
|
|
|
|
|
echo $test
|
|
|
|
|
else
|
|
|
|
|
test_disp=$YELLOW${test/\#/$RESET$MAGENTA\#}$RESET
|
|
|
|
|
if [ "${test:0:1}" == '#' ]; then
|
|
|
|
|
echo -e "$test_disp"
|
|
|
|
|
else
|
|
|
|
|
echo -e "${GREEN}Running:$RESET $test_disp"
|
|
|
|
|
eval "$test" || {
|
|
|
|
|
echo -e $RED"test-release.sh: test '$CUR_TEST' failed at command '$test'"$RESET
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
done <<<${!tests}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prompt_skip() {
|
|
|
|
|
echo -n "Enter 's' to skip, or ENTER to continue: "; read -n1; echo
|
|
|
|
|
[ "$REPLY" == 's' ] && return 0
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-25 09:09:43 +00:00
|
|
|
list_avail_tests() {
|
|
|
|
|
echo "AVAILABLE TESTS:"
|
|
|
|
|
init_tests
|
|
|
|
|
for i in $all_tests; do
|
|
|
|
|
z="d_$i"
|
|
|
|
|
printf " %-8s - %s\n" $i "${!z}"
|
|
|
|
|
done
|
|
|
|
|
echo
|
|
|
|
|
echo "AVAILABLE TEST GROUPS:"
|
|
|
|
|
while read a b c; do
|
|
|
|
|
[ "$a" ] && printf " %-8s - %s\n" $a "$c"
|
|
|
|
|
done <<<$groups_desc
|
|
|
|
|
echo
|
|
|
|
|
echo "By default, all tests are run"
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-26 14:07:35 +00:00
|
|
|
run_tests() {
|
|
|
|
|
[ "$LIST_CMDS" ] || echo "Running tests: $1"
|
|
|
|
|
for t in $1; do
|
2022-10-25 09:09:43 +00:00
|
|
|
desc_id="d_$t" desc=${!desc_id}
|
2022-07-26 14:07:35 +00:00
|
|
|
if [ "$SKIP_ALT_DEP" ]; then
|
2024-07-08 10:51:21 +00:00
|
|
|
ok=$(for a in $noalt_tests $noalt_ok_tests; do if [ $t == $a ]; then echo 'ok'; fi; done)
|
2022-07-26 14:07:35 +00:00
|
|
|
if [ ! "$ok" ]; then
|
|
|
|
|
echo -e "${BLUE}Skipping altcoin test '$t'$RESET"
|
|
|
|
|
continue
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
if [ "$LIST_CMDS" ]; then
|
2022-10-25 09:09:43 +00:00
|
|
|
echo -e "\n### $t: $desc"
|
2022-07-26 14:07:35 +00:00
|
|
|
else
|
2022-10-25 09:09:43 +00:00
|
|
|
echo -e "\n${BLUE}Testing:$RESET $GREEN$desc$RESET"
|
2022-07-26 14:07:35 +00:00
|
|
|
fi
|
|
|
|
|
[ "$PAUSE" ] && prompt_skip && continue
|
|
|
|
|
CUR_TEST=$t
|
2024-01-19 11:05:09 +00:00
|
|
|
run_test $t
|
2022-10-25 09:09:43 +00:00
|
|
|
[ "$LIST_CMDS" ] || echo -e "${BLUE}Finished testing:$RESET $GREEN$desc$RESET"
|
2022-07-26 14:07:35 +00:00
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
check_tests() {
|
|
|
|
|
for i in $tests; do
|
|
|
|
|
echo "$dfl_tests $extra_tests" | grep -q "\<$i\>" || {
|
|
|
|
|
echo "$i: unrecognized argument"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
remove_skipped_tests() {
|
|
|
|
|
tests=$(for t in $tests; do
|
|
|
|
|
[ "$(for s in $SKIP_LIST; do [ $t == $s ] && echo y; done)" ] && continue
|
|
|
|
|
echo $t
|
|
|
|
|
done)
|
|
|
|
|
tests=$(echo $tests)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list_group_symbols() {
|
|
|
|
|
echo -e "Default tests:\n $dfl_tests"
|
|
|
|
|
echo -e "Extra tests:\n $extra_tests"
|
|
|
|
|
echo -e "'noalt' test group:\n $noalt_tests"
|
|
|
|
|
echo -e "'quick' test group:\n $quick_tests"
|
|
|
|
|
echo -e "'qskip' test group:\n $qskip_tests"
|
|
|
|
|
}
|
2019-05-25 15:04:13 +00:00
|
|
|
|
2024-01-19 11:05:09 +00:00
|
|
|
print_ver_hash() {
|
|
|
|
|
python3 -m pip freeze | grep "^$repo\>" | sed 's/.*sha256=//' | cut -c 1-12
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-27 09:42:44 +00:00
|
|
|
do_typescript() {
|
2024-07-27 09:42:50 +00:00
|
|
|
if [ "$DARWIN" ]; then script "$1" $2; else script -O "$1" -c "$2"; fi
|
2024-07-27 09:42:44 +00:00
|
|
|
}
|
|
|
|
|
|
2024-01-19 11:05:09 +00:00
|
|
|
install_package() {
|
|
|
|
|
echo -e "${BLUE}Installing package$YELLOW $repo$RESET"
|
|
|
|
|
rm -rf build dist *.egg-info
|
|
|
|
|
|
|
|
|
|
ver=$(print_ver_hash)
|
|
|
|
|
echo -e "${BLUE}Currently installed version is$MAGENTA $ver$RESET"
|
|
|
|
|
|
|
|
|
|
cmd="python3 -m build --no-isolation --wheel --config-setting=quiet $STDOUT_DEVNULL"
|
|
|
|
|
echo -e "${BLUE}Executing:$CYAN $cmd$RESET"
|
|
|
|
|
eval $cmd
|
|
|
|
|
|
|
|
|
|
cmd="python3 -m pip $QUIET install --break-system-packages dist/*.whl"
|
|
|
|
|
echo -e "${BLUE}Executing:$CYAN $cmd$RESET"
|
|
|
|
|
eval $cmd
|
|
|
|
|
|
|
|
|
|
new_ver=$(print_ver_hash)
|
|
|
|
|
if [ "$ver" == "$new_ver" ]; then
|
|
|
|
|
echo -ne "${YELLOW}Version hash is unchanged. Force install? (y/N):$RESET "
|
|
|
|
|
read -n1
|
|
|
|
|
if [ "$REPLY" == 'y' ]; then
|
|
|
|
|
echo
|
|
|
|
|
cmd="python3 -m pip $QUIET install --break-system-packages --force --no-deps dist/*.whl"
|
|
|
|
|
echo -e "${BLUE}Executing:$CYAN $cmd$RESET"
|
|
|
|
|
eval $cmd
|
|
|
|
|
elif [ "$REPLY" ]; then
|
|
|
|
|
echo; return
|
|
|
|
|
else
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
new_ver=$(print_ver_hash)
|
|
|
|
|
if [ "$ver" == "$new_ver" ]; then
|
|
|
|
|
echo -e "${RED}ERROR: version hash is unchanged$RESET"
|
|
|
|
|
exit 1
|
|
|
|
|
else
|
|
|
|
|
echo -e "${GREEN}OK$RESET"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-19 11:05:09 +00:00
|
|
|
do_reexec() {
|
2024-01-26 10:54:03 +00:00
|
|
|
[ -z "$exec_prog" ] && exec_prog="test/test-release.sh -X $ORIG_ARGS"
|
|
|
|
|
|
2024-01-19 11:05:09 +00:00
|
|
|
if [ "$sdist_dir" ]; then
|
|
|
|
|
target_dir=$sdist_dir
|
|
|
|
|
elif [ "$clone_dir" ]; then
|
|
|
|
|
target_dir="$orig_cwd/.clone-test"
|
|
|
|
|
clone_dir=$target_dir
|
2024-01-26 10:54:03 +00:00
|
|
|
else # TYPESCRIPT=1
|
2024-07-27 09:42:44 +00:00
|
|
|
do_typescript "$orig_cwd/$typescript_file" "$exec_prog"
|
2024-01-26 10:54:03 +00:00
|
|
|
return
|
2024-01-19 11:05:09 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
rm -rf $target_dir
|
|
|
|
|
mkdir $target_dir
|
|
|
|
|
|
|
|
|
|
if [ "$repo" != 'mmgen-wallet' ]; then
|
|
|
|
|
echo -e "${BLUE}Cloning repo $MAGENTA'mmgen-wallet'$RESET ${BLUE}to $YELLOW$target_dir/mmgen-wallet$RESET"
|
|
|
|
|
mkdir -p "$target_dir/mmgen-wallet"
|
|
|
|
|
eval "git clone $orig_cwd/../mmgen-wallet $target_dir/mmgen-wallet $STDOUT_DEVNULL $STDERR_DEVNULL"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$clone_dir" ]; then
|
|
|
|
|
[ "$(git status --porcelain)" ] && VIM_GIT_COMMIT=1 git commit -a
|
|
|
|
|
dest="$clone_dir/$repo"
|
|
|
|
|
rm -rf $dest
|
|
|
|
|
mkdir -p $dest
|
|
|
|
|
echo -e "${BLUE}Cloning repo $MAGENTA'$repo'$BLUE to $YELLOW$dest$RESET"
|
|
|
|
|
eval "git clone . $dest $STDOUT_DEVNULL $STDERR_DEVNULL"
|
|
|
|
|
cd $dest
|
|
|
|
|
echo -e "${BLUE}cd -> $YELLOW$PWD$RESET"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$sdist_dir" ]; then
|
|
|
|
|
rm -rf build dist *.egg-info
|
|
|
|
|
echo -n 'Building sdist...'
|
|
|
|
|
eval "python3 -m build --no-isolation --sdist --config-setting=quiet $STDOUT_DEVNULL"
|
|
|
|
|
echo -e "done\n${BLUE}Unpacking sdist archive to $YELLOW$target_dir$RESET"
|
2024-07-27 09:42:44 +00:00
|
|
|
tar -C $target_dir -zxf dist/*.tar.gz
|
2024-05-22 12:04:35 +00:00
|
|
|
cd $target_dir/${repo//-/[-_]}-*
|
2024-01-19 11:05:09 +00:00
|
|
|
echo -e "${BLUE}cd -> $YELLOW$PWD$RESET"
|
|
|
|
|
if [ "$clone_dir" ]; then rm -rf $clone_dir; fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
[ -e 'test/init.sh' ] && test/init.sh $VERBOSE_SHORTOPT
|
|
|
|
|
|
|
|
|
|
echo -e "\n${BLUE}Executing test runner: ${CYAN}test/test-release $ORIG_ARGS$RESET\n"
|
2024-01-26 10:54:03 +00:00
|
|
|
|
2024-01-19 11:05:10 +00:00
|
|
|
if [ "$TYPESCRIPT" ]; then
|
2024-07-27 09:42:44 +00:00
|
|
|
do_typescript "$orig_cwd/$typescript_file" "$exec_prog"
|
2024-01-19 11:05:10 +00:00
|
|
|
else
|
2024-01-26 10:54:03 +00:00
|
|
|
eval $exec_prog
|
2024-01-19 11:05:10 +00:00
|
|
|
fi
|
2024-01-19 11:05:09 +00:00
|
|
|
}
|
|
|
|
|
|
2024-12-30 11:31:40 +00:00
|
|
|
install_secp256k1_mod_maybe() {
|
|
|
|
|
if [[ "$repo" =~ ^mmgen[-_]wallet ]]; then
|
2025-02-24 11:27:44 +00:00
|
|
|
eval "python3 setup.py build_ext --inplace $STDOUT_DEVNULL"
|
2024-12-30 11:31:40 +00:00
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-30 11:31:39 +00:00
|
|
|
in_nix_environment() {
|
|
|
|
|
for path in ${PATH//:/ }; do
|
|
|
|
|
realpath -q $path | grep -q '^/nix/store/' && break
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-19 11:05:09 +00:00
|
|
|
# start execution
|
|
|
|
|
|
2024-01-19 11:05:09 +00:00
|
|
|
set -e
|
|
|
|
|
set -o functrace
|
|
|
|
|
set -o errtrace
|
|
|
|
|
|
2024-01-19 11:05:09 +00:00
|
|
|
trap 'echo -e "${GREEN}Exiting at user request$RESET"; exit' INT
|
|
|
|
|
|
|
|
|
|
umask 0022
|
|
|
|
|
|
2024-01-19 11:05:09 +00:00
|
|
|
orig_cwd=$(pwd)
|
|
|
|
|
repo=$(basename $orig_cwd)
|
|
|
|
|
|
2019-05-25 15:04:13 +00:00
|
|
|
if [ "$(uname -m)" == 'armv7l' ]; then
|
|
|
|
|
ARM32=1
|
2021-10-13 20:44:44 +00:00
|
|
|
elif [ "$(uname -m)" == 'aarch64' ]; then
|
|
|
|
|
ARM64=1
|
2024-07-27 09:42:50 +00:00
|
|
|
elif [ "$(uname -s)" == 'Darwin' ]; then
|
|
|
|
|
DARWIN=1
|
|
|
|
|
DISTRO='DARWIN'
|
2023-05-21 11:34:16 +00:00
|
|
|
elif [ "$MSYSTEM" ] && uname -a | grep -qi 'msys'; then
|
2024-01-19 11:05:09 +00:00
|
|
|
MSYS2=1
|
2024-07-27 09:42:44 +00:00
|
|
|
DISTRO='MSYS2'
|
2019-05-20 15:44:30 +00:00
|
|
|
fi
|
2019-05-25 15:04:13 +00:00
|
|
|
|
2024-07-11 11:36:21 +00:00
|
|
|
[ "$ARM32" -o "$ARM64" ] && {
|
|
|
|
|
PEXPECT_LONG_TIMEOUT=' --pexpect-timeout=300'
|
|
|
|
|
HTTP_LONG_TIMEOUT='MMGEN_HTTP_TIMEOUT=300 '
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-27 09:42:44 +00:00
|
|
|
if [ -e '/etc/os-release' ]; then
|
2022-08-16 20:35:50 +00:00
|
|
|
DISTRO=$(grep '^ID=' '/etc/os-release' | cut -c 4-)
|
2024-07-27 09:16:43 +00:00
|
|
|
[ "$DISTRO" ] || {
|
|
|
|
|
echo 'Unable to determine distro from /etc/os-release. Aborting'
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
2022-08-16 20:35:50 +00:00
|
|
|
fi
|
|
|
|
|
|
2023-10-13 09:51:14 +00:00
|
|
|
cmdtest_py='test/cmdtest.py -n'
|
2018-02-24 14:39:49 +03:00
|
|
|
objtest_py='test/objtest.py'
|
2019-10-19 15:22:30 +00:00
|
|
|
objattrtest_py='test/objattrtest.py'
|
2024-10-18 10:32:15 +00:00
|
|
|
modtest_py='test/modtest.py --names --quiet'
|
|
|
|
|
daemontest_py='test/daemontest.py --names --quiet'
|
2018-02-24 14:39:49 +03:00
|
|
|
tooltest_py='test/tooltest.py'
|
2019-11-01 12:24:09 +00:00
|
|
|
tooltest2_py='test/tooltest2.py --names --quiet'
|
|
|
|
|
gentest_py='test/gentest.py --quiet'
|
2018-02-24 14:39:49 +03:00
|
|
|
scrambletest_py='test/scrambletest.py'
|
2022-01-27 11:08:07 +00:00
|
|
|
altcoin_mod_opts='--quiet'
|
2018-02-24 14:39:49 +03:00
|
|
|
mmgen_tool='cmds/mmgen-tool'
|
2018-10-31 16:37:34 +00:00
|
|
|
python='python3'
|
2022-10-05 19:22:42 +00:00
|
|
|
rounds=10
|
2024-01-19 11:05:10 +00:00
|
|
|
typescript_file='test-release.out'
|
2024-01-19 11:05:09 +00:00
|
|
|
STDOUT_DEVNULL='>/dev/null'
|
|
|
|
|
STDERR_DEVNULL='2>/dev/null'
|
|
|
|
|
QUIET='--quiet'
|
2022-05-03 21:01:05 +00:00
|
|
|
|
2022-06-09 11:18:10 +00:00
|
|
|
ORIG_ARGS=$@
|
2017-09-26 15:41:11 +03:00
|
|
|
PROGNAME=$(basename $0)
|
2022-07-26 14:07:35 +00:00
|
|
|
|
|
|
|
|
init_groups
|
|
|
|
|
|
2024-01-26 10:54:03 +00:00
|
|
|
while getopts hAbcCdDe:fFILlNOps:StTvVX OPT
|
2017-09-26 15:41:11 +03:00
|
|
|
do
|
|
|
|
|
case "$OPT" in
|
2017-10-28 00:11:00 +03:00
|
|
|
h) printf " %-16s Test MMGen release\n" "${PROGNAME}:"
|
2020-02-18 14:07:51 +00:00
|
|
|
echo " USAGE: $PROGNAME [options] [tests or test group]"
|
2021-10-02 17:54:11 +00:00
|
|
|
echo " OPTIONS: -h Print this help message"
|
|
|
|
|
echo " -A Skip tests requiring altcoin modules or daemons"
|
2023-10-13 09:51:14 +00:00
|
|
|
echo " -b Buffer keypresses for all invocations of 'test/cmdtest.py'"
|
2024-01-19 11:05:09 +00:00
|
|
|
echo " -c Run tests in coverage mode"
|
2024-01-19 11:05:09 +00:00
|
|
|
echo " -C Test from cloned repo (can be combined with -S)"
|
2022-01-06 20:24:20 +00:00
|
|
|
echo " -d Enable Python Development Mode"
|
2021-10-03 17:40:03 +00:00
|
|
|
echo " -D Run tests in deterministic mode"
|
2024-01-26 10:54:03 +00:00
|
|
|
echo " -e PROG With -C, -S or -T, execute PROG instead of this script"
|
2021-10-02 17:54:11 +00:00
|
|
|
echo " -f Speed up the tests by using fewer rounds"
|
|
|
|
|
echo " -F Reduce rounds even further"
|
2024-01-19 11:05:09 +00:00
|
|
|
echo " -I Install the package"
|
2022-07-26 14:07:35 +00:00
|
|
|
echo " -L List available tests and test groups with description"
|
2021-10-02 17:54:11 +00:00
|
|
|
echo " -l List the test name symbols"
|
2023-10-13 09:51:14 +00:00
|
|
|
echo " -N Pass the --no-timings switch to test/cmdtest.py"
|
2021-10-02 17:54:11 +00:00
|
|
|
echo " -O Use pexpect.spawn rather than popen_spawn where applicable"
|
|
|
|
|
echo " -p Pause between tests"
|
2021-10-02 17:54:12 +00:00
|
|
|
echo " -s LIST Skip tests in LIST (space-separated)"
|
2024-01-19 11:05:09 +00:00
|
|
|
echo " -S Build sdist distribution, unpack, and run test"
|
2021-10-02 17:54:11 +00:00
|
|
|
echo " -t Print the tests without running them"
|
2024-01-26 10:54:03 +00:00
|
|
|
echo " -T Record a typescript of the screen output in '$typescript_file'"
|
2023-10-13 09:51:14 +00:00
|
|
|
echo " -v Run test/cmdtest.py with '--exact-output' and other commands"
|
2021-10-02 17:54:11 +00:00
|
|
|
echo " with '--verbose' switch"
|
2023-10-13 09:51:14 +00:00
|
|
|
echo " -V Run test/cmdtest.py and other commands with '--verbose' switch"
|
2022-07-29 16:45:31 +00:00
|
|
|
echo
|
|
|
|
|
echo " For traceback output and error file support, set the EXEC_WRAPPER_TRACEBACK"
|
2024-01-19 11:05:09 +00:00
|
|
|
echo " environment variable"
|
2017-09-26 15:41:11 +03:00
|
|
|
exit ;;
|
2022-05-03 21:01:05 +00:00
|
|
|
A) SKIP_ALT_DEP=1
|
2023-10-13 09:51:14 +00:00
|
|
|
cmdtest_py+=" --no-altcoin"
|
2024-10-18 10:32:15 +00:00
|
|
|
modtest_py+=" --no-altcoin-deps"
|
|
|
|
|
daemontest_py+=" --no-altcoin-deps"
|
2023-11-21 15:48:10 +00:00
|
|
|
scrambletest_py+=" --no-altcoin"
|
|
|
|
|
tooltest2_py+=" --no-altcoin" ;;
|
2023-10-13 09:51:14 +00:00
|
|
|
b) cmdtest_py+=" --buf-keypress" ;;
|
2024-01-19 11:05:09 +00:00
|
|
|
c) mkdir -p 'test/trace'
|
2018-02-26 17:01:20 +00:00
|
|
|
touch 'test/trace.acc'
|
2023-10-13 09:51:14 +00:00
|
|
|
cmdtest_py+=" --coverage"
|
2018-10-31 18:20:59 +00:00
|
|
|
tooltest_py+=" --coverage"
|
2019-02-19 14:53:21 +00:00
|
|
|
tooltest2_py+=" --fork --coverage"
|
2018-10-31 18:20:59 +00:00
|
|
|
scrambletest_py+=" --coverage"
|
2018-10-31 16:37:34 +00:00
|
|
|
python="python3 -m trace --count --file=test/trace.acc --coverdir=test/trace"
|
2024-10-18 10:32:15 +00:00
|
|
|
modtest_py="$python $modtest_py"
|
|
|
|
|
daemontest_py="$python $daemontest_py"
|
2018-02-24 14:39:49 +03:00
|
|
|
objtest_py="$python $objtest_py"
|
2019-10-19 15:22:30 +00:00
|
|
|
objattrtest_py="$python $objattrtest_py"
|
2018-02-24 14:39:49 +03:00
|
|
|
gentest_py="$python $gentest_py"
|
2022-07-26 14:02:36 +00:00
|
|
|
mmgen_tool="$python $mmgen_tool" ;&
|
2024-01-19 11:05:09 +00:00
|
|
|
C) REEXEC=1 clone_dir="$orig_cwd/.cloned-repo" ;;
|
2022-01-06 20:24:20 +00:00
|
|
|
d) export PYTHONDEVMODE=1
|
|
|
|
|
export PYTHONWARNINGS='error' ;;
|
2021-10-03 17:40:03 +00:00
|
|
|
D) export MMGEN_TEST_SUITE_DETERMINISTIC=1
|
|
|
|
|
export MMGEN_DISABLE_COLOR=1 ;;
|
2024-01-26 10:54:03 +00:00
|
|
|
e) exec_prog=$(realpath $OPTARG) ;;
|
2024-10-18 10:32:15 +00:00
|
|
|
f) rounds=6 FAST=1 fast_opt='--fast' modtest_py+=" --fast" daemontest_py+=" --fast" ;;
|
|
|
|
|
F) rounds=3 FAST=1 fast_opt='--fast' modtest_py+=" --fast" daemontest_py+=" --fast" ;;
|
2024-01-19 11:05:09 +00:00
|
|
|
I) INSTALL_PACKAGE=1 ;;
|
2022-07-26 14:07:35 +00:00
|
|
|
L) list_avail_tests; exit ;;
|
|
|
|
|
l) list_group_symbols; exit ;;
|
2023-10-13 09:51:14 +00:00
|
|
|
N) cmdtest_py+=" --no-timings" ;;
|
|
|
|
|
O) cmdtest_py+=" --pexpect-spawn" ;;
|
2019-02-28 10:57:35 +00:00
|
|
|
p) PAUSE=1 ;;
|
2022-05-03 21:01:05 +00:00
|
|
|
s) SKIP_LIST+=" $OPTARG" ;;
|
2024-01-19 11:05:09 +00:00
|
|
|
S) REEXEC=1 sdist_dir="$orig_cwd/.sdist-test" ;;
|
2019-12-07 12:20:21 +00:00
|
|
|
t) LIST_CMDS=1 ;;
|
2024-01-26 10:54:03 +00:00
|
|
|
T) REEXEC=1 TYPESCRIPT=1 ;;
|
2023-10-13 09:51:14 +00:00
|
|
|
v) EXACT_OUTPUT=1 cmdtest_py+=" --exact-output" ;&
|
2024-01-19 11:05:09 +00:00
|
|
|
V) VERBOSE='--verbose' VERBOSE_SHORTOPT='-v' QUIET=''
|
2023-10-13 09:51:14 +00:00
|
|
|
[ "$EXACT_OUTPUT" ] || cmdtest_py+=" --verbose"
|
2024-01-19 11:05:09 +00:00
|
|
|
STDOUT_DEVNULL='' STDERR_DEVNULL=''
|
2024-10-18 10:32:15 +00:00
|
|
|
modtest_py="${modtest_py/--quiet/--verbose}"
|
|
|
|
|
daemontest_py="${daemontest_py/--quiet/--verbose}"
|
2022-01-27 11:08:07 +00:00
|
|
|
altcoin_mod_opts="${altcoin_mod_opts/--quiet/--verbose}"
|
2019-11-01 12:24:09 +00:00
|
|
|
tooltest2_py="${tooltest2_py/--quiet/--verbose}"
|
|
|
|
|
gentest_py="${gentest_py/--quiet/--verbose}"
|
|
|
|
|
tooltest_py+=" --verbose"
|
|
|
|
|
mmgen_tool+=" --verbose"
|
2019-10-19 15:22:30 +00:00
|
|
|
objattrtest_py+=" --verbose"
|
2025-01-03 14:23:14 +00:00
|
|
|
scrambletest_py+=" --verbose" ;;
|
2024-01-19 11:05:09 +00:00
|
|
|
X) IN_REEXEC=1 ;;
|
2017-09-26 15:41:11 +03:00
|
|
|
*) exit ;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
2024-12-30 11:31:39 +00:00
|
|
|
in_nix_environment && parity --help >/dev/null 2>&1 || SKIP_PARITY=1
|
|
|
|
|
|
2025-02-15 09:54:19 +00:00
|
|
|
[ "$MMGEN_DISABLE_COLOR" -o ! -t 1 ] || {
|
2021-10-02 17:54:11 +00:00
|
|
|
RED="\e[31;1m" GREEN="\e[32;1m" YELLOW="\e[33;1m" BLUE="\e[34;1m" MAGENTA="\e[35;1m" CYAN="\e[36;1m"
|
|
|
|
|
RESET="\e[0m"
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-19 11:05:09 +00:00
|
|
|
[ "$REEXEC" -a -z "$IN_REEXEC" ] && { do_reexec; exit; }
|
2024-01-26 10:54:03 +00:00
|
|
|
|
|
|
|
|
[ "$exec_prog" ] && { echo "option -e makes no sense without -C, -S, or -T" ; exit; }
|
|
|
|
|
|
2024-01-19 11:05:09 +00:00
|
|
|
[ "$INSTALL_PACKAGE" ] && { install_package; exit; }
|
|
|
|
|
|
2019-05-20 15:44:30 +00:00
|
|
|
[ "$MSYS2" -a ! "$FAST" ] && tooltest2_py+=' --fork'
|
2018-10-31 18:20:59 +00:00
|
|
|
[ "$EXACT_OUTPUT" -o "$VERBOSE" ] || objtest_py+=" -S"
|
|
|
|
|
|
2017-09-26 15:41:11 +03:00
|
|
|
shift $((OPTIND-1))
|
|
|
|
|
|
2020-02-18 20:28:28 +00:00
|
|
|
case $1 in
|
|
|
|
|
'') tests=$dfl_tests ;;
|
|
|
|
|
'default') tests=$dfl_tests ;;
|
|
|
|
|
'extra') tests=$extra_tests ;;
|
2022-05-03 21:01:05 +00:00
|
|
|
'noalt') tests=$noalt_tests
|
|
|
|
|
SKIP_ALT_DEP=1
|
2023-10-13 09:51:14 +00:00
|
|
|
cmdtest_py+=" --no-altcoin"
|
2024-10-18 10:32:15 +00:00
|
|
|
modtest_py+=" --no-altcoin-deps"
|
|
|
|
|
daemontest_py+=" --no-altcoin-deps"
|
2022-05-03 21:01:05 +00:00
|
|
|
scrambletest_py+=" --no-altcoin" ;;
|
2020-02-18 20:28:28 +00:00
|
|
|
'quick') tests=$quick_tests ;;
|
|
|
|
|
'qskip') tests=$qskip_tests ;;
|
|
|
|
|
*) tests="$*" ;;
|
|
|
|
|
esac
|
2020-02-18 14:07:51 +00:00
|
|
|
|
2022-10-05 19:22:42 +00:00
|
|
|
rounds_min=$((rounds / 2))
|
|
|
|
|
for n in 2 5 10 20 50 100 200 500 1000; do
|
|
|
|
|
eval "rounds${n}x=$((rounds*n))"
|
|
|
|
|
done
|
|
|
|
|
|
2022-07-26 14:07:35 +00:00
|
|
|
init_tests
|
2021-10-02 17:54:12 +00:00
|
|
|
|
|
|
|
|
remove_skipped_tests
|
|
|
|
|
|
2022-07-26 14:02:36 +00:00
|
|
|
check_tests
|
2021-10-02 17:54:11 +00:00
|
|
|
|
2024-07-20 16:40:57 +00:00
|
|
|
test/clean.py
|
2023-06-13 18:32:20 +00:00
|
|
|
|
2024-12-30 11:31:40 +00:00
|
|
|
install_secp256k1_mod_maybe
|
|
|
|
|
|
2021-10-02 17:54:11 +00:00
|
|
|
start_time=$(date +%s)
|
|
|
|
|
|
2017-10-28 00:11:00 +03:00
|
|
|
run_tests "$tests"
|
2018-10-31 18:20:59 +00:00
|
|
|
|
2021-10-02 17:54:11 +00:00
|
|
|
elapsed=$(($(date +%s)-start_time))
|
|
|
|
|
elapsed_fmt=$(printf %02d:%02d $((elapsed/60)) $((elapsed%60)))
|
|
|
|
|
|
|
|
|
|
[ "$LIST_CMDS" ] || {
|
2021-10-03 17:40:03 +00:00
|
|
|
if [ "$MMGEN_TEST_SUITE_DETERMINISTIC" ]; then
|
2022-10-25 09:09:43 +00:00
|
|
|
echo -e "\n${GREEN}All OK"
|
2021-10-03 17:40:03 +00:00
|
|
|
else
|
2022-10-25 09:09:43 +00:00
|
|
|
echo -e "\n${GREEN}All OK. Total elapsed time: $elapsed_fmt$RESET"
|
2021-10-03 17:40:03 +00:00
|
|
|
fi
|
2021-10-02 17:54:11 +00:00
|
|
|
}
|