Files
bitcoin/src/test/main.cpp
Lőrinc 9eba3aafa6 test: avoid undersized Boost.Test signal stacks
Boost.Test registers a `SIGSTKSZ` alternate signal stack as each test binary starts, before any tests run.
On musl, this can be smaller than Linux's hardware-dependent minimum, causing `sigaltstack()` to fail with `ENOMEM` during setup.

Disable Boost.Test's alternate stack in both test entry points.
Signal handlers continue to use the regular process stack. Boost.Test can no longer report stack overflows.

Fixes #36026

Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
2026-08-20 10:10:23 -07:00

39 lines
1.4 KiB
C++

// Copyright (c) 2011-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
/**
* See https://www.boost.org/doc/libs/1_78_0/libs/test/doc/html/boost_test/adv_scenarios/single_header_customizations/multiple_translation_units.html
*/
// Boost.Test's SIGSTKSZ alternate stack can be smaller than Linux requires on musl.
#define BOOST_TEST_DISABLE_ALT_STACK
#define BOOST_TEST_MODULE Bitcoin Core Test Suite
#include <boost/test/included/unit_test.hpp>
#include <test/util/setup_common.h>
#include <functional>
#include <iostream>
/**
* Retrieve the command line arguments from boost.
* Allows usage like:
* `test_bitcoin --run_test="net_tests/cnode_listen_port" -- -checkaddrman=1 -printtoconsole=1`
* which would return `["-checkaddrman=1", "-printtoconsole=1"]`.
*/
const std::function<std::vector<const char*>()> G_TEST_COMMAND_LINE_ARGUMENTS = []() {
std::vector<const char*> args;
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) {
args.push_back(boost::unit_test::framework::master_test_suite().argv[i]);
}
return args;
};
/**
* Retrieve the boost unit test name.
*/
const std::function<std::string()> G_TEST_GET_FULL_NAME = []() {
return boost::unit_test::framework::current_test_case().full_name();
};