mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge #13051: qa: Normalize executable location
fa811b0
qa: Normalize executable location (MarcoFalke)
Pull request description:
This removes the need to override the executable locations by just reading them from the config file. Beside making the code easier to read, running individual test on Windows is now possible by default (without providing further command line arguments).
Note: Of course, it is still possible to manually specify the location through the `BITCOIND` environment variable, e.g. `bitcoin-qt`.
Tree-SHA512: bee6d22246796242d747120ca18aaab089f73067de213c9111182561985c5912228a0b0f7f9eec025ecfdb44db031f15652f30d67c489d481c995bb3232a7ac7
This commit is contained in:
parent
d57503e469
commit
8adbc386a5
@ -4,7 +4,6 @@
|
|||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
"""Test the ZMQ notification interface."""
|
"""Test the ZMQ notification interface."""
|
||||||
import configparser
|
import configparser
|
||||||
import os
|
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
from codecs import encode
|
from codecs import encode
|
||||||
@ -51,8 +50,6 @@ class ZMQTest (BitcoinTestFramework):
|
|||||||
|
|
||||||
# Check that dash has been built with ZMQ enabled.
|
# Check that dash has been built with ZMQ enabled.
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
if not self.options.configfile:
|
|
||||||
self.options.configfile = os.path.abspath(os.path.join(os.path.dirname(__file__), "../config.ini"))
|
|
||||||
config.read_file(open(self.options.configfile))
|
config.read_file(open(self.options.configfile))
|
||||||
|
|
||||||
if not config["components"].getboolean("ENABLE_ZMQ"):
|
if not config["components"].getboolean("ENABLE_ZMQ"):
|
||||||
|
@ -56,12 +56,8 @@ from test_framework.test_framework import BitcoinTestFramework
|
|||||||
from test_framework.util import *
|
from test_framework.util import *
|
||||||
from test_framework.blocktools import create_block, create_coinbase, create_transaction
|
from test_framework.blocktools import create_block, create_coinbase, create_transaction
|
||||||
|
|
||||||
class AcceptBlockTest(BitcoinTestFramework):
|
|
||||||
def add_options(self, parser):
|
|
||||||
parser.add_option("--testbinary", dest="testbinary",
|
|
||||||
default=os.getenv("BITCOIND", "dashd"),
|
|
||||||
help="dashd binary to test")
|
|
||||||
|
|
||||||
|
class AcceptBlockTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.setup_clean_chain = True
|
self.setup_clean_chain = True
|
||||||
self.num_nodes = 2
|
self.num_nodes = 2
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
"""Base class for RPC testing."""
|
"""Base class for RPC testing."""
|
||||||
|
|
||||||
|
import configparser
|
||||||
import copy
|
import copy
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import logging
|
import logging
|
||||||
@ -88,10 +89,10 @@ class BitcoinTestFramework():
|
|||||||
help="Leave dashds and test.* datadir on exit or error")
|
help="Leave dashds and test.* datadir on exit or error")
|
||||||
parser.add_option("--noshutdown", dest="noshutdown", default=False, action="store_true",
|
parser.add_option("--noshutdown", dest="noshutdown", default=False, action="store_true",
|
||||||
help="Don't stop dashds after the test execution")
|
help="Don't stop dashds after the test execution")
|
||||||
parser.add_option("--srcdir", dest="srcdir", default=os.path.normpath(os.path.dirname(os.path.realpath(__file__)) + "/../../../src"),
|
parser.add_option("--srcdir", dest="srcdir", default=os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/../../../src"),
|
||||||
help="Source directory containing dashd/dash-cli (default: %default)")
|
help="Source directory containing dashd/dash-cli (default: %default)")
|
||||||
parser.add_option("--cachedir", dest="cachedir", default=os.path.normpath(os.path.dirname(os.path.realpath(__file__)) + "/../../cache"),
|
parser.add_option("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/../../cache"),
|
||||||
help="Directory for caching pregenerated datadirs")
|
help="Directory for caching pregenerated datadirs (default: %default)")
|
||||||
parser.add_option("--tmpdir", dest="tmpdir", help="Root directory for datadirs")
|
parser.add_option("--tmpdir", dest="tmpdir", help="Root directory for datadirs")
|
||||||
parser.add_option("-l", "--loglevel", dest="loglevel", default="INFO",
|
parser.add_option("-l", "--loglevel", dest="loglevel", default="INFO",
|
||||||
help="log events at this level and higher to the console. Can be set to DEBUG, INFO, WARNING, ERROR or CRITICAL. Passing --loglevel DEBUG will output all logs to console. Note that logs at all levels are always written to the test_framework.log file in the temporary test directory.")
|
help="log events at this level and higher to the console. Can be set to DEBUG, INFO, WARNING, ERROR or CRITICAL. Passing --loglevel DEBUG will output all logs to console. Note that logs at all levels are always written to the test_framework.log file in the temporary test directory.")
|
||||||
@ -102,7 +103,8 @@ class BitcoinTestFramework():
|
|||||||
parser.add_option("--coveragedir", dest="coveragedir",
|
parser.add_option("--coveragedir", dest="coveragedir",
|
||||||
help="Write tested RPC commands into this directory")
|
help="Write tested RPC commands into this directory")
|
||||||
parser.add_option("--configfile", dest="configfile",
|
parser.add_option("--configfile", dest="configfile",
|
||||||
help="Location of the test framework config file")
|
default=os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/../../config.ini"),
|
||||||
|
help="Location of the test framework config file (default: %default)")
|
||||||
parser.add_option("--pdbonfailure", dest="pdbonfailure", default=False, action="store_true",
|
parser.add_option("--pdbonfailure", dest="pdbonfailure", default=False, action="store_true",
|
||||||
help="Attach a python debugger if test fails")
|
help="Attach a python debugger if test fails")
|
||||||
parser.add_option("--usecli", dest="usecli", default=False, action="store_true",
|
parser.add_option("--usecli", dest="usecli", default=False, action="store_true",
|
||||||
@ -129,6 +131,11 @@ class BitcoinTestFramework():
|
|||||||
|
|
||||||
self.options.cachedir = os.path.abspath(self.options.cachedir)
|
self.options.cachedir = os.path.abspath(self.options.cachedir)
|
||||||
|
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read_file(open(self.options.configfile))
|
||||||
|
self.options.bitcoind = os.getenv("BITCOIND", default=config["environment"]["BUILDDIR"] + '/src/bitcoind' + config["environment"]["EXEEXT"])
|
||||||
|
self.options.bitcoincli = os.getenv("BITCOINCLI", default=config["environment"]["BUILDDIR"] + '/src/bitcoin-cli' + config["environment"]["EXEEXT"])
|
||||||
|
|
||||||
self.extra_args_from_options = self.options.dashd_extra_args
|
self.extra_args_from_options = self.options.dashd_extra_args
|
||||||
|
|
||||||
# Set up temp directory and start logging
|
# Set up temp directory and start logging
|
||||||
@ -257,13 +264,13 @@ class BitcoinTestFramework():
|
|||||||
if extra_args is None:
|
if extra_args is None:
|
||||||
extra_args = [[]] * num_nodes
|
extra_args = [[]] * num_nodes
|
||||||
if binary is None:
|
if binary is None:
|
||||||
binary = [None] * num_nodes
|
binary = [self.options.bitcoind] * num_nodes
|
||||||
assert_equal(len(extra_confs), num_nodes)
|
assert_equal(len(extra_confs), num_nodes)
|
||||||
assert_equal(len(extra_args), num_nodes)
|
assert_equal(len(extra_args), num_nodes)
|
||||||
assert_equal(len(binary), num_nodes)
|
assert_equal(len(binary), num_nodes)
|
||||||
old_num_nodes = len(self.nodes)
|
old_num_nodes = len(self.nodes)
|
||||||
for i in range(num_nodes):
|
for i in range(num_nodes):
|
||||||
self.nodes.append(TestNode(old_num_nodes + i, self.options.tmpdir, self.extra_args_from_options, rpchost=rpchost, timewait=timewait, binary=binary[i], stderr=stderr, mocktime=self.mocktime, coverage_dir=self.options.coveragedir, extra_conf=extra_confs[i], extra_args=extra_args[i], use_cli=self.options.usecli))
|
self.nodes.append(TestNode(old_num_nodes + i, self.options.tmpdir, self.extra_args_from_options, rpchost=rpchost, timewait=timewait, bitcoind=binary[i], bitcoin_cli=self.options.bitcoincli, stderr=stderr, mocktime=self.mocktime, coverage_dir=self.options.coveragedir, extra_conf=extra_confs[i], extra_args=extra_args[i], use_cli=self.options.usecli))
|
||||||
|
|
||||||
def start_node(self, i, *args, **kwargs):
|
def start_node(self, i, *args, **kwargs):
|
||||||
"""Start a dashd"""
|
"""Start a dashd"""
|
||||||
@ -450,12 +457,12 @@ class BitcoinTestFramework():
|
|||||||
self.set_genesis_mocktime()
|
self.set_genesis_mocktime()
|
||||||
for i in range(MAX_NODES):
|
for i in range(MAX_NODES):
|
||||||
datadir = initialize_datadir(self.options.cachedir, i)
|
datadir = initialize_datadir(self.options.cachedir, i)
|
||||||
args = [os.getenv("DASHD", "dashd"), "-server", "-keypool=1", "-datadir=" + datadir, "-discover=0", "-mocktime="+str(GENESISTIME)]
|
args = [self.options.bitcoind, "-server", "-keypool=1", "-datadir=" + datadir, "-discover=0", "-mocktime="+str(GENESISTIME)]
|
||||||
if i > 0:
|
if i > 0:
|
||||||
args.append("-connect=127.0.0.1:" + str(p2p_port(0)))
|
args.append("-connect=127.0.0.1:" + str(p2p_port(0)))
|
||||||
if extra_args is not None:
|
if extra_args is not None:
|
||||||
args.extend(extra_args)
|
args.extend(extra_args)
|
||||||
self.nodes.append(TestNode(i, self.options.cachedir, extra_conf=["bind=127.0.0.1"], extra_args=[],extra_args_from_options=self.extra_args_from_options, rpchost=None, timewait=None, binary=None, stderr=stderr, mocktime=self.mocktime, coverage_dir=None))
|
self.nodes.append(TestNode(i, self.options.cachedir, extra_conf=["bind=127.0.0.1"], extra_args=[],extra_args_from_options=self.extra_args_from_options, rpchost=None, timewait=None, bitcoind=self.options.bitcoind, bitcoin_cli=self.options.bitcoincli, stderr=stderr, mocktime=self.mocktime, coverage_dir=None))
|
||||||
self.nodes[i].args = args
|
self.nodes[i].args = args
|
||||||
self.start_node(i)
|
self.start_node(i)
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ import errno
|
|||||||
import http.client
|
import http.client
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
@ -46,7 +45,7 @@ class TestNode():
|
|||||||
To make things easier for the test writer, any unrecognised messages will
|
To make things easier for the test writer, any unrecognised messages will
|
||||||
be dispatched to the RPC connection."""
|
be dispatched to the RPC connection."""
|
||||||
|
|
||||||
def __init__(self, i, dirname, extra_args_from_options, rpchost, timewait, binary, stderr, mocktime, coverage_dir, extra_conf=None, extra_args=None, use_cli=False):
|
def __init__(self, i, dirname, extra_args_from_options, rpchost, timewait, bitcoind, bitcoin_cli, stderr, mocktime, coverage_dir, extra_conf=None, extra_args=None, use_cli=False):
|
||||||
self.index = i
|
self.index = i
|
||||||
self.datadir = os.path.join(dirname, "node" + str(i))
|
self.datadir = os.path.join(dirname, "node" + str(i))
|
||||||
self.rpchost = rpchost
|
self.rpchost = rpchost
|
||||||
@ -55,10 +54,7 @@ class TestNode():
|
|||||||
else:
|
else:
|
||||||
# Wait for up to 60 seconds for the RPC server to respond
|
# Wait for up to 60 seconds for the RPC server to respond
|
||||||
self.rpc_timeout = 60
|
self.rpc_timeout = 60
|
||||||
if binary is None:
|
self.binary = bitcoind
|
||||||
self.binary = os.getenv("BITCOIND", "dashd")
|
|
||||||
else:
|
|
||||||
self.binary = binary
|
|
||||||
self.stderr = stderr
|
self.stderr = stderr
|
||||||
self.coverage_dir = coverage_dir
|
self.coverage_dir = coverage_dir
|
||||||
self.mocktime = mocktime
|
self.mocktime = mocktime
|
||||||
@ -70,7 +66,7 @@ class TestNode():
|
|||||||
self.extra_args_from_options = extra_args_from_options
|
self.extra_args_from_options = extra_args_from_options
|
||||||
self.args = [self.binary, "-datadir=" + self.datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-logtimemicros", "-debug", "-debugexclude=libevent", "-debugexclude=leveldb", "-mocktime=" + str(mocktime), "-uacomment=testnode%d" % i]
|
self.args = [self.binary, "-datadir=" + self.datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-logtimemicros", "-debug", "-debugexclude=libevent", "-debugexclude=leveldb", "-mocktime=" + str(mocktime), "-uacomment=testnode%d" % i]
|
||||||
|
|
||||||
self.cli = TestNodeCLI(os.getenv("BITCOINCLI", "dash-cli"), self.datadir)
|
self.cli = TestNodeCLI(bitcoin_cli, self.datadir)
|
||||||
self.use_cli = use_cli
|
self.use_cli = use_cli
|
||||||
|
|
||||||
# Don't try auto backups (they fail a lot when running tests)
|
# Don't try auto backups (they fail a lot when running tests)
|
||||||
|
@ -303,7 +303,6 @@ def main():
|
|||||||
test_list=test_list,
|
test_list=test_list,
|
||||||
src_dir=config["environment"]["SRCDIR"],
|
src_dir=config["environment"]["SRCDIR"],
|
||||||
build_dir=config["environment"]["BUILDDIR"],
|
build_dir=config["environment"]["BUILDDIR"],
|
||||||
exeext=config["environment"]["EXEEXT"],
|
|
||||||
tmpdir=tmpdir,
|
tmpdir=tmpdir,
|
||||||
jobs=args.jobs,
|
jobs=args.jobs,
|
||||||
enable_coverage=args.coverage,
|
enable_coverage=args.coverage,
|
||||||
@ -313,7 +312,7 @@ def main():
|
|||||||
combined_logs_len=args.combinedlogslen,
|
combined_logs_len=args.combinedlogslen,
|
||||||
)
|
)
|
||||||
|
|
||||||
def run_tests(*, test_list, src_dir, build_dir, exeext, tmpdir, jobs=1, enable_coverage=False, args=None, failfast=False, runs_ci, combined_logs_len=0):
|
def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=False, args=None, failfast=False, runs_ci, combined_logs_len=0):
|
||||||
args = args or []
|
args = args or []
|
||||||
|
|
||||||
# Warn if dashd is already running (unix only)
|
# Warn if dashd is already running (unix only)
|
||||||
@ -329,12 +328,6 @@ def run_tests(*, test_list, src_dir, build_dir, exeext, tmpdir, jobs=1, enable_c
|
|||||||
if os.path.isdir(cache_dir):
|
if os.path.isdir(cache_dir):
|
||||||
print("%sWARNING!%s There is a cache directory here: %s. If tests fail unexpectedly, try deleting the cache directory." % (BOLD[1], BOLD[0], cache_dir))
|
print("%sWARNING!%s There is a cache directory here: %s. If tests fail unexpectedly, try deleting the cache directory." % (BOLD[1], BOLD[0], cache_dir))
|
||||||
|
|
||||||
|
|
||||||
#Set env vars
|
|
||||||
if "BITCOIND" not in os.environ:
|
|
||||||
os.environ["BITCOIND"] = build_dir + '/src/dashd' + exeext
|
|
||||||
os.environ["BITCOINCLI"] = build_dir + '/src/dash-cli' + exeext
|
|
||||||
|
|
||||||
tests_dir = src_dir + '/test/functional/'
|
tests_dir = src_dir + '/test/functional/'
|
||||||
|
|
||||||
flags = ["--srcdir={}/src".format(build_dir)] + args
|
flags = ["--srcdir={}/src".format(build_dir)] + args
|
||||||
|
Loading…
Reference in New Issue
Block a user