mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-11 23:30:05 +02:00
Merge bitcoin/bitcoin#29868: Reintroduce external signer support for Windows
3a18075aedci: Drop `-DENABLE_EXTERNAL_SIGNER=ON` configure option (Hennadii Stepanov)719fa9f4efbuild: Re-enable external signer support for Windows (Hennadii Stepanov)6e5fc2bf9btest: Reintroduce Windows support in `system_tests/run_command` test (Hennadii Stepanov) Pull request description: This PR partially reverts: - https://github.com/bitcoin/bitcoin/pull/28967 - https://github.com/bitcoin/bitcoin/pull/29489 After this PR, we can proceed to actually remove the [unused code](https://github.com/bitcoin/bitcoin/pull/28981#pullrequestreview-1991272752) from `src/util/subprocess.h`. ACKs for top commit: Sjors: ACK3a18075aed. theStack: Light ACK3a18075aedlaanwj: Code review and lightly tested ACK3a18075aedTree-SHA512: 00d200685906e716750aae7cffa0794cca451653738ea590f50dfa28e1f3c5762a9be0ae0917aa0cf7436f00fe1e565236bff2853896530a5879466f7f45cb25
This commit is contained in:
@@ -130,7 +130,7 @@ if(WITH_USDT)
|
|||||||
find_package(USDT MODULE REQUIRED)
|
find_package(USDT MODULE REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
cmake_dependent_option(ENABLE_EXTERNAL_SIGNER "Enable external signer support." ON "NOT WIN32" OFF)
|
option(ENABLE_EXTERNAL_SIGNER "Enable external signer support." ON)
|
||||||
|
|
||||||
cmake_dependent_option(WITH_QRENCODE "Enable QR code support." ON "BUILD_GUI" OFF)
|
cmake_dependent_option(WITH_QRENCODE "Enable QR code support." ON "BUILD_GUI" OFF)
|
||||||
if(WITH_QRENCODE)
|
if(WITH_QRENCODE)
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ BASE_BUILD_DIR=${BASE_BUILD_DIR:-$BASE_SCRATCH_DIR/build-$HOST}
|
|||||||
mkdir -p "${BASE_BUILD_DIR}"
|
mkdir -p "${BASE_BUILD_DIR}"
|
||||||
cd "${BASE_BUILD_DIR}"
|
cd "${BASE_BUILD_DIR}"
|
||||||
|
|
||||||
BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DENABLE_EXTERNAL_SIGNER=ON -DCMAKE_INSTALL_PREFIX=$BASE_OUTDIR"
|
BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_INSTALL_PREFIX=$BASE_OUTDIR"
|
||||||
|
|
||||||
if [[ "${RUN_TIDY}" == "true" ]]; then
|
if [[ "${RUN_TIDY}" == "true" ]]; then
|
||||||
BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
|
BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
|
||||||
|
|||||||
@@ -25,7 +25,11 @@ BOOST_AUTO_TEST_CASE(run_command)
|
|||||||
BOOST_CHECK(result.isNull());
|
BOOST_CHECK(result.isNull());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
#ifdef WIN32
|
||||||
|
const UniValue result = RunCommandParseJSON("cmd.exe /c echo {\"success\": true}");
|
||||||
|
#else
|
||||||
const UniValue result = RunCommandParseJSON("echo {\"success\": true}");
|
const UniValue result = RunCommandParseJSON("echo {\"success\": true}");
|
||||||
|
#endif
|
||||||
BOOST_CHECK(result.isObject());
|
BOOST_CHECK(result.isObject());
|
||||||
const UniValue& success = result.find_value("success");
|
const UniValue& success = result.find_value("success");
|
||||||
BOOST_CHECK(!success.isNull());
|
BOOST_CHECK(!success.isNull());
|
||||||
@@ -33,12 +37,20 @@ BOOST_AUTO_TEST_CASE(run_command)
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
// An invalid command is handled by cpp-subprocess
|
// An invalid command is handled by cpp-subprocess
|
||||||
|
#ifdef WIN32
|
||||||
|
const std::string expected{"CreateProcess failed: "};
|
||||||
|
#else
|
||||||
const std::string expected{"execve failed: "};
|
const std::string expected{"execve failed: "};
|
||||||
|
#endif
|
||||||
BOOST_CHECK_EXCEPTION(RunCommandParseJSON("invalid_command"), subprocess::CalledProcessError, HasReason(expected));
|
BOOST_CHECK_EXCEPTION(RunCommandParseJSON("invalid_command"), subprocess::CalledProcessError, HasReason(expected));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Return non-zero exit code, no output to stderr
|
// Return non-zero exit code, no output to stderr
|
||||||
|
#ifdef WIN32
|
||||||
|
const std::string command{"cmd.exe /c exit 1"};
|
||||||
|
#else
|
||||||
const std::string command{"false"};
|
const std::string command{"false"};
|
||||||
|
#endif
|
||||||
BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, [&](const std::runtime_error& e) {
|
BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, [&](const std::runtime_error& e) {
|
||||||
const std::string what{e.what()};
|
const std::string what{e.what()};
|
||||||
BOOST_CHECK(what.find(strprintf("RunCommandParseJSON error: process(%s) returned 1: \n", command)) != std::string::npos);
|
BOOST_CHECK(what.find(strprintf("RunCommandParseJSON error: process(%s) returned 1: \n", command)) != std::string::npos);
|
||||||
@@ -47,7 +59,11 @@ BOOST_AUTO_TEST_CASE(run_command)
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Return non-zero exit code, with error message for stderr
|
// Return non-zero exit code, with error message for stderr
|
||||||
|
#ifdef WIN32
|
||||||
|
const std::string command{"cmd.exe /c \"echo err 1>&2 && exit 1\""};
|
||||||
|
#else
|
||||||
const std::string command{"sh -c 'echo err 1>&2 && false'"};
|
const std::string command{"sh -c 'echo err 1>&2 && false'"};
|
||||||
|
#endif
|
||||||
const std::string expected{"err"};
|
const std::string expected{"err"};
|
||||||
BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, [&](const std::runtime_error& e) {
|
BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, [&](const std::runtime_error& e) {
|
||||||
const std::string what(e.what());
|
const std::string what(e.what());
|
||||||
@@ -58,17 +74,23 @@ BOOST_AUTO_TEST_CASE(run_command)
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Unable to parse JSON
|
// Unable to parse JSON
|
||||||
|
#ifdef WIN32
|
||||||
|
const std::string command{"cmd.exe /c echo {"};
|
||||||
|
#else
|
||||||
const std::string command{"echo {"};
|
const std::string command{"echo {"};
|
||||||
|
#endif
|
||||||
BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, HasReason("Unable to parse JSON: {"));
|
BOOST_CHECK_EXCEPTION(RunCommandParseJSON(command), std::runtime_error, HasReason("Unable to parse JSON: {"));
|
||||||
}
|
}
|
||||||
// Test std::in
|
#ifndef WIN32
|
||||||
{
|
{
|
||||||
|
// Test stdin
|
||||||
const UniValue result = RunCommandParseJSON("cat", "{\"success\": true}");
|
const UniValue result = RunCommandParseJSON("cat", "{\"success\": true}");
|
||||||
BOOST_CHECK(result.isObject());
|
BOOST_CHECK(result.isObject());
|
||||||
const UniValue& success = result.find_value("success");
|
const UniValue& success = result.find_value("success");
|
||||||
BOOST_CHECK(!success.isNull());
|
BOOST_CHECK(!success.isNull());
|
||||||
BOOST_CHECK_EQUAL(success.get_bool(), true);
|
BOOST_CHECK_EQUAL(success.get_bool(), true);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif // ENABLE_EXTERNAL_SIGNER
|
#endif // ENABLE_EXTERNAL_SIGNER
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user