|
29 | 29 |
|
30 | 30 | os.environ["REQUIRE_WALLET_TYPE_SET"] = "1"
|
31 | 31 |
|
| 32 | +# Minimum amount of space to run the tests. |
| 33 | +MIN_FREE_SPACE = 1.1 * 1024 * 1024 * 1024 |
| 34 | +# Additional space to run an extra job. |
| 35 | +ADDITIONAL_SPACE_PER_JOB = 100 * 1024 * 1024 |
| 36 | +# Minimum amount of space required for --nocleanup |
| 37 | +MIN_NO_CLEANUP_SPACE = 12 * 1024 * 1024 * 1024 |
| 38 | + |
32 | 39 | # Formatting. Default colors to empty strings.
|
33 | 40 | DEFAULT, BOLD, GREEN, RED = ("", ""), ("", ""), ("", ""), ("", "")
|
34 | 41 | try:
|
@@ -424,6 +431,8 @@ def main():
|
424 | 431 | parser.add_argument('--tmpdirprefix', '-t', default=tempfile.gettempdir(), help="Root directory for datadirs")
|
425 | 432 | parser.add_argument('--failfast', '-F', action='store_true', help='stop execution after the first test failure')
|
426 | 433 | parser.add_argument('--filter', help='filter scripts to run by regular expression')
|
| 434 | + parser.add_argument("--nocleanup", dest="nocleanup", default=False, action="store_true", |
| 435 | + help="Leave bitcoinds and test.* datadir on exit or error") |
427 | 436 |
|
428 | 437 |
|
429 | 438 | args, unknown_args = parser.parse_known_args()
|
@@ -518,6 +527,13 @@ def main():
|
518 | 527 | subprocess.check_call([sys.executable, os.path.join(config["environment"]["SRCDIR"], 'test', 'functional', test_list[0].split()[0]), '-h'])
|
519 | 528 | sys.exit(0)
|
520 | 529 |
|
| 530 | + # Warn if there is not enough space on tmpdir to run the tests with --nocleanup |
| 531 | + if args.nocleanup: |
| 532 | + if shutil.disk_usage(tmpdir).free < MIN_NO_CLEANUP_SPACE: |
| 533 | + print(f"{BOLD[1]}WARNING!{BOLD[0]} There may be insufficient free space in {tmpdir} to run the functional test suite with --nocleanup. " |
| 534 | + f"A minimum of {MIN_NO_CLEANUP_SPACE // (1024 * 1024 * 1024)} GB of free space is required.") |
| 535 | + passon_args.append("--nocleanup") |
| 536 | + |
521 | 537 | check_script_list(src_dir=config["environment"]["SRCDIR"], fail_on_warn=args.ci)
|
522 | 538 | check_script_prefixes()
|
523 | 539 |
|
@@ -554,6 +570,11 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=
|
554 | 570 | if os.path.isdir(cache_dir):
|
555 | 571 | 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))
|
556 | 572 |
|
| 573 | + # Warn if there is not enough space on the testing dir |
| 574 | + min_space = MIN_FREE_SPACE + (jobs - 1) * ADDITIONAL_SPACE_PER_JOB |
| 575 | + if shutil.disk_usage(tmpdir).free < min_space: |
| 576 | + print(f"{BOLD[1]}WARNING!{BOLD[0]} There may be insufficient free space in {tmpdir} to run the Bitcoin functional test suite. " |
| 577 | + f"Running the test suite with fewer than {min_space // (1024 * 1024)} MB of free space might cause tests to fail.") |
557 | 578 |
|
558 | 579 | tests_dir = src_dir + '/test/functional/'
|
559 | 580 | # This allows `test_runner.py` to work from an out-of-source build directory using a symlink,
|
@@ -623,6 +644,11 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=
|
623 | 644 | logging.debug("Early exiting after test failure")
|
624 | 645 | break
|
625 | 646 |
|
| 647 | + if "[Errno 28] No space left on device" in stdout: |
| 648 | + sys.exit(f"Early exiting after test failure due to insuffient free space in {tmpdir}\n" |
| 649 | + f"Test execution data left in {tmpdir}.\n" |
| 650 | + f"Additional storage is needed to execute testing.") |
| 651 | + |
626 | 652 | print_results(test_results, max_len_name, (int(time.time() - start_time)))
|
627 | 653 |
|
628 | 654 | if coverage:
|
|
0 commit comments