Skip to content

Commit fa65bc0

Browse files
author
MarcoFalke
committed
test: Run bench sanity checks in parallel with functional tests
1 parent fa9fdbc commit fa65bc0

File tree

4 files changed

+62
-7
lines changed

4 files changed

+62
-7
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,6 @@ jobs:
484484
./src/univalue/object.exe
485485
./src/univalue/unitester.exe
486486
487-
- name: Run benchmarks
488-
run: ./bin/bench_bitcoin.exe -sanity-check
489-
490487
- name: Adjust paths in test/config.ini
491488
shell: pwsh
492489
run: |

src/bench/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,4 @@ if(ENABLE_WALLET)
8484
target_link_libraries(bench_bitcoin bitcoin_wallet)
8585
endif()
8686

87-
add_test(NAME bench_sanity_check
88-
COMMAND bench_bitcoin -sanity-check
89-
)
90-
9187
install_binary_component(bench_bitcoin INTERNAL)

test/functional/test_runner.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
import tempfile
3030
import re
3131
import logging
32+
from test_framework.util import (
33+
Binaries,
34+
export_env_build_path,
35+
get_binary_paths,
36+
)
3237

3338
# Minimum amount of space to run the tests.
3439
MIN_FREE_SPACE = 1.1 * 1024 * 1024 * 1024
@@ -87,7 +92,12 @@
8792
'feature_index_prune.py',
8893
]
8994

95+
# Special script to run each bench sanity check
96+
TOOL_BENCH_SANITY_CHECK = "tool_bench_sanity_check.py"
97+
9098
BASE_SCRIPTS = [
99+
# Special scripts that are "expanded" later
100+
TOOL_BENCH_SANITY_CHECK,
91101
# Scripts that are run by default.
92102
# Longest test should go first, to favor running tests in parallel
93103
# vv Tests less than 5m vv
@@ -457,6 +467,8 @@ def main():
457467
print("Re-compile with the -DBUILD_DAEMON=ON build option")
458468
sys.exit(1)
459469

470+
export_env_build_path(config)
471+
460472
# Build tests
461473
test_list = deque()
462474
if tests:
@@ -511,6 +523,15 @@ def remove_tests(exclude_list):
511523
# Exclude all variants of a test
512524
remove_tests([test for test in test_list if test.split('.py')[0] == exclude_test.split('.py')[0]])
513525

526+
if config["components"].getboolean("BUILD_BENCH") and TOOL_BENCH_SANITY_CHECK in test_list:
527+
# Remove it, and expand it for each bench in the list
528+
test_list.remove(TOOL_BENCH_SANITY_CHECK)
529+
bench_cmd = Binaries(get_binary_paths(config), bin_dir=None).bench_argv() + ["-list"]
530+
bench_list = subprocess.check_output(bench_cmd, text=True).splitlines()
531+
bench_list = [f"{TOOL_BENCH_SANITY_CHECK} --bench={b}" for b in bench_list]
532+
# Start with special scripts (variable, unknown runtime)
533+
test_list.extendleft(reversed(bench_list))
534+
514535
if args.filter:
515536
test_list = deque(filter(re.compile(args.filter).search, test_list))
516537

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or https://opensource.org/license/mit/.
5+
"""Special script to run each bench sanity check
6+
"""
7+
import shlex
8+
import subprocess
9+
10+
from test_framework.test_framework import BitcoinTestFramework
11+
12+
13+
class BenchSanityCheck(BitcoinTestFramework):
14+
def set_test_params(self):
15+
self.num_nodes = 0 # No node/datadir needed
16+
17+
def setup_network(self):
18+
pass
19+
20+
def skip_test_if_missing_module(self):
21+
self.skip_if_no_bitcoin_bench()
22+
23+
def add_options(self, parser):
24+
parser.add_argument(
25+
"--bench",
26+
default=".*",
27+
help="Regex to filter the bench to run (default=%(default)s)",
28+
)
29+
30+
def run_test(self):
31+
cmd = self.get_binaries().bench_argv() + [
32+
f"-filter={self.options.bench}",
33+
"-sanity-check",
34+
]
35+
self.log.info(f"Starting: {shlex.join(cmd)}")
36+
subprocess.run(cmd, check=True)
37+
self.log.info("Success!")
38+
39+
40+
if __name__ == "__main__":
41+
BenchSanityCheck(__file__).main()

0 commit comments

Comments
 (0)