2016-06-26 16:47:03 +03:00
|
|
|
#!/usr/bin/env python
|
2016-11-06 10:12:50 -07:00
|
|
|
# Copyright 2014 BitPay Inc.
|
2016-11-02 22:56:32 +00:00
|
|
|
# Copyright 2016 The Bitcoin Core developers
|
2014-12-13 12:09:33 +08: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 17:51:52 +00:00
|
|
|
from __future__ import division,print_function,unicode_literals
|
2014-08-19 10:28:58 -04:00
|
|
|
import os
|
2016-10-24 12:49:25 +01:00
|
|
|
import sys
|
2014-08-19 10:28:58 -04:00
|
|
|
import bctest
|
2014-09-30 16:05:27 -04:00
|
|
|
import buildenv
|
2016-09-28 10:25:51 -04:00
|
|
|
import argparse
|
2016-10-24 12:49:25 +01:00
|
|
|
import logging
|
2014-08-19 10:28:58 -04:00
|
|
|
|
2016-09-28 10:25:51 -04:00
|
|
|
help_text="""Test framework for bitcoin utils.
|
|
|
|
|
|
|
|
Runs automatically during `make check`.
|
|
|
|
|
2016-11-28 15:19:05 +07: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 22:56:32 +00:00
|
|
|
test/bitcoin-util-test.py --srcdir='srcdir' [--verbose]
|
2016-09-28 10:25:51 -04:00
|
|
|
"""
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2016-11-02 22:56:32 +00: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 10:25:51 -04:00
|
|
|
try:
|
|
|
|
srcdir = os.environ["srcdir"]
|
2016-10-24 12:49:25 +01:00
|
|
|
verbose = False
|
2016-09-28 10:25:51 -04:00
|
|
|
except:
|
|
|
|
parser = argparse.ArgumentParser(description=help_text)
|
|
|
|
parser.add_argument('-s', '--srcdir')
|
2016-10-04 13:02:06 -04:00
|
|
|
parser.add_argument('-v', '--verbose', action='store_true')
|
2016-09-28 10:25:51 -04:00
|
|
|
args = parser.parse_args()
|
|
|
|
srcdir = args.srcdir
|
2016-10-04 13:02:06 -04:00
|
|
|
verbose = args.verbose
|
2016-10-24 12:49:25 +01: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)
|