2016-06-26 09:47:03 -04:00
|
|
|
#!/usr/bin/env python
|
2016-11-06 14:12:50 -03:00
|
|
|
# Copyright 2014 BitPay Inc.
|
2016-11-02 19:56:32 -03:00
|
|
|
# Copyright 2016 The Bitcoin Core developers
|
2014-12-13 01:09:33 -03:00
|
|
|
# Distributed under the MIT software license, see the accompanying
|
2014-08-19 10:28:58 -04:00
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2016-03-20 14:51:52 -03:00
|
|
|
from __future__ import division,print_function,unicode_literals
|
2014-08-19 10:28:58 -04:00
|
|
|
import os
|
2016-10-24 08:49:25 -03:00
|
|
|
import sys
|
2014-08-19 10:28:58 -04:00
|
|
|
import bctest
|
2014-09-30 17:05:27 -03:00
|
|
|
import buildenv
|
2016-09-28 11:25:51 -03:00
|
|
|
import argparse
|
2016-10-24 08:49:25 -03:00
|
|
|
import logging
|
2014-08-19 10:28:58 -04:00
|
|
|
|
2016-09-28 11:25:51 -03:00
|
|
|
help_text="""Test framework for bitcoin utils.
|
|
|
|
|
|
|
|
Runs automatically during `make check`.
|
|
|
|
|
2016-11-28 05:19:05 -03:00
|
|
|
Can also be run manually from the src directory by specifying the source directory:
|
2014-08-19 10:28:58 -04:00
|
|
|
|
2016-11-02 19:56:32 -03:00
|
|
|
test/bitcoin-util-test.py --srcdir='srcdir' [--verbose]
|
2016-09-28 11:25:51 -03:00
|
|
|
"""
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2016-11-02 19:56:32 -03: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 11:25:51 -03:00
|
|
|
try:
|
|
|
|
srcdir = os.environ["srcdir"]
|
2016-10-24 08:49:25 -03:00
|
|
|
verbose = False
|
2016-09-28 11:25:51 -03:00
|
|
|
except:
|
|
|
|
parser = argparse.ArgumentParser(description=help_text)
|
|
|
|
parser.add_argument('-s', '--srcdir')
|
2016-10-04 14:02:06 -03:00
|
|
|
parser.add_argument('-v', '--verbose', action='store_true')
|
2016-09-28 11:25:51 -03:00
|
|
|
args = parser.parse_args()
|
|
|
|
srcdir = args.srcdir
|
2016-10-04 14:02:06 -03:00
|
|
|
verbose = args.verbose
|
2016-10-24 08:49:25 -03: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)
|