mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Merge #10053: [test] Allow functional test cases to be skipped
0c1ade6
Skip rpcbind_test if OS/network requirements are not met. (John Newbery)232b666
Allow test cases to be skipped (John Newbery) Tree-SHA512: d90c956ba6e27e53f422cba6267bdcc60faef9370a7e66b7f6480137f84d9a813442ac477b20fbbc540be2b4636928be910c46e221570ab3b9a5b9f0f11f7fc8
This commit is contained in:
parent
9f07f489de
commit
ae05068c5d
@ -4,6 +4,9 @@
|
|||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
"""Test running bitcoind with the -rpcbind and -rpcallowip options."""
|
"""Test running bitcoind with the -rpcbind and -rpcallowip options."""
|
||||||
|
|
||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import *
|
from test_framework.util import *
|
||||||
from test_framework.netutil import *
|
from test_framework.netutil import *
|
||||||
@ -52,7 +55,9 @@ class RPCBindTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
# due to OS-specific network stats queries, this test works only on Linux
|
# due to OS-specific network stats queries, this test works only on Linux
|
||||||
assert(sys.platform.startswith('linux'))
|
if not sys.platform.startswith('linux'):
|
||||||
|
self.log.warning("This test can only be run on linux. Skipping test.")
|
||||||
|
sys.exit(self.TEST_EXIT_SKIPPED)
|
||||||
# find the first non-loopback interface for testing
|
# find the first non-loopback interface for testing
|
||||||
non_loopback_ip = None
|
non_loopback_ip = None
|
||||||
for name,ip in all_interfaces():
|
for name,ip in all_interfaces():
|
||||||
@ -60,7 +65,16 @@ class RPCBindTest(BitcoinTestFramework):
|
|||||||
non_loopback_ip = ip
|
non_loopback_ip = ip
|
||||||
break
|
break
|
||||||
if non_loopback_ip is None:
|
if non_loopback_ip is None:
|
||||||
assert(not 'This test requires at least one non-loopback IPv4 interface')
|
self.log.warning("This test requires at least one non-loopback IPv4 interface. Skipping test.")
|
||||||
|
sys.exit(self.TEST_EXIT_SKIPPED)
|
||||||
|
try:
|
||||||
|
s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
|
||||||
|
s.connect(("::1",1))
|
||||||
|
s.close
|
||||||
|
except OSError:
|
||||||
|
self.log.warning("This test requires IPv6 support. Skipping test.")
|
||||||
|
sys.exit(self.TEST_EXIT_SKIPPED)
|
||||||
|
|
||||||
self.log.info("Using interface %s for testing" % non_loopback_ip)
|
self.log.info("Using interface %s for testing" % non_loopback_ip)
|
||||||
|
|
||||||
defaultport = rpc_port(0)
|
defaultport = rpc_port(0)
|
||||||
|
@ -41,9 +41,12 @@ from .util import (
|
|||||||
copy_datadir)
|
copy_datadir)
|
||||||
from .authproxy import JSONRPCException
|
from .authproxy import JSONRPCException
|
||||||
|
|
||||||
|
|
||||||
class BitcoinTestFramework(object):
|
class BitcoinTestFramework(object):
|
||||||
|
|
||||||
|
TEST_EXIT_PASSED = 0
|
||||||
|
TEST_EXIT_FAILED = 1
|
||||||
|
TEST_EXIT_SKIPPED = 77
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.num_nodes = 4
|
self.num_nodes = 4
|
||||||
self.setup_clean_chain = False
|
self.setup_clean_chain = False
|
||||||
@ -202,11 +205,11 @@ class BitcoinTestFramework(object):
|
|||||||
print("".join(deque(open(f), MAX_LINES_TO_PRINT)))
|
print("".join(deque(open(f), MAX_LINES_TO_PRINT)))
|
||||||
if success:
|
if success:
|
||||||
self.log.info("Tests successful")
|
self.log.info("Tests successful")
|
||||||
sys.exit(0)
|
sys.exit(self.TEST_EXIT_PASSED)
|
||||||
else:
|
else:
|
||||||
self.log.error("Test failed. Test logging available at %s/test_framework.log", self.options.tmpdir)
|
self.log.error("Test failed. Test logging available at %s/test_framework.log", self.options.tmpdir)
|
||||||
logging.shutdown()
|
logging.shutdown()
|
||||||
sys.exit(1)
|
sys.exit(self.TEST_EXIT_FAILED)
|
||||||
|
|
||||||
def _start_logging(self):
|
def _start_logging(self):
|
||||||
# Add logger and logging handlers
|
# Add logger and logging handlers
|
||||||
|
@ -24,6 +24,9 @@ import subprocess
|
|||||||
import tempfile
|
import tempfile
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
TEST_EXIT_PASSED = 0
|
||||||
|
TEST_EXIT_SKIPPED = 77
|
||||||
|
|
||||||
BASE_SCRIPTS= [
|
BASE_SCRIPTS= [
|
||||||
# Scripts that are run by the travis build process.
|
# Scripts that are run by the travis build process.
|
||||||
# Longest test should go first, to favor running tests in parallel
|
# Longest test should go first, to favor running tests in parallel
|
||||||
@ -258,20 +261,20 @@ def run_tests(test_list, src_dir, build_dir, exeext, jobs=1, enable_coverage=Fal
|
|||||||
job_queue = TestHandler(jobs, tests_dir, test_list, flags)
|
job_queue = TestHandler(jobs, tests_dir, test_list, flags)
|
||||||
|
|
||||||
max_len_name = len(max(test_list, key=len))
|
max_len_name = len(max(test_list, key=len))
|
||||||
results = BOLD[1] + "%s | %s | %s\n\n" % ("TEST".ljust(max_len_name), "PASSED", "DURATION") + BOLD[0]
|
results = BOLD[1] + "%s | %s | %s\n\n" % ("TEST".ljust(max_len_name), "STATUS ", "DURATION") + BOLD[0]
|
||||||
for _ in range(len(test_list)):
|
for _ in range(len(test_list)):
|
||||||
(name, stdout, stderr, passed, duration) = job_queue.get_next()
|
(name, stdout, stderr, status, duration) = job_queue.get_next()
|
||||||
all_passed = all_passed and passed
|
all_passed = all_passed and status != "Failed"
|
||||||
time_sum += duration
|
time_sum += duration
|
||||||
|
|
||||||
print('\n' + BOLD[1] + name + BOLD[0] + ":")
|
print('\n' + BOLD[1] + name + BOLD[0] + ":")
|
||||||
print('' if passed else stdout + '\n', end='')
|
print('' if status == "Passed" else stdout + '\n', end='')
|
||||||
print('' if stderr == '' else 'stderr:\n' + stderr + '\n', end='')
|
print('' if stderr == '' else 'stderr:\n' + stderr + '\n', end='')
|
||||||
print("Pass: %s%s%s, Duration: %s s\n" % (BOLD[1], passed, BOLD[0], duration))
|
print("Status: %s%s%s, Duration: %s s\n" % (BOLD[1], status, BOLD[0], duration))
|
||||||
|
|
||||||
results += "%s | %s | %s s\n" % (name.ljust(max_len_name), str(passed).ljust(6), duration)
|
results += "%s | %s | %s s\n" % (name.ljust(max_len_name), status.ljust(7), duration)
|
||||||
|
|
||||||
results += BOLD[1] + "\n%s | %s | %s s (accumulated)" % ("ALL".ljust(max_len_name), str(all_passed).ljust(6), time_sum) + BOLD[0]
|
results += BOLD[1] + "\n%s | %s | %s s (accumulated)" % ("ALL".ljust(max_len_name), str(all_passed).ljust(7), time_sum) + BOLD[0]
|
||||||
print(results)
|
print(results)
|
||||||
print("\nRuntime: %s s" % (int(time.time() - time0)))
|
print("\nRuntime: %s s" % (int(time.time() - time0)))
|
||||||
|
|
||||||
@ -328,10 +331,15 @@ class TestHandler:
|
|||||||
log_out.seek(0), log_err.seek(0)
|
log_out.seek(0), log_err.seek(0)
|
||||||
[stdout, stderr] = [l.read().decode('utf-8') for l in (log_out, log_err)]
|
[stdout, stderr] = [l.read().decode('utf-8') for l in (log_out, log_err)]
|
||||||
log_out.close(), log_err.close()
|
log_out.close(), log_err.close()
|
||||||
passed = stderr == "" and proc.returncode == 0
|
if proc.returncode == TEST_EXIT_PASSED and stderr == "":
|
||||||
|
status = "Passed"
|
||||||
|
elif proc.returncode == TEST_EXIT_SKIPPED:
|
||||||
|
status = "Skipped"
|
||||||
|
else:
|
||||||
|
status = "Failed"
|
||||||
self.num_running -= 1
|
self.num_running -= 1
|
||||||
self.jobs.remove(j)
|
self.jobs.remove(j)
|
||||||
return name, stdout, stderr, passed, int(time.time() - time0)
|
return name, stdout, stderr, status, int(time.time() - time0)
|
||||||
print('.', end='', flush=True)
|
print('.', end='', flush=True)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user