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