mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-09 19:37:27 -03:00
test: checks for tracepoint tests
For testing the USDT tracepoint API in the functional tests we require: - that we are on a Linux system* - that Bitcoin Core is compiled with tracepoints - that bcc and the the Python bcc module [0] is installed - that we run the tests with the required permissions** otherwise we skip the tests. *: We currently only support tracepoints on Linux. Tracepoints are not compiled on other platforms. **: Currently, we check for root permissions via getuid == 0. It's unclear if it's even possible to run the tests a non-root user with e.g. CAP_BPF, CAP_PERFMON, and access to /sys/kernel/debug/ tracing/. Anyone running these tests as root should carefully review them first and then run them in a disposable VM. [0]: https://github.com/iovisor/bcc/blob/master/INSTALL.md
This commit is contained in:
parent
5f44c5c428
commit
c934087b62
3 changed files with 30 additions and 0 deletions
|
@ -1363,6 +1363,7 @@ if test "$use_usdt" != "no"; then
|
|||
[AC_MSG_RESULT([no]); use_usdt=no;]
|
||||
)
|
||||
fi
|
||||
AM_CONDITIONAL([ENABLE_USDT_TRACEPOINTS], [test "$use_usdt" = "yes"])
|
||||
|
||||
if test "$build_bitcoin_cli$build_bitcoin_tx$build_bitcoin_util$build_bitcoind$bitcoin_enable_qt$use_bench$use_tests" = "nonononononono"; then
|
||||
use_upnp=no
|
||||
|
|
|
@ -25,3 +25,4 @@ RPCAUTH=@abs_top_srcdir@/share/rpcauth/rpcauth.py
|
|||
@ENABLE_ZMQ_TRUE@ENABLE_ZMQ=true
|
||||
@ENABLE_EXTERNAL_SIGNER_TRUE@ENABLE_EXTERNAL_SIGNER=true
|
||||
@ENABLE_SYSCALL_SANDBOX_TRUE@ENABLE_SYSCALL_SANDBOX=true
|
||||
@ENABLE_USDT_TRACEPOINTS_TRUE@ENABLE_USDT_TRACEPOINTS=true
|
||||
|
|
|
@ -9,6 +9,7 @@ from enum import Enum
|
|||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
import pdb
|
||||
import random
|
||||
import re
|
||||
|
@ -821,6 +822,29 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||
except ImportError:
|
||||
raise SkipTest("python3-zmq module not available.")
|
||||
|
||||
def skip_if_no_python_bcc(self):
|
||||
"""Attempt to import the bcc package and skip the tests if the import fails."""
|
||||
try:
|
||||
import bcc # type: ignore[import] # noqa: F401
|
||||
except ImportError:
|
||||
raise SkipTest("bcc python module not available")
|
||||
|
||||
def skip_if_no_bitcoind_tracepoints(self):
|
||||
"""Skip the running test if bitcoind has not been compiled with USDT tracepoint support."""
|
||||
if not self.is_usdt_compiled():
|
||||
raise SkipTest("bitcoind has not been built with USDT tracepoints enabled.")
|
||||
|
||||
def skip_if_no_bpf_permissions(self):
|
||||
"""Skip the running test if we don't have permissions to do BPF syscalls and load BPF maps."""
|
||||
# check for 'root' permissions
|
||||
if os.geteuid() != 0:
|
||||
raise SkipTest("no permissions to use BPF (please review the tests carefully before running them with higher privileges)")
|
||||
|
||||
def skip_if_platform_not_linux(self):
|
||||
"""Skip the running test if we are not on a Linux platform"""
|
||||
if platform.system() != "Linux":
|
||||
raise SkipTest("not on a Linux system")
|
||||
|
||||
def skip_if_no_bitcoind_zmq(self):
|
||||
"""Skip the running test if bitcoind has not been compiled with zmq support."""
|
||||
if not self.is_zmq_compiled():
|
||||
|
@ -902,6 +926,10 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||
"""Checks whether the zmq module was compiled."""
|
||||
return self.config["components"].getboolean("ENABLE_ZMQ")
|
||||
|
||||
def is_usdt_compiled(self):
|
||||
"""Checks whether the USDT tracepoints were compiled."""
|
||||
return self.config["components"].getboolean("ENABLE_USDT_TRACEPOINTS")
|
||||
|
||||
def is_sqlite_compiled(self):
|
||||
"""Checks whether the wallet module was compiled with Sqlite support."""
|
||||
return self.config["components"].getboolean("USE_SQLITE")
|
||||
|
|
Loading…
Reference in a new issue