/ test / functional / tool_bench_sanity_check.py
tool_bench_sanity_check.py
 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()