2016-06-26 15:47:03 +02:00
|
|
|
#!/usr/bin/env python
|
2016-11-06 18:12:50 +01:00
|
|
|
# Copyright 2014 BitPay Inc.
|
2016-11-02 23:56:32 +01:00
|
|
|
# Copyright 2016 The Bitcoin Core developers
|
2014-12-13 05:09:33 +01:00
|
|
|
# Distributed under the MIT software license, see the accompanying
|
2014-08-19 16:28:58 +02:00
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2016-03-20 18:51:52 +01:00
|
|
|
from __future__ import division,print_function,unicode_literals
|
2014-08-19 16:28:58 +02:00
|
|
|
import os
|
2016-10-24 13:49:25 +02:00
|
|
|
import sys
|
2014-08-19 16:28:58 +02:00
|
|
|
import bctest
|
2014-09-30 22:05:27 +02:00
|
|
|
import buildenv
|
2016-09-28 16:25:51 +02:00
|
|
|
import argparse
|
2016-10-24 13:49:25 +02:00
|
|
|
import logging
|
2014-08-19 16:28:58 +02:00
|
|
|
|
2016-09-28 16:25:51 +02:00
|
|
|
help_text="""Test framework for bitcoin utils.
|
|
|
|
|
|
|
|
Runs automatically during `make check`.
|
|
|
|
|
|
|
|
Can also be run manually from the src directory by specifiying the source directory:
|
2014-08-19 16:28:58 +02:00
|
|
|
|
2016-11-02 23:56:32 +01:00
|
|
|
test/bitcoin-util-test.py --srcdir='srcdir' [--verbose]
|
2016-09-28 16:25:51 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2016-11-02 23:56:32 +01:00
|
|
|
# Try to get the source directory from the environment variables. This will
|
|
|
|
# be set for `make check` automated runs. If environment variable is not set,
|
|
|
|
# then get the source directory from command line args.
|
2016-09-28 16:25:51 +02:00
|
|
|
try:
|
|
|
|
srcdir = os.environ["srcdir"]
|
2016-10-24 13:49:25 +02:00
|
|
|
verbose = False
|
2016-09-28 16:25:51 +02:00
|
|
|
except:
|
|
|
|
parser = argparse.ArgumentParser(description=help_text)
|
|
|
|
parser.add_argument('-s', '--srcdir')
|
2016-10-04 19:02:06 +02:00
|
|
|
parser.add_argument('-v', '--verbose', action='store_true')
|
2016-09-28 16:25:51 +02:00
|
|
|
args = parser.parse_args()
|
|
|
|
srcdir = args.srcdir
|
2016-10-04 19:02:06 +02:00
|
|
|
verbose = args.verbose
|
2016-10-24 13:49:25 +02:00
|
|
|
|
|
|
|
if verbose:
|
|
|
|
level = logging.DEBUG
|
|
|
|
else:
|
|
|
|
level = logging.ERROR
|
|
|
|
formatter = '%(asctime)s - %(levelname)s - %(message)s'
|
|
|
|
# Add the format/level to the logger
|
|
|
|
logging.basicConfig(format = formatter, level=level)
|
|
|
|
|
|
|
|
bctest.bctester(srcdir + "/test/data", "bitcoin-util-test.json", buildenv)
|